Commit Changes
Create a well-structured git commit with a conventional commit message derived from the current task context.
Rules
- NEVER use
--no-verify. Pre-commit hooks exist for a reason. If hooks fail, fix the issues and retry.
- NEVER use
git add -A or git add . unless every changed file is relevant. Stage files by name.
- NEVER amend a previous commit unless the user explicitly asks for it.
Step 1: Understand What Changed
Run these in parallel:
git status — see all changed, staged, and untracked files
git diff — see unstaged changes
git diff --cached — see already-staged changes
git log --oneline -5 — see recent commit style for this repo
Review the changes and identify:
- Which files are related to the current task
- Which files are unrelated noise (editor configs, lock files from unrelated installs, etc.)
- Whether any files contain secrets,
.env content, or credentials — never commit those
Step 2: Find the Task Context
Look for task context to derive the commit message from. Check in order:
- Ralph PRD story — if there's an active story, check
.ralph/progress.txt for the current story ID and title. The commit message should reference this.
- Recent conversation — what did the user ask you to do? Use that as the commit description.
- The diff itself — if no other context, derive the purpose from the actual code changes.
Step 3: Craft the Commit Message
Use conventional commits format matching this repo's style:
type(scope): concise description of WHY
Types (pick the right one)
| Type |
When to use |
feat |
New feature or capability |
fix |
Bug fix |
chore |
Maintenance, deps, config, version bumps |
test |
Adding or fixing tests |
docs |
Documentation only |
refactor |
Code restructuring, no behavior change |
style |
Formatting, whitespace, naming |
ci |
CI/CD pipeline changes |
Scope
- If working on a Ralph story: use the story ID — e.g.,
feat(story-3): add user auth
- If working on a specific module: use the module name — e.g.,
fix(loop): handle empty config
- If broad/cross-cutting: omit scope — e.g.,
chore: bump version to 3.28.0
Message rules
- Start with lowercase after the colon
- Focus on why, not what — the diff shows what
- Keep the first line under 72 characters
- If more detail is needed, add a blank line and a body paragraph
Examples from this repo
feat: add Working Principles to CLAUDE.md and plansDirectory to settings
feat(story-3): add user authentication with JWT
fix: bash 3.2 unbound variable when run_loop called with no args
chore: bump version to 3.27.1
test(api): add integration tests for /users endpoint
refactor: extract verification into separate modules
Step 4: Stage and Commit
- Stage only the relevant files by name — do NOT use
git add -A or git add .
- Show the user the proposed commit message and list of staged files before committing
- Ask if the message looks right using AskUserQuestion with options:
- "Looks good, commit it"
- "Let me edit the message" (then ask for their preferred message)
- Run the commit — use a HEREDOC for the message:
git commit -m "$(cat <<'EOF'
type(scope): message here
EOF
)"
- Run
git status after to confirm it succeeded
Step 5: Handle Hook Failures
If pre-commit hooks fail:
- Read the hook output carefully
- Fix the issues the hooks identified (lint errors, secrets detected, etc.)
- Re-stage the fixed files
- Commit again — same message, same process, NO
--no-verify
If hooks auto-fix files (e.g., prettier, eslint --fix):
- Review the auto-fixes
- Stage the auto-fixed files
- Retry the commit
If you cannot resolve hook failures after 5 attempts, stop and explain the issue to the user. Do NOT bypass hooks.
Notes
- If the user says "just commit it" or similar, still follow the process — just skip the AskUserQuestion confirmation
- If there are no changes to commit, say so and stop
- Group related changes into one commit; suggest splitting if changes are unrelated
- When in doubt about the type,
feat for new things, fix for broken things, chore for everything else
1---2name: commit3description: Commit code with conventional commit messages tied to task context. Never skips hooks.4---56# Commit Changes78Create a well-structured git commit with a conventional commit message derived from the current task context.910## Rules1112- **NEVER use `--no-verify`.** Pre-commit hooks exist for a reason. If hooks fail, fix the issues and retry.13- **NEVER use `git add -A` or `git add .`** unless every changed file is relevant. Stage files by name.14- **NEVER amend a previous commit** unless the user explicitly asks for it.1516## Step 1: Understand What Changed1718Run these in parallel:19201. `git status` — see all changed, staged, and untracked files212. `git diff` — see unstaged changes223. `git diff --cached` — see already-staged changes234. `git log --oneline -5` — see recent commit style for this repo2425Review the changes and identify:26- Which files are related to the current task27- Which files are unrelated noise (editor configs, lock files from unrelated installs, etc.)28- Whether any files contain secrets, `.env` content, or credentials — **never commit those**2930## Step 2: Find the Task Context3132Look for task context to derive the commit message from. Check in order:33341. **Ralph PRD story** — if there's an active story, check `.ralph/progress.txt` for the current story ID and title. The commit message should reference this.352. **Recent conversation** — what did the user ask you to do? Use that as the commit description.363. **The diff itself** — if no other context, derive the purpose from the actual code changes.3738## Step 3: Craft the Commit Message3940Use **conventional commits** format matching this repo's style:4142```43type(scope): concise description of WHY44```4546### Types (pick the right one)47| Type | When to use |48|------|-------------|49| `feat` | New feature or capability |50| `fix` | Bug fix |51| `chore` | Maintenance, deps, config, version bumps |52| `test` | Adding or fixing tests |53| `docs` | Documentation only |54| `refactor` | Code restructuring, no behavior change |55| `style` | Formatting, whitespace, naming |56| `ci` | CI/CD pipeline changes |5758### Scope59- If working on a Ralph story: use the story ID — e.g., `feat(story-3): add user auth`60- If working on a specific module: use the module name — e.g., `fix(loop): handle empty config`61- If broad/cross-cutting: omit scope — e.g., `chore: bump version to 3.28.0`6263### Message rules64- Start with **lowercase** after the colon65- Focus on **why**, not what — the diff shows what66- Keep the first line **under 72 characters**67- If more detail is needed, add a blank line and a body paragraph6869### Examples from this repo70```71feat: add Working Principles to CLAUDE.md and plansDirectory to settings72feat(story-3): add user authentication with JWT73fix: bash 3.2 unbound variable when run_loop called with no args74chore: bump version to 3.27.175test(api): add integration tests for /users endpoint76refactor: extract verification into separate modules77```7879## Step 4: Stage and Commit80811. **Stage only the relevant files** by name — do NOT use `git add -A` or `git add .`822. **Show the user** the proposed commit message and list of staged files before committing833. **Ask if the message looks right** using AskUserQuestion with options:84 - "Looks good, commit it"85 - "Let me edit the message" (then ask for their preferred message)864. **Run the commit** — use a HEREDOC for the message:8788```bash89git commit -m "$(cat <<'EOF'90type(scope): message here91EOF92)"93```94955. **Run `git status`** after to confirm it succeeded9697## Step 5: Handle Hook Failures9899If pre-commit hooks fail:1001011. **Read the hook output** carefully1022. **Fix the issues** the hooks identified (lint errors, secrets detected, etc.)1033. **Re-stage** the fixed files1044. **Commit again** — same message, same process, NO `--no-verify`105106If hooks auto-fix files (e.g., prettier, eslint --fix):1071. Review the auto-fixes1082. Stage the auto-fixed files1093. Retry the commit110111**If you cannot resolve hook failures after 5 attempts**, stop and explain the issue to the user. Do NOT bypass hooks.112113## Notes114115- If the user says "just commit it" or similar, still follow the process — just skip the AskUserQuestion confirmation116- If there are no changes to commit, say so and stop117- Group related changes into one commit; suggest splitting if changes are unrelated118- When in doubt about the type, `feat` for new things, `fix` for broken things, `chore` for everything else