|
| 1 | +# Debug Mode Skill |
| 2 | + |
| 3 | +Agent-agnostic, opt-in debug mode for reproducible runtime bugs. It includes |
| 4 | +first-class probe helpers for browser/frontend JavaScript and Node.js, while |
| 5 | +the local collector accepts the same structured events from other runtimes. |
| 6 | + |
| 7 | +Agents add temporary structured probes, collect NDJSON evidence through a |
| 8 | +local loopback collector, wait for you to reproduce manually, fix from log proof, |
| 9 | +verify once, then clean up. |
| 10 | + |
| 11 | +```text |
| 12 | +hypothesize -> instrument -> reproduce -> inspect evidence -> fix -> verify -> clean up |
| 13 | +``` |
| 14 | + |
| 15 | +## When to Use |
| 16 | + |
| 17 | +Use this skill only when you explicitly ask for it, for example: |
| 18 | + |
| 19 | +- `$debug-mode` or `debug mode` |
| 20 | +- instrumented debugging |
| 21 | +- local runtime log collection with temporary probes |
| 22 | + |
| 23 | +For ordinary bug reports, failing tests, build errors, or issues already |
| 24 | +explained by existing logs, agents should debug normally without this workflow. |
| 25 | + |
| 26 | +Full opt-in rules and the agent workflow live in |
| 27 | +[`skills/debug-mode/SKILL.md`](skills/debug-mode/SKILL.md). |
| 28 | + |
| 29 | +## How It Works |
| 30 | + |
| 31 | +1. The agent states ranked hypotheses and adds 3–8 targeted probes. |
| 32 | +2. A small loopback collector receives structured events at `POST /log` and |
| 33 | + writes one NDJSON line per event. |
| 34 | +3. The agent stops and asks you to reproduce the bug manually. |
| 35 | +4. After you reply, it summarizes the log, confirms or rejects hypotheses, |
| 36 | + states the fix acceptance criteria, makes a minimal fix, verifies once with |
| 37 | + probes still active, then removes all instrumentation. |
| 38 | + |
| 39 | +Probe templates for browser/frontend JavaScript and Node/server-side JavaScript |
| 40 | +live under `skills/debug-mode/assets/`. Agents start collection with |
| 41 | +`skills/debug-mode/scripts/start-collector.mjs`; the lower-level collector is |
| 42 | +`skills/debug-mode/scripts/log-server.mjs`; the NDJSON summary script is |
| 43 | +`skills/debug-mode/scripts/summarize-log.mjs`. |
| 44 | + |
| 45 | +Agents run `node <skill-dir>/scripts/start-collector.mjs --session <id>`. The |
| 46 | +wrapper fixes host to `127.0.0.1` and port to `0`, then delegates to |
| 47 | +`log-server.mjs --ensure`. It reuses a healthy collector when available; if it |
| 48 | +starts one, the child binds only to loopback and writes state/log files under |
| 49 | +the OS temp directory. If command authorization is denied, agents stop and wait |
| 50 | +for you to run the same command locally before adding probes. |
| 51 | + |
| 52 | +## Usage |
| 53 | + |
| 54 | +Ask your agent explicitly: |
| 55 | + |
| 56 | +```text |
| 57 | +Use $debug-mode to investigate this reproducible runtime bug with temporary probes, manual reproduction, log evidence, a minimal fix, and cleanup. |
| 58 | +``` |
| 59 | + |
| 60 | +When the agent pauses for manual verification, reply with the leading letter: |
| 61 | + |
| 62 | +```text |
| 63 | +A - Reproduced |
| 64 | +B - Fixed |
| 65 | +C - Other; describe what happened |
| 66 | +``` |
| 67 | + |
| 68 | +Checkpoint wording, evidence format, troubleshooting, and cleanup steps are in |
| 69 | +`SKILL.md`. |
| 70 | + |
| 71 | +## Install |
| 72 | + |
| 73 | +Install or inspect with the open Agent Skills CLI: |
| 74 | + |
| 75 | +```bash |
| 76 | +npx skills add wangnan0916/debug-mode-skill |
| 77 | +npx skills add wangnan0916/debug-mode-skill -g |
| 78 | +npx skills add wangnan0916/debug-mode-skill -a codex |
| 79 | +npx skills add wangnan0916/debug-mode-skill --list |
| 80 | +npx skills update debug-mode |
| 81 | +``` |
| 82 | + |
| 83 | +Use `-g` for global install, `-a codex` for a specific agent, `--list` to list |
| 84 | +without installing, and `npx skills update debug-mode` to update later. |
| 85 | + |
| 86 | +## Layout |
| 87 | + |
| 88 | +```text |
| 89 | +skills/debug-mode/ |
| 90 | + SKILL.md # full agent workflow and protocol |
| 91 | + agents/openai.yaml # Codex / OpenAI skill UI metadata |
| 92 | + assets/ |
| 93 | + browser-log-helper.js # copy into frontend code |
| 94 | + node-log-helper.js # copy into Node/server code |
| 95 | + scripts/ |
| 96 | + start-collector.mjs # safe fixed-host collector entrypoint |
| 97 | + log-server.mjs # loopback NDJSON collector |
| 98 | + summarize-log.mjs # local NDJSON evidence summarizer |
| 99 | +
|
| 100 | +tests/ # Node built-in tests for collector, helpers, and summarizer |
| 101 | +``` |
| 102 | + |
| 103 | +## Safety |
| 104 | + |
| 105 | +- Collector binds to loopback only (`127.0.0.1`, `localhost`, or `::1`). |
| 106 | +- `start-collector.mjs` fixes host to `127.0.0.1` and port to `0`, then delegates |
| 107 | + to the reusable `--ensure` collector path. |
| 108 | +- Approval denial is terminal for that collector command; agents stop until they |
| 109 | + have user-provided collector details or a safe file-based fallback. |
| 110 | +- Probes must not log secrets, tokens, cookies, auth headers, or raw private |
| 111 | + payloads. |
| 112 | +- Temporary instrumentation uses `DEBUG_MODE_PROBE <session_id>` region markers |
| 113 | + so agents can remove it mechanically. |
| 114 | +- Debug logs are local temp evidence and should not be committed. |
| 115 | + |
| 116 | +## Development |
| 117 | + |
| 118 | +```bash |
| 119 | +npm run check |
| 120 | +npm test |
| 121 | +``` |
| 122 | + |
| 123 | +Requires Node.js 24+. Tests use only Node.js built-ins. |
| 124 | + |
| 125 | +## License |
| 126 | + |
| 127 | +MIT. See [LICENSE](LICENSE). |
0 commit comments