Skip to main content

git-commit-guardian

Enforces Conventional Commits format, validates message quality (72 char subject, 80 char body), and BLOCKS Claude Code pollution (co-author/generated-by markers). Use when committing, creating commits, git commit, or when user mentions "commit", "git commit", "commit message", "commit changes", "push changes".

الانتقال إلى التثبيت

معلومات المصدر

المستودع
RunnerQuan/SAFE-Agent
آخر نشاط في المصدر
٣٠ مارس ٢٠٢٦ في ٠٤:٣٣
لغة SKILL.md المكتشفة
الإنجليزية
النجوم
٠
التفرعات
٠

خيارات التثبيت

يُحدَّد Prompt الذي يراجع المصدر أولًا بشكل افتراضي. يمكنك التبديل إلى أمر مباشر أو تنزيل نسخة محلية.

مراجعة ملفات المصدر

اقرأ SKILL.md وأي ملفات مرافقة يعرضها SkillsMP قبل أن تقرر التثبيت.

مستكشف الملفات
5 ملفات

عرض SKILL.md

SKILL.md
تعليمات المصدر · معاينة للقراءة فقط
name
git-commit-guardian
description
Enforces Conventional Commits format, validates message quality (72 char subject, 80 char body), and BLOCKS Claude Code pollution (co-author/generated-by markers). Use when committing, creating commits, git commit, or when user mentions "commit", "git commit", "commit message", "commit changes", "push changes".
allowed-tools
["Read","Bash","Grep","Glob"]
# Git Commit Guardian Enforces professional commit message standards with Conventional Commits format and prevents AI attribution pollution. ## Core Mission This skill ensures every commit follows industry best practices while **eliminating Claude Code's default commit pollution** (co-author lines, generated-by footers). Commits should be clean, professional, and follow the Conventional Commits specification. **Problem Solved:** Claude Code by default adds "Generated with Claude Code" footers and "Co-Authored-By: Claude" lines to every commit. This pollutes git history and exposes AI usage unnecessarily. This skill blocks such patterns and enforces clean commits. ## Instructions ### 1. Intercept Commit Intent **Detect when user wants to commit:** - Direct: "commit", "git commit", "commit changes" - Indirect: "push this", "save changes to git", "create a commit" - After completing work: "done, commit it" **Immediately activate and validate before any commit action.** ### 2. Analyze Staged Changes **Before crafting commit message:** ```bash # View staged files git diff --cached --name-only # View actual changes git diff --cached # Check for sensitive files (BLOCK if found) git diff --cached --name-only | grep -E '\.(env|pem|key|credentials)$' ``` **Determine appropriate commit type from changes:** - New files with features → `feat` - Bug fixes → `fix` - Only docs/comments → `docs` - Only formatting → `style` - Code restructure, no behavior change → `refactor` - Performance improvements → `perf` - Test additions/fixes → `test` - Build system changes → `build` - CI configuration → `ci` - Maintenance/chores → `chore` ### 3. Validate Commit Message Format **Required format (Conventional Commits):** ``` <type>[(scope)][!]: <description> [optional body] [optional footer] ``` **Validation checklist:** - [ ] Type is valid: `feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert` - [ ] Subject line ≤72 characters - [ ] Subject does NOT end with period - [ ] Subject uses imperative mood ("add" not "added", "fix" not "fixed") - [ ] Blank line between subject and body (if body exists) - [ ] Body lines wrapped at 80 characters - [ ] Breaking changes marked with `!` or `BREAKING CHANGE:` footer **If validation fails:** ``` COMMIT BLOCKED - Format Error Subject line exceeds 72 characters (currently: 85) Fix: Shorten to: "feat(compiler): add generic type support" Original: "feat(compiler): add generic type parameter support for class-level generics in IR generation" ``` ### 4. BLOCK Forbidden Patterns (CRITICAL) **These patterns MUST NEVER appear in commits:** ``` FORBIDDEN PATTERNS - ALWAYS BLOCK 1. AI Attribution Footer: "Generated with [Claude Code]" "Generated with Claude Code" "Generated by Claude" "Generated by AI" 2. Co-Author Lines (any variation): "Co-Authored-By: Claude" "Co-authored-by: Claude" "Co-Authored-By: Claude Opus" "Co-Authored-By: Claude Sonnet" "Co-authored-by:.*Claude" "Co-authored-by:.*Anthropic" "Co-Authored-By:.*noreply@anthropic.com" 3. Emoji AI Markers: Lines starting with robot emoji followed by "Generated" ``` **If forbidden pattern detected:** ``` COMMIT BLOCKED - AI Attribution Detected Found forbidden pattern in commit message: Line 5: "Co-Authored-By: Claude <noreply@anthropic.com>" This project requires clean commits without AI attribution. Remove the offending lines and retry. Allowed footers: Closes #123, Fixes #456, BREAKING CHANGE: ``` **This is NON-NEGOTIABLE. Always strip these before committing.** ### 5. Craft Clean Commit Message **Message structure:** ``` <type>(<scope>): <imperative description> <optional body explaining what and why> <optional footer: Closes #123, BREAKING CHANGE:, etc.> ``` **Good examples:** ``` feat(compiler): add generic type parameter support Implements class-level generic handling in IR generation. Method-level generics use identity function pattern. Closes #42 ``` ``` fix(fir): resolve annotation detection for nested interfaces The FIR phase was not traversing nested interface declarations. Added recursive visitor pattern to detect @Fake at all levels. ``` ``` refactor(generation): extract factory generation to dedicated class Separates concerns between implementation and factory generation for better maintainability and testing. ``` ``` docs: update installation guide for Gradle 8.x ``` **Bad examples (NEVER produce these):** ``` Add generic type parameter support Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> ``` ``` Updated some stuff ``` ``` fix bug. ``` ### 6. Execute Commit **Only after all validations pass:** ```bash git commit -m "$(cat <<'EOF' <validated commit message here> EOF )" ``` **Verify commit succeeded:** ```bash git log -1 --format="%H %s" ``` **Output confirmation:** ``` COMMIT SUCCESSFUL Commit: a1b2c3d Message: feat(compiler): add generic type parameter support All validations passed: - Conventional Commits format - Subject: 47/72 characters - No forbidden patterns - Clean commit history maintained ``` ### 7. Handle Edge Cases **Multiple logical changes:** ``` Recommend splitting into multiple commits: 1. refactor(types): extract TypeResolver to separate file 2. feat(types): add variance handling for generic bounds 3. test(types): add unit tests for TypeResolver Use: git add -p (patch mode) to stage selectively ``` **Breaking changes:** ``` feat(api)!: change factory function signature BREAKING CHANGE: fakeXxx() now requires explicit configuration. Migration: fakeXxx() → fakeXxx {} ``` **Reverting commits:** ``` revert: feat(compiler): add generic type parameter support This reverts commit a1b2c3d. Reason: Causing compilation errors in multi-module projects. ``` ## Supporting Files Progressive disclosure for detailed documentation: - **`resources/conventional-commits-reference.md`** - Full Conventional Commits specification - **`resources/commit-message-patterns.md`** - Project-specific good/bad examples ## Related Skills This skill composes with: - **`bdd-test-runner`** - Run tests before committing - **`compilation-validator`** - Validate code compiles before committing This skill enables: - Clean git history - Professional commit messages - Automated changelog generation (from conventional commits) - Semantic versioning automation ## Best Practices 1. **One logical change per commit** - Don't bundle unrelated changes 2. **Write for future readers** - Explain why, not just what 3. **Use imperative mood** - "add feature" not "added feature" 4. **Keep subject concise** - 72 chars max, aim for 50 5. **Never include AI attribution** - Clean, professional commits only 6. **Reference issues when relevant** - `Closes #123`, `Fixes #456` 7. **Mark breaking changes explicitly** - Use `!` or `BREAKING CHANGE:` footer ## Commit Type Reference | Type | When to Use | Example | |------|-------------|---------| | `feat` | New feature for users | `feat(dsl): add configure block for behaviors` | | `fix` | Bug fix for users | `fix(ir): resolve null pointer in type resolution` | | `docs` | Documentation only | `docs: add KMP setup guide` | | `style` | Formatting, no logic change | `style: apply ktfmt formatting` | | `refactor` | Code restructure, same behavior | `refactor: extract visitor to separate class` | | `perf` | Performance improvement | `perf(analysis): cache interface metadata` | | `test` | Adding/fixing tests | `test: add generic bounds test cases` | | `build` | Build system, dependencies | `build: upgrade Kotlin to 2.1.0` | | `ci` | CI configuration | `ci: add KMP matrix to GitHub Actions` | | `chore` | Maintenance, tooling | `chore: update .gitignore patterns` | | `revert` | Reverting previous commit | `revert: feat(api): change return type` | ## Error Messages ### Invalid Type ``` COMMIT BLOCKED - Invalid Commit Type "update" is not a valid Conventional Commits type. Valid types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert Suggested fix: "feat: ..." or "fix: ..." depending on change nature ``` ### Subject Too Long ``` COMMIT BLOCKED - Subject Exceeds 72 Characters Current: 89 characters Limit: 72 characters Original: "feat(compiler): implement comprehensive generic type parameter support for all interface variations" Suggested: "feat(compiler): add generic type parameter support" ``` ### AI Attribution Detected ``` COMMIT BLOCKED - AI Attribution Detected Line 4: "Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>" This project maintains clean commits without AI attribution. Remove this line to proceed. ``` ## Known Limitations - Skill activates on keyword detection; may miss indirect commit references - Cannot enforce rules if user bypasses skill and runs raw git commands - Body line wrapping is advisory (80 chars) not strictly enforced ## References - **Conventional Commits Spec**: https://www.conventionalcommits.org/ - **Git Best Practices**: https://cbea.ms/git-commit/ - **Angular Commit Guidelines**: https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit
عرض على GitHub