Review your changes before you commit
Have Claude Code review uncommitted changes against their intent and flag risks by severity, asking before any check that could change files.
Task: Review your changes before you commit · Other tasks
Fill in the details
Optional. Parts you are least sure about.
Copy your prompt
This site doesn't run Claude or show model output. Results depend on your input and the model you use.
You've edited the prompt, so changes to the fields aren't applied.
Replace what you've entered for this task with the example? This can't be undone.
What you type is kept in this tab's session storage so a reload doesn't lose it. Use "Clear this task" to remove it. Browsers can restore session data when they reopen tabs, so closing a tab isn't a guaranteed way to erase it.
When to use this template
- You have finished a change in a git repository and want a second look before it becomes a commit, while fixes are still cheap and private.
- The change touches something sensitive, such as a migration, a permission check or a public API, and you want those parts called out on their own.
- You want the review measured against what the change was supposed to do, so unrelated edits and scope creep show up as findings.
When not to use it
- You only want a quick correctness pass without describing the intent. Claude Code has a bundled
/code-reviewskill that reviews the current diff in a fresh subagent. - The changes are already pushed and open as a pull request. Review the pull request instead, so comments land where the rest of the team will see them.
- The project is not in a git repository. Without version control there is no uncommitted diff to review; point Claude at the files and use the general code review template.
Why this structure
- The intent field gives the review something to measure against. Without it, Claude can only judge whether the code looks reasonable, not whether it does what you meant.
- The review-only rule is explicit because the working tree holds your unfinished work. Claude reports findings; you decide what to change and when to commit.
- The scope setting decides whether new untracked files are included. A new file is easy to forget in a review, and it is often where stray debug output or secrets end up.
- The flag list in step 2 names the kinds of problem that are hard to undo once committed or pushed, such as secrets and migrations, so they are on the list for every review.
- Step 3 has Claude read each check before running it. Checks that leave files and external state unchanged run directly and add evidence to the findings; checks that may write snapshots, build output or anything outside the project wait for your approval, which keeps the review read-only.
- Sorting findings by severity, and asking for a plain "nothing risky" when that is true, puts the findings that matter for this commit at the top instead of in a long list of minor preferences.
Example input (fictional)
- What the change is meant to do
Add retry with exponential backoff to the payment client, up to three attempts. Nothing else should change.
- Look especially closely at
error handling when all retries fail
- Changes to review
all staged and unstaged changes, plus new files git does not track yet
Follow-ups to send Claude
- Fix the must-fix findings only, then show me the new diff. Do not commit.
- Split the unrelated changes you found into a separate list of files and lines, so I can commit them on their own.
- Write a commit message for these changes that states what changed and why, in under 72 characters for the first line.
Common mistakes
- Leaving the intent vague, such as "some fixes". The review then cannot tell an intended change from an accidental one.
- Asking Claude to review and fix in the same step. Read the findings first; some will be intended, and fixing them would undo your work.
- Treating every finding as a must-fix. A reviewer asked to find problems will usually find some, so decide which ones matter for this commit.
Related templates
- Code review prompt: Ask Claude to review a diff for supported issues, ordered by severity, with a location, impact and suggested fix for each finding.
- Write tests, run them, fix failures: Ask Claude Code to write tests for a file, run them and work through the failures in one go, without weakening a test just to make it pass.
- Draft release notes from git history: Have Claude Code compare two git tags or branches and draft release notes grouped into breaking changes, features and improvements for your readers.
Sources
- Claude Code docs: Prompt library (Anthropic documentation)
- Claude Code best practices: Add an adversarial review step (Anthropic documentation)
- Claude Code docs: Desktop app, review your code (Anthropic documentation)