← スキル一覧に戻る

git-commit
by bostonaholic
There's no place like ~
⭐ 5🍴 0📅 2026年1月20日
SKILL.md
name: git-commit description: Commit with clear messages explaining WHY, following repository conventions
Git Commit
Iron Law
- NO COMMITS WITHOUT REVIEWING GIT DIFF FIRST
- NO COMMIT MESSAGES WITHOUT EXPLAINING WHY
- ONLY COMMIT WHEN USER EXPLICITLY REQUESTS
Process
1. Gather Context (parallel)
git status # Staged/unstaged files
git diff # Unstaged changes
git diff --staged # Staged changes
git log --oneline -5 # Recent commit style
2. Review Changes
- Understand every change in diff
- No secrets (.env, credentials, keys)
- No debug code, console.logs
- Related changes only (one logical unit)
3. Stage and Commit
git add path/to/file1 path/to/file2
git commit -m "$(cat <<'EOF'
feat: add user authentication middleware
Previous implementation left API endpoints unprotected. Adds JWT
validation middleware ensuring only authenticated requests reach
protected endpoints.
EOF
)"
4. Verify
git status # Working tree state
git log -1 --stat # Confirm commit
Message Format
<type>: <subject - imperative mood, 50 chars>
<body - explain WHY, wrap at 72 chars>
Types: feat: fix: refactor: docs: test: chore:
Subject: Imperative mood ("Add" not "Added"), no period, ≤50 chars
Body: Explain WHY, what problem it solves, non-obvious decisions
Pre-commit Hook Changes
If hooks modify files:
- Check authorship:
git log -1 --format='%an %ae' - Check not pushed:
git statusshows "ahead" - If both true:
git add <files> && git commit --amend --no-edit - Otherwise: Create NEW commit
Safety Rules
Never without explicit request:
--force,--force-with-lease--amendon others' commits or pushed commits--no-verify,--no-gpg-signgit reset --hardgit configchanges
Never commit:
.env, credentials, secrets, keys- Broken code (tests must pass)
- Unrelated changes mixed together
Examples
fix: prevent race condition in session creation
Sessions were created before user validation completed, allowing
invalid users to briefly access protected resources. Moves session
creation to after validation succeeds.
refactor: extract validation using Replace Conditional with Polymorphism
Payment processor had 4-level nested conditionals. Applied Fowler's
pattern to create PaymentMethod interface. New payment types now
require zero changes to processor.
Key Takeaways
- Review diff before committing - Never commit unread code
- Explain WHY, not WHAT - Diff shows what; message explains why
- One logical change per commit - Multiple files OK if related
- Only commit when requested - Don't be proactive
- Use heredoc for messages - Ensures proper formatting
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です