Logo Vincent
Back to all posts

Claude Code /init: Generate CLAUDE.md in 10 Seconds

Claude
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:

  1. Scan the project structure — traverse the directory tree, identify the project type (Next.js? Express? Python? Monorepo?)
  2. Analyze config files — read package.json, tsconfig.json, pyproject.toml, Cargo.toml, etc., extracting the tech stack, dependencies, and scripts
  3. Understand the architecture — identify source directories, core modules, and entry points
  4. Detect coding standards — check ESLint, Prettier, lint-staged, and other configs to extract code style conventions
  5. 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 /init give 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

  • /init only works in Claude Code’s interactive mode — you can’t run claude /init directly from the command line
  • If a CLAUDE.md already exists, /init will 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
SpeedSeconds30+ minutes
AccuracyBased on code analysis, objectively accurateBased on personal understanding, may miss things
DepthBroad coverage, but may lack business contextCan include domain logic, known pitfalls
MaintenanceRe-run after project changesMust update manually
Best practiceUse /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.

© 2026 vincentqiao.com . All rights reserved.