| name | smart-init |
| description | Generate optimized CLAUDE.md by analyzing the codebase. Use when starting a new project or when /init is called. Detects stack, patterns, and creates production-ready project config. |
Smart Init - Automatic CLAUDE.md Generator
When the user runs /init or asks to set up the project, analyze the codebase and generate a complete, optimized CLAUDE.md file automatically.
Analysis Steps
1. Detect Tech Stack
- Check
package.json, requirements.txt, pom.xml, Cargo.toml
- Identify frameworks (React, FastAPI, Spring Boot, etc.)
- Find build tools (npm, poetry, maven, cargo)
2. Detect Project Structure
- Find main source directories (
src/, app/, lib/)
- Identify test directories (
tests/, __tests__/, test/)
- Locate config files
3. Detect Commands
- Extract scripts from
package.json, Makefile, pyproject.toml
- Identify common patterns (dev server, tests, build, lint)
4. Detect Conventions
- Check for linter configs (
.eslintrc, ruff.toml)
- Find type checker configs (
tsconfig.json, mypy.ini)
- Identify existing patterns in code (naming, imports)
CLAUDE.md Generation Template
Generate this structure, filling ALL fields automatically:
# [Project Name from package.json/pyproject.toml]
## About
[1-2 line description from package.json description or README]
## Stack
**Languages**: [Detected: Python 3.13, TypeScript, etc.]
**Frameworks**: [Detected: FastAPI, React, Spring Boot, etc.]
**Database**: [Check for postgres, mysql, mongodb in deps]
**Tools**: [Detected: Docker (if Dockerfile exists), Git]
## Structure
\`\`\`
[Actual directory tree of main folders]
\`\`\`
## Commands
\`\`\`bash
# Development
[Extracted from package.json scripts or detected patterns]
# Testing
[Found test commands]
# Build/Deploy
[Found build commands]
\`\`\`
## Code Standards
[Based on detected linter/formatter configs]
- [Language]: [Conventions from existing code]
- [Framework]: [Patterns found in codebase]
- [Testing]: [Test patterns detected]
## Git Workflow
- Branch: `[feature|fix|docs]/description`
- Commits: [If commitlint detected: "Conventional Commits", else: "Descriptive messages"]
## Key Behaviors
1. Read only files explicitly mentioned or necessary
2. Make minimal, focused changes
3. Run tests after code changes
4. Explain approach for complex tasks
## Ignore
- Dependencies: [List actual dependency dirs found]
- Generated: [List actual build dirs found]
---
*Auto-generated by smart-init. Edit as needed.*
Smart Defaults
If something cannot be detected, use intelligent defaults:
For Python projects:
- Structure:
/src, /tests, /docs
- Commands:
pytest, ruff check, mypy
- Standards: Type hints required, async/await for I/O
For JavaScript/TypeScript:
- Structure:
/src, /tests, /public
- Commands:
npm run dev, npm test, npm build
- Standards: ESM imports, strict TypeScript
For Java:
- Structure:
/src/main/java, /src/test/java
- Commands:
./mvnw test, ./mvnw spring-boot:run
- Standards: Constructor injection, no field injection
For any project:
- Git: Conventional commits
- Testing: Arrange-Act-Assert pattern
- Ignore: Standard dependency/build directories
Output Format
- Analyze the codebase (use bash, read files)
- Generate complete CLAUDE.md with NO placeholders
- Save to
.claude/CLAUDE.md
- Show summary of detected configuration
- Ask if user wants to customize anything
Example Output Message
✅ Generated .claude/CLAUDE.md
Detected:
- Stack: Python 3.13 + FastAPI
- Framework patterns: Async/await, Pydantic models
- Tests: pytest (12 test files found)
- Commands: 5 npm scripts extracted
The file is ready to use. Run 'view .claude/CLAUDE.md' to review it.
Want to customize anything?
Critical Rules
- NEVER leave
[placeholder] or [TODO] in the generated file
- If you can't detect something, use smart defaults from above
- The generated file must be immediately usable
- Keep total length <50 lines
- Use actual values from the codebase, not examples