Structured debug snapshots for LLM-assisted debugging
Project description
llmdebug
Structured debug snapshots for LLM-assisted debugging.
llmdebug captures failure-time evidence — exception details, prioritized stack
frames, local variables, and execution context — as a machine-readable artifact
that works for both humans and coding agents. The goal is to make the first
failing run useful, rather than reconstructing state after the fact.
The Debugging Loop
Without structured evidence, a typical loop looks like:
fail → infer missing state → guess patch → rerun → repeat
With llmdebug, the loop becomes:
fail → read snapshot → ranked hypotheses → minimal patch → verify
Installation
pip install 'llmdebug[cli]' # Recommended: pytest plugin + CLI
pip install llmdebug # Core library + pytest plugin only
pip install llmdebug[mcp] # MCP server for IDE integration
Other extras: jupyter, toon, evals — see Configuration Reference.
Quick Start
Pytest (automatic)
Failing tests automatically create .llmdebug/latest.json:
pytest # Failures create .llmdebug/latest.json
llmdebug # View crash summary
llmdebug show --detail context # Full context (git, env, repro command)
llmdebug diff # Compare latest vs previous
Decorator
from llmdebug import debug_snapshot
@debug_snapshot()
def main():
data = load_data()
process(data)
Context Manager
from llmdebug import snapshot_section
with snapshot_section("data_processing"):
result = transform(data)
More entry points (production hooks, web middleware, Jupyter) in the Configuration Reference.
Features
- Automatic capture — pytest plugin, decorator, context manager, production hooks, web middleware
- Rich snapshots — exception chain, prioritized frames, typed locals (array shapes, dtypes), source context
- Layered detail —
crash(~2K tokens) →full(~5K) →context(~10K) disclosure levels - CLI inspection —
show,list,frames,diff,git-context,clean - MCP server — 10 tools for Claude Code, Cursor, and other MCP-capable editors
- Hypothesis engine — auto-generated ranked debugging hypotheses from snapshot patterns
- Privacy controls — PII redaction profiles (
dev/ci/prod), pattern-based redaction - Jupyter integration — cell-error banners +
%llmdebugmagic commands - Compact formats —
json_compact(~40% smaller) andtoon(~50% smaller) for LLM context
CLI
llmdebug # Latest snapshot (crash detail)
llmdebug show --detail full # All frames
llmdebug show --detail context # Everything (git, env, repro)
llmdebug show --json --detail context # JSON output
llmdebug list # List snapshots
llmdebug diff # Compare latest vs previous
llmdebug clean -k 5 # Keep 5 most recent
| Level | Content | ~Tokens |
|---|---|---|
crash (default) |
Exception + crash frame | ~2K |
full |
All frames + traceback | ~5K |
context |
Everything (repro, git, env, coverage) | ~10K |
Full reference: docs/cli-reference.md
MCP Server
pip install llmdebug[mcp]
llmdebug-mcp # Start the MCP server (stdio transport)
| Tool | Description |
|---|---|
llmdebug_diagnose |
Concise crash summary optimized for LLM consumption |
llmdebug_show |
Full expanded JSON snapshot with detail level control |
llmdebug_list |
List available snapshots with metadata |
llmdebug_frame |
Detailed view of a specific stack frame |
llmdebug_git_context |
On-demand enhanced git metadata for crash triage |
llmdebug_diff |
Compare two snapshots to show what changed |
llmdebug_hypothesize |
Generate ranked debugging hypotheses |
llmdebug_rca_status |
Show latest RCA state for a session |
llmdebug_rca_history |
Show RCA attempt history |
llmdebug_rca_advance |
Manually advance RCA state machine |
Claude Code configuration (.mcp.json):
{
"mcpServers": {
"llmdebug": {
"command": "llmdebug-mcp"
}
}
}
Full reference: docs/mcp-reference.md
Output
On failure, .llmdebug/latest.json stores a versioned DebugSession envelope:
{
"schema_version": "2.0",
"kind": "llmdebug.debug_session",
"session": {
"name": "test_training_step",
"timestamp_utc": "2026-01-27T14:30:52Z"
},
"snapshot": {
"exception": {
"type": "ValueError",
"message": "operands could not be broadcast together..."
},
"frames": [
{
"file": "training.py",
"line": 42,
"function": "train_step",
"code": "output = model(x) + residual",
"locals": {
"x": {"shape": [32, 64], "dtype": "float32"},
"residual": {"shape": [32, 128], "dtype": "float32"}
}
}
]
}
}
Configuration
All capture settings are configurable via @debug_snapshot() parameters,
snapshot_section() arguments, or environment variables (for pytest):
LLMDEBUG_OUTPUT_FORMAT=json pytest # Use pretty JSON
LLMDEBUG_REDACTION_PROFILE=ci pytest # Use CI redaction profile
LLMDEBUG_INCLUDE_GIT=false pytest # Disable git context
Full parameter reference, output formats, and redaction profiles: docs/configuration.md
Documentation
| Document | Description |
|---|---|
| Configuration Reference | Parameters, env vars, output formats, API surface |
| CLI Reference | Full CLI command reference |
| MCP Reference | MCP server JSON schemas and parameters |
| Contributing | Development setup and quality gates |
| Quality Map | Which checks block package changes vs staged eval work |
| Eval Framework | Benchmark methodology and analysis |
| Research Roadmap | Forward-looking priorities |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llmdebug-2.27.0.tar.gz.
File metadata
- Download URL: llmdebug-2.27.0.tar.gz
- Upload date:
- Size: 6.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40e9b683ad09ca3ef9b22a83aa97b91cff000df67398f1017239fa4b601139cc
|
|
| MD5 |
6321105149e19f9141316d4a9ac76b70
|
|
| BLAKE2b-256 |
487903123a84e4fe97a428f6af49e17ebe531ff58584010b78b6a293918a064a
|
File details
Details for the file llmdebug-2.27.0-py3-none-any.whl.
File metadata
- Download URL: llmdebug-2.27.0-py3-none-any.whl
- Upload date:
- Size: 127.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f666b362457e254e059900f7757c9359d9bd95bc6fc0bb418a29de302ef1e49a
|
|
| MD5 |
7d1bdf4737fd7913c64e0c5feee70316
|
|
| BLAKE2b-256 |
7fad541e19cbe6e962c853c0a5acce97496c45b09eee8ac0141c156254fdffb8
|