9 nodejs rules available
All nine Copilot rules that match nodejs are short (under 250 characters), and several are only loosely about Node.js: shell scripts, Docker, Git workflow, GitHub Actions and SQL list nodejs as a technology. The file below supplies the Node.js-specific instructions the collection lacks, for Copilot on JavaScript and TypeScript server files.
GitHub Copilot reads repository-wide custom instructions from .github/copilot-instructions.md and path-specific instructions from .github/instructions/*.instructions.md files with an applyTo glob. Copilot can also use AGENTS.md files, where the nearest file in the directory tree takes precedence. Which file types are honored depends on the surface: VS Code, Visual Studio, JetBrains, Xcode, Eclipse and GitHub.com differ.
.github/instructions/nodejs.instructions.mdStarting point, not a tested configuration for your repository. Used for files matching applyTo on surfaces that support path-specific instructions. Review the instructions, adapt the file paths and run your project's existing checks.
---
applyTo: "**/*.js,**/*.mjs,**/*.cjs,**/*.ts"
---
# Node.js instructions for GitHub Copilot
## Focus for this project
- Complete imports in the module system declared by package.json ("type": "module" means import, otherwise require).
- Suggest node:fs/promises and async handlers, not readFileSync, in server code.
- When generating a route, include input validation and an explicit error response.
## 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.
- When reviewing a pull request, comment only where a change breaks one of these instructions and quote the instruction.
Create your own GitHub Copilot 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.
Instruction support differs by surface: VS Code supports repository-wide, path-specific and AGENTS.md instructions; Visual Studio supports repository-wide and path-specific; JetBrains and Xcode use .github/copilot-instructions.md. GitHub's documentation describes AGENTS.md files stored anywhere in the repository, with the nearest file in the directory tree taking precedence, or alternatively a single CLAUDE.md or GEMINI.md in the root. Support differs by surface; GitHub's IDE page lists AGENTS.md among the instruction types for VS Code.
Documentation checked 2026-11-05: GitHub Docs: Adding repository custom instructionsGitHub Docs: Repository instructions in your IDE
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You use Copilot in VS Code on an Express or Fastify service and want completions to use ESM, async fs and input validation by default.
In VS Code, type a comment: // POST /uploads saves the file metadata and returns 201
A completion that uses the project's module syntax, validates the body before writing, awaits async storage calls and returns 201 or 400; no synchronous fs calls.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.
Generate Node.js backend code