agentleFS
wwwrootwwwroot/ai-codex/skills/codex-debug/SKILL.md

codex-debug

Skill1 starsChanged 4 months agoMITView on GitHub

Performs systematic root-cause investigation, crash dump analysis, race condition debugging, memory leak tracing, and post-mortem failure analysis. Produces timestamped debugging reports and fix walkthroughs in codex-drive/walkthroughs/.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All debugging reports generated by codex-debug MUST be Markdown (.md) files with exact date-time metadata.

    line 66

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Codex Debug — Root-Cause Diagnostic & Troubleshooting Skill

The forensic investigation and debugging engine of AI Codex. Isolates root causes, eliminates speculative fixes, and writes verifiable post-mortem walkthroughs.


Overview

codex-debug replaces random guessing with a rigorous scientific debugging method. It establishes a deterministic reproduction, formulates falsifiable hypotheses, traces runtime execution or memory states, identifies the exact line and invariant failure, and provides a verified fix with regression tests.


When to Trigger

  • User runs /codex-debug (e.g., /codex-debug investigate 500 error in checkout, /codex-debug memory leak in background worker, /codex-debug data race on WebSocket connection)
  • Diagnosing failing unit/integration tests, segfaults, unhandled exceptions, or performance regressions
  • Post-incident post-mortem analysis

Execution Workflow

 ┌────────────────────────────────────────────────────────┐
 │ 1. CAPTURE SYMPTOMS & BUILD MINIMAL REPRODUCTION       │
 │    Stack traces, logs, failing assertions, inputs.     │
 └──────────────────────────┬─────────────────────────────┘
                            │
                            ▼
 ┌────────────────────────────────────────────────────────┐
 │ 2. FORMULATE FALSIFIABLE HYPOTHESES                    │
 │    List probable causes based on domain knowledge.     │
 └──────────────────────────┬─────────────────────────────┘
                            │
                            ▼
 ┌────────────────────────────────────────────────────────┐
 │ 3. ISOLATE ROOT CAUSE VIA PROFILING & TRACING          │
 │    Memory inspection, race auditing, line-level proof. │
 └──────────────────────────┬─────────────────────────────┘
                            │
                            ▼
 ┌────────────────────────────────────────────────────────┐
 │ 4. IMPLEMENT FIX & REGRESSION TEST                     │
 │    Ensure root defect is eliminated and cannot recur.  │
 └──────────────────────────┬─────────────────────────────┘
                            │
                            ▼
 ┌────────────────────────────────────────────────────────┐
 │ 5. WRITE POST-MORTEM IN CODEX-DRIVE                    │
 │    Write codex-drive/walkthroughs/YYYY-MM-DD-*.debug.md│
 └────────────────────────────────────────────────────────┘

Debug Walkthrough Specification (codex-drive/walkthroughs/)

All debugging reports generated by codex-debug MUST be Markdown (.md) files with exact date-time metadata.

Filename Format:

codex-drive/walkthroughs/YYYY-MM-DD-<slug>.debug.md

Standard Debug Post-Mortem Template:

# [Issue / Bug Title] Diagnostic & Fix Walkthrough

> **Created At**: YYYY-MM-DD HH:MM:SS (Local Time)
> **Active Codex Edition**: [`skills/codex/<edition>/`](file:///...)
> **Severity**: CRITICAL | HIGH | MEDIUM | LOW
> **Resolution Status**: REPRODUCED | ROOT_CAUSE_CONFIRMED | RESOLVED

---

## 1. Incident Summary & Symptoms
- **Reported Defect**: [Exact error message or unexpected behavior]
- **Environment**: [OS, Runtime version, Hardware/Cloud context]
- **Stack Trace / Error Output**:

[Paste relevant logs / stack trace here]


## 2. Minimal Reproduction Harness
Step-by-step procedure or unit test that reliably triggers the defect:

```typescript
test("reproduce connection timeout under concurrent load", async () => {
    // Exact test case that failed
});

3. Scientific Hypothesis & Isolation Matrix

#HypothesisTest / Verification MethodResult
1Database connection pool exhaustionCheck active pool metrics during burstDisproven (Pool had 80% free)
2Missing await on token refresh causing raceInspect async call graph with static analysis[OK] CONFIRMED ROOT CAUSE

4. Root Cause Deep Dive

  • Mechanism: The background token refresh task spawned an unawaited promise, creating a data race where subsequent HTTP requests executed with expired credentials before the new token was committed to memory.
  • Affected Files: src/auth/token-manager.ts:L45-L62

5. Applied Solution & Code Diff

- void refreshToken(); // [WARNING] Fire and forget race condition
+ await this.refreshTokenMutex.runExclusive(async () => {
+     await this.refreshToken();
+ });

6. Regression Testing & Prevention

  • Added automated regression test: tests/auth/token-race.test.ts.
  • Added linter rule to disallow floating/unawaited promises (@typescript-eslint/no-floating-promises).

---

## Response Protocol

When `codex-debug` finishes:
1. Provide a direct link to `[View Diagnostic Walkthrough](file:///.../codex-drive/walkthroughs/YYYY-MM-DD-<slug>.debug.md)`.
2. Clearly explain the root cause and the specific invariant that failed.
3. Show the exact code fix and verification command (`npm test`, `pytest`, etc.).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.