Search across all documentation pages
/init is a Claude Code slash command that scans a fresh (or existing) repo and drafts a starting CLAUDE.md for you, so you are not writing project memory from a blank page.
Every new project eventually needs a CLAUDE.md describing its conventions, structure, and rules.
Writing one from scratch means re-deriving things Claude Code can already see for itself, like the language, the folder layout, and the test setup.
/init closes that gap by having Claude Code look at the project first and produce a draft, which you then read and correct.
It is the fastest path from "no project memory" to "a working CLAUDE.md," even though the result still needs a human pass.
Quick-reference recipe card - copy-paste ready.
cd my-project
claude
# once inside the Claude Code session:
/initWhen to reach for this:
Here is a full session from an empty CLAUDE.md to a reviewed one, on a small Node.js API project.
# 1. Start Claude Code inside the project root
cd order-service
claude
# 2. Run /init inside the session
/init
# Claude Code scans package.json, the folder structure, existing
# README content, test setup, and any config files, then writes
# a first-pass CLAUDE.md to the project root.
# 3. Review what it produced
cat CLAUDE.mdA typical first draft from /init looks something like this:
# Project: order-service
## Overview
A Node.js REST API for managing customer orders.
## Tech Stack
- Node.js, Express
- PostgreSQL via `pg`
- Jest for testing
## Structure
- `src/routes/` - Express route handlers
- `src/services/` - business logic
- `src/db/` - database access
# 4. Edit the draft to add anything /init couldn't infer,
# like team-specific rules and hard constraints.## Hard Rules
- Never query the database directly from a route handler - go through `src/services/`.
- Always add a test in `__tests__/` for any new route.
- Do not commit directly to `main`.# 5. Commit the finished file
git add CLAUDE.md
git commit -m "Add CLAUDE.md via /init"What this demonstrates:
/init produces a structural first draft (stack, folders, commands) from what it can observe in the repo./init is quick enough to redo whenever the project's shape has changed significantly./init reads the project's files (package manifests, folder structure, existing docs, config) to infer the tech stack and layout.CLAUDE.md at the project root, in plain markdown.CLAUDE.md already exists, running /init again updates it based on the current state of the project rather than creating a duplicate file.CLAUDE.md at the start of every future session.| Category | Reliably captured by /init | Usually needs a human pass |
|---|---|---|
| Tech stack | Yes - inferred from manifests/config | - |
| Folder structure | Yes - inferred from the file tree | - |
| Existing scripts/commands | Yes - from package.json or similar | - |
| Team conventions not visible in code | No | Yes - add by hand |
| Hard rules ("never do X") | No | Yes - add by hand |
| Business context / domain terms | Partial, if documented in README | Often needs adding |
# CLAUDE.md already exists and is a bit stale
/init
# Claude Code re-scans the project and updates CLAUDE.md
# to reflect the current structure, rather than starting over/init infers what it can see, but it cannot know unwritten team conventions. Fix: always read the generated file end to end before committing it./init updates the file based on current project state, which can blur together with prior manual edits if you're not paying attention. Fix: diff the file after re-running /init and confirm your hard rules are still there./init documents what exists, not what should never happen. Fix: add an explicit "Hard Rules" section by hand for anything non-negotiable.pwd, check for the project's manifest file) before running it./init periodically, or update the file by hand when structure changes meaningfully.| Alternative | Use When | Don't Use When |
|---|---|---|
| Write CLAUDE.md by hand from scratch | The project is small and you already know exactly what to document | You want a fast first draft of structural facts already visible in the repo |
/init then manual refinement | Starting a new project or inheriting an undocumented one | The project already has a thorough, accurate CLAUDE.md |
| Copy a CLAUDE.md template from a similar project | You maintain several structurally similar projects | Each project has meaningfully different structure or conventions |
It scans the current project (tech stack, folder structure, existing docs, config files) and writes a first-pass CLAUDE.md documenting what it finds.
No. It works on a fresh repo or an existing one. On a project that already has a CLAUDE.md, running it again updates the file based on current project state.
It can blur together with manual edits when re-run, since it rewrites based on current project state. Always diff the file after a re-run to confirm anything you added by hand is still present.
No. It only inspects the project and writes documentation to CLAUDE.md - it does not execute build steps, install packages, or modify code.
Treat it as a first draft. It reliably captures structural facts like stack and folder layout, but team conventions and hard rules usually need to be added by hand before it's genuinely useful.
To CLAUDE.md at the root of the current project.
/init is intended for the project root. Nested CLAUDE.md files for specific subfolders are typically written by hand for the rules specific to that scope.
Whenever the project's structure has changed enough that the existing CLAUDE.md feels out of date - there's no fixed schedule, it's a judgment call based on how much has drifted.
The scan reflects whatever project (or lack of one) is actually in that directory, which produces an inaccurate or near-empty draft. Confirm you're in the intended project root first.
Only what's visible in the repo itself (code patterns, existing docs). Unwritten team conventions and hard rules need to be added manually after the draft is generated.
No. Claude Code works without a CLAUDE.md - it just starts each session with less standing context about your conventions. /init is a convenience for getting that context in place quickly.
Read it top to bottom and ask whether it accurately reflects where things live and how the project actually works today, then add anything it couldn't infer, like hard rules.
Stack versions: Written against the Claude model lineup current as of ~June 2026 - Claude Fable 5, Claude Opus 4.8, Claude Sonnet 5 (the default), and Claude Haiku 4.5. Model names, pricing, and product features move quickly - verify current specifics at platform.claude.com/docs before relying on them.