Chris-Cullins avatar

debug-run

Programmatically debug code using debug-run CLI with DAP. Use when debugging .NET or Python applicat

by Chris-Cullins|Open Source

debug-run Debugging Skill

Use the debug-run CLI tool to programmatically debug applications via the Debug Adapter Protocol (DAP). This skill enables you to set breakpoints, capture variable state, and evaluate expressions without interactive debugger sessions.

When to Use This Skill

  • Debugging .NET applications (using vsdbg adapter)
  • Debugging Python applications (using debugpy adapter)
  • Debugging JavaScript/TypeScript applications (using js-debug/node adapter)
  • Capturing runtime state at specific code locations
  • Evaluating expressions to inspect object properties
  • Attaching to running processes for live debugging

Prerequisites

debug-run is available via npx (no installation required) or can be installed globally:

# Run directly with npx
npx debug-run --help

# Or install globally
npm install -g debug-run

Check available adapters:

npx debug-run list-adapters

Installing the Skill

To install this skill for AI coding assistants:

# Install to Claude Code (~/.claude/skills/)
npx debug-run install-skill --claude

# Install to GitHub Copilot (~/.copilot/skills/)
npx debug-run install-skill --copilot

# Install to project directory (for project-specific skills)
npx debug-run install-skill --claude --project
npx debug-run install-skill --copilot --project

# Install to custom directory
npx debug-run install-skill --dir /path/to/skills

Language-Specific Guides

For detailed setup, examples, and troubleshooting for each language:

Basic Usage

npx debug-run <program> -a <adapter> -b "<file:line>" [options]

Quick Examples

# .NET
npx debug-run ./bin/Debug/net8.0/MyApp.dll -a vsdbg -b "src/Service.cs:42" --pretty

# Python
npx debug-run ./main.py -a python -b "src/processor.py:25" --pretty

# TypeScript/JavaScript
npx debug-run ./dist/index.js -a node -b "src/index.ts:100" --pretty

Options Reference

Core Options

OptionDescription
-a, --adapter <name>Debug adapter: vsdbg (.NET), python/debugpy (Python), node/js (JS/TS)
-b, --breakpoint <loc>Breakpoint location as file:line (can specify multiple)
-e, --eval <expr>Expression to evaluate at breakpoints (can specify multiple)
--assert <expr>Invariant expression; halts on first violation (can specify multiple)
-t, --timeout <time>Timeout duration: 30s, 2m, 5m (default: 60s)
--prettyPretty-print JSON output
-o, --output <file>Write events to file instead of stdout

Attach Mode

OptionDescription
--attachAttach to running process instead of launching
--pid <id>Process ID for attach mode

Trace Mode

OptionDescription
--traceEnable trace mode - step through code after breakpoint
--trace-intoUse stepIn instead of stepOver (follow into functions)
--trace-limit <N>Max steps in trace mode (default: 500)
--trace-until <expr>Stop trace when expression is truthy
--diff-varsShow only changed variables in trace steps

Token Efficiency

OptionDescription
--expand-servicesFully expand service types (Logger, Repository, etc.)
--show-null-propsInclude null/undefined properties in output
--no-dedupeDisable content-based deduplication

Event Filtering

OptionDescription
--include <types...>Only emit these event types
--exclude <types...>Suppress these event types

Exception Handling

OptionDescription
--break-on-exception <filter>Break on exceptions: all, uncaught, raised
--no-flatten-exceptionsDisable exception chain analysis
--exception-chain-depth <n>Max depth to traverse (default: 10)

Assertions

Use --assert to declare invariants. The debugger halts immediately when any assertion fails:

npx debug-run ./app.dll -a vsdbg \
  -b "src/OrderService.cs:42" \
  --assert "order.Total >= 0" \
  --assert "order.Items.Count > 0" \
  --pretty

Assertions are checked at every breakpoint hit, trace step, and regular step.

Trace Mode

Trace mode automatically steps through code after hitting a breakpoint:

# Basic trace
npx debug-run ./app.dll -a vsdbg -b "src/Service.cs:42" --trace --pretty

# Trace into function calls with limit
npx debug-run ./app.dll -a vsdbg -b "src/Service.cs:42" --trace --trace-into --trace-limit 100 --pretty

# Trace until condition
npx debug-run ./app.dll -a vsdbg -b "src/Service.cs:42" --trace --trace-until "total > 100" --pretty

# Trace with variable diffing (shows only changes)
npx debug-run ./app.dll -a vsdbg -b "src/Service.cs:42" --trace --diff-vars --pretty

Output Format

debug-run outputs NDJSON (newline-delimited JSON) events:

Event Types

EventDescription
session_startDebug session initialized
breakpoint_setBreakpoint configured (check verified field)
process_launchedDebuggee process started
process_attachedAttached to running process
breakpoint_hitBreakpoint was hit with locals and evaluations
assertion_failedAssertion violation with context
trace_startedTrace mode began
trace_stepSingle trace step (with changes if --diff-vars)
trace_completedTrace finished
exception_thrownException occurred
program_outputstdout/stderr from debuggee
process_exitedProgram terminated
session_endSummary with statistics

breakpoint_hit Example

{
  "type": "breakpoint_hit",
  "timestamp": "...",
  "location": {
    "file": "src/Services/OrderService.cs",
    "line": 42,
    "function": "ProcessOrder"
  },
  "stackTrace": [...],
  "locals": {
    "order": { "type": "Order", "value": {...} },
    "this": {...}
  },
  "evaluations": {
    "order.Total": { "result": "125.50" },
    "order.Items.Count": { "result": "3" }
  }
}

Token Efficiency

debug-run includes automatic optimizations for enterprise applications:

Service Type Compaction (default)

Types like Logger, Repository, Service are shown in compact form:

"logger": { "type": "Logger", "value": "{Logger}" }

Null Property Omission (default)

Properties with null/undefined values are omitted.

Content-Based Deduplication (default)

Repeated object content references the first occurrence:

"loyaltyService._features": { "value": "[see: discountService._features]", "deduplicated": true }

Best Practices

  1. Use relative paths for breakpoints: -b "src/MyFile.cs:42" not -b "MyFile.cs:42"

  2. Expression timing: Expressions evaluate BEFORE the breakpoint line executes. Variables assigned on that line will be null/unset.

  3. Unverified breakpoints: In attach mode, breakpoints start as verified: false. They verify when the code path is hit.

  4. Long-running processes: Use appropriate timeouts (-t 5m) and trigger the code path while debug-run is waiting.

Troubleshooting

IssueSolution
"Adapter not installed"Run list-adapters to check available adapters
Breakpoint not hittingVerify path is relative to working directory and line has executable code
Session timeoutIncrease timeout with -t 2m or -t 5m

For language-specific troubleshooting, see the language guides linked above.