feat(agent): instruct sessions to follow repo rules and comment style - #91603
Conversation
|
😎 Merged successfully - details. |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
🤖 CI report✅ Trunk lane — non-backend laneThis PR is assigned to the non-backend lane. It does not run backend Python tests and may merge in parallel with PRs in other lanes. |
HostHog preview —
|
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.
12907b0 to
f473bdd
Compare
Prompt To Fix All With AI### Issue 1
products/desktop/packages/agent/src/adapters/claude/session/instructions.ts:48
**AGENTS.md discovery omits scoped guides**
When a repository has nested `AGENTS.md` files, or maintains independent `AGENTS.md` content alongside `CLAUDE.md`, this instruction skips applicable conventions, causing generated edits to violate the repository rules this feature is intended to enforce.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "feat(agent): instruct sessions to follow..." | Re-trigger Greptile |
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.
skoob13
left a comment
There was a problem hiding this comment.
We might be adding useless tokens here. It's worth checking whether CLAUDE/AGENTS.md applies automatically. If not, makes sense to fix that first.
|
|
||
| Repositories carry their own coding conventions. Before your first edit, discover and read the ones this harness does not load for you: | ||
|
|
||
| - \`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. |
There was a problem hiding this comment.
Shouldn't AGENTS/CLAUDE.md files automatically apply? I don't think we need to mention it here.
There was a problem hiding this comment.
Claude automatically apply for Claude SDK
Agent for Codex
So if you have both, that's great, but if you are having just CLAUDE.md and using our codex, it will be ignored.
If not, makes sense to fix that first.
You mean updating our harness to include the .md files as part of the prompt? If yes, kinda had the solution, but looks really heavy
| Repositories carry their own coding conventions. Before your first edit, discover and read the ones this harness does not load for you: | ||
|
|
||
| - \`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. |
There was a problem hiding this comment.
They should probably migrate to AGENTS/CLAUDE instead.
There was a problem hiding this comment.
Ideally, but a lot of users still using that :(

Problem
AGENTS.md, and add comments that just narrate the change (support ticket 64146).CLAUDE.mdautomatically, but nothing points the agent atAGENTS.md,.cursor/rules/*.mdc, or.cursorrules, and nothing asks it to match the repo's comment style.Changes
alwaysApply,globs) so the agent applies each rule where it belongs.Nothing user-visible changes in the app UI; the change is prompt content.
How did you test this code?
instructions.test.ts, guarding against the block being dropped from the assembled prompt.@posthog/agentfirst.Automatic notifications
Docs update
None.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
/posthog-desktop,/writing-tests,/writing-code-comments,/writing-pr-descriptions,/simplify.turbo typecheck --filter=@posthog/agent, Biome,hogli ci:preflight(pre-push hook).