log-driven-debugging

Guides systematic verification-based debugging for JavaScript/TypeScript (Node.js, Bun, browser). Use when: (1) User reports unexpected behavior, errors, or bugs, (2) Need to trace data flow or state changes without assuming root causes, (3) Issue requires identifying exactly where code deviates from expected behavior.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "log-driven-debugging" with this command: npx skills add bakrrrrr/skills/bakrrrrr-skills-log-driven-debugging

Log-Driven Debugging

Core Principle

Never assume the cause. Verify with logs.

Debugging Workflow

  1. Gather Information

    • Ask: "What is the exact symptom?"
    • Ask: "When does it occur?"
    • Ask: "What is the expected behavior?"
  2. Form Hypotheses

    • List 2-3 probable causes ranked by likelihood
    • Consider: API issues, state mutations, async timing, type errors
  3. Add Targeted Logs

    • Add console.log at probable cause points
    • Use log patterns from patterns.md
    • Always include context: variable names, values, and execution path
  4. Request Console Output

    • Ask user: "Run your code and paste the complete console output"
    • For browser: "Open DevTools (F12) → Console tab → paste output"
  5. Analyze & Iterate

    • Compare actual vs expected values
    • If log missing → code path is different than expected
    • If undefined/null → trace upstream
    • Repeat until root cause found

Log Placement Strategy

  • Entry logs: Log function/method entry with input parameters
  • Exit logs: Log function/method exit with return values
  • Before/after critical operations: Log state before and after mutations
  • Conditional branches: Log which branch executed and why
  • Async operations: Log before and after promises/await points
  • Boundary points: Log data entering/leaving modules or components

Log Format Cheatsheet

ContextFormat
Variableconsole.log('userId:', userId)
Objectconsole.log('user:', JSON.stringify(user, null, 2))
Execution pathconsole.log('[Service] Method starting...')
Errorconsole.error('[API] Failed:', error.message, error.stack)
Timingconsole.time('op'); ... console.timeEnd('op')

Example Interaction

User: "My API call returns undefined but should return user data"

Agent adds logs:

async function getUser(id) {
  console.log("[getUser] Called with id:", id);
  const response = await fetch(`/api/users/${id}`);
  console.log("[getUser] Response status:", response.status);
  const data = await response.json();
  console.log("[getUser] Parsed data:", JSON.stringify(data, null, 2));
  return data.user.profile;
}

Console output reveals:

[getUser] Called with id: 123
[getUser] Response status: 200
[getUser] Parsed data: { "user": { "name": "John" } }

Analysis: data.user.profile is undefined because the API returns { user: { name } } without a profile property → fix: return data.user or update API.

When Not to Use

  • Build/compilation errors: Clear error messages; no logs needed
  • Type-only issues: Use TypeScript compiler diagnostics instead
  • Performance profiling: Use browser DevTools Performance tab
  • Production debugging: Consider structured logging (Winston, Pino)

Common Patterns

See patterns.md for debugging scenarios:

  • API/Network issues
  • State mutation issues
  • Async/timing issues
  • Type/TypeScript issues

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.

Repository SourceNeeds Review
94.2K160.3K
anthropics
Coding

remotion-best-practices

Use this skills whenever you are dealing with Remotion code to obtain the domain-specific knowledge.

Repository Source
2.1K147.9K
remotion-dev
Coding

azure-ai

Service Use When MCP Tools CLI

Repository SourceNeeds Review
155136.1K
microsoft