skip to content

In Cursor's Agent chat, what do `@Commit (Diff of Working State)` and `@Branch (Diff with Main)` attach, and when do you use each?

level: middleimportance: nice to knowfreq 5%

answer

  1. type @ in the chat input
  2. named after git, not literal
  3. uncommitted versus the whole branch
  4. terminal output and earlier chats too
  5. skip it when unsure which files

basics

~20 s

In Cursor's Agent chat, @Commit (Diff of Working State) attaches your uncommitted changes, not a past commit; @Branch (Diff with Main) attaches your full branch diff against main. Use the first for work in progress, the second for the whole feature.

solid answer

~50 s

Typing `@` in Cursor's chat input attaches specific context to the conversation. The two git entries are easy to misread: `@Commit (Diff of Working State)` attaches your **uncommitted changes** — the working state, not the last commit — and `@Branch (Diff with Main)` attaches the **full diff of your branch** against main. Reach for `@Commit` when Agent should look at what you have changed but not yet committed, say before you commit; reach for `@Branch` when it should consider the whole feature, for instance checking it against the team's conventions or drafting a pull-request description. The same menu attaches files and folders, `@Terminals` for terminal output, `@Chats` for an earlier conversation and `@Browser` for the built-in browser. When you do not know which files matter, skip @-mentions: Agent finds relevant files through its own search.

go deeper

for a junior

Know that typing @ attaches files, folders, terminal output, earlier chats and git diffs, and that Agent still searches the repository on its own.

for a middle

Explain that @Commit is the uncommitted working-state diff while @Branch is the full branch against main, and pick the right one for a pre-commit check or a whole-feature review.

for a senior

Use the diff mentions to pin down exactly which change Agent discusses, and coach the team to attach only what is known to matter instead of flooding the context.

for a principal

Treat attached context as part of a reproducible workflow: the diff, the failing output and the manual rule a task needs, named the same way across the team.

## What an @-mention does In Cursor, typing **`@`** in Agent's chat input opens a menu of context you can attach to the conversation. Start typing after the `@` and Cursor narrows the suggestions. Each item you pick is added to the conversation, and you can type `@` several times to attach several items. The point is focus: you hand Agent the material you already know is relevant instead of waiting for it to search. ## The menu | Mention | What it attaches | Typical use | | :-- | :-- | :-- | | `@auth.ts`, `@src/components/` | A file or a folder (type `/` after a folder to go deeper) | Point Agent at a component and its test | | `@Terminals` | Terminal output | A failing test run or a stack trace | | `@Chats` | Context from a previous conversation | Continue a decision made in another chat | | `@Commit (Diff of Working State)` | Your uncommitted changes | Look over work in progress | | `@Branch (Diff with Main)` | Your full branch diff | Consider the whole feature | | `@Browser` | Context from the built-in browser | A page the app is rendering | ## The two git mentions — and the naming trap The labels are short, and the short form misleads: - **`@Commit` is not a commit.** Its full label is *Diff of Working State*: it attaches the changes in your working tree that you have **not yet committed**. Someone who expects "my last commit" gets something else — and if everything is already committed, there may be little or nothing to attach. - **`@Branch` is the whole branch.** *Diff with Main* means the full diff of the current branch against main — every commit on the feature, not only the latest. Choosing between them follows the question you are asking: 1. *"Does what I just changed break the convention?"* — `@Commit`, before you commit. 2. *"Is this feature, as a whole, consistent with our rules?"* — `@Branch`, before you open the pull request. 3. *"Summarise this branch for reviewers."* — `@Branch`, since the reviewers will see the whole diff. Attaching a diff tells Agent precisely which change is under discussion, which is far more reliable than describing the change in words. ## Other context worth attaching - **Files and folders.** When you want Agent to update a component and its tests, mention both files. A folder mention brings in the folder's contents, which is different from a diff. - **`@Terminals`.** Hand over the output of a failing command without copy-pasting it. - **`@Chats`.** Reuse context from an earlier conversation instead of re-explaining it. - **`@Browser`.** Attach what the built-in browser is showing. - **Rules.** An **Apply Manually** project rule enters a conversation only when you `@`-mention it by name, for example `@migration-rules`. Rules can also mention files themselves — `@service-template.ts` inside a rule body includes that file in the rule's context. ## A pre-commit check in practice A typical sequence for checking work against the team's conventions before committing: 1. Make the change and run the tests in Cursor's terminal. 2. In Agent's chat, attach `@Commit (Diff of Working State)` and `@Terminals`, and ask whether the change follows the repository's rules and why the test failed. 3. Fix, commit, and when the feature is complete attach `@Branch (Diff with Main)` to look at the whole branch once more. Each step names exactly which material is in play, so the answer is about this change and not a guess about which one you meant. ## When not to @-mention Cursor's guidance is direct: use @-mentions **when you know which files are relevant**, and if you are not sure which files matter, skip them — Agent finds relevant files through its own search. Over-attaching costs context: each item you mention is added to the conversation whether it turns out to matter or not. How that search works, and which files ignore settings keep away from Agent, is a separate subject from attaching context. ## Summary - `@` attaches context: files, folders, terminal output, earlier chats, git diffs, browser context, manual rules. - `@Commit (Diff of Working State)` = uncommitted changes; `@Branch (Diff with Main)` = the whole branch against main. - Mention what you know is relevant; otherwise let Agent search.

  • You committed everything a minute ago and attach `@Commit (Diff of Working State)` to ask about "my last commit" — what does Agent get?
    Your uncommitted changes, which right after a full commit may be nothing. `@Commit` is the working-state diff, not a past commit. To discuss everything on the feature, attach `@Branch (Diff with Main)` instead, which carries the full branch diff against main.
  • A test run just failed in Cursor's terminal — how do you give the output to Agent without pasting it?
    Type `@Terminals` in the chat input; it includes terminal output as context. Add the test file and the code under test with file @-mentions if you already know which they are.
  • How does an Apply Manually rule join a Cursor conversation?
    Only through an @-mention of the rule by name, such as `@migration-rules`. A rule with `alwaysApply: false`, no `description` and no `globs` is never pulled in by relevance or by file pattern, so mentioning it is the only way in.

  • @Commit attaches the most recent commit you made
  • @Branch attaches only the newest commit on the branch
  • Agent cannot see a file unless you @-mention it
  • @-mentions only work for files, not terminal output or earlier chats
  • Attaching more @-mentions always gives Agent better answers