skills/nodejs-best-practices/SKILL.md
Node.js patterns, async/await best practices, error handling, security hardening, performance optimization, and project structure. Use when building or reviewing Node.js backends and services.
npx skillsauth add melikhanmutlu/web_ar nodejs-best-practicesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
"Node.js excels when you respect its single-threaded, event-driven nature; fight it and you lose."
src/
config/ # Environment config, constants
routes/ # Route definitions (Express/Fastify)
controllers/ # Request handling, input validation
services/ # Business logic (framework-agnostic)
repositories/ # Data access layer (DB queries)
middleware/ # Auth, rate limiting, error handling
models/ # Database models / schemas
utils/ # Pure utility functions
types/ # TypeScript type definitions
jobs/ # Background jobs, cron tasks
__tests__/ # Test files mirroring src structure
Promise.all() when all promises are independent and all must succeedPromise.allSettled() when you need results from all, even if some failPromise.race() for timeouts: race the operation against a timer promiseconst data = fetchData() returns a Promise, not data// Custom error class
class AppError extends Error {
constructor(
message: string,
public statusCode: number = 500,
public isOperational: boolean = true,
public code?: string
) {
super(message);
this.name = this.constructor.name;
Error.captureStackTrace(this, this.constructor);
}
}
// Central error handler middleware (Express)
function errorHandler(err, req, res, next) {
if (err.isOperational) {
return res.status(err.statusCode).json({
error: { message: err.message, code: err.code }
});
}
// Programmer error: log and return generic message
logger.error('Unexpected error', { error: err, stack: err.stack });
return res.status(500).json({ error: { message: 'Internal server error' } });
}
unhandledRejection and uncaughtException eventsmonitorEventLoopDelay from perf_hooksprocess.memoryUsage()--max-old-space-size to set heap limits explicitlyasync function shutdown(signal: string) {
logger.info(`Received ${signal}, shutting down gracefully`);
// 1. Stop accepting new connections
server.close();
// 2. Finish in-flight requests (give them a timeout)
await drainConnections(30_000);
// 3. Close DB pools, Redis clients, message queues
await db.end();
await redis.quit();
// 4. Exit
process.exit(0);
}
process.on('SIGTERM', () => shutdown('SIGTERM'));
process.on('SIGINT', () => shutdown('SIGINT'));
--detectOpenHandles to catch resource leakstools
# AI Marketing Suite — Main Orchestrator You are a comprehensive AI marketing analysis and content generation system for Claude Code. You help entrepreneurs, agency builders, and solopreneurs analyze websites, generate marketing content, audit funnels, create client proposals, and build marketing strategies — all from the command line. ## Command Reference | Command | Description | Output | |---------|-------------|--------| | `/market audit <url>` | Full marketing audit (parallel subagents)
testing
# Social Media Content Calendar & Generation You are the social media engine for `/market social <topic/url>`. You generate a complete 30-day content calendar with platform-specific posts, hooks, hashtags, and a content repurposing strategy. Every post is ready to publish or hand to a social media manager. ## When This Skill Is Invoked The user runs `/market social <topic/url>`. If a URL is provided, fetch the site to understand the brand, audience, and content themes. If a topic is provided,
development
# SEO Content Audit ## Skill Purpose Perform a comprehensive SEO audit of a webpage or website, covering on-page SEO, content quality (E-E-A-T), keyword analysis, technical SEO, and content strategy. This skill combines automated analysis via `scripts/analyze_page.py` with expert-level manual review to produce an actionable SEO audit document. ## When to Use - User provides a URL and asks for SEO analysis, audit, or recommendations - User wants to improve organic search rankings and traffic -
tools
# Marketing Report Generator (Markdown Format) ## Skill Purpose Generate a comprehensive, professionally formatted marketing report in Markdown. This skill compiles data from all previous audit and analysis results into a single, client-ready document with scores, findings, recommendations, and a prioritized action plan with revenue impact estimates. ## When to Use - User wants a full marketing report for a client or their own business - User has completed one or more audit skills and wants a