Create .claudeignore
Analyze the repository structure and generate a .claudeignore file that
excludes directories and files which waste context tokens without
providing useful source code.
Step 1: Scan the repository
Run these commands to understand the project structure:
List all top-level directories:
find . -maxdepth 1 -type d | sort
Measure directory sizes to identify large non-source content:
du -sh */ .*/ 2>/dev/null | sort -rh | head -30
Detect the project type from manifest files:
- Python:
pyproject.toml, setup.py, requirements.txt
- Node/JS:
package.json
- Rust:
Cargo.toml
- Go:
go.mod
- Java/Kotlin:
pom.xml, build.gradle
- Ruby:
Gemfile
- Mixed: multiple of the above
Check what .gitignore already excludes (for reference, not copying):
cat .gitignore 2>/dev/null
Step 2: Classify directories and files
Apply this heuristic to every entry: "Would I ever want Claude to
edit or inspect this for normal coding tasks?" If no, it belongs in
.claudeignore.
Things that are large, generated, noisy, secret, or not useful for
day-to-day coding decisions should be ignored. Source code, key
configs, and docs should stay visible.
Start from .gitignore as a baseline, then:
- Remove anything Claude still needs for reasoning (manifests,
core config, docs).
- Add anything generated or irrelevant to code changes that
.gitignore keeps (e.g., data/, notebooks/, large media).
Sort entries into these categories:
Always ignore (caches, build artifacts, dependencies)
These never contain useful source code for Claude:
| Pattern |
Ecosystem |
Why |
.venv/, venv/, env/ |
Python |
Virtual environment packages |
node_modules/ |
Node.js |
npm/yarn packages |
__pycache__/ |
Python |
Bytecode cache |
*.pyc |
Python |
Compiled bytecode files |
.mypy_cache/ |
Python |
Type checker cache |
.ruff_cache/ |
Python |
Linter cache |
.pytest_cache/ |
Python |
Test runner cache |
.cache/ |
General |
Generic caches |
target/ |
Rust/Java |
Build artifacts |
build/, dist/ |
General |
Build output |
.gradle/ |
Java/Kotlin |
Gradle cache |
.next/ |
Next.js |
Build output |
.nuxt/ |
Nuxt.js |
Build output |
.turbo/ |
Turborepo |
Build cache |
vendor/ |
Go/PHP |
Vendored dependencies |
coverage/, htmlcov/ |
General |
Coverage reports |
.tox/, .nox/ |
Python |
Test environment tools |
.cargo/ |
Rust |
Cargo cache |
Always ignore (secrets and credentials)
These reduce the chance sensitive content enters context:
| Pattern |
Why |
.env |
Environment secrets |
.env.* |
Per-environment secrets |
*.pem, *.key |
Private certificates and keys |
*-credentials.json |
Service account credentials |
.secrets/ |
Secret stores |
Always ignore (tool/IDE config)
| Pattern |
Why |
.cursor/ |
Cursor IDE state |
.idea/ |
JetBrains IDE config |
.vscode/ |
VS Code config (unless project-shared) |
.playwright-mcp/ |
Playwright MCP temp files |
.dolt/, .doltcfg/ |
Dolt/beads database internals |
Always ignore (logs and noise)
| Pattern |
Why |
*.log |
Log files |
logs/ |
Log directories |
*.sqlite, *.db |
Local databases |
Ignore if large (> 1 MB) and not source code
Review these on a case-by-case basis:
notebooks/ — Jupyter notebooks with embedded outputs
reports/ — Generated analysis reports
docs/ — If dominated by generated API docs or large assets
stubs/ — Type stubs
debug/ — Ephemeral diagnostic scripts
data/, datasets/ — Data files (unless small config/fixture data)
assets/, static/, public/ — Media and static files
fixtures/ — Test fixtures if large
Never ignore (source code and key files — keep readable)
src/, lib/, app/ — Application source
tests/, test/, spec/ — Test source
scripts/ — Build/utility scripts
config/ — Configuration files
prompts/ — Prompt templates
tools/ — Developer tools
frontend/ — Frontend source (but ignore frontend/node_modules/)
README.md, CLAUDE.md, AGENTS.md — Project documentation
pyproject.toml, package.json, Cargo.toml, go.mod — Manifests
tsconfig.json, eslint.config.* — Core tooling config
Over-ignoring these makes Claude guess incorrectly about app structure
and tooling.
Step 3: Present the plan
Show the user a table of what will be ignored and why:
| Directory | Size | Category | Reason |
|-----------|------|----------|--------|
| .venv/ | 1.7 GB | dependency cache | Python packages |
| ... | ... | ... | ... |
Also note any borderline decisions where the user might disagree.
Ask:
"Here's what I'd ignore. Want me to add or remove anything before I
write the file?"
Step 4: Write the file
After confirmation, write .claudeignore in the project root.
Group entries by category with comment headers. Use trailing slashes
for directories. Example:
# Python caches
.venv/
__pycache__/
.mypy_cache/
.ruff_cache/
.pytest_cache/
# Build artifacts
build/
dist/
# IDE/tool config
.cursor/
.idea/
# Large non-source directories
notebooks/
data/
Step 5: Report
After writing, report:
- Number of entries added
- Estimated context savings (rough, based on directory sizes)
- Reminder that specific files from ignored directories can still be
read on demand via explicit path
Constraints
- Never ignore source code directories (
src/, lib/, tests/,
scripts/, etc.) unless the user explicitly asks.
- Never silently ignore
config/ — it almost always contains
important configuration.
- Never ignore project manifests (
pyproject.toml, package.json,
Cargo.toml, go.mod, tsconfig.json) — Claude needs these to
understand the project stack.
- Never ignore
README.md or CLAUDE.md — these orient Claude.
- Always include secrets.
.env, .env.*, private keys, and
credential files should always be in .claudeignore, even if not
in .gitignore — defense in depth against leaking into context.
- Present the plan before writing. Do not write without user
confirmation.
- Use .gitignore as starting point, not as copy source.
.claudeignore serves a different purpose — .gitignore excludes
from version control, .claudeignore excludes from AI context.
They often overlap but are not the same. Start from .gitignore,
remove what Claude needs, add what Claude doesn't.
- Prefer directories over globs.
node_modules/ is better than
**/node_modules/** for readability.
Argument handling
If the user passes arguments (e.g., create data/ logs/), treat them
as additional directories to include in the ignore list. Still run the
full scan — the arguments are additions, not the complete list.
1---2name: create-23description: Analyze a repository and generate a new .claudeignore file that excludes directories and files wasting context tokens.4---56# Create .claudeignore78Analyze the repository structure and generate a `.claudeignore` file that9excludes directories and files which waste context tokens without10providing useful source code.1112---1314## Step 1: Scan the repository1516Run these commands to understand the project structure:17181. List all top-level directories:19 ```20 find . -maxdepth 1 -type d | sort21 ```22232. Measure directory sizes to identify large non-source content:24 ```25 du -sh */ .*/ 2>/dev/null | sort -rh | head -3026 ```27283. Detect the project type from manifest files:29 - Python: `pyproject.toml`, `setup.py`, `requirements.txt`30 - Node/JS: `package.json`31 - Rust: `Cargo.toml`32 - Go: `go.mod`33 - Java/Kotlin: `pom.xml`, `build.gradle`34 - Ruby: `Gemfile`35 - Mixed: multiple of the above36374. Check what `.gitignore` already excludes (for reference, not copying):38 ```39 cat .gitignore 2>/dev/null40 ```4142---4344## Step 2: Classify directories and files4546Apply this heuristic to every entry: **"Would I ever want Claude to47edit or inspect this for normal coding tasks?"** If no, it belongs in48`.claudeignore`.4950Things that are **large, generated, noisy, secret, or not useful for51day-to-day coding decisions** should be ignored. Source code, key52configs, and docs should stay visible.5354Start from `.gitignore` as a baseline, then:55- **Remove** anything Claude still needs for reasoning (manifests,56 core config, docs).57- **Add** anything generated or irrelevant to code changes that58 `.gitignore` keeps (e.g., `data/`, `notebooks/`, large media).5960Sort entries into these categories:6162### Always ignore (caches, build artifacts, dependencies)6364These never contain useful source code for Claude:6566| Pattern | Ecosystem | Why |67|---------|-----------|-----|68| `.venv/`, `venv/`, `env/` | Python | Virtual environment packages |69| `node_modules/` | Node.js | npm/yarn packages |70| `__pycache__/` | Python | Bytecode cache |71| `*.pyc` | Python | Compiled bytecode files |72| `.mypy_cache/` | Python | Type checker cache |73| `.ruff_cache/` | Python | Linter cache |74| `.pytest_cache/` | Python | Test runner cache |75| `.cache/` | General | Generic caches |76| `target/` | Rust/Java | Build artifacts |77| `build/`, `dist/` | General | Build output |78| `.gradle/` | Java/Kotlin | Gradle cache |79| `.next/` | Next.js | Build output |80| `.nuxt/` | Nuxt.js | Build output |81| `.turbo/` | Turborepo | Build cache |82| `vendor/` | Go/PHP | Vendored dependencies |83| `coverage/`, `htmlcov/` | General | Coverage reports |84| `.tox/`, `.nox/` | Python | Test environment tools |85| `.cargo/` | Rust | Cargo cache |8687### Always ignore (secrets and credentials)8889These reduce the chance sensitive content enters context:9091| Pattern | Why |92|---------|-----|93| `.env` | Environment secrets |94| `.env.*` | Per-environment secrets |95| `*.pem`, `*.key` | Private certificates and keys |96| `*-credentials.json` | Service account credentials |97| `.secrets/` | Secret stores |9899### Always ignore (tool/IDE config)100101| Pattern | Why |102|---------|-----|103| `.cursor/` | Cursor IDE state |104| `.idea/` | JetBrains IDE config |105| `.vscode/` | VS Code config (unless project-shared) |106| `.playwright-mcp/` | Playwright MCP temp files |107| `.dolt/`, `.doltcfg/` | Dolt/beads database internals |108109### Always ignore (logs and noise)110111| Pattern | Why |112|---------|-----|113| `*.log` | Log files |114| `logs/` | Log directories |115| `*.sqlite`, `*.db` | Local databases |116117### Ignore if large (> 1 MB) and not source code118119Review these on a case-by-case basis:120121- `notebooks/` — Jupyter notebooks with embedded outputs122- `reports/` — Generated analysis reports123- `docs/` — If dominated by generated API docs or large assets124- `stubs/` — Type stubs125- `debug/` — Ephemeral diagnostic scripts126- `data/`, `datasets/` — Data files (unless small config/fixture data)127- `assets/`, `static/`, `public/` — Media and static files128- `fixtures/` — Test fixtures if large129130### Never ignore (source code and key files — keep readable)131132- `src/`, `lib/`, `app/` — Application source133- `tests/`, `test/`, `spec/` — Test source134- `scripts/` — Build/utility scripts135- `config/` — Configuration files136- `prompts/` — Prompt templates137- `tools/` — Developer tools138- `frontend/` — Frontend source (but ignore `frontend/node_modules/`)139- `README.md`, `CLAUDE.md`, `AGENTS.md` — Project documentation140- `pyproject.toml`, `package.json`, `Cargo.toml`, `go.mod` — Manifests141- `tsconfig.json`, `eslint.config.*` — Core tooling config142143Over-ignoring these makes Claude guess incorrectly about app structure144and tooling.145146---147148## Step 3: Present the plan149150Show the user a table of what will be ignored and why:151152```153| Directory | Size | Category | Reason |154|-----------|------|----------|--------|155| .venv/ | 1.7 GB | dependency cache | Python packages |156| ... | ... | ... | ... |157```158159Also note any borderline decisions where the user might disagree.160161Ask:162> "Here's what I'd ignore. Want me to add or remove anything before I163> write the file?"164165---166167## Step 4: Write the file168169After confirmation, write `.claudeignore` in the project root.170171Group entries by category with comment headers. Use trailing slashes172for directories. Example:173174```175# Python caches176.venv/177__pycache__/178.mypy_cache/179.ruff_cache/180.pytest_cache/181182# Build artifacts183build/184dist/185186# IDE/tool config187.cursor/188.idea/189190# Large non-source directories191notebooks/192data/193```194195---196197## Step 5: Report198199After writing, report:200201- Number of entries added202- Estimated context savings (rough, based on directory sizes)203- Reminder that specific files from ignored directories can still be204 read on demand via explicit path205206---207208## Constraints209210- **Never ignore source code directories** (`src/`, `lib/`, `tests/`,211 `scripts/`, etc.) unless the user explicitly asks.212- **Never silently ignore `config/`** — it almost always contains213 important configuration.214- **Never ignore project manifests** (`pyproject.toml`, `package.json`,215 `Cargo.toml`, `go.mod`, `tsconfig.json`) — Claude needs these to216 understand the project stack.217- **Never ignore `README.md` or `CLAUDE.md`** — these orient Claude.218- **Always include secrets.** `.env`, `.env.*`, private keys, and219 credential files should always be in `.claudeignore`, even if not220 in `.gitignore` — defense in depth against leaking into context.221- **Present the plan before writing.** Do not write without user222 confirmation.223- **Use .gitignore as starting point, not as copy source.**224 `.claudeignore` serves a different purpose — `.gitignore` excludes225 from version control, `.claudeignore` excludes from AI context.226 They often overlap but are not the same. Start from `.gitignore`,227 remove what Claude needs, add what Claude doesn't.228- **Prefer directories over globs.** `node_modules/` is better than229 `**/node_modules/**` for readability.230231---232233## Argument handling234235If the user passes arguments (e.g., `create data/ logs/`), treat them236as additional directories to include in the ignore list. Still run the237full scan — the arguments are additions, not the complete list.