GenesisTools debugging-master
git clone https://github.com/genesiscz/GenesisTools
T=$(mktemp -d) && git clone --depth=1 https://github.com/genesiscz/GenesisTools "$T" && mkdir -p ~/.claude/skills && cp -r "$T/plugins/genesis-tools/skills/debugging-master" ~/.claude/skills/genesiscz-genesistools-debugging-master && rm -rf "$T"
plugins/genesis-tools/skills/debugging-master/SKILL.mdDebugging Master
Runtime data beats static analysis. Instead of guessing, instrument code with targeted logging, reproduce the bug, and analyze real runtime data.
Critical Rule
NEVER guess at runtime values or execution flow. Instrument, reproduce, analyze. One
dbg.dump() is worth a hundred lines of static reasoning.
Quick Reference
tools debugging-master start --session <name> # Start session, copy snippet tools debugging-master get # Read logs (L1 compact) tools debugging-master get -l dump,error # Filter by level tools debugging-master get --last 5 # Last 5 entries tools debugging-master expand d2 # Schema view (L2, default) tools debugging-master expand d2 --full # Full data (L3) tools debugging-master expand d2 --query 'x[*].y' # JMESPath projection (L3) tools debugging-master tail # Live tail tools debugging-master sessions # List all sessions tools debugging-master diff --session s1 --against s2 # Compare two runs tools debugging-master cleanup # Remove instrumentation
When to Use
- Runtime bugs: Values aren't what you expect, logic branches wrong
- Performance issues: Something is slow but you don't know what
- Execution flow: Code paths are unclear, order of operations is wrong
- Data inspection: Need to see actual shapes/values at runtime
- Intermittent failures: Need to capture state when the bug occurs
- Comparing runs: Passing vs failing, before vs after
Setup
# First time for a project - copies llm-log snippet into your project tools debugging-master start --session fix-auth-bug --path src/utils # Subsequent runs - remembers snippet path tools debugging-master start --session fix-auth-bug
The
start command:
- Copies/updates
(orllm-log.ts
) into the configured snippet path.php - Creates a session log file
- Outputs the import path to use in instrumentation
Instrumentation
Rules
- Always wrap in region markers - enables automated cleanup:
// #region @dbg import { dbg } from '../utils/llm-log'; // #endregion @dbg - Every debug line gets its own region block - granular removal:
// #region @dbg dbg.dump('userData', userData); // #endregion @dbg - Use
to generate ready-to-paste blocks with correct imports and markers.tools debugging-master snippet <type> <label>
API Methods
| Method | Use For | Example |
|---|---|---|
| Inspect any value | |
| Log a message with optional data | |
| Warnings | |
| Capture errors with stack | |
| Start a timer | |
| End timer, log duration | |
| Mark execution reached a point | |
| Assert + log pass/fail | |
| Capture multiple variables at once | |
| Trace with optional data | |
Hypothesis Tagging
Tag instrumentation with hypothesis IDs to filter later:
// #region @dbg dbg.dump('token', token, { h: 'H1' }); // #endregion @dbg // #region @dbg dbg.dump('session', session, { h: 'H2' }); // #endregion @dbg
Then filter:
tools debugging-master get --hypothesis H1
Instrumentation Example
import express from 'express'; // #region @dbg import { dbg } from '../utils/llm-log'; // #endregion @dbg async function handleAuth(req: Request) { // #region @dbg dbg.dump('reqHeaders', req.headers, { h: 'H1' }); // #endregion @dbg // #region @dbg dbg.timerStart('token-verify'); // #endregion @dbg const token = await verifyToken(req.headers.authorization); // #region @dbg dbg.timerEnd('token-verify'); // #endregion @dbg // #region @dbg dbg.dump('verifiedToken', token, { h: 'H1' }); // #endregion @dbg if (!token.valid) { // #region @dbg dbg.error('token invalid', new Error('Token verification failed')); // #endregion @dbg return { status: 401 }; } // #region @dbg dbg.checkpoint('auth-passed'); // #endregion @dbg return { status: 200, user: token.user }; }
Reading Logs — Progressive Detail (3 Levels)
Always start at L1 and drill down. This saves tokens.
L1: Compact Timeline (get
)
gettools debugging-master get
Output:
Session: fix-auth-bug (23 entries, 4.2s span) Summary: 5 dump 3 checkpoint 2 error 1 timer-pair (avg 340ms) 8 info 3 trace 1 assert (0 failed) 1 raw File: src/api.ts #1 14:32:05.123 info "starting auth flow" #2 14:32:05.200 dump userData [ref:d2] 2.4KB #3 14:32:05.201 timer db-query 341ms File: src/auth/handler.ts #4 14:32:05.542 checkpoint after-query #5 14:32:05.543 dump queryResult [ref:d5] 890B #6 14:32:05.600 error "auth token expired" [ref:e6] stack Tip: Expand a ref -> tools debugging-master expand d2
Values >200 chars get a
[ref:XX]. Use filtering to narrow down:
tools debugging-master get -l dump,error # Only dumps and errors tools debugging-master get --last 5 # Last 5 entries tools debugging-master get --hypothesis H1 # Only hypothesis H1
L2: Schema View (expand
, default)
expandtools debugging-master expand d2
Shows the structure/shape of the data without full values. Three schema modes:
tools debugging-master expand d2 # skeleton (default) tools debugging-master expand d2 --schema typescript # TypeScript interface tools debugging-master expand d2 --schema schema # JSON Schema
L3: Full Data (expand --full
or --query
)
expand --full--querytools debugging-master expand d2 --full # Everything tools debugging-master expand d2 --query 'user.email' # Just one field tools debugging-master expand d2 --query 'items[*].name' # Array projection
Token efficiency rule: L1 -> L2 -> L3. Never jump to
--full without checking the schema first.
Workflow: Hypothesis-Driven (Complex Bugs)
Recommended for bugs where the root cause is unclear.
- Form hypotheses (2-3 guesses about what's wrong)
- Start session:
tools debugging-master start --session <descriptive-name> - Instrument — add targeted
calls near suspected code, tag withdbg.*
,{h: 'H1'}{h: 'H2'} - Ask user to reproduce the bug
- Read L1:
— scan summary and timelinetools debugging-master get - Drill into refs:
for structure,expand <ref>
for specific fields--query - Analyze — confirm or eliminate hypotheses based on actual data
- Iterate — if not resolved, add more instrumentation and repeat from step 4
- Fix the bug with confidence (you have the data)
- Cleanup:
tools debugging-master cleanup
Workflow: Quick Instrumentation (Simple Bugs)
For straightforward issues where you just need to see a value.
tools debugging-master start --session quick-check- Add 1-3
callsdbg.dump() - Ask user to reproduce
tools debugging-master get --last 5- Fix and
cleanup
Workflow: Performance Profiling
// #region @dbg dbg.timerStart('total-request'); // #endregion @dbg // #region @dbg dbg.timerStart('db-query'); // #endregion @dbg const data = await db.query(sql); // #region @dbg dbg.timerEnd('db-query'); // #endregion @dbg // #region @dbg dbg.timerStart('transform'); // #endregion @dbg const result = transform(data); // #region @dbg dbg.timerEnd('transform'); // #endregion @dbg // #region @dbg dbg.timerEnd('total-request'); // #endregion @dbg
Read timings:
tools debugging-master get -l timer
Workflow: Execution Flow Tracing
// #region @dbg dbg.checkpoint('handler-entry'); // #endregion @dbg if (condition) { // #region @dbg dbg.checkpoint('branch-a'); // #endregion @dbg } else { // #region @dbg dbg.checkpoint('branch-b'); // #endregion @dbg } // #region @dbg dbg.checkpoint('before-return'); // #endregion @dbg
Read flow:
tools debugging-master get -l checkpoint
Workflow: Session Comparison
Compare a failing run against a passing run to spot divergence:
# Run 1 (failing) tools debugging-master start --session auth-fail # ... reproduce failing case ... # Run 2 (passing) tools debugging-master start --session auth-pass # ... reproduce passing case ... # Compare tools debugging-master diff --session auth-fail --against auth-pass tools debugging-master diff --session auth-fail --against auth-pass -l checkpoint # Just flow
JMESPath Quick Reference
Use with
tools debugging-master expand <ref> --query '<expression>':
data.field # Nested field access data.nested.deep.value # Multi-level nesting items[0] # First array element items[-1] # Last array element items[0:3] # Slice (first 3) items[*].name # All names from array of objects items[?status=='active'] # Filter array by condition items[?age>`25`] # Numeric comparison (backtick numbers) items[?contains(name, 'foo')] # String contains filter {id: id, name: name} # Object projection (pick fields) items[*].{id: id, n: name} # Array of projections length(items) # Count items sort_by(items, ×tamp) # Sort by field max_by(items, &duration) # Max by field join(', ', items[*].name) # Join names into string @ # Current node (identity)
Common Patterns
# Get just email from a user dump --query 'data.user.email' # Get all error messages from an array --query 'data.errors[*].message' # Filter to failed items and get their IDs --query 'data.items[?status==`failed`].id' # Get summary stats --query '{total: length(items), first: items[0].name, last: items[-1].name}'
HTTP Server Mode
For browser debugging or environments where file writes are not possible:
# Start with HTTP server tools debugging-master start --session browser-debug --serve # Server starts on http://localhost:7243
Send logs via fetch:
// #region @dbg fetch('http://127.0.0.1:7243/log/browser-debug', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ level: 'dump', label: 'componentState', data: state, location: 'App.tsx:42', ts: Date.now() }) }).catch(() => {}); // #endregion @dbg
Use
tools debugging-master snippet dump myVar --http to generate these blocks automatically.
PHP Support
Use
--language php when starting a PHP project:
tools debugging-master start --session laravel-bug --language php --path app/Support
PHP API uses static methods (
LlmLog:: instead of dbg.):
// #region @dbg require_once __DIR__ . '/../app/Support/llm-log.php'; // #endregion @dbg // #region @dbg LlmLog::dump('userData', $userData); // #endregion @dbg // #region @dbg LlmLog::timerStart('db-query'); // #endregion @dbg $result = DB::table('users')->get(); // #region @dbg LlmLog::timerEnd('db-query'); // #endregion @dbg
PHP HTTP mode auto-detects Guzzle. If installed, uses Guzzle; otherwise falls back to
file_get_contents.
Cleanup Checklist
Always clean up after debugging is resolved:
# 1. Remove all @dbg blocks from project files, archive logs to /tmp tools debugging-master cleanup # 2. If cleanup reports formatting-only diffs, fix them: tools debugging-master cleanup --repair-formatting # 3. If you want to keep logs permanently: tools debugging-master cleanup --keep-logs ./debug-logs/
What cleanup does:
- Scans all project files for
...// #region @dbg
blocks// #endregion @dbg - Removes those blocks
- Archives session logs to
/tmp/<datetime>-llmlog-<session>.jsonl - Reports files with formatting-only diffs (blank lines left by block removal)
runs--repair-formatting
on files with only whitespace diffsgit checkout
moves archived logs to a permanent location--keep-logs <path>
What cleanup does NOT do:
- Delete sessions from config
- Permanently delete log data (always archives first)
- Touch files with non-debug changes
Token Efficiency Tips
- Filter with
— don't load all entries when you only need dumps-l <level> - Use
— when the log is long, read only recent entries--last N - Use
beforeexpand
— check schema/shape firstexpand --full - Use
with JMESPath — extract only the fields you need--query - Use
for machine processing (pipe to--format json
)tools json - Use
— filter to specific hypothesis when multiple are tagged--hypothesis <tag> - Use
for performance work — skip everything except timing dataget -l timer