Skip to content
Languages

JavaScript AGENTS.md

Plain JavaScript repos still need a boundary. This file tells the agent to follow the module system the package already uses, to validate input that arrives as JSON, and to run the existing lint and test scripts.

Paste, then editJavaScript MCP servers

Do not let an agent add TypeScript, a bundler, or a new test framework as a side effect of a small fix.

In this stack

What to tell the agent

Do

  • Name the node version the engines field requires, when it has one.
  • Tell the agent which directory holds scripts versus library code.
  • Ask it to add a regression test next to the existing tests.
  • Point at the lint config so it does not invent a style.

Leave alone

  • Introducing TypeScript types in a .js file via checkJs without being asked.
  • Catching errors and continuing as if the call succeeded.
  • Installing a package that overlaps one already in the dependencies.
Starter file

AGENTS.md to copy

Save this as AGENTS.md at the root of the repository, or next to the package it covers. Replace the commands with the ones in this repo. See which agents read the file.

AGENTS.md
# JavaScript

## Modules
- Match the module system already in package.json ("type": module or CommonJS). Do not mix import and require in one package.
- Keep the files' existing style. Do not convert the package to TypeScript unless the task asks for that migration.

## Data
- Validate JSON, query strings, and environment values before using their fields.
- Do not trust the shape of an API response because a previous call happened to look that way.

## Checks
- Run the test script in package.json.
- Run the lint script when the package has one.
- On failure, quote the command and the first stack frame that points at project code.

## Leave alone
- Do not rewrite lockfiles by hand.
- Do not add a bundler, transpiler, or second test runner for a one-file change.
Commands to confirm

Checks named in the file

Confirm each command exists here before you rely on it. Delete the ones this repository does not use.

  • Tests. npm test
  • Lint, when the package defines it. npm run lint
FAQ

Questions

What is the JavaScript AGENTS.md for?

It keeps a JavaScript agent on the package's module system and on the scripts in package.json.

Should a JavaScript fix start by adding TypeScript?

Only when the task is the migration. A bugfix stays in the module system the package already ships. Adding a compiler changes CI, the published files, and every import.

How should an agent check untyped JSON?

Read the fields you need and reject the rest at the edge of the program, with the validator or the manual checks the file next door already uses. Do not spread an unknown object into a function call.

Keep going

Related on MCPpedia