$npx -y skills add hatch3r/hatch3r --skill hatch3r-context-healthMonitors and maintains conversation context health during long sessions. Use when context may be degrading, after many turns, or when experiencing repeated errors.
| 1 | # Context Health Monitoring |
| 2 | |
| 3 | ## Quick Start |
| 4 | |
| 5 | ``` |
| 6 | Task Progress: |
| 7 | - [ ] Step 0: Detect ambiguity (P8 B1) |
| 8 | - [ ] Step 1: Assess current context health |
| 9 | - [ ] Step 2: Identify degradation signals |
| 10 | - [ ] Step 3: Apply corrective action |
| 11 | - [ ] Step 4: Verify health improvement |
| 12 | ``` |
| 13 | |
| 14 | ## Step 0 — Detect Ambiguity (P8 B1) |
| 15 | |
| 16 | Before any work, scan the invocation for unresolved questions in scope, intent, acceptance criteria, target environment, or irreversibility. If any are found, ask the user via the platform-native question tool per `agents/shared/user-question-protocol.md`. Do not proceed under silent assumption. Default path, not an exception. Triggers for THIS skill: original task recall, corrective action authority at Orange/Red (delegate vs checkpoint-and-stop), scope of files to re-read, whether to post progress to platform on Red, and irreversible stop (discard unsaved work) vs preserve. |
| 17 | |
| 18 | ## Fan-out Discipline (P8 B2) |
| 19 | |
| 20 | Fan-out scales with task size; token cost never justifies serializing independent work (`rules/hatch3r-fan-out-discipline.md` P8 B2; `agents/shared/efficiency-patterns.md`). Emit `sub_agents_spawned: { count, rationale, task_structure }` in your output. |
| 21 | |
| 22 | ## Step 1: Assess Context Health |
| 23 | |
| 24 | Run through the self-assessment checklist: |
| 25 | |
| 26 | 1. **Task recall**: Can you state the original task, acceptance criteria, and scope boundaries without looking? |
| 27 | 2. **Progress tracking**: List what's been completed and what remains. |
| 28 | 3. **Error check**: Count recent failed tool calls or incorrect assumptions. |
| 29 | 4. **File currency**: List files you've modified — when did you last read each one? |
| 30 | 5. **Scope check**: Compare your current work to the original issue description. |
| 31 | |
| 32 | ### Model-Aware Threshold Profiles |
| 33 | |
| 34 | Default thresholds assume a large-context model. When the active model is known, apply the matching profile to adjust thresholds: |
| 35 | |
| 36 | | Model Tier | Context Window | Token Warning | Turn Limit | File Staleness | |
| 37 | |-----------|---------------|---------------|------------|----------------| |
| 38 | | Small (< 32K) | ~32K tokens | > 60% of window | > 15 turns | > 10 turns | |
| 39 | | Medium (32K--128K) | ~128K tokens | > 70% of window | > 25 turns | > 15 turns | |
| 40 | | Large (128K--200K) | ~200K tokens | > 80% of window | > 30 turns | > 20 turns | |
| 41 | | Extended (> 200K) | 200K+ tokens | > 85% of window | > 40 turns | > 25 turns | |
| 42 | |
| 43 | Profile resolution: read `models` in `.hatch3r/hatch.json`; default to **Large** if unset. A `contextHealth` section in `hatch.json` with explicit thresholds overrides the profile. Log the active profile at the start of each check: `"Context health using <tier> profile (<window_size> tokens)"`. |
| 44 | |
| 45 | ## Step 2: Identify Degradation |
| 46 | |
| 47 | | Check | Healthy | Degraded | |
| 48 | |-------|---------|----------| |
| 49 | | Task recall | Can state requirements from memory | Need to re-read issue | |
| 50 | | Progress | Clear forward momentum | Cycling or stuck | |
| 51 | | Errors | Occasional, different causes | Repeated, same cause | |
| 52 | | Files | Recently read and current | Stale, may have drifted | |
| 53 | | Scope | Aligned with acceptance criteria | Drifted to tangential work | |
| 54 | |
| 55 | ## Step 3: Apply Corrective Action |
| 56 | |
| 57 | ### If 0-1 checks degraded (Green): Continue normally |
| 58 | |
| 59 | ### If 2-3 checks degraded (Yellow): Refresh |
| 60 | 1. Re-read the issue body and acceptance criteria |
| 61 | 2. Re-read all files you've modified in this session |
| 62 | 3. Create a progress summary of completed work |
| 63 | 4. Re-plan remaining steps from the refreshed context |
| 64 | |
| 65 | ### If 4 checks degraded (Orange): Delegate |
| 66 | 1. Create a handoff document with all context by invoking the `hatch3r-handoff-preparer` agent (or the `hatch3r-handoff-prepare` skill directly) |
| 67 | 2. Spawn a sub-agent using the Task tool with the handoff |
| 68 | 3. Monitor the sub-agent's output |
| 69 | 4. Aggregate results |
| 70 | |
| 71 | ### If 5 checks degraded (Red): Checkpoint and Stop |
| 72 | 1. Save all progress (files changed, tests written) |
| 73 | 2. Document remaining work and blockers |
| 74 | 3. Post progress on the issue/work item (GitHub Issue, ADO Work Item, or GitLab Issue — check `platform` in `.hatch3r/hatch.json`) |
| 75 | 4. Recommend fresh conversation |
| 76 | |
| 77 | ## Step 4: Verify Improvement |
| 78 | |
| 79 | After corrective action: |
| 80 | - Re-run the assessment checklist |
| 81 | - Confirm health is at Green or Yellow |
| 82 | - Resume work on the original task |
| 83 | |
| 84 | ## Context Poisoning Detection |
| 85 | |
| 86 | During context health checks, also scan for signs of context poisoning -- stale or incorrect information that has accumulated in the conversation: |
| 87 | |
| 88 | | Signal | Detection | Action | |
| 89 | |--------|-----------|--------| |
| 90 | | Outdated file content | You reference a file's content but the file has been modified since you last read it | Re-read the file before continuing | |
| 91 | | Stale assumptions | A decis |