Lean CLAUDE.md Generator from Repo Inspection

Claude Code inspects your repository and writes a CLAUDE.md under 200 lines with verified commands first, checkable conventions, anti-patterns and the reasons behind key decisions.

You get: Working code with an explanation

More like this

Ready to use: no blanks to fill in.

The prompt

lean-claude-md-generator-from-repo-inspection.md
You are a senior engineer setting up Claude Code for this repository. Inspect the repo before writing anything: package manifests, Makefile or scripts, CI config, lint, type and test config, the README, and recent commits. If you cannot tell how tests are run or which package manager is used, ask me one short question first. Then write a CLAUDE.md under 200 lines. Rules: 1) Commands come first: install, build, run one test file, full tests, lint, typecheck. Verify each against config files and mark any you could not verify. 2) Include only conventions that a command or a code search can check; drop advice like 'write clean code'. 3) List anti-patterns you actually found in this repo, each with a one-line reason, and record key architectural decisions with why they were made. 4) Do not copy the README; link to it. Output in this order: a short list of assumptions and unverified items, the full CLAUDE.md in one code block with sections Commands, Conventions, Anti-patterns, and Decisions and Why, the final line count, then three next actions for me.

Example output

AI-written example
<!-- REVIEW NOTES (delete before committing)
Assumptions and unverified items:
- pnpm confirmed by pnpm-lock.yaml and "packageManager" field in package.json.
- Node 20 taken from .nvmrc and the CI matrix.
- `pnpm db:migrate` verified in package.json, but I did not run it (needs a live Postgres).
- `pnpm test:e2e` is in package.json, but CI never calls it. UNVERIFIED that it still passes.
- No deploy command documented. The CI deploy job calls an internal script I could not inspect.
-->

# invoice-api

Fastify + TypeScript service for invoice generation and payment reconciliation.
Setup, API overview and env var table are in [README.md](./README.md). Not repeated here.

## Commands

| Task | Command | Status |
|---|---|---|
| Install | `pnpm install --frozen-lockfile` | verified (CI) |
| Dev server | `pnpm dev` (tsx watch, port 3000) | verified |
| Build | `pnpm build` (tsc -p tsconfig.build.json) | verified |
| One test file | `pnpm vitest run src/billing/tax.test.ts` | verified (vitest.config.ts) |
| Full unit tests | `pnpm test` | verified (CI) |
| Integration tests | `pnpm test:int` (needs `docker compose up -d db`) | verified |
| E2E tests | `pnpm test:e2e` | UNVERIFIED, not run in CI |
| Lint | `pnpm lint` (eslint, zero warnings allowed) | verified (CI) |
| Typecheck | `pnpm typecheck` (tsc --noEmit) | verified (CI) |
| Format check | `pnpm format:check` (prettier) | verified |
| DB migrate | `pnpm db:migrate` | verified in package.json, not run |
| Generate migration | `pnpm db:generate` after editing `src/db/schema.ts` | verified in package.json |

Before finishing any task, run: `pnpm lint && pnpm typecheck && pnpm test`.

## Conventions

Each rule below can be checked with the command shown.

- ESM only. Relative imports end in `.js`. Check: `pnpm typecheck`.
- Named exports only, except `*.config.ts`. Check: `rg "export default" src` returns nothing.
- Environment variables are read only in `src/config/env.ts`. Check: `rg "process\.env" src --glob '!src/config/env.ts'` returns nothing.
- Money is integer cents in a `Cents` branded type from `src/billing/money.ts`. Check: `rg "amount:\s*number" src` returns nothing.
- Every route has a Zod schema in `src/routes/<name>/schema.ts`. Check: each `routes/
Generated from this prompt by AI. Your results will vary.

Tips and common edits

Run it from the repo root at the start of a Claude Code session on a project that has no CLAUDE.md or has an outdated one. No paste is needed because Claude Code reads the repo itself.

Questions about this prompt

More in Claude Code

Claude Code Feature Implementation Plan and Build from a Ticket with Repo Convention Discovery

Has Claude Code investigate how similar features are built in the repository, produce an implementation plan with acceptance tests, then implement it in verified increments. Surfaces risks, open questions, and next actions before and after coding.

Codebase Tour for a Specific Task

Explores a repo through the lens of your task and explains the architecture, key files and data flow, then says where to start.

CLAUDE.md or AGENTS.md Audit: Cut, Rewrite as Checkable Rules, Move to Skills

Turns a pasted CLAUDE.md or AGENTS.md into a shorter file of verifiable rules and names which procedures belong in skills.

Cursor Project Rules Generator for Your Repo's Stack

Has Cursor inspect your repository and write 3-5 scoped .mdc rules, each with globs, a description and a deliberately chosen attach mode.

Agent Run Post-Mortem: Trace Root Cause and Prompt or Tool Fixes

Analyzes a pasted agent trace to find the first real failure and proposes exact prompt rewrites or tool changes, each with a test.

Characterization Tests Before a Refactor

Writes tests that lock in a module's current behavior, including edge cases and quirks, so you can refactor safely.

Checkpoint and Rollback Manager with Compensation Steps and Failure Injection Tests

Guides Claude Code to implement checkpoint snapshots, rollback modes, and compensating actions for side-effecting agent phases, then prove them with failure-injection tests. Helps you decide the rollback strategy per phase.

Claude Code Behavior-Preserving Refactor with Characterization Tests and Staged Commits

Guides Claude Code to refactor a module safely by first pinning current behavior with characterization tests, then applying small reversible steps with verification after each. Delivers a diff, risk register, and rollback plan.

Claude Code Hook Writer: Auto-Run Lint, Typecheck or Tests After Edits

Produces a PostToolUse hook entry for settings.json, the script it calls and a concrete procedure to test that the check runs after file edits.

Claude Code Plan-Then-Implement a Feature With Approval Checkpoints

Makes Claude Code explore the repo, write a step-by-step plan for your approval, then build the feature in small verified steps, stopping at each checkpoint for your go-ahead.

Claude Code Root-Cause Bug Investigation with Failing Test and Minimal Patch

Directs Claude Code to reproduce a bug, trace it to a root cause using repository evidence, write a failing regression test, and apply the smallest safe fix. Ends with a verified diff, risks, and next actions.

Coding Agent Task Brief with Guardrails, Test Plan, and Rollback Steps

Creates a scoped brief for an AI coding agent that limits file changes, defines tests, and includes a rollback plan and review checklist.