CLAUDE.md for Teams: Shared Rules, Personal Rules and a Git Workflow That Avoids Conflicts
16 November 2026 · Updated 28 November 2026 · 12 min read · by Yang Kai
Run CLAUDE.md with a small team without the merge conflicts and rule wars: what belongs in the shared file, what stays personal, and a review workflow that keeps it trustworthy.
Checklist inside: Team CLAUDE.md starter plus review checklist
Contents
- The short version
- How Claude Code actually loads the layers
- The three layers, and why mixing them causes fights
- What the shared file must never contain
- Split the file before it starts causing conflicts
- The git workflow: treat it like a schema file
- Team starter plus review checklist
- Stack and commands (agreed facts — update in the same PR as any change)
- Boundaries (team-agreed; personal files may not loosen these)
- Definition of done (every PR, every author)
- Ownership
- CLAUDE.md rule review
- One rule, end to end: a worked example
- Keeping it alive with more than one author
- How we researched this
A solo CLAUDE.md can be idiosyncratic. It only has to match one person’s habits, and when it is wrong, one person notices.
The day a second developer’s agent reads the same file, every vague line becomes two different behaviours. One developer’s agent runs the tests before committing; the other’s does not, because the file said “test your changes” and the two of them read it differently. Team CLAUDE.md is not a bigger solo file. It is a small file with an ownership model.
This guide covers what changes when the file has multiple authors and multiple readers: the layer split that keeps personal preferences out of the shared contract, the loading behaviour that makes contradictions dangerous, and a pull-request workflow that keeps the file short and true.
The layer mechanics come from Anthropic’s Claude Code memory documentation, checked in November 2026. The single-person foundations still apply — if your own file is not yet in decent shape, the structure that works for solo projects is the prerequisite.
The short version
| Layer | File | Holds | Shared? |
|---|---|---|---|
| Shared project file | CLAUDE.md at the repo root |
Build/test commands, stack facts, boundaries, definition of done | Yes — committed to git |
| Personal project overrides | CLAUDE.local.md |
One developer’s preferences for this repo | No — gitignored |
| Personal global defaults | ~/.claude/CLAUDE.md |
What follows you to every project | No — your machine only |
| Managed policy (if your org deploys one) | OS-level path, set by IT | Organisation-wide instructions | Yes — and it cannot be excluded |
Keep the shared file to what a new hire’s agent needs on day one and the whole team agrees is true. Everything else goes down a layer.
How Claude Code actually loads the layers
Team setups go wrong when people assume the files override each other like CSS. Anthropic’s memory documentation describes a different model, and three details of it drive everything else in this article:
- Files concatenate; they do not override. Every applicable file is added to context. Where two files contradict each other, nothing resolves the conflict — the documentation is blunt that Claude may pick one arbitrarily.
- Load order runs broad to specific. Managed policy first, then your user file, then project files from parent directories down to the working directory. Within one directory,
CLAUDE.local.mdloads afterCLAUDE.md. - Subdirectory files load on demand. A CLAUDE.md in a subfolder is not read at launch; it loads when the agent first works on a file in that folder.
The practical rule falls straight out of the first point: personal layers may add preferences, but they must never contradict shared facts. If the shared file says the package manager is pnpm and your local file says npm, you have not customised anything — you have built a coin flip into every session.
The same documentation advises keeping each file short — under roughly 200 lines — because long files consume context and dilute the rules that matter. That advice is doing quiet work in every section below.
The three layers, and why mixing them causes fights
The shared project file — CLAUDE.md at the repo root, committed to git. This holds what must be true for everyone’s agent: build and test commands, stack facts, boundaries around dangerous areas, the definition of done. The test for inclusion is strict: would a new hire’s agent need this on day one, and would the whole team agree it is true?
Personal project overrides — CLAUDE.local.md, gitignored. This holds one developer’s preferences for this repo: “I run the dev server on port 4322,” “explain diffs before applying them.” Personal files load alongside the shared one, so preferences layer on top of the contract without amending it.
Personal global defaults — ~/.claude/CLAUDE.md in your home directory. This holds what follows you everywhere: your communication style, your editor habits, tools you always have installed. Nothing project-specific belongs here, because it will silently apply to the next project too.
Most team friction comes from layer violations: someone commits a personal preference to the shared file, and now everyone’s agent behaves like that one person. The fix is rarely an argument about the preference itself — it is moving it down a layer.
A note on the fourth layer. Larger organisations can deploy a managed policy file at an operating-system level path — set by IT, applied to every user on the machine, and not excludable by project or user files. Most small teams will never see one. If yours has one, treat it as read-only law above the shared file: do not restate its rules in the repo (they will drift), and do not write shared rules that contradict it, for the same coin-flip reason covered next.
What the shared file must never contain
Three exclusions keep the shared file trustworthy:
- No personal workflow preferences, for the reason above.
- No secrets or environment-specific values — paths containing your username, internal URLs only one person’s network can reach, anything resembling a credential.
- No aspirational rules: instructions describing the codebase you are migrating toward rather than the one in the repo today. An agent follows the file literally; a rule about a framework you have not adopted yet will be applied to code that does not use it.
If your team also runs other agents, settle the portability questions early. The AGENTS.md field guide covers the shared instruction-file format other tools read, and AGENTS.md vs CLAUDE.md maps where the two overlap — before two instruction files drift into contradicting each other.
Split the file before it starts causing conflicts
A shared file under 200 lines rarely conflicts. When it grows past that, do not let it become a monolith everyone edits in the same place. Two documented mechanisms split it:
Imports. A CLAUDE.md can pull in other files with @path syntax — @docs/git-workflow.md, for example — and the imported content loads with it. Splitting by topic (one file for testing rules, one for release rules) means two developers usually edit different files, and most merge conflicts never happen.
Path-scoped rules. Markdown files in .claude/rules/ can carry paths frontmatter so a rule loads only when the agent works on matching files. Subtree conventions — the API folder’s error-handling pattern, the migration folder’s naming rules — belong there, or in a subdirectory CLAUDE.md that loads on demand, instead of taxing every session in the repo.
Both mechanisms serve the same end as the context budget audit: every line in the always-loaded file is paid for in every session, by every developer.
The git workflow: treat it like a schema file
CLAUDE.md edits are small but have an outsized effect, so they deserve more ceremony than a typo fix and less than a feature:
- One change per pull request. A PR that adds one rule and explains the incident behind it reviews in a minute. A PR that rewrites six sections reviews never.
- The PR description names the failure. “Agent ran the wrong package manager twice this week” is a reason. “Improving the file” is not.
- A second person runs the rule. Before merging, someone else does one real task with the new rule in place. Rules that sound clear and behave strangely are common — especially wording that two readers parse differently.
- Conflicts resolve by shortening. When two branches edit the same section, the merge almost always reveals duplication. Resolve by cutting to the single checkable sentence both sides can accept, not by concatenating both versions.
Enforcement helps where prose ends. Rules that can be checked mechanically belong in hooks or CI rather than in the file at all — the memory documentation itself makes this point, describing CLAUDE.md as context rather than enforced configuration. Configuring Claude Code for continuous integration is where the team-level guardrails live once you outgrow per-session habits, and permission settings are where the boundaries that must never be crossed get enforced mechanically.
Team starter plus review checklist
# Project: [Name] — [one-line purpose]
## Stack and commands (agreed facts — update in the same PR as any change)
- Framework/runtime: [e.g. Astro 5, TypeScript strict]
- Package manager: [one only] — install: `[cmd]`, dev: `[cmd]`
- Build: `[cmd]` · Test: `[cmd]` · Check: `[cmd]`
## Boundaries (team-agreed; personal files may not loosen these)
- Never edit: lockfile by hand, .env*, published content in [path]
- Ask first: schema changes, dependency additions, deploy config
## Definition of done (every PR, every author)
- [ ] Build and tests pass locally
- [ ] Diff is one concern; unrelated changes split out
- [ ] Summary states what was NOT tested
## Ownership
- This file changes by PR only, one rule per PR, with the
incident or failure that motivated it in the description.
- Personal preferences go in CLAUDE.local.md (gitignored).
And the checklist to run when reviewing a proposed rule:
## CLAUDE.md rule review
- [ ] Is it true of the repo TODAY (not the planned repo)?
- [ ] Can compliance be checked — by a test, a diff, or a glance?
- [ ] Does it belong to everyone, or is it one person's habit?
→ habit = CLAUDE.local.md, not this file
- [ ] Does it contradict anything in the shared file or a personal layer?
- [ ] Does it duplicate a rule already here in other words?
- [ ] Could a hook or CI check enforce it instead of prose?
- [ ] Did a second person run one real task under this rule?
- [ ] Is the motivating incident named in the PR description?
One rule, end to end: a worked example
The workflow above is abstract until you watch a single rule travel through it:
- The incident. On Tuesday, a developer’s agent installs dependencies with npm in a pnpm repo. The lockfile changes, CI fails, twenty minutes disappear.
- The PR. A one-line addition to the shared file: “Package manager: pnpm only — install with
pnpm install.” The description names Tuesday’s incident and links the failed build. - The second-person run. A teammate pulls the branch and does a real task that touches dependencies. The agent uses pnpm without being reminded. The rule is clear to a reader who did not write it.
- The merge and the prune. The rule merges. In the same PR, an obsolete line about a framework the team dropped in September comes out — additions are the natural moment to look for neighbours that no longer earn their context.
Total cost: one small PR and ten minutes of a teammate’s time. Total benefit: every future session, for every developer, stops paying for that incident.
Keeping it alive with more than one author
Solo, you prune your file when you repeat yourself. In a team, add a calendar to that instinct: a short review whenever onboarding happens, and whenever the stack changes.
The highest-value team ritual is the newest member reading the file and flagging every line they cannot verify against the repo. Fresh eyes find stale rules that everyone else has learned to skim past. The patterns in agent memory patterns apply here too: memory that is never pruned becomes a liability with good formatting.
A light cadence keeps the reviews from becoming a project of their own:
| Trigger | What to check | Time it should take |
|---|---|---|
| New developer onboards | Every line verifiable against the repo? | 15 minutes, once |
| Stack or tooling changes | Commands and facts sections still true? | In the same PR as the change |
| A rule causes a bad session | Rewrite it or move it to a hook — do not just delete the evidence | One small PR |
| Quarterly, if none of the above happened | Duplication, stale facts, anything over the size guide | 30 minutes |
Notice what is not on the list: a standing meeting about the file. CLAUDE.md maintenance rides on events the team already has.
Disagreements about rules are usually disagreements about workflow wearing a file’s clothing. Settle the workflow, then write the one sentence that records the settlement. A team CLAUDE.md should read like a short list of decisions the team has already made — because that is exactly what it is.
How we researched this
Desk research, stated plainly: the loading model, load order, subdirectory behaviour and the short-file guidance are from Anthropic’s official Claude Code memory documentation, checked in November 2026. The workflow — layers, one-rule PRs, review checklist — is the organisational pattern those mechanics point to, not a claim about any specific team’s results. The Claude Code hub collects the related guides.
FAQ
Where do personal Claude Code preferences go in a team repo?
In CLAUDE.local.md, gitignored, or in your user-level ~/.claude/CLAUDE.md — never in the shared project CLAUDE.md. Personal files layer on top of the shared rules without amending the team’s contract.
How should a team change its CLAUDE.md? By pull request, one rule per change, with the incident that motivated it in the description — and ideally a second person running one real task under the new rule before it merges.
How do we resolve merge conflicts in CLAUDE.md? By shortening, not concatenating. Conflicts usually expose two wordings of overlapping rules; keep the single checkable sentence both sides accept and cut the rest. Splitting the file with imports or path-scoped rules prevents most conflicts from happening at all.
What happens if CLAUDE.local.md contradicts the shared file? Nothing resolves it. The files are concatenated into context rather than overriding each other, and where they contradict, the agent may follow either one. Keep personal files to preferences that never touch shared facts.
How big should a team’s shared CLAUDE.md be?
Short. Anthropic’s documentation advises keeping each memory file under roughly 200 lines. If the shared file outgrows that, split it with @path imports or move subtree rules into .claude/rules/ or subdirectory files.
Team conventions only stick if individuals already have a working file, which is why your first CLAUDE.md is the recommended starting point before adopting the shared version.
Category: Claude Code & Context Engineering · Tags: #claude-code #claude-md #git #automation
Next step: this article is part of Claude Code guides, which covers the full topic from first setup to advanced use.