Node.js · TypeScript · Fastify
Fastify rules for Cursor
Plugin, schema and error-handling rules for Fastify APIs.
The rule
Save as .cursor/rules/fastify.mdc. Cursor picks it up on the next request.
.cursor/rules/fastify.mdc
--- description: Fastify API conventions globs: src/**/*.ts alwaysApply: false --- - Organize features as Fastify plugins registered with fastify.register; use fastify-plugin only when decorators must be shared. - Declare a JSON schema (or TypeBox/Zod type provider) for every route's body, params, querystring and response. - Use async handlers and return values instead of calling reply.send where possible. - Throw errors created with @fastify/error or http-errors; let the error handler format responses. - Use fastify.log (pino), not console.log. - Close resources in onClose hooks so tests can shut the server down cleanly.
How Cursor loads this rule
Read from the frontmatter above, per Cursor's rules documentation.
alwaysApply: falsewithglobs: src/**/*.ts: attached automatically when a matching file is in context.- Keep the
.mdcextension. A plain.mdfile in .cursor/rules is ignored by the rules system. - Prefer to generate your own? Type
/create-rulein Agent and describe what you want; Cursor saves the file to .cursor/rules. - Team Rules come first, then Project Rules like this one, then User Rules. Earlier sources win when guidance conflicts.
Cursor rules setup guideCursor Team RulesLet Cursor run commands without asking
Using another agent too?
The same instructions work as plain Markdown in AGENTS.md, which Codex, Gemini CLI, GitHub Copilot and most other coding agents read.
AGENTS.md (section)
## Fastify - Organize features as Fastify plugins registered with fastify.register; use fastify-plugin only when decorators must be shared. - Declare a JSON schema (or TypeBox/Zod type provider) for every route's body, params, querystring and response. - Use async handlers and return values instead of calling reply.send where possible. - Throw errors created with @fastify/error or http-errors; let the error handler format responses. - Use fastify.log (pino), not console.log. - Close resources in onClose hooks so tests can shut the server down cleanly.
More templates
Get Cursor rules and settings changes by email
When Cursor changes how rules, run modes or settings work, we update these templates from the docs and send a short note. One email a week at most.
Reviewed Oct 17, 2026. Written by AgentAtlas. Adapt it to your codebase before relying on it.