automated-instrumented-debugging

Automated Instrumented Debugging

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "automated-instrumented-debugging" with this command: npx skills add minleev5/automated-instrumented-debugging-skill/minleev5-automated-instrumented-debugging-skill-automated-instrumented-debugging

Automated Instrumented Debugging

Core Philosophy: Don't guess. Instrument, measure, and let the data reveal the root cause.

Overview

This skill empowers you to debug complex issues by systematically injecting lightweight probes (fetch calls) into the codebase. These probes stream real-time execution data (function entries, variable states, errors) to a local debug server, allowing you to reconstruct the exact execution flow without relying on scattered console logs or interactive debuggers.

When to Use

  • Complexity: The bug involves data flow across 3+ functions or asynchronous chains.

  • Invisibility: Code runs in blind environments (Docker, CI, remote servers).

  • Persistency: You need to analyze the chronology of events post-execution.

  • Systematic Analysis: You need hard evidence to prove a hypothesis.

Systematic Debugging Process

Follow this 4-phase loop to resolve issues efficiently.

Phase 1: Strategy & Setup

Don't rush to code. First, define what you need to capture.

  • Start Server: Ensure bootstrap.js is running (node .agent/skills/automated-instrumented-debugging/scripts/bootstrap.js ).

  • Hypothesize: What variable or flow is likely broken?

  • Plan Probes: Decide where to place #region DEBUG blocks (Entry, Exit, Error, State).

Phase 2: Instrumentation (The "Probe")

Inject probes using the standard templates. Always use the #region DEBUG wrapper for easy cleanup.

  • Trace Flow: Log Function Entry/Exit to see the path.

  • Snapshot State: Log local variables and arguments.

  • Catch Errors: Log try-catch blocks in critical paths.

(See "Instrumentation Templates" below for code patterns)

Phase 3: Evidence Collection & Analysis

Run the reproduction case and let the data speak.

  • Trigger: Run the test/script to reproduce the bug.

  • Query: Fetch logs via curl http://localhost:9876/logs/{session} .

  • Analyze:

  • Did the function get called? (Check Entry logs)

  • Was the data correct? (Check Variable logs)

  • Where did it crash? (Check Error logs/Last successful log)

Phase 4: Resolution & Cleanup

Fix the root cause and restore the codebase.

  • Fix: Apply the fix based on evidence.

  • Verify: Run tests to confirm the fix.

  • Cleanup: Crucial! Remove all #region DEBUG blocks using the cleanup script: node .agent/skills/automated-instrumented-debugging/scripts/cleanup.js

  • Shutdown: Stop the debug server if no longer needed.

Instrumentation Templates

  1. Function Entry (Trace Path)

// #region DEBUG - {SESSION} fetch('http://localhost:9876/log', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ session: '{SESSION}', type: 'enter', fn: '{FUNC}', file: '{FILE_PATH}', // Use absolute path or relative to project root data: { arg1, arg2 }, // Snapshot arguments }), }).catch(() => {}); // #endregion

  1. Variable Snapshot (Inspect State)

// #region DEBUG - {SESSION} fetch('http://localhost:9876/log', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ session: '{SESSION}', type: 'var', fn: '{FUNC}', file: '{FILE_PATH}', data: { varName: value }, }), }).catch(() => {}); // #endregion

  1. Function Exit (Result & Timing)

// #region DEBUG - {SESSION} fetch('http://localhost:9876/log', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ session: '{SESSION}', type: 'exit', fn: '{FUNC}', data: { result }, }), }).catch(() => {}); // #endregion

  1. Error Capture (Catch & Report)

// #region DEBUG - {SESSION} fetch('http://localhost:9876/log', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ session: '{SESSION}', type: 'error', fn: '{FUNC}', data: { error: err.message, stack: err.stack }, }), }).catch(() => {}); // #endregion

Anti-Patterns

❌ Sync Fetch Trap: Using fetch without considering execution order in critical paths. -> Fix: Always use .catch(() => {}) and place probes after variable definitions.

❌ Committing Probes: Forgetting to run cleanup.js . -> Fix: Add cleanup as a mandatory step in your "Resolution & Cleanup" workflow.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

claw2ui

Generate interactive web pages (dashboards, charts, tables, reports) and serve them via public URL. Use this skill when the user explicitly asks for data vis...

Registry SourceRecently Updated
General

WeChat Article Summarize

Read one or more WeChat public account article links from mp.weixin.qq.com, extract cleaned full text and optional image links, summarize each article in Chi...

Registry SourceRecently Updated
General

Openfinance

Connect bank accounts to AI models using openfinance.sh

Registry SourceRecently Updated
General

---

合同审查清单AI助手 - 5类合同+3大特殊条款,风险识别与修改建议

Registry SourceRecently Updated