debug-express_skill
6
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill snakeo/claude-debug-and-refactor-skills-plugin --skill debug-express- SKILL.md12.8 KB
Overview
This skill helps you systematically debug Express.js and Node.js applications using proven diagnostic techniques. It guides you through middleware execution issues, routing problems, CORS errors, async error handling, memory leaks, and unhandled promise rejections. It also documents practical tools and patterns like DEBUG, Node Inspector, VS Code debugging, Morgan, and diagnostic middleware.
How this skill works
It walks through a four-phase debugging methodology: reproduce and isolate, gather information, analyze and hypothesize, then fix and verify. It explains how to inspect middleware stack, enable DEBUG logs, attach Chrome DevTools or VS Code, use request logging with Morgan, and add diagnostic middleware to capture request/response details. The skill includes command snippets, common error patterns, and a quick reference for fast troubleshooting.
When to use it
- When a route returns 404 or is unreachable
- When middleware appears not to run or requests hang
- When browsers block requests with CORS errors
- When async handlers cause unhandled rejections or crashes
- When memory usage grows or you suspect leaks
- When you need step-through debugging with breakpoints
Best practices
- Enable DEBUG selectively (express:router, express:application) before broad logging
- Register CORS, body parser, and other global middleware before routes
- Wrap async route handlers with a Promise catcher and keep a global error handler last
- Log requests with Morgan in development and rotate logs in production
- Inspect app._router.stack to verify middleware and route order
- Make one change at a time and add tests to prevent regressions
Example use cases
- Fixing a 404 caused by a catch-all middleware registered too early
- Tracing why an async database call crashes the server using asyncHandler and breakpoints
- Resolving CORS preflight failures by adding CORS middleware before routes and handling OPTIONS
- Finding a memory leak by taking heap snapshots in Chrome DevTools and replacing unbounded caches with LRU
- Attaching VS Code or node --inspect to step through middleware chain and inspect req/res
FAQ
Wrap handlers with an asyncHandler that returns Promise.resolve(fn(...)).catch(next) and keep a global error handler as the last middleware.
When should I use DEBUG vs Node Inspector?
Use DEBUG for lightweight runtime logs and fast iteration. Use Node Inspector or VS Code when you need breakpoints, full stack inspection, or heap snapshots.