Skip to content
mentoor

Topic 1 of 5 · 4 min read

Shared agent rules for a team

Goal: Decide which rules belong in the shared project memory file versus personal settings, and review a change to them.

Put the rules every agent and every teammate needs into one committed file, and keep personal taste out of it. A file such as AGENTS.md or CLAUDE.md sits in the repository, is reviewed like code, and is read by the agent at the start of each session.

Check yourself · 1 of 3

Which line belongs in the team's committed AGENTS.md?

Choose one answer

Why it matters

Without a shared file, each engineer teaches their own agent separately. One person's agent runs npm test, another's runs pnpm vitest, a third never learns that generated files must not be edited. The same mistake is made, noticed and fixed over and over. A committed file turns one person's lesson into everyone's default. It also gives you a place to review the rules: a bad rule now shows up in a pull request instead of hiding in someone's laptop.

What goes where

  1. Shared and committed: how to build, test and lint; the folder layout; naming and error-handling conventions; things the agent must never touch (migrations that were already applied, vendored code, generated files); the definition of done for this repo.
  2. Shared skills and hooks: repeatable procedures, such as "how we add an API endpoint", and checks that must always run, such as a hook that runs the formatter after every edit. If a rule must hold every time, a hook enforces it. A sentence in the memory file only asks.
  3. Personal and not committed: your editor habits, your preferred tone of explanation, your own shortcuts, local paths, anything with a token or password. Claude Code, Cursor, Copilot and Codex all have a personal layer for this.

How to keep the file healthy

  • Write rules as short, checkable lines. "Run pnpm test:unit before saying a task is done" can be checked. "Write good code" cannot.
  • Say why when the reason is not obvious. An agent that knows why a rule exists applies it better.
  • Review changes to the file with the same care as code. A new line applies to every future session of every teammate.
  • Prune. Old and conflicting rules waste the agent's context and get ignored.

Before and after

Before, in a committed file:

- I like short answers.
- Use my local DB at /Users/sam/pg.
- Be careful with the payments code.

After:

- Run `pnpm test:unit` and `pnpm lint` before reporting a task done.
- Never edit `src/generated/`; run `pnpm codegen` instead.
- Changes under `src/payments/` need a human reviewer from @payments.

The first version mixes taste, a private path and a vague warning. The second is shared, concrete and checkable.

What goes wrong

  • A dumping ground. Hundreds of lines nobody reads; the agent follows few of them.
  • Secrets in the file. It is in git history forever.
  • Rules without enforcement. "Never push to main" in prose is a hope; branch protection is a rule.

Examples

Reviewing a change to the shared file

A pull request adds the line "Always auto-fix lint errors across the whole repo". The reviewer asks for a narrower rule: "Fix lint errors only in files you changed." The wider rule would let every agent task produce a huge, unrelated diff.

Prose or hook?

The team keeps finding unformatted code in pull requests, even though the memory file says to run the formatter. They add a hook that runs the formatter after each file edit. The memory file keeps one line explaining why the hook exists.

Key points

  • A committed AGENTS.md or CLAUDE.md gives every teammate's agent the same build, test and convention rules.
  • Personal taste, local paths and secrets belong in personal settings, never in the shared file.
  • Write rules as short lines that can be checked, and give the reason when it is not obvious.
  • Use hooks or CI for rules that must hold every time, because a line of prose only asks the agent.
  • Review changes to the shared file like code, since one new line affects every future session.

Common mistakes

  • Copying one person's personal preferences into the committed file.
  • Writing vague rules such as "be careful" that no one can check.
  • Putting tokens, passwords or internal URLs with credentials in the file.
  • Never pruning, so old and conflicting rules pile up.

Check yourself · 2 of 3

A rule must hold every time an agent edits a file, such as running the formatter. What is the most reliable way?

Choose one answer

Check yourself · 3 of 3

Why should changes to the shared agent memory file go through pull-request review?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic