From f473bdd2d977305ad3e854c7dd1ca8bb4aad23b8 Mon Sep 17 00:00:00 2001 From: Vojta Bartos Date: Mon, 31 Aug 2026 15:19:44 +0200 Subject: [PATCH 1/2] feat(agent): instruct sessions to follow repo rules and comment style Coding agent sessions ignored conventions kept in Cursor rules and AGENTS.md, and added comments that narrate the change. A Repository Conventions block in the appended instructions now tells the agent to read those files before its first edit and to match the surrounding code's comment density. --- .../src/adapters/claude/session/instructions.test.ts | 1 + .../src/adapters/claude/session/instructions.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/products/desktop/packages/agent/src/adapters/claude/session/instructions.test.ts b/products/desktop/packages/agent/src/adapters/claude/session/instructions.test.ts index d720e82a01dd..b5b9067b544c 100644 --- a/products/desktop/packages/agent/src/adapters/claude/session/instructions.test.ts +++ b/products/desktop/packages/agent/src/adapters/claude/session/instructions.test.ts @@ -22,6 +22,7 @@ describe("buildAppendedInstructions", () => { "# Plan Mode", "# MCP Tool Access", "# Data Handling", + "# Repository Conventions", "# Shell Efficiency", ])("always appends %s", (heading) => { expect(buildAppendedInstructions({ spokenNarration: false })).toContain( diff --git a/products/desktop/packages/agent/src/adapters/claude/session/instructions.ts b/products/desktop/packages/agent/src/adapters/claude/session/instructions.ts index 93e611c76c57..59bc377b6f70 100644 --- a/products/desktop/packages/agent/src/adapters/claude/session/instructions.ts +++ b/products/desktop/packages/agent/src/adapters/claude/session/instructions.ts @@ -40,6 +40,17 @@ const DATA_HANDLING = ` Material you were given as task context — customer conversations, support tickets, logs, internal threads — stays out of code, test data, comments, commit messages, and pull request text. Rewriting it, summarizing it, or swapping out names and domains does not clear it. `; +const REPOSITORY_CONVENTIONS = ` +# Repository Conventions + +Repositories carry their own coding conventions. Before your first edit, discover and read the ones this harness does not load for you: + +- \`AGENTS.md\` at the repo root, when there is no \`CLAUDE.md\` (\`CLAUDE.md\` itself is loaded for you automatically). +- Cursor rule files: \`.cursor/rules/*.mdc\` and the legacy \`.cursorrules\`. These are never loaded automatically. A rule's frontmatter tells you its scope: \`alwaysApply: true\` rules apply to every change, \`globs\` scope a rule to matching files. + +Follow those conventions, and match the style of the surrounding code even where no rule states it. Comment density matters most: do not add comments that narrate the change or restate what the code plainly does. Keep only comments a rule or the existing code style would call for. +`; + const SHELL_EFFICIENCY = ` # Shell Efficiency @@ -77,6 +88,7 @@ const BASE_INSTRUCTIONS = PLAN_MODE + MCP_TOOLS + DATA_HANDLING + + REPOSITORY_CONVENTIONS + SHELL_EFFICIENCY; /** Shell-word shaped, so nothing else in the variable reaches the prompt. */ From 41a4b592d7ce31a913f82f617af14a21ddd6699e Mon Sep 17 00:00:00 2001 From: Vojta Bartos Date: Mon, 31 Aug 2026 15:41:07 +0200 Subject: [PATCH 2/2] fix(agent): cover nested and independent convention files in the prompt AGENTS.md guidance no longer gates on CLAUDE.md being absent: the agent checks AGENTS.md at the root and in edited directories, and skips only content that mirrors CLAUDE.md. Nested .cursor/rules/ directories are named as well. --- .../agent/src/adapters/claude/session/instructions.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/products/desktop/packages/agent/src/adapters/claude/session/instructions.ts b/products/desktop/packages/agent/src/adapters/claude/session/instructions.ts index 59bc377b6f70..1f212c056659 100644 --- a/products/desktop/packages/agent/src/adapters/claude/session/instructions.ts +++ b/products/desktop/packages/agent/src/adapters/claude/session/instructions.ts @@ -45,8 +45,8 @@ const REPOSITORY_CONVENTIONS = ` Repositories carry their own coding conventions. Before your first edit, discover and read the ones this harness does not load for you: -- \`AGENTS.md\` at the repo root, when there is no \`CLAUDE.md\` (\`CLAUDE.md\` itself is loaded for you automatically). -- Cursor rule files: \`.cursor/rules/*.mdc\` and the legacy \`.cursorrules\`. These are never loaded automatically. A rule's frontmatter tells you its scope: \`alwaysApply: true\` rules apply to every change, \`globs\` scope a rule to matching files. +- \`AGENTS.md\` files: at the repo root and in any directory whose files you edit. \`CLAUDE.md\` is loaded for you automatically; when an \`AGENTS.md\` merely mirrors it you can move on, but when it carries its own content, follow that too. +- Cursor rule files: \`.cursor/rules/*.mdc\` (the repo root's, and any nested \`.cursor/rules/\` near the files you edit) and the legacy \`.cursorrules\`. These are never loaded automatically. A rule's frontmatter tells you its scope: \`alwaysApply: true\` rules apply to every change, \`globs\` scope a rule to matching files. Follow those conventions, and match the style of the surrounding code even where no rule states it. Comment density matters most: do not add comments that narrate the change or restate what the code plainly does. Keep only comments a rule or the existing code style would call for. `;