Gitignore Manager
Goal
Analyze repository state and create or update .gitignore with clear, safe patterns.
Success means generated files, secrets, caches, and local runtime state are ignored while source files, templates, docs, tests, and intentional config remain trackable.
Stop when the user has either an audit report or a scoped .gitignore change with a diff and verification notes.
Modes
Infer mode from the user prompt:
- Audit/report only: when the prompt says check, audit, review, inspect, or asks a question.
- Edit mode: when the prompt says update, add, fix, create, ignore, or otherwise asks for a file change.
- If the prompt is empty or ambiguous, report findings first and ask before editing.
Gather Context
Run the narrowest useful commands:
git ls-files
git status --porcelain
cat .gitignore 2>/dev/null || true
fd -H -t f -e env -e pem -e key -e sqlite -e db 2>/dev/null | head -20
fd -H -t d -g 'node_modules' -g '__pycache__' -g '.direnv' -g 'target' -g 'dist' -g 'build' 2>/dev/null | head -20
Use find only if fd is unavailable.
Classify Files
Always ignore security and privacy material:
.env, .env.*
*.pem, *.key, *.p12
*.sqlite, *.db
.credentials, credentials.json
*.secret, secrets/
.netrc or .npmrc when they contain tokens
Always ignore generated and build artifacts:
node_modules/, dependency vendor directories when repo policy does not track them
__pycache__/, *.pyc
target/, dist/, build/, out/
.next/, .nuxt/, .cache/
coverage/, .nyc_output/
*.log, logs/
Always ignore editor and OS runtime state:
.idea/, local .vscode/ state unless the repo intentionally tracks shared settings
*.swp, *.swo, *~
.DS_Store, Thumbs.db
Always ignore Nix and direnv outputs:
.direnv/
result, result-*
Review case by case:
- Lock files, based on project policy.
- Generated docs or generated source, based on ownership model.
- Local override configs.
Keep tracked:
- Source code, tests, docs, and templates.
flake.nix and flake.lock in Nix projects.
.envrc when it contains no secrets.
- Project config files intentionally managed by the repo.
Pattern Rules
- Prefer general patterns such as
*.log over one-off filenames when safe.
- Use trailing slashes for directories.
- Group patterns by category with comments.
- Preserve existing custom patterns unless they are demonstrably wrong.
- Use negation patterns for intentional exceptions.
- Avoid broad patterns that could hide source code.
Default structure:
# ===== OS =====
.DS_Store
Thumbs.db
# ===== Editors =====
.idea/
.vscode/
*.swp
*.swo
*~
# ===== Secrets & Credentials =====
.env
.env.*
*.pem
*.key
.credentials
# ===== Dependencies =====
node_modules/
vendor/
__pycache__/
# ===== Build Outputs =====
dist/
build/
target/
# ===== Caches =====
.cache/
.direnv/
.pytest_cache/
# ===== Logs =====
*.log
logs/
# ===== Nix =====
result
result-*
# ===== Project Specific =====
Safety Checks
Before editing:
- Check whether proposed patterns would match source, docs, tests, or tracked config.
- Identify already-tracked files that should be untracked separately with
git rm --cached.
- Preserve project-specific exceptions.
- Keep the change scoped to
.gitignore unless the user requests cleanup.
After editing:
git diff -- .gitignore
git status --porcelain
Report Format
Use this shape:
## Current State
- Tracked files: <count>
- Untracked files: <count>
- Existing ignore patterns: <count or summary>
## Recommended Changes
- <pattern or file>: <reason>
## Accidental Tracking Risks
- <tracked file>: <why it may need git rm --cached>
## Verification
- <command>: <result>
1---2name: gitignore3description: Audit or update a repository .gitignore from tracked, untracked, generated, and sensitive files. Use for gitignore cleanup, ignore pattern design, and accidental-tracking checks.4---56# Gitignore Manager78## Goal910Analyze repository state and create or update `.gitignore` with clear, safe patterns.1112Success means generated files, secrets, caches, and local runtime state are ignored while source files, templates, docs, tests, and intentional config remain trackable.1314Stop when the user has either an audit report or a scoped `.gitignore` change with a diff and verification notes.1516## Modes1718Infer mode from the user prompt:1920- Audit/report only: when the prompt says check, audit, review, inspect, or asks a question.21- Edit mode: when the prompt says update, add, fix, create, ignore, or otherwise asks for a file change.22- If the prompt is empty or ambiguous, report findings first and ask before editing.2324## Gather Context2526Run the narrowest useful commands:2728```bash29git ls-files30git status --porcelain31cat .gitignore 2>/dev/null || true32fd -H -t f -e env -e pem -e key -e sqlite -e db 2>/dev/null | head -2033fd -H -t d -g 'node_modules' -g '__pycache__' -g '.direnv' -g 'target' -g 'dist' -g 'build' 2>/dev/null | head -2034```3536Use `find` only if `fd` is unavailable.3738## Classify Files3940Always ignore security and privacy material:4142- `.env`, `.env.*`43- `*.pem`, `*.key`, `*.p12`44- `*.sqlite`, `*.db`45- `.credentials`, `credentials.json`46- `*.secret`, `secrets/`47- `.netrc` or `.npmrc` when they contain tokens4849Always ignore generated and build artifacts:5051- `node_modules/`, dependency vendor directories when repo policy does not track them52- `__pycache__/`, `*.pyc`53- `target/`, `dist/`, `build/`, `out/`54- `.next/`, `.nuxt/`, `.cache/`55- `coverage/`, `.nyc_output/`56- `*.log`, `logs/`5758Always ignore editor and OS runtime state:5960- `.idea/`, local `.vscode/` state unless the repo intentionally tracks shared settings61- `*.swp`, `*.swo`, `*~`62- `.DS_Store`, `Thumbs.db`6364Always ignore Nix and direnv outputs:6566- `.direnv/`67- `result`, `result-*`6869Review case by case:7071- Lock files, based on project policy.72- Generated docs or generated source, based on ownership model.73- Local override configs.7475Keep tracked:7677- Source code, tests, docs, and templates.78- `flake.nix` and `flake.lock` in Nix projects.79- `.envrc` when it contains no secrets.80- Project config files intentionally managed by the repo.8182## Pattern Rules8384- Prefer general patterns such as `*.log` over one-off filenames when safe.85- Use trailing slashes for directories.86- Group patterns by category with comments.87- Preserve existing custom patterns unless they are demonstrably wrong.88- Use negation patterns for intentional exceptions.89- Avoid broad patterns that could hide source code.9091Default structure:9293```gitignore94# ===== OS =====95.DS_Store96Thumbs.db9798# ===== Editors =====99.idea/100.vscode/101*.swp102*.swo103*~104105# ===== Secrets & Credentials =====106.env107.env.*108*.pem109*.key110.credentials111112# ===== Dependencies =====113node_modules/114vendor/115__pycache__/116117# ===== Build Outputs =====118dist/119build/120target/121122# ===== Caches =====123.cache/124.direnv/125.pytest_cache/126127# ===== Logs =====128*.log129logs/130131# ===== Nix =====132result133result-*134135# ===== Project Specific =====136```137138## Safety Checks139140Before editing:1411421. Check whether proposed patterns would match source, docs, tests, or tracked config.1432. Identify already-tracked files that should be untracked separately with `git rm --cached`.1443. Preserve project-specific exceptions.1454. Keep the change scoped to `.gitignore` unless the user requests cleanup.146147After editing:148149```bash150git diff -- .gitignore151git status --porcelain152```153154## Report Format155156Use this shape:157158```markdown159## Current State160- Tracked files: <count>161- Untracked files: <count>162- Existing ignore patterns: <count or summary>163164## Recommended Changes165- <pattern or file>: <reason>166167## Accidental Tracking Risks168- <tracked file>: <why it may need git rm --cached>169170## Verification171- <command>: <result>172```