Live Repo Snapshot
- Root: !
git rev-parse --show-toplevel 2>/dev/null || pwd - Status: !
(git status --short 2>/dev/null || echo "not a git repo") | head -n 50 - Top-level files: !
ls -1A | head -n 50
Goal
Audit this repository's Claude Code setup and scaffold ONLY project-specific config Claude cannot infer by reading code. Never create, edit, or overwrite any file until the user approves the Gap Report.
Phase 1: Read-Only Discovery (NO edits)
- Inspect existing config if present:
CLAUDE.md,.claude/CLAUDE.md,CLAUDE.local.md,AGENTS.md,.claude/rules/,.claude/settings.json,.mcp.json,.claude/skills/, legacy.claude/commands/, and.gitignore. - Detect build, test, typecheck, and lint commands from manifests (
package.json,Makefile,pyproject.toml,Cargo.toml,go.mod,.github/workflows/). If workspace manifests exist (pnpm-workspace.yaml,turbo.json,apps/,packages/), note it as a monorepo. - Detect sensitive paths (
.env*,.env.example,secrets/, credentials), generated or protected folders (migrations/,dist/,src/gen/), and UI test tools (Playwright, Puppeteer, simulators).
Phase 2: Gap Report & Approval Gate
Present a concise bullet-point Gap Report:
- Config Audit: Flag
CLAUDE.mdfiles over 200 lines, emphatic/shouting rules (IMPORTANT!,NEVER) or stack boilerplate Claude can read from code, missing.gitignoreentries (CLAUDE.local.md,.claude/settings.local.json), or legacy.claude/commands/files that should move to.claude/skills/. - Fastest Feedback Loop: Recommend exact single-file test, typecheck, and lint commands.
- Permissions & Hooks: Use the "can I take it back?" rule: keep reversible preferences in
CLAUDE.md, and enforce irreversible actions (secret exposure, destructive edits) viapermissions.denyor hooks. Recommend explicit.envsecret deny rules (keeping.env.examplereadable if present),Bash(git push *)inpermissions.ask, and optionalPostToolUse(formatter),PreToolUse(protected-path blocker), orStop(typecheck/lint) hooks.
Ask 3 to 5 batched questions with sensible defaults:
- Which verification command(s) should be allowed, how fast do they run, and should any fast check run in a
Stophook (guarded withstop_hook_activeand a clean-working-tree early exit)? - Are there misleading legacy directories or conventions Claude must not copy?
- Which files or paths should be blocked via
permissions.denyor aPreToolUsehook? (Also confirm addingCLAUDE.local.mdand.claude/settings.local.jsonto.gitignore.) - Should we create path-scoped
.claude/rules/*.mdfiles (or per-package rules in a monorepo)? - Do you want a brief read-only codebase summary after setup?
STOP here and wait for explicit user approval before writing any files.
Phase 3: Write Approved Files
Write ONLY approved files. For existing CLAUDE.md, .claude/settings.json, or .gitignore, merge new entries and preserve existing non-conflicting rules/hooks instead of clobbering them.
CLAUDE.md(target under 80 lines, hard cap <200 lines): Exact commands (install, single test, full test, typecheck, lint), non-obvious conventions or anti-patterns, and env gotchas. Do not duplicate notes Claude already tracks in project Auto-Memory (MEMORY.md)..gitignore(if approved): AppendCLAUDE.local.mdand.claude/settings.local.jsonif missing..claude/rules/<domain>.md(if approved): Move area-specific conventions out of rootCLAUDE.mdusing YAMLpaths:glob frontmatter..claude/settings.json(if approved): Never putautoModein repo.claude/settings.json(Claude Code ignores it at project scope).permissions.allow: Safe verification commands (space before trailing*; no wildcards before subcommands; never wildcard wrappers likenpx *,devbox run *,docker exec *,sudo *,bash *,sh *,env *).permissions.ask: Side-effect commands (e.g.,Bash(git push *), which Auto Mode allows by default).permissions.deny: Explicit secret variants (Read/Editfor./.env,./.env.local,./.env.development,./.env.production,./.env.staging,./.env.test,**/equivalents, and./secrets/**) so.env.exampleremains readable (Edit(path)coversEdit,Write, andNotebookEdit).- Optional
PostToolUsehook: Non-blocking local formatter with--before"$f"and early exit0whenfile_pathis empty. - Optional
PreToolUsehook: Block edits to protected folders (e.g.,migrations/,src/gen/) by exiting with code2and writing the reason tostderr. - Optional
Stophook: Exit0whenstop_hook_activeis"true"OR when inside a git repo with a clean working tree (no modified, staged, or untracked files); verify tool availability, then run the check redirecting errors tostderr(1>&2 || exit 2).
Phase 4: Post-Setup Validation
- If the user opted in to Q5, provide a concise read-only codebase architecture summary.
- Instruct the user to run:
/context allto verifyCLAUDE.mdloaded and check token footprint./doctor prompt-auditto catch conflicting, outdated, or redundant instructions (re-run after major model upgrades)./auto-mode-setup(optional) to configure trusted repos, buckets, and domains in~/.claude/settings.json./verify(optional) to record.claude/skills/verify/SKILL.mdfor pre-commit app checks, or/run-skill-generatorto record.claude/skills/run-<name>/for complex launch recipes.


