Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Instrument Python code with toggleable debug output using swarm-debug. Use when adding debug statements, print statemens, or logging. Use when toggling debug visibility, managing debug statements, or working with the swarm_debug module. NOTE: you should never use print or logging statements, only use debug.
.claude/skills/openswarm-ai-swarm-debug/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 86% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 102% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 155% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 85% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 89% | 0% |
A non-invasive debug logger for Python. You add debug() calls to code; visibility is controlled per-file via CLI or GUI without modifying source.
~/.swarm-debug/projects/<hash>/debug_toggles.json directly with cat, head, tail, read, or any file tool. The raw JSON is an internal per-project cache and may be stale or inconsistent with the actual codebase.swarm-debug status or swarm-debug status --json to inspect state. The CLI rescans for debug( calls and returns the true resolved state.debug_toggles.json directly (stored per-project under ~/.swarm-debug/projects/<hash>/). Use swarm-debug toggle, swarm-debug set-color, swarm-debug set-emoji, etc.Before running any swarm-debug command, you must find the environment that has the swarm-debug package installed:
.vscode/settings.json in the project root for a python.defaultInterpreterPath. If it points to a venv (e.g. ${workspaceFolder}/backend/.venv/bin/python), activate that venv first:bash source <path-to-that-venv>/bin/activate
.vscode/settings.json exists (or it has no interpreter path), search the project for a .venv directory that contains the swarm-debug package:bash find . -path '*/.venv/bin/swarm-debug' -print -quit If found, activate that venv.
swarm-debug package is installed. Do NOT fall back to reading the raw JSON file or guessing a system Python path.pythonfrom swarm_debug import debug debug(my_var) # prints: [func_name] : my_var: int = 42 debug("checkpoint") # prints: [func_name] : checkpoint (italic) debug(err) # errors auto-force ON with red output debug("x=%s y=%s", x, y) # %-style formatting
debug() inspects the call stack to extract the caller's file, function, variable names, and indentation. No format strings or manual labels needed -- pass variables directly.
pythondebug(*args, mode='debug', override_max_chars=False, sep=<auto>, end='\n', pretty=True, lang=None, table=<auto>)
| Kwarg | Type | Default | Description | |---|---|---|---| | mode | str | "debug" | Log level. "all" (always), "debug" (default), "test" (high priority) | | override_max_chars | bool | False | Bypass the 3000-char truncation limit | | sep | str | auto | Join all args with this separator (like print(sep=...)) | | pretty | bool | True | Pretty-print dicts, lists, sets, tuples, dataclasses with Rich | | lang | str\|None | None | Syntax-highlight all args as this language (e.g. "sql", "json", "html") | | table | bool | auto | Force table layout on/off. Auto-on when >1 non-text data args |
All output is rendered with Rich. Function names in the output are clickable file links (in terminals that support OSC 8 hyperlinks like iTerm2 and Windows Terminal). Type annotations are shown in dim text for non-string values.
Pretty-printed data structures (on by default):
pythondebug(my_dict) # dicts, lists, sets, dataclasses are pretty-printed with Rich debug(my_dict, pretty=False) # opt out for flat single-line output
Syntax-highlighted strings (explicit lang= kwarg):
pythondebug(sql_query, lang="sql") # SQL keyword highlighting debug(json_string, lang="json") # JSON syntax coloring debug(html_body, lang="html") # HTML highlighting
Table layout (auto: on when >1 non-text data args, off otherwise):
pythondebug(x, y, z) # 3 data args -> table with Name | Type | Value columns debug(x) # single arg -> inline output (no table) debug("msg", x) # 1 text + 1 data arg -> inline (only 1 data arg) debug("msg", x, y) # 1 text + 2 data args -> table debug(x, y, z, table=False) # force per-line output debug(x, table=True) # force table even for a single arg
Diff output -- compare two values with a unified diff:
pythondebug.diff(old_state, new_state) # default label "diff" debug.diff(old_state, new_state, label="state") # custom label
Timing -- measure how long a block takes:
pythonwith debug.time("database query"): result = db.execute(query) # prints: [func] : ⏱ database query took 0.123s (green/yellow/red based on duration)
Truncation: values over 3000 chars are truncated (first 1500 + ... + last 1500). Pass override_max_chars=True to disable.
Indent group markers: when indentation level changes between debug() calls, a visual rule line is emitted to mark the group boundary.
All commands work standalone (no server required). Paths are relative to project root.
bash# View current state swarm-debug status # human-readable tree with [ON]/[OFF] tags swarm-debug status --json # machine-readable JSON (pipe to jq, python, etc.) swarm-debug stats # flat table of all files with path/status/color/emoji # Toggle visibility swarm-debug toggle on src/agents/planner.py # single file swarm-debug toggle off src/agents/ # whole directory (recursive) swarm-debug toggle on --all # everything # Configuration swarm-debug set-root /path/to/project swarm-debug set-color src/agents/planner.py "#ff0000" # single file swarm-debug set-color src/agents/ "#ff0000" # directory (propagates lightened color to children) swarm-debug set-emoji src/agents/planner.py "🔴" # single file swarm-debug set-emoji src/agents/ "🔴" # directory (propagates emoji to children) swarm-debug reset # reset all colors/emojis (with confirmation) # GUI swarm-debug gui # launches web UI at localhost:6969 swarm-debug gui --port 8080 # custom port swarm-debug gui --verbose # show all server logs in the terminal # Cursor skill management swarm-debug install-cursor-skill # copy SKILL.md to .cursor/skills/swarm-debug/ swarm-debug uninstall-cursor-skill # remove the skill directory # Package management swarm-debug --version # show version (also checks for updates and skill staleness) swarm-debug --upgrade # upgrade to latest version from PyPI swarm-debug --help-all # detailed help for all commands + API-only endpoints
debug() calls to files you want to observe.swarm-debug set-root /path/to/project (only needed once; persisted in ~/.swarm-debug/projects/<hash>/root_dir.txt).swarm-debug toggle on src/core/engine.py.swarm-debug toggle off src/core/engine.py.~/.swarm-debug/projects/<hash>/debug_toggles.json (where <hash> is derived from the project root path), but this file should never be read or written directly. Always use the CLI commands to inspect or modify state.needs_resync.txt flag is set. The next debug() call in the running program reloads the config automatically -- no restart needed..py files that contain debug( calls appear in the tree.set_manually for toggles, set_manually_color for color, set_manually_emoji for emoji). When you explicitly set a file's value, its flag is set so parent propagation won't override it.debug() argument is an Exception or contains "error", it always prints (red, with a cross emoji), regardless of toggle state.debug() reads source indentation and renders nested output with visual indent bars.bash# Get JSON and extract toggled-on files with jq swarm-debug status --json | jq '.. | objects | select(.is_toggled == true and (.children | not)) | .name'
SWARM_DEBUG_ROOT -- overrides the project root (highest priority, above persisted file and cwd).| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 4,453 | 5,102 | +15% | 1 | 1 | 0% | 653 | 2,647 | +305% | 0 | 0 | — |
case-02 | fail→fail | 9,205 | 4,554 | -51% | 1 | 1 | 0% | 1,795 | 2,675 | +49% | 0 | 0 | — |
case-03 | fail→fail | 4,571 | 4,052 | -11% | 1 | 1 | 0% | 194 | 2,556 | +1218% | 0 | 0 | — |
case-04 | fail→pass | 9,398 | 4,958 | -47% | 1 | 1 | 0% | 1,688 | 3,139 | +86% | 0 | 0 | — |
case-05 | pass→pass | 8,995 | 5,687 | -37% | 1 | 1 | 0% | 1,435 | 3,291 | +129% | 0 | 0 | — |
case-06 | pass→pass | 6,757 | 3,911 | -42% | 1 | 1 | 0% | 1,234 | 3,017 | +144% | 0 | 0 | — |
case-07 | fail→pass | 7,666 | 21,387 | +179% | 1 | 1 | 0% | 1,313 | 2,654 | +102% | 0 | 0 | — |
case-08 | fail→pass | 6,575 | 3,726 | -43% | 1 | 1 | 0% | 1,200 | 3,054 | +155% | 0 | 0 | — |
case-09 | fail→pass | 8,157 | 2,255 | -72% | 1 | 1 | 0% | 1,507 | 2,795 | +85% | 0 | 0 | — |
case-10 | fail→pass | 8,383 | 2,693 | -68% | 1 | 1 | 0% | 1,508 | 2,846 | +89% | 0 | 0 | — |
case-11 | fail→pass | 18,158 | 5,075 | -72% | 1 | 1 | 0% | 1,012 | 2,931 | +190% | 0 | 0 | — |
case-12 | pass→pass | 14,270 | 1,686 | -88% | 1 | 1 | 0% | 2,554 | 2,677 | +5% | 0 | 0 | — |
case-13 | fail→pass | 12,323 | 1,915 | -84% | 1 | 1 | 0% | 2,324 | 2,676 | +15% | 0 | 0 | — |
case-14 | pass→pass | 16,923 | 2,204 | -87% | 1 | 1 | 0% | 2,787 | 2,734 | -2% | 0 | 0 | — |
case-15 | fail→pass | 17,705 | 2,944 | -83% | 1 | 1 | 0% | 3,290 | 2,622 | -20% | 0 | 0 | — |
case-16 | fail→pass | 8,059 | 7,374 | -8% | 1 | 1 | 0% | 1,351 | 2,721 | +101% | 0 | 0 | — |
case-17 | fail→pass | 21,412 | 1,976 | -91% | 1 | 1 | 0% | 3,602 | 2,656 | -26% | 0 | 0 | — |
case-18 | fail→pass | 11,136 | 2,737 | -75% | 1 | 1 | 0% | 2,090 | 2,642 | +26% | 0 | 0 | — |
case-19 | fail→fail | 11,428 | 1,855 | -84% | 1 | 1 | 0% | 1,930 | 2,653 | +37% | 0 | 0 | — |
case-20 | fail→pass | 8,052 | 3,404 | -58% | 1 | 1 | 0% | 1,454 | 2,593 | +78% | 0 | 0 | — |
case-21 | pass→pass | 24,707 | 1,485 | -94% | 1 | 1 | 0% | 4,703 | 2,578 | -45% | 0 | 0 | — |
case-22 | fail→pass | 21,326 | 2,011 | -91% | 1 | 1 | 0% | 3,993 | 2,664 | -33% | 0 | 0 | — |
case-23 | fail→pass | 15,091 | 2,236 | -85% | 1 | 1 | 0% | 2,678 | 2,723 | +2% | 0 | 0 | — |
case-24 | fail→fail | 6,566 | 1,418 | -78% | 1 | 1 | 0% | 1,159 | 2,591 | +124% | 0 | 0 | — |
case-25 | fail→pass | 9,224 | 1,897 | -79% | 1 | 1 | 0% | 1,771 | 2,581 | +46% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted, and 21 counted toward the lift figure. The other 4 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +60 percentage points is the difference between those two pass rates over the 21 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.