skills/debug/SKILL.md
Instrument web/web-app code with structured debug logging via a global variable (window.__debug_logs). Produces a clean JSON timeline for reproducing and diagnosing bugs. Use when user wants to debug a feature or track down a bug.
npx skillsauth add Weaverse/.agents debugInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Debug a web/web-app issue by instrumenting code with structured logging via window.__debug_logs. This skill does NOT use console.log — all debug data is collected in a single global array for clean export and analysis.
window.__debug_logs collects structured log entrieswindow.__debug_logs to a JSON fileAnalyze $ARGUMENTS and the relevant code to understand:
Use AskUserQuestion if the bug description is unclear or if you need to narrow down the scope.
Explore the codebase and identify every critical point in the code path where data changes or decisions are made. Typical points include:
Map out these points before writing any code.
Add this initialization at the app entry point or at the top of the root component/page being debugged (whichever is more appropriate):
// --- DEBUG START ---
if (typeof window !== 'undefined') {
window.__debug_logs = []
}
// --- DEBUG END ---
If there are many log points, add a small helper near the initialization:
// --- DEBUG START ---
function __debugLog(key: string, data: Record<string, unknown>) {
if (typeof window !== 'undefined' && window.__debug_logs) {
window.__debug_logs.push({
timestamp: Date.now(),
key,
...data,
})
}
}
// --- DEBUG END ---
At each instrumentation point, push a structured entry:
// --- DEBUG START ---
__debugLog('initial_data', {
data: { id: product.id, status: product.status, price: product.price },
})
// --- DEBUG END ---
Every entry MUST have these fields:
| Field | Type | Description |
|-------------|----------|-----------------------------------------------------------------------------|
| timestamp | number | Date.now() — milliseconds since epoch |
| key | string | Descriptive snake_case ID for this point (see naming conventions below) |
Additional fields are added as needed per log point (e.g., data, props, state, error, response).
Use descriptive, snake_case keys that tell a story when read in sequence:
first_load
initial_props
fetch_start
fetch_response
state_after_fetch
on_filter_change
filtered_results
on_item_click
selected_item_data
on_submit
submit_response
error_caught
CRITICAL: Only log what's relevant to the bug. For each log point:
Example — instead of logging an entire product list:
// ❌ Bad: logs everything
__debugLog('products_loaded', { data: products })
// ✅ Good: logs what matters
__debugLog('products_loaded', {
data: {
count: products.length,
firstId: products[0]?.id,
lastId: products[products.length - 1]?.id,
statuses: [...new Set(products.map(p => p.status))],
},
})
ALL debug code MUST be wrapped in clearly marked comments for easy removal:
// --- DEBUG START ---
__debugLog('some_key', { data: relevantData })
// --- DEBUG END ---
This makes cleanup trivial — search for DEBUG START and remove all blocks.
Check if there is a spec folder for the feature being debugged:
.specs/).debug/ subfolder inside it.debug/ in the project rootDetermine the next available index:
.debug/logs-1.json
.debug/logs-2.json
.debug/logs-3.json
...
Create the file with a placeholder:
[]
After instrumenting, output clear instructions:
Debug instrumentation is ready.
To capture logs:
1. Reproduce the bug in your browser
2. Open DevTools console and run: copy(JSON.stringify(window.__debug_logs, null, 2))
3. Paste into: <path-to-debug-file>
4. Then ask me to analyze the logs and fix the bug
To clean up after debugging:
- Search for "DEBUG START" and remove all blocks between DEBUG START/END markers
If the user provides a populated debug JSON file or asks to analyze:
timestamp and key fieldsconsole.log — all logging goes through window.__debug_logs only// --- DEBUG START --- and // --- DEBUG END ---// --- DEBUG START ---
declare global {
interface Window {
__debug_logs: Array<Record<string, unknown>>
}
}
// --- DEBUG END ---
useEffect for React, onMounted for Vue, etc.)development
Capture current work context for handoff to another agent/developer. Gathers git state, todos, and modified files into a structured handoff document saved to the related spec folder.
development
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
documentation
Create detailed implementation plans for features. Asks clarifying questions, suggests solutions, proposes architecture, and outputs a structured plan document. Use when user wants to plan a feature before coding.
tools
Commit changes with well-crafted messages, grouping related files into separate commits