Every Claude Code session starts from zero. No memory of your project structure, your team's conventions, or which commands should never run unsupervised.
That's what CLAUDE.md is for — it's the file Claude Code reads at the start of every session. But writing one from scratch means figuring out what to include, what format to use, and what safety rules actually matter.
I made a script that does it for you.
What It Does
claude-md-generator.sh is a Bash script that asks 8 questions about your project and generates a CLAUDE.md file with:
- Project overview and tech stack
- Code style and testing commands
- Language-specific rules (from 7 presets: Python, JavaScript/TypeScript, Go, Rust, Java, Shell, Other)
- Optional safety modules:
- Dangerous command protection (
rm -rf,git reset --hard, etc.) - External action gates (require approval before
git push, API calls) - Error tracking conventions
- Dangerous command protection (
Try It
Interactive mode — answer 8 questions:
curl -sLO https://gist.githubusercontent.com/yurukusa/9e710dece35d673dd71e678dfa55eaa3/raw/claude-md-generator.sh
bash claude-md-generator.sh
Defaults mode — generate with sensible defaults, no prompts:
bash claude-md-generator.sh --defaults
Custom output path:
bash claude-md-generator.sh --defaults --output ./my-project/CLAUDE.md
What the Output Looks Like
Running with defaults produces a file with 8 sections:
# CLAUDE.md — My Project
## Project Overview
...
## Tech Stack & Language Rules
- Language: Python
- Run `python -m py_compile` after editing .py files
...
## Dangerous Command Protection
NEVER run these commands without explicit user approval:
- `rm -rf`
- `git reset --hard`
...
## External Action Safety
Before any external action (git push, API calls, posting):
1. State what you're about to do
2. Wait for approval
...
Each section is conditional — if you say "no" to dangerous command protection, that section is omitted. You get exactly what you need.
Why This Exists
I've been running Claude Code autonomously for months. The first thing I learned: without CLAUDE.md, the AI will:
- Run
rm -rfon directories it thinks are "temporary" - Push code to GitHub without asking
- Forget your linting rules and introduce style violations
- Lose context on what it was doing when the session restarts
A good CLAUDE.md prevents all of these. But writing one from scratch took me multiple iterations. This script captures what I learned.
Get the Script
- Standalone Gist: claude-md-generator.sh
- Part of a larger toolkit: claude-code-ops-starter — 4 free safety hooks + the generator + a CLAUDE.md template
No dependencies beyond Bash. No network calls. MIT licensed.
Running Claude Code without CLAUDE.md is like hiring someone without telling them the house rules. The script takes 30 seconds. The safety rules last every session.
For the complete autonomous operations setup, see the CC-Codex Ops Kit ($9.99) — 22 files, 15-minute setup.
Generated a CLAUDE.md? Scan your setup for security risks — free, 30 seconds, nothing installed. A good CLAUDE.md is step one. Knowing what else you're missing is step two.
Top comments (0)