Background Knowledge
Commit Format Rules
Structure:
<type>(<scope>): <description>
[optional context paragraph]
- <Action> <component> <detail>
[explanation paragraph]
Co-Authored-By: <Model Name> <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 - Footer:
Co-Authored-Byis REQUIRED for all AI commits
Phase 1: Configuration Verification
Goal: Load project-specific git configuration and valid scopes.
Actions:
- FIRST: 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
scopes:list in YAML frontmatter
Phase 2: Change Analysis
Goal: Identify logical units of work and infer commit scopes.
Actions:
- Run
git diff --cachedandgit diffto get code differences (MUST NOT traverse files directly) - Analyze diff to identify coherent 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
Goal: Remove AI-generated slop before committing.
Actions:
- Launch agent with Task tool (model: sonnet) to review changes
- Remove AI patterns: extra comments, unnecessary defensive checks,
anycasts, inconsistent style - Agent runs autonomously without user confirmation
Phase 4: Commit Creation
Goal: Create atomic commits following Conventional Commits format.
Actions (repeat for each logical unit):
- Draft commit message per
Commit Format Rulesabove - Validate: title <50 chars lowercase imperative; body has bullets + explanation paragraph; footer has
Co-Authored-By - Stage relevant files and create commit