Claude-skill-registry git-commit-assistant
Assists with careful Git commits in any repository. Activates when committing changes, checking .gitignore, or generating commit messages. Ensures proper file exclusion (credentials, MCP configs, personal settings), identifies untracked files, and generates Conventional Commits messages with Japanese explanations.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/git-commit-assistant" ~/.claude/skills/majiayu000-claude-skill-registry-git-commit-assistant && rm -rf "$T"
skills/data/git-commit-assistant/SKILL.mdGit Commit Assistant Skill
Purpose
Provide comprehensive Git commit assistance with:
- Automatic .gitignore validation and updates
- Intelligent file classification
- High-quality Conventional Commits message generation
- Protection against committing sensitive files
Activation Triggers
Automatically activate when:
- User says "commit", "git commit", "コミット", "コミットしたい"
- User mentions ".gitignore"
- User asks about what to commit/exclude
- User requests to push changes to remote
Workflow
Phase 1: Repository Analysis
-
Check Git status
- Run
to get machine-readable outputgit status --porcelain - Identify modified, deleted, untracked files
- Check current branch with
git branch --show-current - Verify repository is not in detached HEAD state
- Run
-
Analyze .gitignore
- Read existing .gitignore (if present)
- Check against known critical patterns from
rules/gitignore-patterns.md - Identify missing critical patterns (credentials, MCP configs, personal settings)
-
Classify files
- AUTO_EXCLUDE: Sensitive/environment-specific files (never commit)
- AUTO_COMMIT: Obviously safe files (source code, docs, configs)
- CONFIRM: Ambiguous files requiring user input
Phase 2: .gitignore Management
-
Check for sensitive patterns
Critical patterns that must be present:
- Credentials:
,*.key
,*.pem
,*credentials*
,*secret*.env - MCP configs:
,.claude.json.mcp.json* - Personal settings:
,settings.jsonsettings.local.json - Build artifacts:
,node_modules/
,dist/*.log - OS files:
,.DS_StoreThumbs.db
- Credentials:
-
Propose .gitignore updates
- Show missing patterns
- Explain why each pattern is needed (security, environment dependency)
- Ask user to approve updates using AskUserQuestion
-
Update .gitignore
- Apply approved patterns
- Stage .gitignore if updated
Phase 3: File Selection
-
Auto-classify files using rules
AUTO_EXCLUDE (never commit):
- Pattern:
,*credentials*
,*.key
,*.pem
,*secret**password* - Pattern:
,.claude.json.mcp.json* - Pattern:
,settings.jsonsettings.local.json - Pattern:
,.env
,.env.local.env.*.local - Pattern:
,node_modules/
,vendor/
,dist/build/ - Pattern:
,*.log*.cache - Pattern:
,.DS_Store
,Thumbs.dbdesktop.ini
AUTO_COMMIT (generally safe):
- Pattern:
(documentation)*.md - Pattern:
,.gitignore.editorconfig - Pattern:
,src/**
,internal/**
(source code)lib/** - Pattern:
,*_test.go
,*.test.ts
(tests)*.test.tsx - Pattern:
,package.json
,go.mod
(manifests)Cargo.toml - Pattern:
(CI configs).github/workflows/* - Pattern:
(Skills)~/.claude/skills/** - Pattern:
(Knowledge base)~/.claude/knowledge/**
CONFIRM (user decision):
- Files > 1MB
- New directories
- Executable files
- Config files (not in AUTO lists)
- Pattern:
-
User confirmation for ambiguous files
- Present clear options using AskUserQuestion
- Show file contents preview if helpful
- Allow multi-select when appropriate
-
Final file list
- Compile files to commit
- Show summary to user before proceeding
Phase 4: Commit Message Generation
-
Analyze changes
- Review
for staged changesgit diff --cached - Review
for file operations (add, delete, rename)git status - Identify change patterns and scope
- Review
-
Determine commit type
Follow Conventional Commits specification:
: New features or capabilitiesfeat
: Bug fixesfix
: Documentation only changesdocs
: Formatting, whitespace, no code changestyle
: Code restructuring without behavior changerefactor
: Performance improvementsperf
: Adding or updating teststest
: Build system or external dependency changesbuild
: CI configuration changesci
: Maintenance tasks, dependency updateschore
-
Generate message
Template structure:
<type>(<scope>): <subject> - <bullet point 1> - <bullet point 2> - <bullet point 3> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>Guidelines:
- Subject: Concise, imperative mood, max 50 chars (English preferred)
- Bullets: Japanese OK, explain what/why/impact
- 3-5 bullets typically sufficient
- No file lists (git handles that)
- No emojis except attribution
-
Review with user
- Show generated message
- Allow edits if needed
Phase 5: Commit & Push
-
Stage files
- Use
for new/modified filesgit add - Use
for deleted filesgit rm - Handle renames properly (git detects automatically)
- Use
-
Create commit
- Apply generated message using heredoc for proper formatting
- Example:
git commit -m "$(cat <<'EOF'\n...\nEOF\n)" - Verify commit success
-
Optionally push
- Check if remote exists:
git remote -v - Check if branch tracks remote:
git branch -vv - Ask user if should push
- Execute
if approvedgit push origin <branch>
- Check if remote exists:
File Classification Details
AUTO_EXCLUDE Priority Checks
-
Credentials/Secrets (Highest priority)
- Any file containing "credential", "secret", "password", "key"
files.env
,*.pem
files*.key- Action: Exclude immediately, warn user, ensure in .gitignore
-
MCP Configuration (High priority)
,.claude.json
,.mcp.json.mcp.json.backup- Reason: Contains local environment paths
- Action: Exclude, ensure in .gitignore
-
Personal Settings (High priority)
,settings.jsonsettings.local.json- IDE settings:
,.vscode/settings.json.idea/workspace.xml - Action: Exclude, ensure in .gitignore
-
Build Artifacts (Medium priority)
,node_modules/
,vendor/
,dist/build/
,*.log
,*.cachecoverage/- Action: Exclude, ensure in .gitignore
AUTO_COMMIT Safe Patterns
-
Documentation
,*.mddocs/**- Reason: Shareable knowledge
- Action: Commit
-
Source Code
,src/**
,internal/**lib/**
,*_test.go
,*.test.ts*.test.tsx- Reason: Core project files
- Action: Commit
-
Configuration (Shareable)
,.gitignore
,.editorconfig.prettierrc
,package.json
,tsconfig.jsongo.mod.github/workflows/**- Reason: Team-shared configuration
- Action: Commit
-
Skills & Knowledge
~/.claude/skills/**~/.claude/knowledge/**- Reason: Shareable expertise
- Action: Commit
CONFIRM Cases
-
Large files (>1MB)
- Show file size
- Ask user if intentional
- Suggest Git LFS if appropriate
-
New directories
- Show directory contents (first level)
- Ask user about purpose
- Help classify based on purpose
-
Executable files
,*.exe
,*.bin*.app- Ask if it's a build artifact or checked-in tool
Commit Message Quality Checks
Before finalizing:
-
Format validation
- Verify Conventional Commits format:
type(scope): subject - Check subject length (≤50 chars recommended)
- Ensure imperative mood
- Verify Conventional Commits format:
-
Content validation
- Verify bullets explain what/why/impact
- Check for meaningful description (not just "update files")
- Ensure proper attribution
-
Sensitive content scan
- Scan diff for patterns like:
- API keys:
[A-Za-z0-9_-]{20,} - Passwords:
password.*=.* - URLs with credentials:
://.*:.*@
- API keys:
- Warn user if suspicious patterns found
- Scan diff for patterns like:
Error Handling
Merge conflicts
- Detect:
git status | grep "both modified" - Action: Guide user to resolve first, offer to show conflict files
Detached HEAD
- Detect:
returns emptygit branch --show-current - Action: Suggest creating branch with
git switch -c <branch-name>
Nothing to commit
- Detect:
returns empty after staginggit status --porcelain - Action: Inform clearly, suggest
to check working directorygit status
Uncommitted changes during checkout
- Detect: Error when switching branches
- Action: Offer to stash changes or commit them first
Integration with Global CLAUDE.md
Global CLAUDE.md should only contain:
## Git操作 コミットは `git-commit-assistant` Skill が支援する。 基本原則: Conventional Commits形式、絵文字不使用、必要十分な解説。 詳細は `~/.claude/skills/git-commit-assistant/SKILL.md` を参照。
All detailed rules, patterns, and templates are in this Skill's files.
Supporting Files
: Comprehensive .gitignore pattern libraryrules/gitignore-patterns.md
: Detailed file classification rulesrules/file-classification.md
: Commit message template and examplestemplates/commit-message.md
Usage Tips
When NOT to use this Skill
- Simple typo fixes in docs (just commit directly)
- When you want to commit with custom message format
- Emergency hotfixes (speed matters more than format)
When to DEFINITELY use this Skill
- First commit in new repo
- Committing to
(high risk of exposing sensitive configs)~/.claude/ - Large changesets with multiple types of changes
- When unsure about what to commit/exclude
Maintenance
This Skill should be updated when:
- New file types need classification rules
- New sensitive patterns are discovered
- Commit message conventions evolve
- New tech stacks require specific patterns