xdebug
FreeNo executable scriptsNot checkedPHP debugging and analysis tools using Xdebug. Use when asked to trace, debug, profile, analyze coverage, or compare executions of PHP code. Trigger phrases…
About this skill
Xdebug MCP Tools
Non-invasive PHP debugging and analysis tools. No var_dump() or code modification needed.
Tool Paths
Tools are installed globally via composer. Use absolute paths. The paths below assume Composer's default global bin directory; if composer global config bin-dir --absolute prints a different directory, use that one:
| Tool | Path |
|---|---|
| xtrace | ~/.composer/vendor/bin/xtrace |
| xstep | ~/.composer/vendor/bin/xstep |
| xprofile | ~/.composer/vendor/bin/xprofile |
| xcoverage | ~/.composer/vendor/bin/xcoverage |
| xback | ~/.composer/vendor/bin/xback |
| xcompare | ~/.composer/vendor/bin/xcompare |
| xrepl | ~/.composer/vendor/bin/xrepl |
Tool Selection Guide
| User Request | Tool |
|---|---|
| Trace, execution flow, show function calls | xtrace |
| Step debugging, breakpoints, inspect variables, track variable changes | xstep |
| Profile, performance, bottlenecks, slow code | xprofile |
| Coverage, test coverage, which lines tested | xcoverage |
| Backtrace, call stack, how did we get here | xback |
| Compare variable states across two runs, normal vs edge case, compare with git branch | xcompare |
| Interactive debugging, REPL, step manually (human-friendly) | xrepl |
"Trace" Ambiguity
The word "trace" can mean different things:
- Forward Trace →
xtrace(records execution from start to finish) - Backtrace / Stack Trace →
xback(shows call stack at a point) - Step through / Debug (recording) →
xstep(records N steps from a breakpoint, JSON output) - Interactive debugging →
xrepl(human-friendly REPL session, not JSON)
xtrace - Forward Trace (Full)
Trace execution forward from start to finish. Captures complete execution flow, function calls, parameters, and timing data.
Output: Text by default; --json gives JSON with a schema URL for semantic details and AI analysis strategies.
Key fields: {lines, functions, max_depth, db_queries}
~/.composer/vendor/bin/xtrace [--json] [--context=TEXT] [--include-vendor=PATTERNS] -- command
Examples
~/.composer/vendor/bin/xtrace --context="Debug login" -- php login.php
~/.composer/vendor/bin/xtrace --context="Test analysis" -- vendor/bin/phpunit tests/UserTest.php
~/.composer/vendor/bin/xtrace --include-vendor="bear/*" -- php app.php
When to Use
- "Trace this code"
- "Show execution flow"
- "What functions are called?"
- General PHP debugging (default choice)
xstep - Forward Trace (Step-by-Step)
Stop at breakpoint, step forward N times, record variable changes at each step. See how variable values affect branching ("this variable was X, so it went into this branch").
Output: Slim, deduplicated JSON with a $schema URL — fields you might expect inline can live elsewhere, so read the linked schema to interpret the structure and reconstruct variable state. The schema is the source of truth; do not infer the format from examples.
~/.composer/vendor/bin/xstep --break=file.php:line --steps=N [--context=TEXT] [--include-vendor=PATTERNS] -- command
Options
--break=file.php:line- Single breakpoint location--break=file.php:line:condition- Conditional (e.g.,$user==null)--steps=N- Step forward N times from breakpoint--watch=EXPR- Only record steps when expression value changes (can specify multiple times)--vars=LIST- Record only these local variables (e.g.,--vars='$this,$items')
Examples
# Step 20 times from line 42
~/.composer/vendor/bin/xstep --break="user.php:42" --steps=20 --context="Track auth" -- php user.php
# Conditional breakpoint
~/.composer/vendor/bin/xstep --break="user.php:15:\$id==null" --steps=10 -- php user.php
# Watch variable changes in loop
~/.composer/vendor/bin/xstep --break="loop.php:10" --watch="\$i" --steps=100 -- php loop.php
# Multiple watches
~/.composer/vendor/bin/xstep --break="app.php:25" --watch="\$user->getStatus()" --watch="count(\$items)" --steps=50 -- php app.php
Workflow Tips
- Need more steps? Set new breakpoint at where you stopped, run again
- Too much variable info? Use xtrace first to see flow, then xstep for details
When to Use
- "Track how variable changes step by step"
- "Why did it branch this way?"
- "What's the variable value at line X?"
xprofile - Performance Profiler
Identify performance bottlenecks with precision data.
Output: Text by default; --json gives JSON with a schema URL. time_ms/memory_mb are measured from the cachegrind summary; bottlenecks is a structured array. Read the linked schema for the field shapes — don't infer the format here.
Key fields: {time_ms, memory_mb, bottlenecks}
~/.composer/vendor/bin/xprofile [--json] [--context=TEXT] [--include-vendor=PATTERNS] -- command
Examples
~/.composer/vendor/bin/xprofile --context="Optimize processing" -- php process.php
~/.composer/vendor/bin/xprof
Install xdebug in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the xdebug skill do?
PHP debugging and analysis tools using Xdebug. Use when asked to trace, debug, profile, analyze coverage, or compare executions of PHP code. Trigger phrases include "trace this function", "profile this code", "check coverage", "debug PHP", "set breakpoint", "find the bottleneck", "why is this slow", "compare two runs", "トレース", "プロファイル", "カバレッジ", "比較".
How do I install the xdebug skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the xdebug skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
by Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
by Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
by Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
by Anthropic