> ## Documentation Index
> Fetch the complete documentation index at: https://cisco-ea52c096.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Git workflows

> Use Claude Code's git commands to commit changes, review code, inspect diffs, and work with pull request comments.

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.

```text theme={null}
> /commit
```

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`

<Note>
  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.
</Note>

**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.

```text theme={null}
> /review
```

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:

```text theme={null}
> /review 142
```

<Tip>
  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.
</Tip>

## `/diff` — view current changes

Run `/diff` to see your uncommitted changes and per-turn diffs in the current session.

```text theme={null}
> /diff
```

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.

```text theme={null}
> /pr_comments
```

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.

<Note>
  `/pr_comments` requires the `gh` CLI to be installed and authenticated. Run `gh auth status` to verify.
</Note>

## Working with branches

Claude Code does not have a dedicated branch command, but you can ask Claude to manage branches using plain language:

```text theme={null}
> Create a new branch called feature/user-avatar from main and push it.
```

```text theme={null}
> Cherry-pick commit abc123 onto a new branch called hotfix/session-null
  and open a draft PR targeting main.
```

```text theme={null}
> What commits are on this branch that aren't in main yet?
```

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:

<Steps>
  <Step title="Make changes">
    Ask Claude to implement a feature or fix a bug. Claude edits the relevant files.

    ```text theme={null}
    > Add input validation to the POST /users endpoint. Return 400 with
      a validation error message if `email` is missing or malformed.
    ```
  </Step>

  <Step title="Review the diff">
    Check what changed before committing.

    ```text theme={null}
    > /diff
    ```
  </Step>

  <Step title="Commit">
    Let Claude stage and commit with a generated message.

    ```text theme={null}
    > /commit
    ```

    Claude inspects recent commits, writes a message that matches your style (for example: `fix: validate email on POST /users`), and creates the commit.
  </Step>

  <Step title="Review the code">
    Run a full code review before pushing.

    ```text theme={null}
    > /review
    ```
  </Step>

  <Step title="Push and open a PR">
    Ask Claude to push the branch and open a pull request.

    ```text theme={null}
    > Push this branch and open a PR targeting main. Use the commit
      message as the PR title. Mark it as a draft.
    ```
  </Step>

  <Step title="Address review comments">
    After teammates leave comments, fetch and respond to them.

    ```text theme={null}
    > /pr_comments
    ```

    ```text theme={null}
    > Address all the review comments on this PR.
    ```
  </Step>
</Steps>

## Tips for commit messages and review quality

<CardGroup cols={2}>
  <Card title="Let Claude match your style" icon="pencil">
    `/commit` reads your recent git log before writing a message. The more consistent your existing commit history, the better Claude's messages will be.
  </Card>

  <Card title="Stage selectively before /commit" icon="check-square">
    Use `git add` to stage only the files you want in a commit before running `/commit`. Claude respects what's staged.
  </Card>

  <Card title="Use /review before pushing" icon="shield">
    Running `/review` on a local branch catches issues before they become PR review comments from teammates.
  </Card>

  <Card title="Address PR comments in one pass" icon="messages-square">
    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.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.