Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ describe("buildAppendedInstructions", () => {
expect(withNarration.startsWith(withoutNarration)).toBe(true);
expect(withoutNarration.length).toBeGreaterThan(0);
});

it("tells the agent to follow repo conventions, including Cursor rules", () => {
const instructions = buildAppendedInstructions({ spokenNarration: false });
expect(instructions).toContain("# Repository Conventions");
expect(instructions).toContain(".cursor/rules/");
expect(instructions).toContain("comment density");
});
});
16 changes: 15 additions & 1 deletion packages/agent/src/adapters/claude/session/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ Optimize for the fewest shell round trips.
- Never rerun a command solely to reproduce output you already have.
`;

const REPOSITORY_CONVENTIONS = `
# Repository Conventions

Make your changes read like the surrounding code so they pass review unchanged. Match the repository's own conventions rather than imposing your own defaults.

- Before writing code, look for repo-level convention files and follow them: \`CLAUDE.md\`, \`AGENTS.md\`, \`.cursorrules\`, and any rule files under \`.cursor/rules/\` (usually \`*.mdc\`). You load \`CLAUDE.md\` and \`AGENTS.md\` automatically, but you do NOT read Cursor rules on your own — open and honor those files yourself whenever they are present.
- Mirror the existing code's style: naming, formatting, imports, and especially comment density. Do NOT add comments that narrate your change or restate what the code plainly does. Only add a comment where the surrounding code already would, or where it explains genuinely non-obvious intent. Unnecessary comments read as noise and are a common review complaint.
`;

const SPOKEN_NARRATION = `
# Spoken Narration

Expand All @@ -64,7 +73,12 @@ How to phrase the line:
`;

const BASE_INSTRUCTIONS =
BRANCH_NAMING + PULL_REQUEST_LINKS + PLAN_MODE + MCP_TOOLS + SHELL_EFFICIENCY;
BRANCH_NAMING +
PULL_REQUEST_LINKS +
PLAN_MODE +
MCP_TOOLS +
SHELL_EFFICIENCY +
REPOSITORY_CONVENTIONS;

export function buildAppendedInstructions(opts: {
spokenNarration: boolean;
Expand Down
Loading