# Operation: Suggest Conventions **Purpose:** Generate project-specific commit message convention recommendations based on historical analysis and best practices. ## Parameters From `$ARGUMENTS` (after operation name): - `count:N` - Number of commits to analyze (default: 50) - `branch:name` - Branch to analyze (default: current branch) - `format:json|text` - Output format (default: text) - `include_examples:true|false` - Include example commits (default: true) - `priority:high|medium|low|all` - Filter by recommendation priority (default: all) ## Workflow ### 1. Validate Repository ```bash if ! git rev-parse --git-dir >/dev/null 2>&1; then echo "Error: Not in a git repository" exit 1 fi ``` ### 2. Gather Historical Data Execute analysis operations to collect data: **A. Style Analysis:** ```bash ./.scripts/style-analyzer.sh ``` **B. Pattern Detection:** ```bash ./.scripts/pattern-detector.py --count --branch ``` **C. Scope Extraction:** ```bash ./.scripts/scope-extractor.sh --count --branch ``` ### 3. Execute Convention Recommender Invoke the convention-recommender.py utility script: ```bash ./.scripts/convention-recommender.py --count --branch --priority ``` The script will: - Analyze aggregated historical data - Identify current conventions and gaps - Generate recommendations by priority - Provide examples and implementation guidance - Create project-specific guidelines ### 4. Recommendation Categories **A. Format Recommendations** - Commit message structure - Subject line format - Body organization - Footer conventions **B. Type Recommendations** - Commonly used types - Type selection guidance - Project-specific type meanings **C. Scope Recommendations** - Standard scopes for the project - Scope naming patterns - When to use each scope **D. Content Recommendations** - Writing style (imperative mood, tense) - Capitalization and punctuation - Issue reference format - Breaking change documentation **E. Process Recommendations** - Pre-commit validation - Atomicity guidelines - Review practices ### 5. Recommendation Priority Levels **HIGH Priority (Critical for consistency):** - Adopt conventional commits if not using (< 50% usage) - Fix major inconsistencies (> 30% deviation) - Establish missing critical patterns **MEDIUM Priority (Improve quality):** - Refine existing patterns (50-80% consistency) - Add missing optional elements - Enhance documentation practices **LOW Priority (Nice-to-have):** - Fine-tune minor details - Advanced features (co-authors, trailers) - Optimization opportunities ### 6. Output Structure **Text Format (default):** ``` Project-Specific Commit Convention Recommendations ================================================== Analysis: 50 commits on branch 'main' Current Consistency: 85/100 (GOOD) Generated: 2024-03-10 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔴 HIGH PRIORITY RECOMMENDATIONS 1. Continue Using Conventional Commits Status: ✓ Already adopted (87% usage) Action: Maintain current practice Benefit: Enables automated changelog, semantic versioning Format: (): Example from project: ✓ feat(auth): implement OAuth2 authentication ✓ fix(api): handle null pointer in user endpoint 2. Standardize Subject Line Length Status: ○ Needs improvement (avg: 47 chars, σ=12) Action: Keep subject lines under 50 characters Current: 15% exceed limit Target: < 5% exceed limit ✓ Good: "feat(auth): add OAuth provider support" ✗ Too long: "feat(auth): implement OAuth2 authentication with support for multiple providers including Google and GitHub" ✓ Better: "feat(auth): add OAuth multi-provider support" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🟡 MEDIUM PRIORITY RECOMMENDATIONS 3. Increase Body Usage for Complex Changes Status: ○ Moderate usage (34% of commits) Action: Add body for non-trivial changes Benefit: Better context for code review and history When to add body: • Multiple files changed (>3) • Complex logic changes • Breaking changes • Security-related changes Example from project: feat(auth): implement OAuth2 authentication - Add OAuth2 flow implementation - Support Google and GitHub providers - Include middleware for route protection - Add configuration management 4. Consistent Issue References Status: ✓ Good usage (67% of commits) Action: Reference issues consistently Current format: "Closes #123", "Fixes #456" Recommendation: Continue current practice Patterns detected in project: ✓ Closes #123 (45% of references) ✓ Fixes #456 (38% of references) ✓ Refs #789 (17% of references) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🟢 LOW PRIORITY RECOMMENDATIONS 5. Consider Adding Co-Author Attribution Status: ✗ Rare usage (2% of commits) Action: Add co-authors for pair programming Format: Co-authored-by: Name Example: feat(api): add user management endpoint Co-authored-by: Jane Doe 6. Document Breaking Changes Explicitly Status: ○ Occasional (8% of commits) Action: Use BREAKING CHANGE footer when applicable Format: feat(api): change authentication flow BREAKING CHANGE: API now requires OAuth tokens instead of API keys. Update client applications. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📋 PROJECT-SPECIFIC STYLE GUIDE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ COMMIT MESSAGE FORMAT --------------------- ():