xiaohongshu
xiaohongshu
debug
Debug code, analyze errors, interpret stack traces, find root causes, and suggest fixes. Use when troubleshooting bugs, analyzing crashes, or investigating unexpected behavior.
Full skill instructions
Comprehensive debugging assistance for finding and fixing bugs.
Python Stack Traces:
# Read and analyze Python tracebacks
# Look for:
# - File paths and line numbers
# - Exception types
# - Variable values
# - Call stack order
# Common patterns:
# - AttributeError: Check object types
# - KeyError: Check dictionary keys
# - IndexError: Check list bounds
# - TypeError: Check function arguments
# - ImportError: Check module installation
JavaScript Stack Traces:
// Analyze JavaScript errors
// Look for:
// - Error type (TypeError, ReferenceError, etc.)
// - File and line numbers
// - Function call stack
// - Async operation context
// Common patterns:
// - "Cannot read property 'x' of undefined"
// - "x is not a function"
// - "Maximum call stack size exceeded"
Parse Application Logs:
# Find errors in logs
grep -i "error\|exception\|fatal\|critical" logs/*.log
# Find warnings
grep -i "warn\|warning" logs/*.log
# Analyze by timestamp
grep "2026-01-22" logs/*.log | grep -i "error"
# Count error types
grep -i "error" logs/*.log | cut -d: -f2 | sort | uniq -c | sort -rn
# Find patterns before crashes
grep -B10 "fatal\|crash" logs/*.log
Structured Log Analysis:
# JSON logs
cat logs/app.log | jq 'select(.level == "error")'
cat logs/app.log | jq 'select(.statusCode >= 500)'
# Parse specific fields
cat logs/app.log | jq '.timestamp, .message, .error'
# Group by error type
cat logs/app.log | jq -r '.error.type' | sort | uniq -c | sort -rn
Null/Undefined Issues:
# Find potential null reference errors
grep -r "\..*\." . --include="*.js" --include="*.py"
# Check for null checks
grep -r "if.*is None\|if.*== None" . --include="*.py"
grep -r "if.*=== null\|if.*!== null" . --include="*.js"
Race Conditions:
# Find potential race conditions
grep -r "threading\|Thread\|async\|await" . --include="*.py" --include="*.js"
# Check for proper locking
grep -r "lock\|mutex\|semaphore" . --include="*.py" --include="*.js"
# Find shared state
grep -r "global\|shared\|static" . --include="*.py" --include="*.js"
Memory Leaks:
# Find potential memory leaks (Python)
grep -r "global\|cache" . --include="*.py"
# JavaScript event listeners without cleanup
grep -r "addEventListener" . --include="*.js" | grep -v "removeEventListener"
# Unclosed file handles
grep -r "open(" . --include="*.py" | grep -v "with\|close()"
Off-by-One Errors:
# Check loop boundaries
grep -r "range(.*len\|for.*in.*length" . --include="*.py" --include="*.js"
# Array access patterns
grep -r "\[.*-\s*1\]\|\[.*+\s*1\]" . --include="*.py" --include="*.js"
Add Debug Logging:
# Python debug logging
import logging
logging.basicConfig(level=logging.DEBUG)
def problematic_function(arg):
logging.debug(f"Input: {arg}, Type: {type(arg)}")
# ... rest of function
logging.debug(f"Output: {result}")
return result
// JavaScript debug logging
function problematicFunction(arg) {
console.log('Input:', arg, 'Type:', typeof arg);
console.trace('Call stack');
// ... rest of function
console.log('Output:', result);
return result;
}
Binary Search Debugging:
# Comment out half the code to isolate the issue
# Use git bisect to find the commit that introduced the bug
git bisect start
git bisect bad # Current commit is bad
git bisect good <commit-hash> # Known good commit
# Test each commit until bug is found
git bisect reset
Rubber Duck Debugging:
# Explain the code step by step:
1. What is the expected input?
2. What transformations happen?
3. What is the expected output?
4. Where does actual differ from expected?
Python Debugger (pdb):
# Add breakpoint
import pdb; pdb.set_trace()
# Or Python 3.7+
breakpoint()
# pdb commands:
# n - next line
# s - step into
# c - continue
# p variable - print variable
# pp variable - pretty print
# l - list code
# w - where (stack trace)
# q - quit
Node.js Debugger:
# Start with debugger
node inspect app.js
# Or use Chrome DevTools
node --inspect app.js
node --inspect-brk app.js # Break on first line
# Debugger commands:
# cont, c - Continue
# next, n - Next line
# step, s - Step in
# out, o - Step out
# watch('expr') - Watch expression
Browser DevTools:
// Add breakpoint
debugger;
// Console debugging
console.log('Value:', value);
console.table(arrayOfObjects);
console.time('label');
// ... code ...
console.timeEnd('label');
// Conditional breakpoints in DevTools:
// Right-click line number > Add conditional breakpoint
// e.g., user.id === 123
Find Performance Bottlenecks:
# Python profiling
import cProfile
import pstats
cProfile.run('slow_function()', 'output.prof')
stats = pstats.Stats('output.prof')
stats.sort_stats('cumulative')
stats.print_stats(20)
# Line profiler
# pip install line_profiler
@profile
def slow_function():
# Code here
pass
# Run: kernprof -l -v script.py
// Node.js profiling
node --prof app.js
node --prof-process isolate-*.log
// Or use Chrome DevTools Performance tab
Memory Profiling:
# Python memory profiler
from memory_profiler import profile
@profile
def memory_heavy_function():
# Code here
pass
# Run: python -m memory_profiler script.py
# Node.js memory profiling
node --inspect --expose-gc app.js
# Use Chrome DevTools Memory tab to take heap snapshots
SQL Query Debugging:
-- Add EXPLAIN to understand query execution
EXPLAIN SELECT * FROM users WHERE email = '[email protected]';
-- Check for missing indexes
EXPLAIN ANALYZE SELECT ...;
-- Find slow queries
SELECT * FROM pg_stat_statements ORDER BY total_time DESC LIMIT 10;
ORM Debugging:
# Django debug toolbar
# settings.py
DEBUG = True
INSTALLED_APPS += ['debug_toolbar']
# SQLAlchemy echo
engine = create_engine('sqlite:///db.db', echo=True)
# Sequelize logging
const sequelize = new Sequelize({
logging: console.log
});
HTTP Request Debugging:
# cURL with verbose output
curl -v https://api.example.com/endpoint
# Check DNS resolution
nslookup api.example.com
dig api.example.com
# Test connectivity
ping api.example.com
telnet api.example.com 443
# Trace route
traceroute api.example.com
API Debugging:
# Request/Response logging
curl -v -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"test"}'
# Check SSL/TLS
openssl s_client -connect api.example.com:443
# Monitor network traffic
tcpdump -i any port 443
Step 1: Reproduce the Error
Step 2: Gather Information
# System information
uname -a
python --version
node --version
# Environment variables
env | grep -i app
# Dependencies
pip list
npm list --depth=0
# Recent changes
git log --oneline -10
git diff HEAD~1
Step 3: Isolate the Issue
Step 4: Analyze
Step 5: Form Hypothesis
Step 6: Test Hypothesis
Step 7: Fix and Verify
Process Debugging:
# Find running processes
ps aux | grep python
ps aux | grep node
# Check process details
top -p <pid>
htop -p <pid>
# Monitor system resources
vmstat 1
iostat -x 1
# Check open files
lsof -p <pid>
# Trace system calls
strace -p <pid>
strace -c python script.py # Count syscalls
Container Debugging:
# Docker logs
docker logs <container-id>
docker logs -f <container-id> # Follow
# Execute in container
docker exec -it <container-id> bash
# Inspect container
docker inspect <container-id>
# Container stats
docker stats <container-id>
When debugging, verify:
Use /debug when:
The skill will help analyze errors, suggest debugging approaches, and guide you to the root cause.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience