--- name: ck-context-guard description: Enforces workflow context rules automatically. Reminds to use ck-cook after planning completes, enforces descriptive file naming conventions. Activates automatically after plan agent completion and before file creation. --- # ck-context-guard Automatic guard that enforces workflow context transitions and naming conventions. Two behaviors that fire at specific workflow moments. Never invoked manually. ## When Active - **Cook-After-Plan Reminder**: Fires when a planning agent (`ck-planning`) completes - **Descriptive Name Guidance**: Fires before every file write or creation ## Don't Use When - This is a background guard — never invoke manually --- ## Cook-After-Plan Reminder **Trigger:** When a planning subagent stops (completes or is terminated). **Behavior:** Outputs a mandatory reminder to use `ck-cook` before starting implementation: ``` MUST invoke /cook --auto skill before implementing the plan. Best Practice: Run /clear then /cook {full-absolute-path-to-plan.md} ``` If an active plan path is available in session state, the reminder includes the full absolute path to `plan.md`. This is critical for worktree and multi-window workflows where a new session (after `/clear`) needs to locate the plan. **Why absolute path matters:** When working in git worktrees or opening a new Claude Code window after planning, relative paths break. The full absolute path ensures the plan is findable regardless of which directory the new session starts in. **Purpose:** Enforces the workflow discipline of: 1. Plan first (with `ck-planning`) 2. Clear context to reset window 3. Implement with `ck-cook` (not ad-hoc implementation) This prevents a common anti-pattern: starting to implement directly after planning without clearing the context, which leads to a bloated context window during implementation. --- ## Descriptive Name Guidance **Trigger:** Before every file write or creation (`PreToolUse` on write operations). **Injected guidance:** ``` ## File naming guidance: - Skip this guidance if creating markdown or plain text files - Prefer kebab-case for JS/TS/Python/shell (.js, .ts, .py, .sh) with descriptive names - C#/Java/Kotlin/Swift: PascalCase (.cs, .java, .kt, .swift) - Go/Rust: snake_case (.go, .rs) - Other languages: follow their ecosystem's standard naming convention - Goal: self-documenting names for LLM tools (Grep, Glob, Search) ``` **Purpose:** Ensures that file names communicate intent at a glance. When LLM tools search the codebase using glob or grep patterns, descriptive kebab-case names like `user-authentication-service.ts` are immediately understandable without reading file contents. **Note:** Guidance is skipped for markdown and plain text files — those already have human-readable names by convention. --- ## Workflow Integration `ck-context-guard` enforces the canonical workflow transition: ``` ck-planning → [plan.md created] ↓ [Cook-After-Plan fires] ↓ User runs /clear ↓ ck-cook path/to/plan.md --auto ↓ [Implementation begins with clean context] ``` This guard prevents the anti-pattern of implementing immediately after planning in the same context window, which bloats the window and reduces implementation quality. --- ## Configuration ```json // $HOME/.claude/.ck.json { "hooks": { "cook-after-plan-reminder": true, "descriptive-name": true } } ```