.codex/skills/debug-agent/SKILL.md
Systematic evidence-based debugging using runtime logs. Generates hypotheses, instruments code with NDJSON logs, guides reproduction, analyzes log evidence, and iterates until root cause is proven with cited log lines. Use when the user reports a bug, unexpected behavior, or asks to debug an issue.
npx skillsauth add bitsocialnet/5chan debug-agentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are now in DEBUG MODE. You must debug with runtime evidence.
Why this approach: Traditional AI agents jump to fixes claiming 100% confidence, but fail due to lacking runtime information. They guess based on code alone. You cannot and must NOT fix bugs this way — you need actual runtime data.
Your systematic workflow:
#region debug log / #endregion markers and deleting those blocks (see Cleanup section). If failed: FIRST remove any code changes from rejected hypotheses (keep only instrumentation and proven fixes), THEN generate NEW hypotheses from different subsystems and add more instrumentationCritical constraints:
Run the debug server in daemon mode before any instrumentation. The --daemon flag starts the server in the background and exits immediately with the server info — no backgrounding or & required.
npx debug-agent --daemon
The command prints a single JSON line to stdout and exits:
{
"sessionId": "a1b2c3",
"port": 54321,
"endpoint": "http://127.0.0.1:54321/ingest/a1b2c3",
"logPath": "/tmp/debug-agent/debug-a1b2c3.log"
}
Capture and remember these values:
endpoint value (the HTTP endpoint URL where logs will be sent via POST requests)logPath value (NDJSON logs are written here)sessionId value (unique identifier for this debug session)If the server fails to start, STOP IMMEDIATELY and inform the user.
Example log entry:
{
"sessionId": "a1b2c3",
"id": "log_1733456789_abc",
"timestamp": 1733456789000,
"location": "test.js:42",
"message": "User score",
"data": { "userId": 5, "score": 85 },
"runId": "run1",
"hypothesisId": "A"
}
ENDPOINT and SESSION_ID with values from Step 0), even if filesystem access is available:fetch('ENDPOINT',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({sessionId:'SESSION_ID',location:'file.js:LINE',message:'desc',data:{k:v},timestamp:Date.now()})}).catch(()=>{});
In non-JavaScript languages (Python, Go, Rust, Java, C, C++, Ruby), instrument by opening the log path in append mode using standard library file I/O, writing a single NDJSON line with your payload, and then closing the file. Keep these snippets as tiny and compact as possible (ideally one line, or just a few).
Decide how many instrumentation logs to insert based on the complexity of the code under investigation and the hypotheses you are testing. A single well-placed log may be enough when the issue is highly localized; complex multi-step flows may need more. Aim for the minimum number that can confirm or reject ALL your hypotheses. Guidelines:
Choose log placements from these categories as relevant to your hypotheses:
Each log must map to at least one hypothesis (include hypothesisId in payload).
Use this payload structure: {sessionId, runId, hypothesisId, location, message, data, timestamp}
REQUIRED: Wrap EACH debug log in a collapsible code region:
// #region debug log, // #endregion for JS/TS)FORBIDDEN: Logging secrets (tokens, passwords, API keys, PII)
DELETE request to the server endpoint to clear the log file before each run. For example: curl -X DELETE ENDPOINT (replace ENDPOINT with the endpoint value from Step 0).runId="post-fix" to distinguish verification runs from initial debugging runs.setTimeout, sleep, or artificial delays as a "fix"; use proper reactivity/events/lifecycles.When it is time to remove instrumentation (after verified fix or user request):
#region debug log markers (e.g., grep/ripgrep for #region debug log)#region debug log line through its corresponding #endregion line (inclusive)git diff to review all changes — confirm only your intentional fix remains and no stray debug code was missedThis is why wrapping every debug log in #region debug log / #endregion is mandatory — it enables deterministic cleanup.
| Method | Effect |
| --------------------------- | ------------------------------------------- |
| POST /ingest/:sessionId | Append JSON body as NDJSON line to log file |
| GET /ingest/:sessionId | Read full log file contents |
| DELETE /ingest/:sessionId | Clear the log file |
tools
Profile app performance while browsing, collecting Web Vitals and React rerender data via react-scan. Orchestrates parallel profiler subagents via playwright-cli to capture navigation timing, long tasks, layout shifts, LCP, React commit counts, render bursts, and per-component render data. Use when profiling browsing performance, finding bottlenecks, diagnosing excessive rerenders, or auditing page performance.
tools
Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.
tools
Create a GitHub issue from recent changes, commit only relevant diffs on a short-lived task branch, push that branch, and open a PR into master that will close the issue on merge. Use when the user says "make closed issue", "close issue", or wants to create a tracked, already-resolved GitHub issue for completed work.
development
Formats GitHub issue titles and descriptions for tracking problems that were fixed. Use when proposing or implementing code changes, creating GitHub issues, or when the user asks for issue suggestions.