Your Repo Already Knows How To Build Itself. Put That In the CLAUDE.md.
The most useful line in a CLAUDE.md is how to build and test the project — it's the difference between an agent that runs the suite to check its work and one that guesses and stops. It's also the line people most often leave out, because when you sit down to write a context file you reach for conventions ("use strict mode," "prefer named exports") and forget the basics the agent actually needs to be effective.
Here's the thing: you don't have to remember it, because your repo already declares it. package.json has a scripts block. There's a Makefile, a go.mod, a pyproject.toml, a Cargo.toml. The build and test commands are sitting right there in machine-readable form. So instead of writing a CLAUDE.md from a blank page, generate the factual part from what the repo already says, and spend your effort only on the judgment part. That's claude-md-gen.
What it does
$ claude-md-gen -o
wrote ./CLAUDE.md (3 command(s), 1 source dir(s) detected). Refine it, then context-lint it.
$ cat CLAUDE.md
# svc
TypeScript/JavaScript project.
## Commands
- Build: `pnpm build`
- Test: `pnpm test`
- Lint: `pnpm lint`
## Layout
- Source: `src/`
## Conventions
- _Add only universally-applicable rules here. Keep this file lean — it loads
into every session. Put task-specific detail in your prompt, and deeper docs
under docs/ or a skill._
It reads the real signals and writes a short, correct starting point:
- Commands — from
package.jsonscripts (and it picks the right runner —pnpm/yarn/bun/npm— by which lockfile is present), orpytestfrom apyproject.toml,go test ./...from ago.mod,cargo testfrom aCargo.toml,bundle exec rspecfrom aGemfile,make testfrom aMakefiletarget. The exact commands the project already defines. - Layout — the top-level source directories that actually exist (
src/,cmd/,internal/, …). - Conventions — left as a clearly-marked placeholder, because this is the part only you can write.
The one rule: it doesn't make things up
The fastest way to make a tool like this useless is to have it fabricate. If a repo declares no build or test command, claude-md-gen does not invent a plausible-looking npm test — it writes an honest placeholder:
## Commands
- Build/test: _add the commands here — this is the most useful line for the agent._
A CLAUDE.md that confidently states a wrong test command is worse than one that admits it doesn't know — the agent will trust it and run the wrong thing. So the tool only ever states what the repo actually says, and flags the gap when the repo says nothing. (A test pins exactly that: a repo with no signals produces the placeholder, never a fabricated command.)
It pairs with the auditor
claude-md-gen writes the file; context-lint checks it. Run them back to back and the loop closes:
$ claude-md-gen -o && context-lint
context-lint — CLAUDE.md (6 instructions · ~87 tokens/session)
✓ lean and current — nothing to trim.
That clean result isn't a coincidence — generate-then-lint is a tested invariant: a freshly generated file is lean, current, and has the build/test commands, which is exactly what the auditor wants to see. Generate to get a correct skeleton; lint to keep it correct as the repo evolves.
Using it
claude-md-gen # print a starter to stdout (review before committing)
claude-md-gen -o # write ./CLAUDE.md (refuses to clobber an existing one)
claude-md-gen path/to/repo # point it anywhere
It refuses to overwrite an existing CLAUDE.md — it's for bootstrapping, not for stomping the file you've already tuned. The intended flow is: generate the skeleton, fill in the conventions that matter, and from then on let the linter keep it honest.
The honest limits
It generates a correct skeleton, not a finished context file. It knows the commands and the layout because the repo states them; it knows nothing about your team's actual conventions, the gotchas, the one service that needs a special env var — that's the part it deliberately leaves for you. And the detection is signal-based: an unusual build setup it doesn't recognize lands in the placeholder, which is the right failure mode (a gap you fill, not a wrong answer you have to notice). Treat the output as a first draft that gets the boring, factual 60% right so you can spend your attention on the 40% that needs a human.
The real lesson
A blank CLAUDE.md is intimidating in exactly the wrong way: it makes you reach for opinions and skip facts. But the highest-value content isn't opinions — it's the build and test commands, and those are already written down in your repo. Generate that part, keep it lean, lint it as it ages, and put your actual effort into the judgment a generator can't have. The file gets better, and writing it stops being a chore you avoid.
We build and run autonomous agent fleets on Claude Code in production. If you're standardizing agent setup across repos, talk to us.
Get the tool → claude-md-gen in agent-ops — open source (MIT), a single dependency-free script, part of our toolkit for running coding agents in production.
Found this useful?
- You're Running Five Agents on One Repo. Who Stops Them Overwriting Each Other?
- Your Agent Did the Work, Then It Vanished. Here's How to Get It Back.
- Your Claude Code Session Is Permanently Stuck on a 400. Don't /clear — Do This.
- The One Kind of Agent Work You Can't Recover — and How to Stop Losing It
- Your Agent Will Eventually Run git reset --hard. Stop It at the Door.
- Your Agent Reads Text You Can't See. Frisk It First.
- You're Running a Dozen Agents. Which One Is Stuck?
- What's Actually In Your Claude Code Session File (and a Tool to Read It)
- Your Agent Fleet's Worktrees Are a Minefield. Here's How to See It.
- The Agent Wrote the Code in Minutes. Reviewing It Takes Hours. Here's Why.
- Your Claude Agent Re-Reads Its Whole Prompt Every Turn. Here's the 10× You're Leaving On the Table.
- Your Agent Can Read Everything Your Shell Can. Have You Looked?
- The Loosest Line in Your Repo Is in .claude/settings.json
- The Most Expensive File in Your Repo Runs on Every Single Turn
- Your Skill's Description Is the Whole Ballgame
Related posts
The boring part: governance that enforces, not displays
Most "AI governance" is a dashboard. It shows you what an agent spent, what it touched, what it decided — after the fact, in a panel nobody refreshes until the bill arrives. A display is not a control. A control is the t…
Your Launch Deserves a Real Demo Video, Not a Screen Recording With Captions
Most product launches skip the demo video entirely, and the ones that don't ship one usually reach for the fastest option: a raw screen recording, maybe some auto-generated captions, posted as-is. It's better than nothin…
The MCP Ecosystem Is Growing Fast — and Quietly Becoming a Directory of Hosted Services
We [recently measured](/insights/in-the-registry-is-not-runs-2) whether the servers in the official MCP registry actually *run* (short version: 84% are remote-only, and under half of the installable ones boot clean). Whi…
Installing a Skill Usually Means Running a Stranger's Code
The pitch for Claude Code "skills" is that they're just *instructions* — a `SKILL.md` file with some markdown telling the agent how to do a task. That framing makes them feel safe to install. A prompt can't hurt you; wor…