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."4metadata:5 source: https://skillmd.com/skills/wcygan/gitignore6---78# Gitignore Manager910## Goal1112Analyze repository state and create or update `.gitignore` with clear, safe patterns.1314Success means generated files, secrets, caches, and local runtime state are ignored while source files, templates, docs, tests, and intentional config remain trackable.1516Stop when the user has either an audit report or a scoped `.gitignore` change with a diff and verification notes.1718## Modes1920Infer mode from the user prompt:2122- Audit/report only: when the prompt says check, audit, review, inspect, or asks a question.23- Edit mode: when the prompt says update, add, fix, create, ignore, or otherwise asks for a file change.24- If the prompt is empty or ambiguous, report findings first and ask before editing.2526## Gather Context2728Run the narrowest useful commands:2930```bash31git ls-files32git status --porcelain33cat .gitignore 2>/dev/null || true34fd -H -t f -e env -e pem -e key -e sqlite -e db 2>/dev/null | head -2035fd -H -t d -g 'node_modules' -g '__pycache__' -g '.direnv' -g 'target' -g 'dist' -g 'build' 2>/dev/null | head -2036```3738Use `find` only if `fd` is unavailable.3940## Classify Files4142Always ignore security and privacy material:4344- `.env`, `.env.*`45- `*.pem`, `*.key`, `*.p12`46- `*.sqlite`, `*.db`47- `.credentials`, `credentials.json`48- `*.secret`, `secrets/`49- `.netrc` or `.npmrc` when they contain tokens5051Always ignore generated and build artifacts:5253- `node_modules/`, dependency vendor directories when repo policy does not track them54- `__pycache__/`, `*.pyc`55- `target/`, `dist/`, `build/`, `out/`56- `.next/`, `.nuxt/`, `.cache/`57- `coverage/`, `.nyc_output/`58- `*.log`, `logs/`5960Always ignore editor and OS runtime state:6162- `.idea/`, local `.vscode/` state unless the repo intentionally tracks shared settings63- `*.swp`, `*.swo`, `*~`64- `.DS_Store`, `Thumbs.db`6566Always ignore Nix and direnv outputs:6768- `.direnv/`69- `result`, `result-*`7071Review case by case:7273- Lock files, based on project policy.74- Generated docs or generated source, based on ownership model.75- Local override configs.7677Keep tracked:7879- Source code, tests, docs, and templates.80- `flake.nix` and `flake.lock` in Nix projects.81- `.envrc` when it contains no secrets.82- Project config files intentionally managed by the repo.8384## Pattern Rules8586- Prefer general patterns such as `*.log` over one-off filenames when safe.87- Use trailing slashes for directories.88- Group patterns by category with comments.89- Preserve existing custom patterns unless they are demonstrably wrong.90- Use negation patterns for intentional exceptions.91- Avoid broad patterns that could hide source code.9293Default structure:9495```gitignore96# ===== OS =====97.DS_Store98Thumbs.db99100# ===== Editors =====101.idea/102.vscode/103*.swp104*.swo105*~106107# ===== Secrets & Credentials =====108.env109.env.*110*.pem111*.key112.credentials113114# ===== Dependencies =====115node_modules/116vendor/117__pycache__/118119# ===== Build Outputs =====120dist/121build/122target/123124# ===== Caches =====125.cache/126.direnv/127.pytest_cache/128129# ===== Logs =====130*.log131logs/132133# ===== Nix =====134result135result-*136137# ===== Project Specific =====138```139140## Safety Checks141142Before editing:1431441. Check whether proposed patterns would match source, docs, tests, or tracked config.1452. Identify already-tracked files that should be untracked separately with `git rm --cached`.1463. Preserve project-specific exceptions.1474. Keep the change scoped to `.gitignore` unless the user requests cleanup.148149After editing:150151```bash152git diff -- .gitignore153git status --porcelain154```155156## Report Format157158Use this shape:159160```markdown161## Current State162- Tracked files: <count>163- Untracked files: <count>164- Existing ignore patterns: <count or summary>165166## Recommended Changes167- <pattern or file>: <reason>168169## Accidental Tracking Risks170- <tracked file>: <why it may need git rm --cached>171172## Verification173- <command>: <result>174```