nodejs-best-practices
What it does
This guide teaches you how to make good decisions when programming with Node.js, focusing on understanding the principles behind choices rather than just copying code. It helps you select the best tools and approaches for different situations.
When to use it
- βWhen deciding which 'framework' (code organization tool) to use.
- βWhen thinking about how to structure your program.
- βWhen implementing security measures.
Skill link
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/nodejs-best-practices/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βHow can I choose the best framework for a high-performance API in Node.js?β
5 new skills a week. 1 minute to read.
How it works
The AI analyzes your needs and suggests the best tools and programming patterns. It asks questions to understand your project and helps you think about the consequences of each choice.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Node.js Best Practices
Principles and decision-making for Node.js development in 2025. Learn to THINK, not memorize code patterns.
When to Use
Use this skill when making Node.js architecture decisions, choosing frameworks, designing async patterns, or applying security and deployment best practices.
β οΈ How to Use This Skill
This skill teaches decision-making principles, not fixed code to copy.
- ASK user for preferences when unclear
- Choose framework/pattern based on CONTEXT
- Don't default to same solution every time
1. Framework Selection (2025)
Decision Tree
What are you building?
β
βββ Edge/Serverless (Cloudflare, Vercel)
β βββ Hono (zero-dependency, ultra-fast cold starts)
β
βββ High Performance API
β βββ Fastify (2-3x faster than Express)
β
βββ Enterprise/Team familiarity
β βββ NestJS (structured, DI, decorators)
β
βββ Legacy/Stable/Maximum ecosystem
β βββ Express (mature, most middleware)
β
βββ Full-stack with frontend
βββ Next.js API Routes or tRPC
Comparison Principles
| Factor | Hono | Fastify | Express |
|---|---|---|---|
| Best for | Edge, serverless | Performance | Legacy, learning |
| Cold start | Fastest | Fast | Moderate |
| Ecosystem | Growing | Good | Largest |
| TypeScript | Native | Excellent | Good |
| Learning curve | Low | Medium | Low |
Selection Questions to Ask:
- What's the deployment target?
- Is cold start time critical?
- Does team have existing experience?
- Is there legacy code to maintain?
2. Runtime Considerations (2025)
Native TypeScript
Node.js 22+: --experimental-strip-types
βββ Run .ts files directly
βββ No build step needed for simple projects
βββ Consider for: scripts, simple APIs
Module System Decision
ESM (import/export)
βββ Modern standard
βββ Better tree-shaking
βββ Async module loading
βββ Use for: new projects
CommonJS (require)
βββ Legacy compatibility
βββ More npm packages support
βββ Use for: existing codebases, some edge cases
Runtime Selection
| Runtime | Best For |
|---|---|
| Node.js | General purpose, largest ecosystem |
| Bun | Performance, built-in bundler |
| Deno | Security-first, built-in TypeScript |
3. Architecture Principles
Layered Structure Concept
Request Flow:
β
βββ Controller/Route Layer
β βββ Handles HTTP specifics
β βββ Input validation at boundary
β βββ Calls service layer
β
βββ Service Layer
β βββ Business logic
β βββ Framework-agnostic
β βββ Calls repository layer
β
βββ Repository Layer
βββ Data access only
βββ Database queries
βββ ORM interactions
Why This Matters:
- Testability: Mock layers independently
- Flexibility: Swap database without touching business logic
- Clarity: Each layer has single responsibility
When to Simplify:
- Small scripts β Single file OK
- Prototypes β Less structure acceptable
- Always ask: "Will this grow?"
4. Error Handling Principles
Centralized Error Handling
Pattern:
βββ Create custom error classes
βββ Throw from any layer
βββ Catch at top level (middleware)
βββ Format consistent response
Error Response Philosophy
Client gets:
βββ Appropriate HTTP status
βββ Error code for programmatic handling
βββ User-friendly message
βββ NO internal details (security!)
Logs get:
βββ Full stack trace
βββ Request context
βββ User ID (if applicable)
βββ Timestamp
Status Code Selection
| Situation | Status | When |
|---|---|---|
| Bad input | 400 | Client sent invalid data |
| No auth | 401 | Missing or invalid credentials |
| No permission | 403 | Valid auth, but not allowed |
| Not found | 404 | Resource doesn't exist |
| Conflict | 409 | Duplicate or state conflict |
| Validation | 422 | Schema valid but business rules fail |
| Server error | 500 | Our fault, log everything |
5. Async Patterns Principles
When to Use Each
| Pattern | Use When |
|---|---|
async/await |
Sequential async operations |
Promise.all |
Parallel independent operations |
Promise.allSettled |
Parallel where some can fail |
Promise.race |
Timeout or first response wins |
Event Loop Awareness
I/O-bound (async helps):
βββ Database queries
βββ HTTP requests
βββ File system
βββ Network operations
CPU-bound (async doesn't help):
βββ Crypto operations
βββ Image processing
βββ Complex calculations
β¦
FAQ
What is a 'framework'?
A framework is a set of tools and rules that helps organize and speed up program development by providing a ready-made structure.
What does 'think instead of memorizing code' mean?
It means understanding why a solution works and when to use it, rather than just copy-pasting code snippets without knowing the reason.
Do I need to know Node.js programming to use this?
This guide is for those who already have some familiarity with Node.js and want to make better decisions about how to structure and build their projects.
Details
Original description by the author
Node.js development principles and decision-making. Framework selection, async patterns, security, and architecture. Teaches thinking, not copying.
Popularity
- GitHub stars
- 48k
- Ranking position
- #5309
- License
- MIT
- Updated
- 10/15/2026
Comments
- β¦
More skills from this repository
00-andruia-consultant
48kHelps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
007
48kLets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
10-andruia-skill-smith
48kHelps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
20-andruia-niche-intelligence
48kLets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.