Claude Code /init: Generate CLAUDE.md in 10 Seconds
What is /init
If you’ve used Claude Code, you know about CLAUDE.md — the file that tells Claude Code everything about your project so it doesn’t start every session from scratch.
But writing CLAUDE.md by hand can be tedious, especially when you’re picking up a new project or dealing with a legacy codebase where even you don’t have the full picture yet.
That’s where /init comes in.
/init is a slash command in Claude Code’s interactive mode. It automatically scans your entire codebase and generates a CLAUDE.md file for you.
In short: you don’t have to write it yourself — let Claude Code do it.
What It Does
When you run /init in your project root, Claude Code will:
- Scan the project structure — traverse the directory tree, identify the project type (Next.js? Express? Python? Monorepo?)
- Analyze config files — read
package.json,tsconfig.json,pyproject.toml,Cargo.toml, etc., extracting the tech stack, dependencies, and scripts - Understand the architecture — identify source directories, core modules, and entry points
- Detect coding standards — check ESLint, Prettier, lint-staged, and other configs to extract code style conventions
- Generate CLAUDE.md — compile all of the above into a structured Markdown file and write it to the project root
The whole process is automatic. You just review the output and confirm.
How to Use It
Basic Usage
Navigate to your project directory, start Claude Code, and type:
/init
That’s it. Claude Code will analyze your project — taking anywhere from a few seconds to half a minute depending on project size — and present the generated CLAUDE.md for your review.
Once you confirm, the file is written to your project root.
When to Use It
- Picking up a new project — unfamiliar with the code? Let
/initgive you a structured overview. The generated CLAUDE.md doubles as a solid project summary - Adding docs to a legacy project — been running for years with no CLAUDE.md? One command fixes that
- Exploring open source projects — clone it, run
/init, and instantly get the big picture - Team collaboration — commit the generated file so everyone on the team benefits when using Claude Code
Things to Keep in Mind
/initonly works in Claude Code’s interactive mode — you can’t runclaude /initdirectly from the command line- If a CLAUDE.md already exists,
/initwill update it based on the current codebase rather than overwriting it - The generated content is a great starting point, but you should manually refine and supplement it
What the Generated CLAUDE.md Looks Like
A typical /init output includes these sections:
# CLAUDE.md
## Project Overview
Brief description of the project, tech stack, and core functionality.
## Commands
Common build, test, lint, and deploy commands.
## Architecture
Directory structure, core modules, and data flow.
## Code Style
Coding conventions, formatter config, naming rules.
## Development Workflow
Dev process, branching strategy, CI/CD details.
The specifics vary by project type and complexity. A simple Node.js app might get a few dozen lines; a large monorepo will be more detailed.
Real-World Examples
Example 1: Next.js Project
Running /init in a Next.js 15 project generates something like:
# CLAUDE.md
## Project Overview
A Next.js 15 application using App Router with TypeScript and Tailwind CSS.
## Commands
| Command | Purpose |
| ---------------- | -------------------- |
| `npm run dev` | Start dev server |
| `npm run build` | Production build |
| `npm run lint` | Run ESLint |
| `npm run test` | Run tests with Jest |
## Architecture
- `src/app/` - App Router pages and layouts
- `src/components/` - Reusable UI components
- `src/lib/` - Utility functions and shared logic
- `src/styles/` - Global styles and Tailwind config
## Code Style
- TypeScript strict mode enabled
- Prettier with 2-space indent, single quotes
- ESLint with Next.js recommended rules
Example 2: Monorepo
Running /init in a Lerna + Nx monorepo:
# CLAUDE.md
## Project Overview
A frontend monorepo managed by Lerna + Nx with npm workspaces.
## Commands
| Command | Purpose |
| ------------------ | ------------------------------------ |
| `npm run build` | Build all packages (lerna run build) |
| `npm run test` | Test all packages |
| `npm run lint` | Full pipeline: build → lint → test |
## Monorepo Rules
- Install deps from root: `npm i <pkg> -w <sub-package>`
- Run scripts from root: `npm run <script> -w <sub-package>`
- Never cd into sub-packages to install or run scripts.
## Packages
- `packages/app` - Main web application (Next.js)
- `packages/ui` - Shared UI component library
- `packages/utils` - Common utility functions
Example 3: Python Project
Running /init in a FastAPI project:
# CLAUDE.md
## Project Overview
A FastAPI REST API with SQLAlchemy ORM and PostgreSQL.
## Commands
| Command | Purpose |
| ------------------------------ | -------------------- |
| `uvicorn app.main:app --reload`| Start dev server |
| `pytest` | Run tests |
| `alembic upgrade head` | Run DB migrations |
## Architecture
- `app/main.py` - Application entry point
- `app/routers/` - API route handlers
- `app/models/` - SQLAlchemy models
- `app/schemas/` - Pydantic schemas
- `alembic/` - Database migrations
## Code Style
- Black formatter, line length 88
- isort for import sorting
- Type hints required on all functions
/init vs Writing CLAUDE.md by Hand
| /init (auto-generated) | Manual | |
|---|---|---|
| Speed | Seconds | 30+ minutes |
| Accuracy | Based on code analysis, objectively accurate | Based on personal understanding, may miss things |
| Depth | Broad coverage, but may lack business context | Can include domain logic, known pitfalls |
| Maintenance | Re-run after project changes | Must update manually |
| Best practice | Use /init as a base, then refine manually | — |
My recommendation: start with /init to generate a baseline, then manually add the things code analysis can’t capture — business-specific gotchas, known pitfalls, team conventions, and architectural decisions.
Final Thoughts
/init is a small but practical command in Claude Code. The problem it solves is simple: you don’t have to write CLAUDE.md from scratch.
For new projects, it quickly establishes Claude Code’s understanding of your codebase. For legacy projects, it fills in the “AI-friendly” documentation that’s always been missing.
Next time you pick up a new project, try typing /init in Claude Code and see how well it understands your code. You might be surprised by how accurate it is — after all, code doesn’t lie.
More Articles
- I Built a Bot That Runs Claude Code From Chat
- Claude Code /fast: Same Opus, 2x Speed — Worth It?
- Claude Code MCP: Give Your AI Access to Any Tool
- Claude Code /model: Opus vs Sonnet vs Haiku Guide
- Claude Code in 2026: The Only Setup Guide You Need
- The Complete Guide to Claude: From Chat to Code to Automation
- CCBot - 24x Development Efficiency Boost
- Shocking! This Tool Lets Programmers Finish 95 Minutes of Work in 4 Minutes! 24x Efficiency Boost
- Claude Code /add-dir: The Monorepo Command You Miss
- Claude Code /compact: Free Up Context, Keep Progress
- Claude Code /btw Command Explained: Quick Side Questions Without Breaking Flow
- Claude Code /stats: See How Much AI Does For You
- Claude Code /status Command Explained: Your Session Dashboard
- Why AI-First Startups Only Need One Programming Language
- Best Practice for External Knowledge in Claude Code: GitHub MCP + Context7
- Claude Code Token-Saving Tip: The Power of the Exclamation Mark
- Claude Code /resume Command Explained: Don't Let Your Conversations Go to Waste
- Claude Code /usage Command Explained: Know Your Remaining Quota
- Claude Code /tasks Command Explained: Master Your Background Tasks
- Claude Code Skills Explained: Build Your Custom Command Library
- Claude Code /plan Explained: Think Before You Code
- Claude Code /memory Explained: Make AI Truly Remember Your Project
- cc-ping: Ping All Your Claude Code Configs in One Command