skip to content

A Cursor team keeps its conventions in project rules, yet Cmd/Ctrl+K inline edits keep ignoring them — why, and what does reach inline edit?

level: seniorimportance: should knowfreq 8%

answer

  1. which surfaces the rules system feeds
  2. Agent (Chat) only, all four modes
  3. not Tab, not inline edit, not Bugbot
  4. User Rules skip Cmd/Ctrl+K too
  5. hooks apply to Cmd+K operations

basics

~20 s

Cursor's rules apply only to Agent (Chat) — Agent, Ask, Plan and Debug modes — not to Tab, inline edit or Bugbot, and User Rules skip inline edit too. Hooks do reach it: Cursor says its Agent hooks cover Cmd+K.

solid answer

~50 s

This is documented behaviour, not a bug: Cursor's rules help says "Rules only apply to Agent (Chat). They do not apply to Tab completion, Inline Edit, or Bugbot PR reviews", and the rules FAQ adds that User Rules are not applied to inline edit either. So an `.mdc` rule with `alwaysApply: true` reaches every Agent conversation — Agent, Ask, Plan and Debug — but never the `Cmd+K` prompt. Inline edit acts on the selection and the instruction you type. What does reach it: **hooks** — the hooks page says its Agent hooks, `afterFileEdit` and `beforeSubmitPrompt` among them, apply to Cmd+K as well as Agent Chat, so a formatter in a committed `.cursor/hooks.json` runs on inline edits; and `.cursorignore` blocks inline edit from ignored files. The fixes: route convention-heavy changes through Agent with `Cmd/Ctrl+L`, state the convention in the instruction, and enforce what is mechanical with a hook.

code

json · 6 lines
json
{
  "version": 1,
  "hooks": {
    "afterFileEdit": [{ "command": ".cursor/hooks/format.sh" }]
  }
}

go deeper

for a junior

Recall that Cursor's rules are read by Agent, in all its modes, and not by Tab or the Cmd/Ctrl+K inline edit prompt.

for a middle

Explain the documented scope — Agent (Chat) yes; Tab, inline edit and Bugbot no; User Rules not in inline edit — and why changing a rule's apply mode cannot fix it.

for a senior

Diagnose the team's surprise and propose layered fixes: route convention-heavy work through Agent, state constraints in the instruction, and enforce mechanical rules with an afterFileEdit hook or CI.

for a principal

Decide what belongs in guidance versus enforcement: rules steer one surface, hooks and CI hold across all of them, and a policy that relies on rules alone leaves inline edits ungoverned.

## The symptom A team has written its conventions as Cursor **project rules** — `.mdc` files in `.cursor/rules`, some with `alwaysApply: true`. Agent follows them. But when developers select a function and use **inline edit** (`Cmd+K` on Mac, `Ctrl+K` on Windows/Linux), the result ignores the house error-handling style, the naming scheme, the forbidden library. Rewording the rule changes nothing. ## Why: the rules system feeds Agent, not inline edit Cursor documents the scope in three places: - the rules help page: "Rules only apply to Agent (Chat). They do not apply to Tab completion, Inline Edit, or Bugbot PR reviews"; - the rules reference FAQ: "User Rules are not applied to Inline Edit (Cmd/Ctrl+K). They are only used by Agent (Chat)"; - the Agent help page: project rules, user rules and team rules apply in Agent, Ask, Plan and Debug modes, "included in every conversation regardless of which mode you're using". So the dividing line is the surface, not the rule's type or wording. A rule's apply mode decides when Agent sees it; nothing about a rule makes the `Cmd+K` prompt see it. Inline edit acts on the selected code and the instruction you type. | Control | Reaches Agent (all modes) | Reaches inline edit (`Cmd/Ctrl+K`) | |---|---|---| | Project rules in `.cursor/rules` | Yes | No | | User Rules (Customize → Rules) | Yes | No | | Team Rules | Yes | No | | Agent hooks in `hooks.json` | Yes | Yes — the hooks page says they apply to Cmd+K | | `.cursorignore` | Yes, blocks access | Yes, blocks access | ## What does reach inline edit **Hooks.** Cursor's hooks are scripts declared in `hooks.json` that run before or after stages of the agent loop. The hooks page groups them as Agent hooks, Tab hooks and app lifecycle hooks, and says the Agent hooks — `sessionStart`, `beforeSubmitPrompt`, `afterFileEdit`, `stop` and the rest — "apply to Cmd+K and Agent Chat operations". Two are useful here: - `afterFileEdit` fires after a file is edited and is the documented place for formatters; a project hook in `.cursor/hooks.json` runs from the project root; - `beforeSubmitPrompt` sees a prompt before submission and can validate it. Project hooks are committed with the repository and load automatically for team members who open the project in a trusted workspace; user hooks live in `~/.cursor/hooks.json`. **The ignore file.** `.cursorignore` blocks access to listed files from Agent, Tab and inline edit alike. It is a file-access control, not a way to express conventions. ## A worked example Suppose a project rule with `alwaysApply: true` says "functions that call the payment gateway return the team's `Result` type and never throw". A developer selects one such function, presses `Cmd+K` and types "convert this to async". The rule never enters that request, so the converted function may well throw on failure. Nothing is broken: the developer used a surface the rule does not reach. The same instruction sent with `Cmd/Ctrl+L` starts an Agent conversation in which the always-applied rule is included, and the conversion is far more likely to keep the `Result` shape. A check of the result — a linter rule, a test, or a hook — is what catches the case either way. The diagnostic question to ask first is therefore not "what is wrong with the rule?" but "which surface produced this edit?". If the answer is inline edit or Tab, rule wording is irrelevant. ## What a team can do 1. **Send convention-heavy changes to Agent.** Select the code and press `Cmd/Ctrl+L`; Agent starts with the selection as context, and the rules apply there. 2. **Say the constraint in the inline instruction.** For a one-off edit, "convert to async, keep the existing `Result` return type" carries the convention where a rule cannot. 3. **Enforce the mechanical part with a hook.** Formatting and import ordering belong in an `afterFileEdit` hook (or the repository's own linters and CI) so they hold on every surface. 4. **Tell people.** Most of the surprise disappears once the team knows that rules are Agent's briefing, not an editor-wide policy. ## Related scope facts worth keeping straight - Rules do not affect Tab either; Tab has its own hooks (`beforeTabFileRead`, `afterTabFileEdit`). - Bugbot does not take these rules; it reads its own rule files. - Ask mode is part of Agent, so rules do apply there — only the inline surfaces are outside.

  • A Cursor rule is set to Always Apply. Does that bring it into inline edit?
    No. The apply mode — Always Apply, Apply Intelligently, Apply to Specific Files or Apply Manually — only decides when Agent includes the rule. Cursor's documentation says rules apply to Agent (Chat) and not to inline edit, so no rule setting extends them to the `Cmd/Ctrl+K` prompt.
  • Does a project hook in .cursor/hooks.json run for every developer on the team?
    Cursor's hooks page says project hooks are committed with the repository and load automatically for team members who open the project in a trusted workspace. Running from the project root, their command paths are written like `.cursor/hooks/format.sh`.

Project rules are the briefing handed to the crew that works through Agent; inline edit is a quick fix-it visit that never receives the briefing, while a hook is the inspector at the door who checks every job, quick visits included.

  • Setting alwaysApply: true makes a Cursor rule reach Cmd+K inline edits.
  • User Rules apply to every Cursor AI feature, inline edit included.
  • Inline edit ignoring the project rules is a bug to report.
  • Cursor hooks fire only for Agent Chat, never for Cmd+K.
  • Rules are skipped in Ask mode, the same way as in inline edit.