MR
Mayur Rathi
@mayurrathi
⭐ 40.7k GitHub stars

Nodejs Best Practices

Nodejs Best Practices is an code AI skill with a core value of Node. It helps developers solve real-world problems in the code domain, boosting efficiency, automating repetitive tasks, and optimizing workflows.

Node.js development principles and decision-making. Framework selection, async patterns, security, and architecture. Teaches thinking, not copying.

Last verified on: 2026-07-07

Quick Facts

Category code
Works With Claude
Source sickn33/antigravity-awesome-skills
Stars ⭐ 40.7k
Last Verified 2026-07-07
Risk Level Low
mkdir -p ./skills/nodejs-best-practices && curl -sfL https://raw.githubusercontent.com/sickn33/antigravity-awesome-skills/main/skills/nodejs-best-practices/SKILL.md -o ./skills/nodejs-best-practices/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# 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


text
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:

1. What's the deployment target?

2. Is cold start time critical?

3. Does team have existing experience?

4. Is there legacy code to maintain?


---


2. Runtime Considerations (2025)


Native TypeScript


text
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


text
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


text
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


text
Pattern:
├── Create custom error classes
├── Throw from any layer
├── Catch at top level (middleware)
└── Format consistent response

Error Response Philosophy


text
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

🎯 Best For

  • Security auditors
  • DevSecOps teams
  • Compliance officers
  • Copywriters
  • Marketing teams

💡 Use Cases

  • Auditing dependencies for known CVEs
  • Scanning API endpoints for auth gaps
  • Writing landing page headlines
  • Creating email drip sequences

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Nodejs Best Practices to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Can this replace a dedicated SAST tool?

AI-based security review is complementary to SAST tools. Use it as a first-pass filter, not a replacement.

Can this match my brand voice?

Yes — provide brand guidelines and tone examples in your prompt for consistent output.

Is Nodejs Best Practices compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Nodejs Best Practices?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Nodejs Best Practices?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/nodejs-best-practices/SKILL.md, ready to use.

⚠️ Common Mistakes to Avoid

Only scanning surface-level issues

Deep security review requires understanding your app architecture, not just regex patterns.

Using generic templates

Great copy requires understanding your audience. Customize the skill output for your specific buyers.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills