cosmicstack-labs/nodejs-patterns
Async control flow, error handling, module design, streams, and production hardening
npx skills add https://github.com/cosmicstack-labs/mercury-agent-skills --skill nodejs-patterns
Production-grade Node.js backend patterns.
// Good
async function getUser(id) {
const user = await db.findUser(id);
return user;
}
// Avoid raw callbacks or.then() chains
// Sequential (slow)
const user = await fetchUser(id);
const posts = await fetchPosts(id);
// Parallel (fast)
const [user, posts] = await Promise.all([
fetchUser(id),
fetchPosts(id),
]);
process.on('uncaughtException', (err) => {
console.error('Uncaught:', err);
// Graceful shutdown
server.close(() => process.exit(1));
});
process.on('unhandledRejection', (reason) => {
console.error('Unhandled Rejection:', reason);
});
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 }),
});
});
Take cosmicstack-labs/nodejs-patterns from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.