debugging
Skill59 starsChanged 9 months agoMITView on GitHub
Guides use of the debug_state tool and runtime introspection to diagnose agent issues between turns. Load this skill when something goes wrong during a session and you need to inspect agent state, token usage, event history, or tool availability.
116 other projects use a version of this.
Adopted by
Most recently taken up by
- thistleknot/skillstheir own version, first seen Nov 8, 2026
- DevNewbie1826/skillstheir own version, first seen Nov 8, 2026
- MasihMoafi/skillstheir own version, first seen Nov 8, 2026
- ishandutta2007/Awesome-Claude-Skillstheir own version, first seen Nov 8, 2026
- idavidov13/agentic-playwrighttheir own version, first seen Nov 8, 2026
- profdorly/ultimate-dev-skillstheir own version, first seen Nov 8, 2026
Used with
Projects with it also use Problem-Solving Techniques, media-processing and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
truongtv22SkillProblem-Solving Techniques
Apply systematic problem-solving techniques for complexity spirals (simplification cascades), innovation blocks (collision-zone thinking), recurring patterns (meta-pattern recognition), assumption constraints (inversion exercise), scale uncertainty (scale game), and dispatch when stuck. Techniques derived from Microsoft Amplifier project patterns adapted for immediate application.
Also in 4 projects that use this
mrgoonieSkillmedia-processing
Process multimedia files with FFmpeg (video/audio encoding, conversion, streaming, filtering, hardware acceleration) and ImageMagick (image manipulation, format conversion, batch processing, effects, composition). Use when converting media formats, encoding videos with specific codecs (H.264, H.265, VP9), resizing/cropping images, extracting audio from video, applying filters and effects, optimizing file sizes, creating streaming manifests (HLS/DASH), generating thumbnails, batch processing images, creating composite images, or implementing media processing pipelines. Supports 100+ formats, hardware acceleration (NVENC, QSV), and complex filtergraphs.
Also in 6 projects that use this
JetBrainsSkillssr
Guide for using Structural Search and Replace in IntelliJ. Use when creating or modifying SSR inspections or search patterns.
Also in 3 projects that use this
mrgoonieSkillweb-frameworks
Build modern full-stack web applications with Next.js (App Router, Server Components, RSC, PPR, SSR, SSG, ISR), Turborepo (monorepo management, task pipelines, remote caching, parallel execution), and RemixIcon (3100+ SVG icons in outlined/filled styles). Use when creating React applications, implementing server-side rendering, setting up monorepos with multiple packages, optimizing build performance and caching strategies, adding icon libraries, managing shared dependencies, or working with TypeScript full-stack projects.
Also in 6 projects that use this
DevNewbie1826Skillremove-ai-slops
Remove AI-generated code slop from branch changes or an explicit file list while preserving behavior, including junk tests (prose pins, source greps, copied inventories, mock echoes), each proven by its class rule before a cut. Use when asked to remove slop, clean AI code, deslop, clean up generated code, strip slop, prune junk tests, or review generated-code cleanup. Start by locking behavior with regression tests, then use the category and workflow references.
Also in 3 projects that use this
DevNewbie1826Skillprogramming
MUST USE for work on Python, Rust, TypeScript, JavaScript, or Go source files and project manifests, and whenever a test or spec file is written, reshaped, reviewed, or deleted. Triggers: write or edit code; add, change, or delete a test; test authoring gate; junk tests; new project; Go HTTP service (gin lane); Bubble Tea TUI; CJK IME; Connect-Go RPC; sqlc or pgx; branded IDs; exhaustive matching; unsafe Rust; Miri; oversized file; refactoring; logging, log levels, structured logging, or observability; arena, allocator, bumpalo, const fn, const generics, compile-time programming, zero-allocation APIs, bitfields, repr, scope guards, errdefer-style cleanup, Zig-like patterns, zero-copy parsing, packed data, or FFI; Rust public API design or macros.
Also in 3 projects that use this
- +6 more from mrgoonie
Other versions116 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 116
- tursodatabase/turso★ 25ksame name
- JetBrains/intellij-community★ 21ksame name
- DetachHead/rebased★ 6.5ksame name
- mrgoonie/claudekit-skills★ 2.2ksame name
- JetBrains/MPS★ 1.7ksame name
- danieleteti/delphimvcframework★ 1.4ksame name
- glommer/pgmicro★ 1.2ksame name
- karrioapi/karrio★ 799same name
- rapidaai/voice-ai★ 755same name
- i-am-manware/Manware-s-AI-Learning-Toolkit★ 717same name
106 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- ci-preflightSkill
- citationsSkill
- codegen-syncSkill
- docsSkill
- elixir-cyclic-depsSkill
- gitSkill
- lint-and-formatSkill
- live-testsSkill
The file
We split this skill into the rules it gives an agent
9 rules. 0 are common, 3 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 104 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 41
When debug is enabled, Opal keeps an in-memory event log (bounded ring buffer of the last 400 events) and exposes the debug_state tool.
- Very specific: line 67
When include_messages is true, the snapshot includes recent messages from the conversation (default: 20, max: 200).
- Distinctive: line 75
Use this when you need the complete picture — events, messages, and state all together.
- Very specific: line 81
Check token_usage.current_context_tokens against token_usage.context_window.
- Very specific: line 91
If a tool you expect is missing from enabled, check whether its feature flag is off.
- Distinctive: line 128
All commands run from the repo root.
- Very specific: line 132
Use scripts/opal-rpc.exs to send a single JSON-RPC method and get a JSON response:
- Very specific: line 155
Use scripts/opal-session.exs to start a session, send a prompt, and collect the complete event stream:
- Distinctive: line 188
No stdio pipe management or process lifecycle issues
“Common” is measured: kept by at least 6 in 10 of the 104 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Debugging Skill
You use the debug_state tool and Opal's runtime introspection to diagnose problems during a session. This skill teaches you when and how to self-diagnose.
When to act
- A tool call fails unexpectedly or returns surprising results.
- The agent seems stuck in a loop or keeps retrying the same action.
- You suspect context is getting large and may be near the token limit.
- A feature (sub-agents, skills) doesn't seem to be working.
- The user asks you to debug yourself or inspect your own state.
The debug feature is disabled by default
The debug_state tool and the in-memory event log are gated behind the debug feature flag, which is off by default. If you try to call debug_state and the tool isn't available, tell the user they need to enable it first.
How the user enables debug mode
From the TUI menu: Press Ctrl+\ (or the configured menu hotkey) to open the Opal Menu, then toggle Debug introspection on. This takes effect immediately for the current session.
From Elixir code:
Opal.start_session(%{
features: %{debug: %{enabled: true}}
})Via application config:
config :opal,
features: %{debug: %{enabled: true}}When debug is enabled, Opal keeps an in-memory event log (bounded ring buffer of the last 400 events) and exposes the debug_state tool. When debug is disabled, the event log is cleared and the tool is filtered out of the active tool set.
Using debug_state
Basic snapshot (no messages, no events)
debug_state({})Returns: session ID, model info, provider, working directory, token usage, tool availability, and queue state.
With recent events
debug_state({"event_limit": 100})The event_limit parameter controls how many recent events to include (default: 50, max: 500). Events are returned newest-first and include a timestamp, event type, and a truncated data preview.
With conversation messages
debug_state({"include_messages": true, "message_limit": 10})When include_messages is true, the snapshot includes recent messages from the conversation (default: 20, max: 200). Each message shows its role, ID, and truncated content.
Full diagnostic
debug_state({"event_limit": 200, "include_messages": true, "message_limit": 50})Use this when you need the complete picture — events, messages, and state all together.
What to look for
Token pressure
Check token_usage.current_context_tokens against token_usage.context_window. If usage is above 80%, context compaction may be imminent. If it's above 90%, the agent may start losing earlier conversation context.
Tool availability
The tools section shows three lists:
all— every tool registered with the agentenabled— tools currently active (respects feature flags and disabled_tools)disabled— tool names explicitly disabled
If a tool you expect is missing from enabled, check whether its feature flag is off. For example, debug_state won't appear in enabled unless features.debug.enabled is true.
Queue state
pending_steers— steering messages waiting to be injected. Non-zero means the user sent a steer that hasn't been processed yet.remaining_tool_calls— tool calls from the LLM that haven't been executed. Non-zero during tool execution is normal; non-zero when idle suggests a stuck state.has_pending_tool_task— true when a tool is actively running in a background task.
Event timeline
Events reveal the actual execution flow. Look for:
request_start→request_end— one LLM round-trip. Check if there are excessive retries.tool_execution_start→tool_execution_end— tool lifecycle. Missingendevents suggest a crash or timeout.error— any error events indicate failures.agent_abort— the user cancelled mid-execution.
Common patterns
| Symptom | What to check |
| Tool not available | tools.enabled list, feature flags |
| Slow responses | Event timestamps — look for gaps between request_start and request_end |
| Repeated errors | Recent events for error type entries |
| Context too large | token_usage.current_context_tokens vs context_window |
| Steer not working | queues.pending_steers — if non-zero, agent hasn't processed it yet |
Relationship to external inspection
The debug_state tool is for self-diagnosis — the agent inspecting its own state. For external inspection by a human, Opal also supports connecting a second terminal via Erlang distribution (mise run inspect). See docs/inspecting.md for that workflow.
The key difference: debug_state works within a turn and returns structured JSON the agent can reason about. External inspection gives a live event stream a human watches in real time.
Integration testing with opal-server
Beyond unit tests (mix test) and the debug_state tool, you can spin up a real opal-server instance and interact with it programmatically. This lets you verify end-to-end behavior after making changes — e.g., "does session/start still work after I refactored config?"
All commands run from the repo root.
One-off RPC calls
Use scripts/opal-rpc.exs to send a single JSON-RPC method and get a JSON response:
# Liveness check
mix run --no-start ../../scripts/opal-rpc.exs -- opal/ping
# Start a session and see the full response
mix run --no-start ../../scripts/opal-rpc.exs -- session/start '{"working_dir": "/tmp"}'
# Check auth status
mix run --no-start ../../scripts/opal-rpc.exs -- auth/status
# List saved sessions
mix run --no-start ../../scripts/opal-rpc.exs -- session/list
# Get agent state (use session_id from session/start)
mix run --no-start ../../scripts/opal-rpc.exs -- agent/state '{"session_id": "abc123"}'The output is JSON with ok: true/false and either result or error. This is useful for testing RPC handler changes, config parsing, auth flow, etc.
Full session lifecycle
Use scripts/opal-session.exs to start a session, send a prompt, and collect the complete event stream:
# Send a prompt and see the full event lifecycle
mix run --no-start ../../scripts/opal-session.exs -- "What tools do you have?"
# With a specific model
mix run --no-start ../../scripts/opal-session.exs -- "List files" --model copilot:gpt-4.1
# JSON event output (one event per line, for programmatic parsing)
mix run --no-start ../../scripts/opal-session.exs -- "Hello" --json --timeout 15000
# With a working directory (agent will discover context files there)
mix run --no-start ../../scripts/opal-session.exs -- "Read README.md" --working-dir /path/to/projectHuman-readable mode prints events to stderr and the final response to stdout. JSON mode (--json) prints one JSON object per event line, useful for piping to jq or programmatic analysis.
When to use these scripts
| Scenario | Tool |
| Verify an RPC method works after changing handler.ex | opal-rpc.exs |
| Test session startup after config/builder changes | opal-rpc.exs with session/start |
| Verify auth flow changes | opal-rpc.exs with auth/status |
| Test end-to-end prompt→response→tool flow | opal-session.exs |
| Verify event stream after changing agent/events code | opal-session.exs --json |
| Reproduce a bug with a specific prompt | opal-session.exs |
How they work
Both scripts boot the Opal OTP application in-process (no child process or stdio transport) and call Opal.RPC.Handler.handle/2 directly. This means:
- No stdio pipe management or process lifecycle issues
- Fast startup (reuses compiled BEAM)
- Full access to the same code paths as the real server
- Distribution and RPC transport are disabled to avoid side effects
Source files
lib/opal/tool/debug.ex— Thedebug_statetool implementationlib/opal/agent/event_log.ex— In-memory bounded event log (ETS ring buffer)lib/opal/agent/tool_runner.ex— Where feature flags filter active toolslib/opal/config.ex—Opal.Config.Featuresstruct with:debugtogglescripts/opal-rpc.exs— One-off RPC call script for integration testingscripts/opal-session.exs— Full session lifecycle script with event streaming
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

