/ignore – Project-Aware .gitignore
Intent
This skill helps the agent create or update a .gitignore file based on the actual project layout and tech stack, instead of using a one-size-fits-all template.
Use it when:
- The user types
/ignore
- The user asks to create, update, or audit a
.gitignore
- A new project is initialized and no
.gitignore exists yet
High-Level Workflow
- Discover project type and tools
- Decide which ignore templates apply
- Generate a
.gitignore candidate
- Safely merge with any existing
.gitignore
- Show a short summary of what was added/changed
Keep changes minimal and reversible (back up existing .gitignore before modifying).
Step 1 – Discover Project Stack
Work from the repository root.
- Detect languages / frameworks (examples, not exhaustive):
- Node/JS/TS:
package.json, pnpm-lock.yaml, yarn.lock, node_modules/
- Python:
pyproject.toml, requirements.txt, .venv/, __pycache__/
- Go:
go.mod, go.sum
- Rust:
Cargo.toml, Cargo.lock, target/
- Java / JVM:
pom.xml, build.gradle, .gradle/, *.iml
- Frontend frameworks:
next.config.*, vite.config.*, webpack.config.*
- Detect tools / editors:
- VS Code:
.vscode/
- JetBrains:
.idea/
- OS junk:
.DS_Store, Thumbs.db
- Detect build / artifact directories:
dist/, build/, .turbo/, .next/, coverage/, out/, tmp/, logs/
You do not need to be perfect; detect the obvious signals and choose sensible defaults.
Step 2 – Choose Ignore Coverage
Based on discovery, decide which groups to include:
- Core OS / editor noise: macOS, Windows, IDEs
- Language / runtime specific: Node, Python, Go, Rust, etc.
- Tooling / build artifacts: bundlers, coverage, temporary directories
Prefer including too little over too much:
- Do not ignore lockfiles (
package-lock.json, pnpm-lock.yaml, yarn.lock, Cargo.lock, etc.).
- Do not ignore source directories (
src/, app/, etc.).
- Only ignore
env/.env.* if consistent with workspace conventions and security rules; never remove existing entries that intentionally ignore env files.
Step 3 – Generate .gitignore Content
Create an in-memory list of lines for the candidate .gitignore with small, focused sections.
Suggested structure (keep each section short):
# OS
.DS_Store
Thumbs.db
# Editors
.vscode/
.idea/
# Node
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Build output
dist/
build/
coverage/
.next/
.turbo/
out/
# Environments
.env.local
.env.development.local
.env.test.local
.env.production.local
Add or remove sections depending on the detected stack (for non-Node projects, skip Node‑specific lines, etc.).
Step 4 – Merge with Existing .gitignore
When a .gitignore already exists:
- Read existing contents into a set of lines.
- Back up the file to
.gitignore.bak in the repository root before modifying.
- For each candidate line:
- If the line is already present (exact string match, ignoring trailing whitespace), do nothing.
- If it is new, append it at the end in the appropriate section, preserving section comments as much as possible.
- Avoid deleting or rewriting user-defined patterns; never remove custom rules unless explicitly asked.
When no .gitignore exists:
- Create a new
.gitignore in the project root.
- Write only the lines relevant to the detected stack and tools.
Step 5 – Report Back to the User
After writing the file, summarize:
- Created vs updated: whether
.gitignore was new or modified.
- Key sections added: e.g., “Node artifacts”, “macOS junk files”, “VS Code project settings”.
- Number of new patterns added.
Example summary:
Result: Updated existing .gitignore (backed up to .gitignore.bak).
Added: Node build artifacts, macOS .DS_Store, VS Code workspace folder ignores.
Patterns added: 14 new entries.
Notes & Safety
- Be conservative when inferring what to ignore; it is better to under‑ignore and let the user add more entries than to hide important files.
- Never ignore the entire project directory,
.* generically, or critical configuration directories unless the repository already does so.
- If the user asks to regenerate from scratch, confirm by backing up the existing
.gitignore and clearly stating that you are replacing its contents.
1---2name: ignore3description: Generate or update a .gitignore file based on the current project stack and tools. Use when the user invokes /ignore or asks to create, fix, or audit a .gitignore for the current repository.4---56# /ignore – Project-Aware .gitignore78## Intent910This skill helps the agent create or update a `.gitignore` file **based on the actual project layout and tech stack**, instead of using a one-size-fits-all template.1112Use it when:13- The user types `/ignore`14- The user asks to create, update, or audit a `.gitignore`15- A new project is initialized and no `.gitignore` exists yet1617## High-Level Workflow18191. **Discover project type and tools**202. **Decide which ignore templates apply**213. **Generate a `.gitignore` candidate**224. **Safely merge with any existing `.gitignore`**235. **Show a short summary of what was added/changed**2425Keep changes **minimal and reversible** (back up existing `.gitignore` before modifying).2627## Step 1 – Discover Project Stack2829Work from the repository root.30311. **Detect languages / frameworks** (examples, not exhaustive):32 - Node/JS/TS: `package.json`, `pnpm-lock.yaml`, `yarn.lock`, `node_modules/`33 - Python: `pyproject.toml`, `requirements.txt`, `.venv/`, `__pycache__/`34 - Go: `go.mod`, `go.sum`35 - Rust: `Cargo.toml`, `Cargo.lock`, `target/`36 - Java / JVM: `pom.xml`, `build.gradle`, `.gradle/`, `*.iml`37 - Frontend frameworks: `next.config.*`, `vite.config.*`, `webpack.config.*`382. **Detect tools / editors**:39 - VS Code: `.vscode/`40 - JetBrains: `.idea/`41 - OS junk: `.DS_Store`, `Thumbs.db`423. **Detect build / artifact directories**:43 - `dist/`, `build/`, `.turbo/`, `.next/`, `coverage/`, `out/`, `tmp/`, `logs/`4445You do not need to be perfect; detect the obvious signals and choose sensible defaults.4647## Step 2 – Choose Ignore Coverage4849Based on discovery, decide which groups to include:5051- **Core OS / editor noise**: macOS, Windows, IDEs52- **Language / runtime specific**: Node, Python, Go, Rust, etc.53- **Tooling / build artifacts**: bundlers, coverage, temporary directories5455Prefer **including too little** over **too much**:56- Do **not** ignore lockfiles (`package-lock.json`, `pnpm-lock.yaml`, `yarn.lock`, `Cargo.lock`, etc.).57- Do **not** ignore source directories (`src/`, `app/`, etc.).58- Only ignore `env`/`.env.*` if consistent with workspace conventions and security rules; never remove existing entries that intentionally ignore env files.5960## Step 3 – Generate .gitignore Content6162Create an in-memory list of lines for the candidate `.gitignore` with **small, focused sections**.6364Suggested structure (keep each section short):6566```text67# OS68.DS_Store69Thumbs.db7071# Editors72.vscode/73.idea/7475# Node76node_modules/77npm-debug.log*78yarn-debug.log*79yarn-error.log*80pnpm-debug.log*8182# Build output83dist/84build/85coverage/86.next/87.turbo/88out/8990# Environments91.env.local92.env.development.local93.env.test.local94.env.production.local95```9697Add or remove sections depending on the detected stack (for non-Node projects, skip Node‑specific lines, etc.).9899## Step 4 – Merge with Existing .gitignore100101When a `.gitignore` already exists:1021031. **Read existing contents** into a set of lines.1042. **Back up** the file to `.gitignore.bak` in the repository root before modifying.1053. For each candidate line:106 - If the line is already present (exact string match, ignoring trailing whitespace), do nothing.107 - If it is new, append it at the end in the appropriate section, preserving section comments as much as possible.1084. Avoid deleting or rewriting user-defined patterns; **never remove custom rules** unless explicitly asked.109110When no `.gitignore` exists:1111121. Create a new `.gitignore` in the project root.1132. Write only the lines relevant to the detected stack and tools.114115## Step 5 – Report Back to the User116117After writing the file, summarize:118119- **Created vs updated**: whether `.gitignore` was new or modified.120- **Key sections added**: e.g., “Node artifacts”, “macOS junk files”, “VS Code project settings”.121- **Number of new patterns** added.122123Example summary:124125> **Result**: Updated existing `.gitignore` (backed up to `.gitignore.bak`). 126> **Added**: Node build artifacts, macOS `.DS_Store`, VS Code workspace folder ignores. 127> **Patterns added**: 14 new entries.128129## Notes & Safety130131- Be conservative when inferring what to ignore; it is better to under‑ignore and let the user add more entries than to hide important files.132- Never ignore the entire project directory, `.*` generically, or critical configuration directories unless the repository already does so.133- If the user asks to regenerate from scratch, confirm by backing up the existing `.gitignore` and clearly stating that you are replacing its contents.134