Instruments code with global logging to produce clean JSON timelines for debugging.
Install
mkdir -p .claude/skills/debug-hta218 && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/17577" && unzip -o skill.zip -d .claude/skills/debug-hta218 && rm skill.zipInstalls to .claude/skills/debug-hta218
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
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.Key capabilities
- →Instrument web/web-app code with structured debug logging
- →Collect debug entries into a global `window.__debug_logs` array
- →Insert log points at key data changes or decisions
- →Prune logged data to include only relevant information
- →Wrap debug code with clear start/end markers for easy removal
- →Provide instructions for capturing and analyzing logs
How it works
The skill instruments web application code by inserting structured log points that record data changes and decisions into a global array. This creates a timeline of events for bug reproduction and diagnosis.
Inputs & outputs
When to use debug
- →Tracking down frontend state bugs
- →Debugging user interaction flows
- →Analyzing application data transitions
About this skill
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.
How It Works
- A global array
window.__debug_logscollects structured log entries - Debug statements are inserted at key points in the code flow
- The dev reproduces the bug, then copies
window.__debug_logsto a JSON file - An agent reads that JSON to diagnose and fix the issue
Phase 1: Understand the Bug
Analyze $ARGUMENTS and the relevant code to understand:
- What feature/component is affected?
- What is the expected vs actual behavior?
- What data flows through the affected code path?
Use AskUserQuestion if the bug description is unclear or if you need to narrow down the scope.
Phase 2: Identify Key Instrumentation Points
Explore the codebase and identify every critical point in the code path where data changes or decisions are made. Typical points include:
- Initial load / mount: component mount, initial data fetch
- Data arrival: API responses, store hydration, prop changes
- User interactions: clicks, form changes, selections
- State transitions: state updates, effect triggers, re-renders
- Derived computations: filtered lists, computed values, transformations
- Error boundaries: catch blocks, error states, fallbacks
Map out these points before writing any code.
Phase 3: Instrument the Code
3.1 — Initialize the global logger
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 ---
3.2 — Add a helper (optional, for convenience)
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 ---
3.3 — Insert log points
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 ---
Log Entry Format
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).
Key Naming Conventions
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
Data Pruning Rules
CRITICAL: Only log what's relevant to the bug. For each log point:
- ✅ Log IDs, statuses, counts, flags, selected values
- ✅ Log the specific fields that might be wrong
- ✅ Log array lengths instead of full arrays (unless the array content matters)
- ✅ Log error messages and codes
- ❌ Do NOT log entire API responses — pick the relevant fields
- ❌ Do NOT log full component props — pick what matters
- ❌ Do NOT log DOM elements or React internals
- ❌ Do NOT log large objects (images, blobs, full user profiles)
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))],
},
})
Wrapping Convention
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.
Phase 4: Prepare the Debug Output File
4.1 — Find or create the output location
Check if there is a spec folder for the feature being debugged:
- Look for a matching folder in the specs directory (check project config or default
.specs/) - If a spec folder exists → create a
.debug/subfolder inside it - If no spec folder exists → create
.debug/in the project root
4.2 — Create the empty log file
Determine the next available index:
.debug/logs-1.json
.debug/logs-2.json
.debug/logs-3.json
...
Create the file with a placeholder:
[]
4.3 — Tell the dev what to do
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
Phase 5: Analyze Logs (when the dev comes back with filled logs)
If the user provides a populated debug JSON file or asks to analyze:
- Read the JSON file
- Build a timeline of events from the
timestampandkeyfields - Identify anomalies:
- Unexpected data values
- Missing expected log entries (gaps in the flow)
- Wrong ordering of events
- State inconsistencies between steps
- Correlate findings with the code
- Propose a fix
Important Rules
- NO
console.log— all logging goes throughwindow.__debug_logsonly - Prune aggressively — each log entry should be small and focused
- Mark all debug code with
// --- DEBUG START ---and// --- DEBUG END --- - TypeScript: If the project uses TypeScript, add the global type declaration:
// --- DEBUG START --- declare global { interface Window { __debug_logs: Array<Record<string, unknown>> } } // --- DEBUG END --- - Don't break the app — debug instrumentation must not change any behavior
- Framework-aware: Use appropriate patterns for the framework (e.g.,
useEffectfor React,onMountedfor Vue, etc.)
When not to use it
- →When using `console.log` for debugging
- →When logging entire API responses or large objects
- →When debug instrumentation changes application behavior
Limitations
- →Does not use `console.log` for debugging
- →Requires aggressive pruning of logged data
- →Debug instrumentation must not change any behavior
How it compares
This skill provides a structured, global logging mechanism that avoids noisy console output and allows for clean JSON export and analysis, unlike scattered `console.log` statements.
Compared to similar skills
debug side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| debug (this skill) | 0 | 1mo | No flags | Intermediate |
| obsidian-observability | 5 | 10d | Review | Intermediate |
| vue-debug-guides | 4 | 5mo | No flags | Intermediate |
| agentation | 6 | 5mo | Review | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by hta218
View all by hta218 →You might also like
obsidian-observability
jeremylongshore
Set up comprehensive logging and monitoring for Obsidian plugins. Use when implementing debug logging, tracking plugin performance, or setting up error reporting for your Obsidian plugin. Trigger with phrases like "obsidian logging", "obsidian monitoring", "obsidian debug", "track obsidian plugin".
vue-debug-guides
vuejs-ai
Vue 3 debugging and error handling for runtime errors, warnings, async failures, and SSR/hydration issues. Use when diagnosing or fixing Vue issues.
agentation
benjitaylor
Add Agentation visual feedback toolbar to a Next.js project
vrm-springbone-physics
Project-N-E-K-O
Debugging and fixing VRM SpringBone physics issues in three-vrm, including hair/clothing physics that flies upward, sticks out horizontally, or behaves unnaturally.
debugging-skill
bitovi
Always start a fresh browser session after any file change, walk through the full user flow, and monitor for errors before proceeding with further work.
expect
zakad00e2
Use when editing .tsx/.jsx/.css/.html, React components, pages, routes, forms, styles, or layouts. Also when asked to test, verify, validate, QA, find bugs, check for issues, or fix expect-cli failures.