搜索

PythonReactSEOPDF
GitHub Skill

debugging

Systematic debugging strategies and error analysis patterns. Auto-triggers when investigating bugs, analyzing stack traces, or troubleshooting issues.

bigdegenenergy☆ 0 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Debugging Skill

The Scientific Method of Debugging

  1. Observe: Gather information about the bug
  2. Hypothesize: Form theories about the cause
  3. Predict: What should happen if hypothesis is correct?
  4. Test: Verify the hypothesis
  5. Iterate: Refine or reject, repeat

Information Gathering Checklist

  • Error message and full stack trace
  • Steps to reproduce (exact sequence)
  • Expected vs actual behavior
  • Environment details (OS, versions, config)
  • Recent changes (commits, deployments)
  • Frequency (always, intermittent, first occurrence)
  • Impact scope (one user, all users, specific conditions)

Debugging Strategies

Binary Search (Bisect)
# Git bisect to find breaking commit
git bisect start
git bisect bad HEAD
git bisect good v1.0.0
# Test each commit, mark good/bad until found
Rubber Duck Debugging
  1. Explain the code line-by-line out loud
  2. State what each line SHOULD do
  3. Compare expectations to actual behavior
  4. The explanation often reveals the bug
Wolf Fence Algorithm
  1. Insert a check in the middle of the code
  2. Determine which half contains the bug
  3. Repeat, narrowing down to the exact location
Minimal Reproducible Example
  1. Remove unrelated code
  2. Simplify inputs
  3. Isolate the failing case
  4. Create standalone reproduction

Common Bug Categories

Logic Errors
  • Off-by-one errors in loops
  • Incorrect boolean logic
  • Wrong operator (= vs ==)
  • Missing null checks
  • Race conditions
State Errors
  • Uninitialized variables
  • Stale state/cache
  • Mutation of shared state
  • Incorrect order of operations
Integration Errors
  • API contract mismatches
  • Serialization/deserialization issues
  • Timezone handling
  • Encoding problems (UTF-8)
Resource Errors
  • Memory leaks
  • Connection pool exhaustion
  • File handle leaks
  • Deadlocks

Debugging Tools by Language

JavaScript/TypeScript
// Conditional breakpoints
debugger;

// Console methods
console.log(value);
console.table(array);
console.trace();
console.time('operation');
console.timeEnd('operation');

// Chrome DevTools
// - Network tab for API calls
// - Performance tab for profiling
// - Memory tab for leak detection
Python
# Built-in debugger
import pdb; pdb.set_trace()

# IPython debugger (better UX)
import ipdb; ipdb.set_trace()

# Logging
import logging
logging.debug(f"Variable value: {var}")

# Profiling
import cProfile
cProfile.run('function()')
General
# Trace system calls
strace -f ./program

# Network debugging
tcpdump -i any port 8080
curl -v http://localhost:8080

# Memory debugging
valgrind ./program

Error Message Analysis

Stack Trace Reading
  1. Start from the bottom (root cause)
  2. Find YOUR code (not library code)
  3. Note the line number and function
  4. Check the error type and message
Common Patterns
NullPointerException → Missing null check
TypeError → Wrong type passed/returned
KeyError/IndexError → Invalid key/index access
ConnectionError → Network/service issue
TimeoutError → Operation too slow or hanging

When Stuck

  1. Take a break (fresh eyes help)
  2. Explain the problem to someone else
  3. Search error message (include quotes)
  4. Check recent changes in version control
  5. Question your assumptions
  6. Add more logging/instrumentation
  7. Try to make it worse (understanding helps)

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-26
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!