Install in seconds
Install this skill
Copy the command and run it in your terminal. You can review the source before installing.
terminal
git clone https://github.com/crbnos/carbon

Works with Git. The repository opens in your current directory.

🐛
QualityTypeScript

Debugging Difficult Bugs

by crbnos

Add temporary unconditional JSONL logging to runtime code paths to observe elusive bugs, then reproduce the issue and identify the root cause. Ideal when static analysis is insufficient, especially for concurrency, state management, or UI reproduction.

2.3K stars325 forksAdded 2026/07/21
agentic-platformassemblylinebusinesserpleanmanagementmanufacturingmcp-servermespostgresqlqmsreact-routersupabasetypescript

Documentation

README

debugging-difficult-bugs — instrument, reproduce, read, then fix

Core idea: when you can't see the failure by reading code, make the runtime tell you. Add temporary append-only JSONL logging along the real code path, reproduce the real issue once, read the log chronologically, and only then fix. Never make a second speculative fix without new runtime evidence.

Announce at start: "Using the debugging-difficult-bugs skill — instrumenting the runtime path to observe the failure."

Step 1: State the uncertainty

Write down: what you believe, what you can't verify statically, and the exact runtime path that must be observed (route → service → query, edge function, job).

Step 2: Add temporary unconditional instrumentation

Rules:

  • Unconditional — never gated behind an env var, debug flag, or log level. If reproduction requires remembering to set a flag, it will silently not fire.
  • Append-only JSONL, one JSON object per line, to a file in the process's working directory.
  • Log boundaries and decisions, not every line: function entry/exit, branch decisions with the data that caused them, state before/after mutation, async ordering markers, caught errors, return-value shapes.
  • Log shapes, not payloads: ids, keys, counts, statuses. Never log tokens, auth headers, cookies, or full user content.
import { appendFileSync } from "node:fs";
import { join } from "node:path";

function debugBug(event: string, data: Record<string, unknown> = {}) {
  appendFileSync(
    join(process.cwd(), "debug-difficult-bug.jsonl"),
    `${JSON.stringify({ ts: new Date().toISOString(), event, ...data })}\n`
  );
}

debugBug("service.beforeUpdate", { id, companyId, status: row.status });

Carbon multi-process note. The ERP/MES dev servers, edge functions (Docker edge-runtime container), and Inngest handlers run as separate processes with different working directories. Log process.cwd() + a process role once at startup, or use distinct filenames (debug-erp.jsonl, debug-edge.jsonl). For edge functions, console.error JSON lines (visible in container logs) can stand in when the container filesystem is awkward to reach.

Step 3: Reproduce the real issue once

  • Prefer reproducing yourself: boot the stack (crbn up if not already running), authenticate with /auth, and drive the exact failing flow with agent-browser (the /test skill documents Carbon's form gotchas — requestSubmit, react-aria blur).
  • If only the user can reproduce (their data, their environment), tell them exactly: "I added temporary logging. Reproduce the issue once, then point me at <cwd>/debug-difficult-bug.jsonl."

Step 4: Read the log BEFORE fixing

Read chronologically and answer, in writing:

  1. Did the instrumented path actually run?
  2. What was the expected sequence of events?
  3. What was the actual sequence?
  4. What is the first point where state/order/branch diverges from expectation?

That first divergence is the root cause candidate. Feed it back into the root-cause brief (or write one now) — then implement via /fix, whose failing regression test must assert the actual divergence you observed, not your earlier assumption.

Step 5: Clean up — mandatory

  • Remove every temporary log call, helper, and import.
  • Delete generated .jsonl files.
  • Check the final diff explicitly for leftovers: git diff | grep -n "debugBug\|debug-difficult\|\.jsonl" → expect no hits.

The final diff contains only the fix and its tests.

Done when

  • The first divergence point is identified from log evidence (quote the lines)
  • The fix landed via /fix with a red→green regression test asserting that behavior
  • Reproduction of the original flow now passes
  • Zero instrumentation remnants in the diff

More from crbnos

Other Claude Code skills by this author in the directory.

🌐
1w ago

Agent Browser

Browser automation CLI for AI agents. Use it to navigate pages, fill forms, click buttons, take screenshots, extract data, test web apps, or automate any browser task.
Automation
+0%2.3K325
🔑
1w ago

Carbon Dev Auth

Authenticates a local browser session against the Carbon ERP dev server using DEV_BYPASS_EMAIL, enabling automated testing and manual verification. Leaves session open for subsequent commands.
Automation
+0%2.3K325
📚
1w ago

Carbon Docs

Author, edit, or extend Carbon's documentation site — a Fumadocs + Next.js app. Use for reader-facing guides, reference pages, and documentation IA. Grounds every claim in source code and follows a warm-paper house style.
Writing
+0%2.3K325
1w ago

Check and Commit

Runs a sequence of code quality gates (type generation, formatting, linting, typecheck, tests, build, i18n) on changed files, fixes simple issues, and commits only when all checks pass. Ideal after a code fix, task execution, or manual changes before committing.
Quality
+0%2.3K325
🔄
1w ago

Conductor

Drive a single work item through a doer→gate→judge→keep-or-revert→ledger cycle to a gated PR, unattended. Use for tightly-scoped bugs, usability tweaks, or small features with explicit acceptance criteria.
Automation
+0%2.3K325
🤖
1w ago

Create AGENTS.md

Generates or refreshes AGENTS.md files for Carbon packages and ERP modules by analyzing the actual source code. Ensures every documentation claim is verified against real functions, tables, and exports.
Writing
+0%2.3K325