Node.js Cursor Rules Template
Generate production-ready Node.js Cursor rules for Project Rules (.mdc), AGENTS.md, or legacy .cursorrules. This template encodes stack-specific conventions for projects using Node.js. JavaScript runtime built on V8 with event-driven, non-blocking I/O.
The Complete Node.js Cursor Rules
The full rule set in all three formats Cursor understands — copy the one your project uses. Project Rules (.mdc) load per-file via globs, AGENTS.md is portable across AI tools, and .cursorrules is the legacy single-file format.
Replacing a legacy file? Read the guide to migrate .cursorrules to Cursor Project Rules (.mdc) before copying this template into your project.
---
description: "Project Structure"
alwaysApply: false
---
- Use ES modules ("type": "module" in package.json).
- Use spaces for indentation.
- Use camelCase for variables and functions.
- Organize code by feature, not by file type.
- Use src/ for source code, tests/ for tests.
- Use barrel exports (index.js) for clean API surfaces.---
description: "Async Patterns"
alwaysApply: false
---
- Use async/await over callbacks and raw promises.
- Use try/catch for error handling in async functions.
- Use Promise.all() for parallel independent operations.
- Use Promise.allSettled() when partial failures are acceptable.
- Avoid blocking the event loop — don't use sync file/network operations.
- Use AbortController for cancellable async operations.---
description: "Streams & Buffers"
alwaysApply: false
---
- Use streams for processing large data sets (pipeline pattern).
- Use stream.pipeline() or pipeline() from stream/promises.
- Use Transform streams for data transformation.
- Handle backpressure with proper stream consumption.
- Use Buffer for binary data — prefer Buffer.from() over new Buffer().
- Use Readable.from() for converting iterables to streams.---
description: "Security"
alwaysApply: false
---
- Never use eval() or Function() with user input.
- Use helmet or equivalent for HTTP security headers.
- Use input validation libraries (zod, joi) for all user input.
- Use parameterized queries or ORM to prevent SQL injection.
- Use crypto.randomUUID() for generating unique IDs.
- Keep dependencies updated — run npm audit regularly.Customize These Rules
The generator below is preloaded with the Node.js template. Adjust indentation, quotes, naming, add your own rules, then download — no need to start from scratch on the homepage.
What This Template Covers
Required guidance
- - Project Structure
- - Async Patterns
- - Streams & Buffers
- - Security
Default style
- - Indentation: 2 spaces
- - Quotes: single
- - Semicolons: enabled
- - Naming: camelCase
Frequently Asked Questions
- What does the Node.js Cursor rules template include?
- It includes 4 rule sections covering project structure, async patterns, streams & buffers and other Node.js development conventions.
- Can I generate Node.js Project Rules and AGENTS.md from the same template?
- Yes. The generator can export the same stack-specific guidance as modern Project Rules (.mdc), AGENTS.md, or a legacy .cursorrules file.
- Should I combine Node.js with other Cursor rules templates?
- Yes. You can combine Node.js with related templates such as TypeScript, Tailwind CSS, Docker, or backend frameworks when your project uses multiple technologies.