Skip to main content
Claude Code integrates tightly with git. You can commit changes, review code, inspect diffs, and fetch PR comments without leaving your terminal session.

/commit — create a git commit

Run /commit and Claude inspects your staged and unstaged changes, reads recent commit history to match your project’s message style, and creates a commit with a generated message.
Claude does the following:
  1. Runs git status and git diff HEAD to see all changes
  2. Checks git log to learn your project’s commit message conventions
  3. Stages relevant files and writes a commit message focused on the “why” of the change
  4. Creates the commit using git commit
Claude will not commit files that appear to contain secrets (for example, .env or credentials.json). If you ask it to commit those files, it will warn you first.
What Claude commits:
  • Summarizes the nature of the change: new feature, bug fix, refactor, docs, etc.
  • Uses the commit message style already present in your repository (conventional commits, imperative mood, etc.)
  • Never uses --amend or skips hooks unless you explicitly ask
Safety rules Claude follows during /commit:
  • Never runs git config changes
  • Never skips hooks (--no-verify)
  • Never creates an empty commit if there are no changes
  • Never uses interactive git commands (git rebase -i, git add -i)

/review — review code

Run /review to get a code review of your current changes against the base branch.
For teams on Pro or Max plans, /review runs as /ultrareview — a cloud-based review that takes 10–20 minutes and uses a fleet of specialized agents to find bugs, security issues, and logic errors. You’ll be notified when the results arrive. To review a specific pull request by number:
Ultrareview requires your branch to be pushed and uses the GitHub app if installed. If the diff is too large to bundle, push a PR and use /review <PR number> instead.

/diff — view current changes

Run /diff to see your uncommitted changes and per-turn diffs in the current session.
This shows:
  • All uncommitted changes in the working tree
  • A per-turn view of what Claude changed in the current session
Use this to audit what Claude has done before committing.

/pr_comments — fetch PR comments

Run /pr_comments to fetch and display all comments on the current pull request.
Claude uses the GitHub CLI (gh) to:
  1. Get the PR number and repository from gh pr view
  2. Fetch PR-level comments via the GitHub API
  3. Fetch inline code review comments, including the diff context, file path, and line number for each
Comments are displayed in a readable format grouped by file and thread. Inline comments show the diff_hunk so you can see exactly what the reviewer was looking at.
/pr_comments requires the gh CLI to be installed and authenticated. Run gh auth status to verify.

Working with branches

Claude Code does not have a dedicated branch command, but you can ask Claude to manage branches using plain language:
Claude uses the shell and git commands to carry out the operation, showing you the exact commands it runs.

Example: full workflow from change to PR

Here’s a realistic end-to-end example:
1

Make changes

Ask Claude to implement a feature or fix a bug. Claude edits the relevant files.
2

Review the diff

Check what changed before committing.
3

Commit

Let Claude stage and commit with a generated message.
Claude inspects recent commits, writes a message that matches your style (for example: fix: validate email on POST /users), and creates the commit.
4

Review the code

Run a full code review before pushing.
5

Push and open a PR

Ask Claude to push the branch and open a pull request.
6

Address review comments

After teammates leave comments, fetch and respond to them.

Tips for commit messages and review quality

Let Claude match your style

/commit reads your recent git log before writing a message. The more consistent your existing commit history, the better Claude’s messages will be.

Stage selectively before /commit

Use git add to stage only the files you want in a commit before running /commit. Claude respects what’s staged.

Use /review before pushing

Running /review on a local branch catches issues before they become PR review comments from teammates.

Address PR comments in one pass

After running /pr_comments, ask Claude to “address all the review comments” in a single prompt. It reads each comment and makes the relevant edits.