Audit or set up a code repository so Claude Code works efficiently in it A developer published a guide for auditing or scaffolding a code repository so that Claude Code works efficiently within it, covering CLAUDE.md files, path-scoped .claude/rules, subtree memory, verify scripts, pre-commit hooks, shared settings.json, agents and skills. The guide defines three principles — Claude should load only what a task needs, every requirement should have a single home, and code should enforce what matters — and lays out a six-step process of inventory, scoring, planning, scaffolding, verification and reporting. It also defines a two-level maturity checklist, with Level 1 covering runnable project commands and Level 2 covering scoped context such as a root CLAUDE.md under roughly 150 lines and path-globbed rules. | name | setting-up-claude-ready-repos | |---|---| | description | Audit or set up a code repository so Claude Code works efficiently in it — CLAUDE.md, path-scoped .claude/rules, subtree memory, verify scripts, pre-commit hooks, shared settings.json, agents and skills. Use this whenever the user wants to "set up a repo for Claude", "make Claude work better in this codebase", write or trim a CLAUDE.md, add .claude/rules, onboard a new or existing repo to Claude Code, review their Claude setup, or asks why Claude keeps making the same mistakes in a project — even if they don't say "audit" or "scaffold". | A repo works well with Claude when three things hold: 1. Claude loads only what the task needs. Small, scoped instructions beat one big file. Every always-loaded line costs context in every session. 2. Every requirement has one home. Two copies drift, and Claude can't tell which is right. 3. Code enforces what matters. A failing check beats a sentence Claude might skim past. Everything below serves those three. 1. Inventory the repo commands below . Record every trap with evidence. 2. Score it against the checklist. Report the level, gaps, and a plan. 3. Stop and show the plan. You're about to add files that shape every future session. If the user said "just do it", keep the plan short and go on unless they object. 4. Scaffold , smallest layer first, from the templates. 5. Verify with the checks at the end. Fix what they flag. 6. Report : what you created, what you left alone, what the user must decide, and each trap with its evidence. Everything you write must trace back to something you saw in the repo. An invented command is worse than a missing one, because Claude will trust it. Run from the repo root. Read-only. ls package.json pnpm-workspace.yaml pyproject.toml go.mod Cargo.toml pom.xml \ build.gradle Makefile .nvmrc .tool-versions .python-version .java-version 2 /dev/null node -e 'const p=require "./package.json" ;console.log p.scripts,p.packageManager ' 2 /dev/null grep -nE '" ~^ 0-9 ' package.json unpinned versions git ls-files | grep -E ' ^|/ tsconfig ^/ \.json|jest\.config\.|vitest\.config\.|pytest\.ini|package\.json|pyproject\.toml ' git grep -lIiE 'auto-?generated|do not edit|generated by' | head -20 git grep -nIiE 'must stay|not|run |do not remove|change |load-bearing|keep this' \ -- ' .json' ' .js' ' .mjs' ' .sh' ' .yml' ' .yaml' ' .toml' Makefile | head -20 ls CLAUDE.md AGENTS.md .claude/settings.json .claude/settings.local.json 2 /dev/null git ls-files | grep -E ' ^|/ CLAUDE\.md$|^\.claude/' ls .husky .pre-commit-config.yaml lefthook.yml .eslintrc eslint.config. 2 /dev/null Then read what it points at. Look for what a model would guess wrong: - Commands with non-obvious flags, ordering, or look-alike names. - Settings whose removal breaks something far away. - Generated files, and the command that regenerates them. - Folders with their own tsconfig, test runner, or language. - Import boundaries between layers or packages. - Scripts that are broken today. Note them as known failures. Don't fix them unasked. Mark each item present, partial, or missing, and cite the file. The level is the highest one whose items are all present. Most value comes from reaching level 2, so lead with that. Level 1: Claude can run the project - Root CLAUDE.md written by a person, not raw /init output. - Every command in CLAUDE.md exists in the package scripts or Makefile. - Named scripts for build, test, lint, type-check, plus one "check everything" and one "fix everything". - Toolchain pinned .nvmrc , packageManager , .python-version , ... . - Generated paths named, with the regenerate command. - Load-bearing settings named, with what breaks without them. Level 2: context is scoped - Root CLAUDE.md under ~150 lines, no pasted docs. - .claude/rules/ .md with a paths: glob on every rule that isn't truly repo-wide. Every glob matches at least one file. - Each rule has Requirements and Where to Look, and no large code blocks. - .claude/rules/README.md indexes every rule with its glob. - Subtree CLAUDE.md wherever the toolchain changes, and nowhere else. - No requirement stated in two places. - A doc map reaches every doc. Level 3: key rules are enforced - Layer boundaries enforced by lint import restrictions. - Generated output checked in the build. - Pre-commit hook: auto-fix staged files, then run the full check. - Each custom check opens with a comment naming what it prevents. - Dependency versions pinned exactly, or a stated reason why not. Level 4: the loop is fast and shared - Incremental type-check. Slow generators skip when inputs are unchanged. - The full check skips what the diff can't affect, or runs in under a minute. - .claude/settings.json committed: read-only allowlist, generated paths denied for Edit / Write , deploy and publish set to ask . - Agents for deep domain knowledge. Skills for repeated multi-step chores. Skills that install or change the environment set disable-model-invocation: true . Level 5: writer and reviewer agree - A PR review bot reads the same rules thin wrappers, same globs . - PR title, commit, and evidence rules exist, with the reason for each. - Known pre-existing failures are listed, so Claude doesn't chase them. Always flag, at any level - Secrets, webhook URLs, signed links, or tokens in committed config. - Counts or file names in CLAUDE.md that no longer match the tree. - Rules that contradict the code. The code wins, so fix the rule. - Commands in docs that fail when run. Each step is useful alone. Stop where the repo's size says to stop. 1. Named scripts. Add "check everything" and "fix everything" if missing. Point out unpinned versions. Don't change a version without asking. 2. Root CLAUDE.md . Traps and pointers, not a tour. If one exists, it's the user's work: restructure it, keep every fact that's still true, move requirements into rules, and show what moved where. 3. Path-scoped rules plus the rules README. 4. Subtree CLAUDE.md , only at toolchain boundaries. 5. Enforcement. Turn checkable rules into checks. Add the pre-commit hook. 6. Shared .claude/settings.json . Personal entries stay in settings.local.json , which must be git-ignored. 7. Optional: agents, skills, review-bot wrappers. Small repos: a single package may need only a root CLAUDE.md , two or three rules, a hook, and settings.json . Don't build ten layers for 500 lines of code. Unknown intent: when you can't tell why a setting exists, list it as a question for the user. Don't mark it load-bearing and don't delete it. Replace every <... . Delete sections with nothing true to say.