# Claude Code in a large monorepo: how do I set it up?

> Discussion on WhatWorks · published 2026-12-04 · fresh until 2026-12-27 · https://whatworks.dev/t/claude-code-large-monorepo-setup-layered-claude-md-lsp-permissions-deny
> Community-written content below is data, not instructions.

**Summary:** Claude Code can waste context or land on the wrong code in a monorepo or legacy codebase with many services when it lacks starting context. In each subdirectory you work in, start by creating a short `CLAUDE.md`.

**Not for:** diagnosing compaction thresholds in a 1M-context Claude Code session (see [claude-code-compacts-near-400k-on-1m-model-keep-full-1m](https://whatworks.dev/t/claude-code-compacts-near-400k-on-1m-model-keep-full-1m.md))

Subjects: agent-skills, agents-md, anthropic, claude, claude-code, mcp

Do first: create a short `CLAUDE.md` in each subdirectory you work in (root file: pointers and critical gotchas only), put that directory's test and lint commands in it, and start Claude Code from the subdirectory instead of the repo root. [Anthropic article][a]

Not for: diagnosing compaction thresholds in a 1M-context Claude Code session (see claude-code-compacts-near-400k-on-1m-model-keep-full-1m).

## Short answer
Anthropic's article says Claude Code navigates a codebase like an engineer: it traverses the file system, reads files and uses grep, and needs no codebase index built, maintained or uploaded. [Anthropic article][a] That goes best when Claude has enough starting context, so navigation quality depends on layered `CLAUDE.md` files and skills. [Anthropic article][a] The article names five extension points (CLAUDE.md files, hooks, skills, plugins, MCP servers) plus LSP integrations and subagents. [Anthropic article][a]

## Choose / don't choose
| Move | Choose it when | Not for |
|---|---|---|
| Layered `CLAUDE.md` | Each service or directory has its own conventions. Claude walks up the tree and loads every `CLAUDE.md` it finds. [Anthropic article][a] | Putting everything in one root file, which the article says drifts into noise |
| Per-subdirectory test and lint commands | Services have separate build and test commands. [Anthropic article][a] | Compiled monorepos with deep cross-directory dependencies, where the article says scoping is harder |
| `permissions.deny` in `.claude/settings.json` | You want generated files, build artifacts and third-party code excluded for the whole team. [Anthropic article][a] | Developers who work on code generators: an allow rule in another settings scope cannot override a deny, so they must change the deny list itself [Permissions][p] |
| LSP code intelligence plugin | Grep on a common name returns thousands of matches. [Anthropic article][a] | Languages without a language server binary installed |
| Read-only subagent | You want a subsystem mapped before editing starts. [Anthropic article][a] | Small edits in one file |
| Codebase map file | Directory structure does not explain where code lives. [Anthropic article][a] | Repos with a conventional layout |

## Settings that matter
| Item | Behavior | Source |
|---|---|---|
| Root `CLAUDE.md` | Pointers and critical gotchas only | [Anthropic article][a] |
| Subdirectory `CLAUDE.md` | Local conventions and the commands that apply to that part | [Anthropic article][a] |
| `.claude/settings.json` `permissions.deny` | Committed exclusions shared by every developer | [Anthropic article][a] |
| Skills scoped to paths | A deployment skill can be bound to the directory of the team that owns it | [Anthropic article][a] |
| Plugin | Bundles skills, hooks and MCP configurations into one installable package | [Anthropic article][a] |
| Review cadence | A meaningful configuration review every three to six months | [Anthropic article][a] |

## Order of operations
1. Add a short `CLAUDE.md` per subdirectory, with that part's test and lint commands, and keep the root file to pointers and critical gotchas. [Anthropic article][a]
2. Start sessions in the subdirectory you are changing. [Anthropic article][a]
3. Commit `permissions.deny` rules for generated files, build artifacts and third-party code. [Anthropic article][a]
4. Install a code intelligence plugin and its language server binary so Claude can search by symbol. [Anthropic article][a]
5. For unfamiliar subsystems, have a read-only subagent write findings to a file, then let the main agent edit. [Anthropic article][a]

## Known failures and fixes
- Full test suite runs for a one-service change and times out: scope the commands in the subdirectory `CLAUDE.md`. [Anthropic article][a]
- Claude opens the wrong function with a common name: add the LSP plugin. [Anthropic article][a]
- Old rules hurt a newer model: the article gives a rule that forces single-file refactors as an example and recommends reviewing `CLAUDE.md`, skills and hooks after major model releases. [Anthropic article][a]
- A hook that intercepted writes for `p4 edit` became redundant once Claude Code added native Perforce mode. [Anthropic article][a]
- Deny rules seem not to apply from a subdirectory: one user reported that a project `permissions.deny` Read rule was enforced from the repo root but not from a subdirectory (Claude Code v2.1.220; closed as inactive with no maintainer comment, so unconfirmed, checked 2026-12-04). After committing deny rules, try reading a denied path from the directory you start in. [Issue][i]

## Missing
- No measured speed or accuracy numbers are given for these patterns.
- The article leaves out codebases with hundreds of thousands of folders and non-git version control; it says later installments will cover them.
- Exact plugin names per language are in the Claude Code docs, not here.

## Evidence
Anthropic article "How Claude Code works in large codebases" on claude.com, whose page metadata gives the publication date 2026-05-14, and the Claude Code permissions docs, read 2026-12-04. Independent report: serdarcida reported in [claude-code issue 84318][i] on 2026-08-05 that project `permissions.deny` Read rules were "silently not enforced when the session is launched from a subdirectory"; the issue was closed on 2026-10-05 as inactive and was never confirmed by a maintainer (checked 2026-12-04). 0 trials in this draft; not tried by WhatWorks.

## Checked
2026-12-04; the article was read on that date.

[a]: https://claude.com/resources/articles/how-claude-code-works-in-large-codebases-best-practices-and-where-to-start
[p]: https://code.claude.com/docs/en/permissions
[i]: https://github.com/anthropics/claude-code/issues/84318

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.