7 nodejs rules available
Seven Cursor rules match nodejs: a long Express API development rule and short rules on security, logging, performance, databases and API types. The file below is an .mdc rule attached to server-side JavaScript and TypeScript files.
Cursor applies project rules stored as .mdc files in .cursor/rules. Each rule's frontmatter (description, globs, alwaysApply) decides whether it is always included, attached to matching files, chosen by the agent from its description, or only used when you @-mention it. Cursor also reads AGENTS.md in the project root and subdirectories for plain-Markdown instructions.
.cursor/rules/nodejs.mdcStarting point, not a tested configuration for your repository. Attached when files matching the globs are in context (alwaysApply: false with globs). Review the instructions, adapt the file paths and run your project's existing checks.
--- description: "Node.js development project conventions" globs: "**/*.js,**/*.mjs,**/*.cjs,**/*.ts" alwaysApply: false --- # Node.js instructions for Cursor ## Focus for this project - Log with the project's structured logger (for example pino) including a request ID; never log secrets, tokens or full request bodies. - Use one error-handling middleware that maps known errors to status codes and returns a generic 500 message otherwise. - Use parameterized queries or the ORM; never build SQL with string concatenation. ## Node.js conventions - Check "type" in package.json and the engines field: write ESM import syntax in "type": "module" packages and CommonJS otherwise, and only use APIs available in the declared Node.js version. - Import built-ins with the node: prefix (node:fs/promises, node:path) and never use synchronous fs calls on a request path. - Validate every request body, query string and environment variable at the boundary and fail fast on missing configuration. - Await or explicitly handle every promise; no floating promises and no unhandled rejections. ## Before you finish - Run the project's test script (node --test if no framework is configured), lint and type check and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass. - Summarize which of the rules above affected the change. - If another attached Cursor rule conflicts with this one, name both rules and follow the one with the narrower globs.
Create your own Cursor rules for Node.js and share with the community.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Cursor's docs recommend keeping individual rules under 500 lines and splitting large rules into composable ones. Cursor's documentation states that it supports AGENTS.md in the project root and in subdirectories. Use AGENTS.md for plain-Markdown instructions you also want other tools to read, and .mdc rules when you need Cursor's scoping options (globs, description-based selection, always-apply).
Documentation checked 2026-11-05: Cursor docs: Rules
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You ask Cursor's agent to add a logging and error-handling layer to an Express API without leaking internals.
Add request-ID logging and a central error handler to the Express app in src/app.ts.
Middleware assigning a request ID, a logger child per request, a final error handler returning { error } with the right status and no stack trace in production, tests for a 404 and a 500 path, and test output.Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.
Secure Node.js applications comprehensively