Skip to content

feat(agent): Instruct agent to follow repo rules and match comment style - #3900

Open
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/agent-follow-repo-conventions
Open

feat(agent): Instruct agent to follow repo rules and match comment style#3900
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/agent-follow-repo-conventions

Conversation

@posthog

@posthog posthog Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Problem

An inbox-beta user (ticket #64146) asked whether they can give the coding agent extra guidance, and reported that generated PRs don't follow their coding style, add lots of unnecessary comments that just explain the fix, and ignore the repo's cursor/claude rules. Giving direction at Create-PR time already shipped (the feedback steering prompt), but nothing made the agent honor the repo's own conventions or match its comment style.

Changes

Added a Repository Conventions block to the agent's appended system-prompt instructions (buildAppendedInstructionsbuildSystemPrompt), which is applied to every session (desktop and cloud, including inbox-generated PRs). It tells the agent to:

  • Discover and follow repo-level convention files before writing code: CLAUDE.md, AGENTS.md, .cursorrules, and rule files under .cursor/rules/ (*.mdc). Claude Code loads CLAUDE.md/AGENTS.md natively but never reads Cursor rules, so the instruction explicitly points the agent at them.
  • Mirror the existing code's style, especially comment density – don't add comments that narrate the change or restate what the code plainly does.

Why: directly addresses the beta feedback that PRs ignore coding style, over-comment, and skip the repo's cursor/claude rules.

How did you test this?

  • Added and ran packages/agent/src/adapters/claude/session/instructions.test.ts – asserts the new "Repository Conventions" block is present (referencing .cursor/rules/ and comment density). All 4 tests pass via pnpm exec vitest run.
  • Change is confined to a leaf constant file (instructions.ts) with no new imports.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code from an inbox report

Adds a "Repository Conventions" block to the agent's appended system-prompt
instructions telling it to discover and follow repo-level convention files
(CLAUDE.md, AGENTS.md, .cursorrules, .cursor/rules/*.mdc) and to mirror the
existing code's comment density instead of adding narrating comments.

Claude Code loads CLAUDE.md/AGENTS.md natively but never reads Cursor rules,
and nothing previously reinforced matching the repo's comment style. This
addresses inbox-beta feedback that generated PRs ignore the user's coding
style, add unnecessary comments, and don't follow the repo's cursor/claude
rules.

Applies to every session (desktop and cloud, including inbox-generated PRs)
via buildAppendedInstructions -> buildSystemPrompt.

Generated-By: PostHog Code
Task-Id: 0a966bbb-531f-439e-a3c2-c2c6b0aabb79
@trunk-io

trunk-io Bot commented Jul 28, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 1ecb403.

@Twixes
Twixes marked this pull request as ready for review July 28, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants