Git Commit Guardian
Enforces professional commit standards and prevents AI attribution pollution.
Instructions
1. Intercept Commit Intent
Detect: "commit", "git commit", "commit changes", "push this", "done, commit it". Activate immediately before any commit action.
2. Analyze Staged Changes
git diff --cached --name-only
git diff --cached
# Check for sensitive files (BLOCK if found)
git diff --cached --name-only | grep -E '\.(env|pem|key|credentials)$'
Determine commit type from changes:
feat— New feature filesfix— Bug fixesdocs— Only docs/commentsrefactor— Restructure, same behaviortest— Test additions/fixesbuild— Build system, dependencieschore— Maintenance
Fakt-specific scopes: compiler, fir, ir, generation, analysis, dsl, gradle, annotations, samples
3. Validate Commit Message
Required format:
<type>[(scope)]: <description>
[optional body]
[optional footer]
Validation rules:
- Valid type:
feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert - Subject ≤72 characters
- No trailing period
- Imperative mood ("add" not "added")
- Blank line between subject and body
- Body lines wrapped at 80 characters
4. BLOCK Forbidden Patterns (CRITICAL)
These MUST NEVER appear in commits:
FORBIDDEN — ALWAYS BLOCK:
1. "Generated with [Claude Code]" / "Generated with Claude Code" / "Generated by Claude"
2. "Co-Authored-By: Claude" / "Co-authored-by:.*Claude" / "Co-authored-by:.*Anthropic"
3. "Co-Authored-By:.*noreply@anthropic.com"
4. Robot emoji + "Generated"
If detected:
COMMIT BLOCKED — AI Attribution Detected
Found: "Co-Authored-By: Claude <noreply@anthropic.com>"
This project requires clean commits without AI attribution.
Remove the offending line and retry.
NON-NEGOTIABLE. Always strip before committing.
5. Execute Commit
Only after all validations pass:
git commit -m "$(cat <<'EOF'
<validated commit message>
EOF
)"
Verify:
git log -1 --format="%H %s"
6. Handle Edge Cases
Multiple logical changes — recommend splitting:
1. refactor(types): extract TypeResolver to separate file
2. feat(types): add variance handling
3. test(types): add unit tests for TypeResolver
Error Messages
Invalid Type:
COMMIT BLOCKED — Invalid Type
"update" is not valid. Use: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
Subject Too Long:
COMMIT BLOCKED — Subject exceeds 72 characters (currently: {n})
Suggested: "{shortened version}"
Supporting Files
resources/conventional-commits-reference.md— Full specresources/commit-message-patterns.md— Project-specific examples
Related Skills
bdd-test-runner— Run tests before committingcompilation— Validate code compiles before committing
Converted and distributed by TomeVault — claim your Tome and manage your conversions.