Skip to content

Team collaboration with coding agents makes the repository—rather than individual engineers—the owner of every agent’s operating context: one committed AGENTS.md core with thin adapters for Claude Code, Codex, and Cursor, review settlements codified as rules in the same pull request, branch-committed plans for clean handoffs, and automated checks proving rules load reliably.

Two engineers on your team ask their agents for a new API endpoint on Monday morning. One gets a handler wrapped in your asyncHandler() throwing AppError; the other gets a bare async function throwing raw errors in the wrong folder. Code review burns 30 comments on settled conventions before anyone checks whether the endpoint works. This guide equips tech leads and engineers to put those conventions in the repository where every agent reads them once.

Shared context covers everything any teammate’s agent needs to produce code reviewers accept. Personal context covers preferences that only speed up one engineer. Mixing the two causes rules to rot: personal shortcuts committed to the shared core turn into contested dogma nobody agreed on.

ContextScopeWhere it livesWho approves changes
Build/test commands, definition of done, protected paths, human gatesSharedRoot AGENTS.mdHarness owner via CODEOWNERS PR
Package-specific invariants or risk-area conventionsSharedSubdirectory AGENTS.mdPackage owner
Active ticket specs, plans, and handoff notesShared (branch-scoped)docs/plans/<ticket-id>.mdTicket owner (deleted or archived on merge)
Repeatable multi-step workflows (releases, migrations, triage)Shared (loaded on demand)Agent Skills (SKILL.md, see skills)Skill owner
Verbosity, editor habits, local convenience shortcutsPersonalUser-level settings or gitignored local filesEach engineer
Session discoveries from one engineer’s workPersonal until promotedTool memory, promoted into AGENTS.md by PRHarness owner upon promotion

One canonical core, thin per-tool adapters

Section titled “One canonical core, thin per-tool adapters”

Maintain one source of truth in root and directory AGENTS.md files, and resist duplicating rules across vendor-specific configs. Every duplicated rule drifts the first time someone updates only one file.

  • Shared core: commit a thin root CLAUDE.md whose first line imports @AGENTS.md, followed only by Claude-specific instructions (for example, references to .claude/agents/ subagents or hook expectations). Keep review-only criteria in REVIEW.md.
  • Personal: store local preferences in gitignored CLAUDE.local.md and promote recurring discoveries from session memory into AGENTS.md via pull request.
  • Deterministic controls: enforce hard limits with managed and project Hooks (PreToolUse, PostToolUse, Stop), never prose alone. See Claude Code docs.

Package multi-step team procedures as open Agent Skills (SKILL.md, browse patterns at skills.wondel.ai) so they load on demand instead of bloating every session’s base context. Connect shared internal tools through MCP servers owned by the team (MCP hub).

Three routines that keep team context accurate

Section titled “Three routines that keep team context accurate”

Draft AGENTS.md from patterns your repository actually ships rather than outdated wiki pages.

  1. Sample representative modules. Have an agent inspect 3–4 route handlers, 2–3 core components, adjacent test files, and CI workflows to extract real commands, helper names, and a list of conflicting patterns.
  2. Resolve conflicts in one 30-minute meeting. Pick one canonical pattern for each inconsistency with your frequent reviewers and list deprecated patterns explicitly under Do not.
  3. Commit core, thin adapters, and CODEOWNERS together. Keep root AGENTS.md tight (under ~150 lines) and assign a named harness owner to review changes.
  4. Announce the operating norm. Tell the team where the core lives and establish that recurring convention comments in PR review now become rule updates.

2. Turn review settlements into rules in the same PR

Section titled “2. Turn review settlements into rules in the same PR”

Shared rules stay current only when code review feeds them. Whenever a review thread settles an architectural or error-handling convention, add one imperative bullet with a one-line why to AGENTS.md inside that same pull request. A convention settled only in a closed review comment vanishes after merge; codified in AGENTS.md, it steers both authoring sessions and automated reviewers (Claude Code Review, Codex GitHub review, and Cursor Bugbot) on the next pull.

Three guardrails keep the file lean:

  • Cite the trigger: every rule PR links the review thread, incident, or onboarding miss that motivated it.
  • Single harness owner: anyone can propose a rule, while one named owner prevents contradictions and bloat.
  • Second comment = harness bug: the second time a reviewer explains the same convention in a month, the fix belongs in a linter or AGENTS.md.

Rules capture how the team builds; branch plans capture what a ticket is doing right now. When a plan lives only in one engineer’s local chat history, nobody else’s agent can pick up the branch or review changes against intent.

  • Keep one ticket plan at docs/plans/<ticket-id>.md on the feature branch: goal, acceptance criteria, settled design decisions, and verification commands (spec-driven development).
  • Append a verified Handoff section before passing a branch to a teammate (completed commits, ordered remaining checklist, rejected options, exact verification command + exit result, and codebase gotchas).
  • Delete or archive the plan on merge so stale plans never mislead future sessions.

How to verify every agent follows shared rules

Section titled “How to verify every agent follows shared rules”

Verify conformance through three progressively stronger layers instead of relying on manual line checks:

  1. Deterministic gates first. Move every mechanically checkable rule into linters, type checks, formatters, or fitness functions. Models need not memorize rules a compiler or linter enforces automatically.
  2. Automated harness audit in CI. Run npx @wondelai/harness-audit --ci on pull requests touching harness files to detect bloated instruction files, policy duplication between AGENTS.md and tool adapters, missing CODEOWNERS, or retired configuration keys (harness audit guide).
  3. Conformance pass and monthly review metric. Before requesting human review, run an automated conformance review checking the branch diff strictly against root and touched-directory AGENTS.md files. Track convention-tagged human review comments per merged PR each month: the count should steadily decline as deterministic gates and AGENTS.md absorb them.

Failure modes when teams share agent context

Section titled “Failure modes when teams share agent context”
  • Core drifts from live code. Agents repeat patterns the team retired months ago. Recovery: re-audit AGENTS.md against representative source modules quarterly and reconcile every mismatch in one PR.
  • Tool configurations diverge. One engineer’s agent ignores conventions followed by everyone else because of a stale AGENTS.override.md, a missing @AGENTS.md import in CLAUDE.md, or a stale .cursor/rules/ copy. Recovery: delete duplicate copies and override files, enforce single-source checks via @wondelai/harness-audit, and verify loaded instructions in a fresh session after major tool upgrades.
  • Context bloat crowds out late rules. Long files hit size caps or lose model attention near the bottom. Recovery: move procedures into on-demand SKILL.md skills, shift checkable rules into linters, and trim dead lines with pruning context files.
  • Rules state “what” without “why”. Agents apply a rule in HTTP handlers yet ignore it in background jobs because they cannot generalize intent. Recovery: attach a one-line rationale to every bullet.
  • Prose rules treated as security boundaries. An instruction saying “never read .env” fails under prompt injection or accidental tool calls. Recovery: enforce hard boundaries with hooks, sandboxes, permission policies, and branch protection (agent hooks).

Review vendor documentation for current rule-loading precedence and channel integrations: Claude Code docs, OpenAI Codex docs, Cursor docs, Agent Skills, and MCP.

Did this guide help you?

One tap, no sign-in.

not at all a lot