safe-commit
git commit を行う際に自動発動。禁止ディレクトリ(ai/, .serena/)のコミット防止と、論理的なコミット分割を支援する。
When & Why to Use This Skill
The Safe Commit skill is a specialized Git workflow enhancer for Claude that ensures repository integrity and clean version control history. It acts as an automated guardrail by preventing the accidental commitment of restricted directories (such as session logs or internal configurations) and provides a structured framework for logical commit splitting and quality-focused commit messaging.
Use Cases
- Preventing Sensitive Data Leaks: Automatically identifies and unstages temporary files or session logs in directories like 'ai/' or '.serena/' before they can be committed to the repository.
- Logical Change Organization: Facilitates the splitting of large, complex code changes into smaller, logical commits using the '/commit-plan' feature, making code reviews more efficient.
- Enforcing Commit Standards: Implements a pre-commit checklist to ensure that every commit message explains the 'why' behind a change and that no unauthorized files are staged.
- Automated Workflow Safety: Provides a fail-safe mechanism for developers and AI agents to avoid 'messy' commits, ensuring that only intended and well-structured changes reach the codebase.
| name | safe-commit |
|---|---|
| description | git commit を行う際に自動発動。禁止ディレクトリ(ai/, .serena/)のコミット防止と、論理的なコミット分割を支援する。 |
Safe Commit
コミット前に必ず以下を確認・実行する。
禁止ディレクトリのチェック
コミット前に必ず実行:
# ステージングされた禁止ファイルを確認
git diff --cached --name-only | grep -E '^(ai/|\.serena/)'
# 存在する場合はアンステージ
git reset HEAD -- ai/ .serena/ 2>/dev/null || true
禁止対象
ai/- セッションログ、一時ファイル.serena/- Serena MCP設定
これらは 絶対にコミットしない。
コミット計画
複数の論理的変更がある場合は /commit-plan を実行して分割を検討。
チェックリスト
コミット実行前:
-
git diff --cached --name-onlyで禁止ディレクトリがないか確認 - 禁止ファイルがあれば
git reset HEAD -- ai/ .serena/ - 変更が論理的に分割されているか確認
- コミットメッセージが "why" を説明しているか確認