$npx -y skills add Borda/AI-Rig --skill investigateSystematic diagnosis for unknown failures — local environment, tool setup, CI vs local divergence, hook misbehavior, and runtime anomalies. Gathers signals broadly, ranks hypotheses, uses adversarial review (Codex or foundry:challenger) for ambiguous cases, probes each, and repor
| 1 | <objective> |
| 2 | |
| 3 | Diagnose unknown failures: broken local setup, environment mismatch, tool misbehavior, hook problems, CI vs local divergence, permission errors, runtime anomalies. Gather signals broadly, eliminate hypotheses systematically, report confirmed root cause + recommended next skill. No fixes — diagnosis only. |
| 4 | NOT for: known Python test failures with traceback (use `/develop:debug` (requires `develop` plugin)); `.claude/` config quality sweep (use `/foundry:audit`). |
| 5 | |
| 6 | </objective> |
| 7 | |
| 8 | <inputs> |
| 9 | |
| 10 | - **$ARGUMENTS**: required — symptom, question, or failing command, e.g.: |
| 11 | - `"hooks not firing on Save"` |
| 12 | - `"codex:codex-rescue agent exits 127 on this machine"` |
| 13 | - `"/calibrate times out every run"` |
| 14 | - `"CI fails but passes locally"` |
| 15 | - `"uv run pytest can't find conftest.py"` |
| 16 | |
| 17 | - **`--fast`**: optional flag — skip Step 4 adversarial Codex review; use when speed matters more than thoroughness or Codex unavailable. |
| 18 | |
| 19 | If $ARGUMENTS empty or too vague, use AskUserQuestion: "What exactly is failing or behaving unexpectedly? Include the command and any error output you can share." |
| 20 | |
| 21 | </inputs> |
| 22 | |
| 23 | <compaction> |
| 24 | Key boundary 1: end of Step 2 (signals.md written to run-dir), before Step 3 rank hypotheses. |
| 25 | Key boundary 2: end of Step 3 (hypotheses.md written), refreshed again after each Step 5 probe verdict — so a mid-loop compaction does NOT re-rank or re-probe. |
| 26 | Preserve: INVESTIGATE_RUN, symptom.txt, signals.md, hypotheses.md paths; adversarial-review path (codex/challenger) if Step 4 ran; probe ledger (hypothesis → Confirmed/Ruled-out/Inconclusive). |
| 27 | Terminal path: end of Step 6 (report + follow-up gate complete). |
| 28 | </compaction> |
| 29 | |
| 30 | <workflow> |
| 31 | |
| 32 | **Task hygiene**: load and follow the protocol below. |
| 33 | ```bash |
| 34 | # loads: compaction-contract.md |
| 35 | # audit-skip: resilience-replication |
| 36 | _FS=$(python "${CLAUDE_PLUGIN_ROOT:-plugins/cc_foundry}/bin/resolve_shared_path.py" foundry skills/_shared 2>/dev/null || echo "plugins/cc_foundry/skills/_shared") # timeout: 5000 |
| 37 | cat "$_FS/task-hygiene.md" |
| 38 | ``` |
| 39 | |
| 40 | **Task tracking**: TaskCreate tasks for Gather, Hypothesise, Probe, Report; mark in_progress/completed as you go. |
| 41 | |
| 42 | ## Step 1: Parse symptom and scope |
| 43 | |
| 44 | ```bash |
| 45 | export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" |
| 46 | KEEP_ITEMS="" |
| 47 | if [[ "$ARGUMENTS" =~ --keep[[:space:]]\"([^\"]+)\" ]]; then |
| 48 | KEEP_ITEMS="${BASH_REMATCH[1]}" |
| 49 | fi |
| 50 | ARGUMENTS=$(echo "$ARGUMENTS" | sed 's/--keep "[^"]*"//g') |
| 51 | rm -f .temp/state/skill-contract.md ${TMPDIR:-/tmp}/investigate-verdicts-${CSID} # clear stale contract + probe ledger (compaction-contract.md §Lifecycle) # timeout: 5000 |
| 52 | echo "$KEEP_ITEMS" > "${TMPDIR:-/tmp}/investigate-keep-items-${CSID}" |
| 53 | ``` |
| 54 | |
| 55 | From $ARGUMENTS extract: |
| 56 | |
| 57 | - **What**: specific failure or anomaly |
| 58 | - **Where**: local / CI / both; which tool or command; which skill or hook if applicable |
| 59 | - **When**: started recently (after change) or always broken; intermittent or consistent |
| 60 | |
| 61 | **Unsupported flag check** — after all supported flags extracted (`--fast`, `--keep`), scan `$ARGUMENTS` for remaining `--<token>` tokens. If found: print `! Unknown flag(s): \`--<token>\`. Supported: \`--fast\`, \`--keep\`.` then invoke `AskUserQuestion` — (a) **Abort** (stop, re-invoke with correct flags) · (b) **Continue ignoring** (skip unknown flags, proceed). On Abort: stop. |
| 62 | |
| 63 | ## Step 2: Gather signals |
| 64 | |
| 65 | **Init run directory unconditionally at start of Step 2** — `$INVESTIGATE_RUN` must be set even when Step 4 skipped (`--fast` path), so Step 6's read of `$INVESTIGATE_RUN/*-review.md` does not expand to `/codex-review.md` or unset reference. Step 4 creates review files only when adversarial review runs; Step 6 must guard reads with `[ -f <path> ]`. |
| 66 | |
| 67 | ```bash |
| 68 | export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" |
| 69 | # timeout: 5000 |
| 70 | INVESTIGATE_RUN=".temp/investigate/$(date -u +%Y-%m-%dT%H-%M-%SZ)" |
| 71 | mkdir -p "$INVESTIGATE_RUN" |
| 72 | echo "$INVESTIGATE_RUN" > "${TMPDIR:-/tmp}/investi |