Background Knowledge
Commit Format Rules
Structure:
<type>(<scope>): <description>
[optional context paragraph]
- <Action> <component> <detail>
[explanation paragraph - REQUIRED, explains the "why" behind changes]
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rules:
-
Title: ALL LOWERCASE, ≤50 chars, imperative, no period. Add "!" before ":" for breaking changes
-
Types: feat , fix , docs , refactor , perf , test , chore , build , ci , style
-
Body (REQUIRED): Bullet points with - prefix, imperative verbs, ≤72 chars/line
-
Explanation paragraph (REQUIRED): Explains the "why" behind the changes, not just the "what"
-
Footer: Co-Authored-By is REQUIRED for all AI commits
Workflow Execution
Launch a general-purpose agent that executes all 4 phases in a single task. This ensures atomic execution and proper context preservation.
Prompt template:
Execute the complete commit workflow (4 phases) for any staged/unstaged changes.
Phase 1: Configuration Verification
- Read
.claude/git.local.mdto load project configuration - If file not found, load
git:config-gitskill using the Skill tool to create it - Extract valid scopes from YAML frontmatter
Phase 2: Change Analysis
- Run
git diff --cachedandgit diffto get code differences - Analyze diff to identify logical units
- Infer scope(s) from file paths and changes using the valid scopes loaded in Phase 1
- If inferred scope not in the valid scopes list, load
git:config-gitskill using the Skill tool to update configuration
Phase 3: AI Code Quality Check (model: sonnet)
- Review changes for AI slop patterns
- Remove all AI generated slop introduced in the git diff:
- Extra comments that a human wouldn't add or is inconsistent with the rest of the file
- Extra defensive checks or try/catch blocks that are abnormal for that area of the codebase (especially if called by trusted/validated codepaths)
- Casts to
anyto get around type issues - Any other style that is inconsistent with the file
Phase 4: Commit Creation
- Draft commit message following Conventional Commits format:
- Title: lowercase, ≤50 chars, imperative, no period
- Context paragraph: optional background before bullet points
- Bullet points with
-prefix, imperative verbs, ≤72 chars/line - Explanation paragraph after bullet points (REQUIRED) - explains the "why"
- Footer: Co-Authored-By: <Model Name> <noreply@anthropic.com>
- Valid models: Claude Sonnet 4.6, Claude Opus 4.6, Claude Haiku 4.5
- Validate message format
- Stage files and create commit
If no changes, report "No changes to commit" and exit.
Execute: Launch a general-purpose agent using the prompt template above