nodejs-patterns
Async control flow, error handling, module design, streams, and production hardening
npx skills add cosmicstack-labs/mercury-agent-skills --skill nodejs-patterns --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Node.js Patterns Production-grade Node.js backend patterns. ## Async Patterns ### Prefer Async/Await ```javascript // Good async function getUser(id) { const user = await db.findUser(id); return user; } // Avoid raw callbacks or.then() chains ``` ### Parallel Execution ```javascript // Sequential (slow) const user = await fetchUser(id); const posts = await fetchPosts(id); // Parallel (fast) const [user, posts] = await Promise.all([ fetchUser(id), fetchPosts(id), ]); ``` ## Error Handling ### Global Handler ```javascript process.on('uncaughtException', (err) => { console.error('Uncaught:', err); // Graceful shutdown server.close(() => process.exit(1)); }); process.on('unhandledRejection', (reason) => { console.error('Unhandled Rejection:', reason); }); ``` ### Express Error Middleware ```javascript app.use((err, req, res, next) => { const status = err.status || 500; res.status(status).json({ error: err.message, ...(process.env.NODE_ENV === 'development' && { stack: err.stack }), }); }); ``` ## Module Design - Single responsibility per module - Export a class or factory function, not plain objects - Use dependency injection for testability - Prefer CommonJS (require) or ESM (import
- Async Patterns
- Prefer Async/Await
- Parallel Execution
- Error Handling
- Global Handler
- Express Error Middleware
- Module Design
- Production Hardening
What does the nodejs-patterns skill do?
Async control flow, error handling, module design, streams, and production hardening
How do I install it?
Run `npx skills add cosmicstack-labs/mercury-agent-skills --skill nodejs-patterns --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From cosmicstack-labs/mercury-agent-skills, a repository with 364 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.