What it does
/init scans your entire codebase and generates a baseline CLAUDE.md — the instruction file that tells Claude Code (and any AI working on your repo) your project's rules, stack, conventions, and structure. It reads:
package.jsonand lock files (extracts dependencies, build scripts, Node version)tsconfig.json/eslint.config.js/ linting setup (strictness rules, language targets)- Directory structure and README (if one exists)
- A sample of your source files (to infer patterns: naming, folder conventions, styling approach)
- CI config (
.github/workflows/, build pipeline) - Dockerfile, docker-compose, environment file templates
From this, it synthesizes:
- Tech stack and version baselines
- Language and style rules (TypeScript strictness, naming conventions, import patterns)
- Key architectural patterns (where data flows, how auth works, API conventions)
- Pre-commit / deployment workflows
- Security guardrails already in place
- Accessibility and performance standards
The output is a readable, structured CLAUDE.md with sections on stack, rules, anti-patterns, and commit protocol. It's a starting point — not gospel.
When to use it
New project: Onboard a fresh codebase to Claude Code in under a minute. Beats writing CLAUDE.md from scratch.
Existing project without CLAUDE.md: Retrofit one. The scan finds patterns already baked into your code (even if undocumented) and writes them down so they stay consistent.
Periodic refresh: Run it quarterly. If your stack evolved but CLAUDE.md didn't, /init re-scans and surfaces gaps.
Do NOT use it on a tiny hobby project where you're comfortable keeping rules in your head — the overhead isn't worth it. Do use it on anything with multiple files, a team, or rules you want enforced.
Try it yourself
Open your project in Claude Code, run /init from the terminal, and watch it scan the codebase. The agent will print a summary of what it found (dependencies, structure, inferred rules) and ask whether to write the generated CLAUDE.md. Read the output and edit it before committing — the generated version is smart but incomplete; add your product requirements, non-obvious conventions, and security rules that the code alone doesn't reveal.
Gotchas
The scan can miss context. If your build system is baroque (custom tsc wrapper, polyrepo with shared config), the agent might misread it. Always review the generated CLAUDE.md against your actual practices.
It reads a sample, not all code. If your project has 500 components but only 20 get scanned, style rules inferred from that sample might not apply everywhere. Spot-check and add clarifications.
No project history. The scan doesn't know why you chose Go over Rust, or why you don't use Tailwind — it only sees the end state. Add a "Why this stack" section if decisions matter.
Generated rules are generic. Rules about rate limits, RLS patterns, or deployment gates live in your business logic, not the file structure. You'll always hand-write those parts.
Start with /init, then invest 10 minutes refining: add a product statement, your team's coding philosophy, any security non-negotiables, and the commit protocol you actually enforce. That's a CLAUDE.md that sticks.
Try it yourself
Type the command in the fake terminal. Nothing leaves your browser.