--- description: "Scan for untracked runtime artifacts and update .gitignore patterns." trigger: "//ignore" --- # ``` ``` # Git Ignore Maintenance Protocol ## Goal Maintain repository hygiene by identifying untracked runtime artifacts (logs, caches, temp files) and generating precise `.gitignore` patterns to exclude them, ensuring only source code and config are tracked. ## Cognitive Protocol: ReAct (Reason + Act) *Reference: `.github/knowledge/example.ReAct.md`* ## Phase 1: Security & User Validation (REQUIRED) **Objective:** Ensure all git operations occur as the correct repository owner. **Enforced Workflow:** 1. **ACT:** Execute `whoami`. 2. **OBSERVATION:** * If `chester`: Proceed to Phase 2. * If `root` (or other): * **ACT:** `su - chester` * **ACT:** `whoami` (Verify switch). * **CONSTRAINT:** If switch fails, **STOP** and report error. Do not touch git. ## Phase 2: Artifact Analysis (The Scan) **Objective:** Identify *what* is untracked and *why*. 1. **ACT:** Execute `git status --short`. 2. **THOUGHT (ReAct):** For each `??` (untracked) item, determine its nature: * **Runtime Artifact?** (e.g., `*.log`, `__pycache__`, `tmp/`). -> **IGNORE.** * **Generated Data?** (e.g., `dist/`, `build/`). -> **IGNORE.** * **Environment/Secrets?** (e.g., `.env`, `id_rsa`). -> **IGNORE IMMEDIATELY.** * **Source/Config?** (e.g., `compose.yaml`, `src/main.py`). -> **DO NOT IGNORE.** (Flag to user). ## Phase 3: Pattern Generation (Meta-Prompting) **Objective:** Create specific, resilient patterns. Do not use overly broad wildcards. * **Bad Pattern:** `*log*` (Might ignore `logic.py`). * **Good Pattern:** `*.log` or `logs/`. ## Phase 4: Execution & Verification **Action Plan:** 1. **Append:** Add the identified patterns to the relevant `.gitignore` (Root or Service-level). 2. **Verify:** Run `git status` again to confirm the files are no longer listed. ## Example Output ### 🛡️ User Validation * Current User: `chester` (Verified) ### 📋 Analysis * `_thelab/core/media/ghost/content/logs/` -> **Log Directory** (Safe to ignore) * `src/.DS_Store` -> **OS Garbage** (Safe to ignore) * `config.json` -> **Configuration** (⚠️ User attention required - track or ignore?) ### 📝 Action Taken Appended to `_thelab/.gitignore`: ```gitignore # Ghost Blog Logs _thelab/core/media/ghost/content/logs/ # OS Files .DS_Store ✅ Verification git status is clean.