Skip to content
Languages

TypeScript AGENTS.md

TypeScript agents drift when they silence the compiler. This file tells the agent to keep strict checking on, to type external data at the boundary, and to run the project's typecheck before it reports success.

Paste, then editTypeScript MCP servers

Match the commands to the repo. A pnpm workspace, a Bun repo, and an npm package do not share one invocation.

In this stack

What to tell the agent

Do

  • Point the agent at tsconfig.json instead of restating every compiler flag.
  • Name the package manager so it does not mix npm and pnpm in one workspace.
  • Ask it to update a test when it changes a public function's behavior.
  • Keep path aliases consistent with the existing imports.

Leave alone

  • Adding // @ts-ignore or // @ts-expect-error to hide a new error.
  • Widening a public type to any or unknown to satisfy a call site.
  • Introducing a second test runner beside the one the repo uses.
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
# TypeScript

## Types
- Keep strict compiler options as they are. Do not set strict to false to get a file to compile.
- Type data that crosses a boundary (HTTP, database, env) with a schema or an explicit type. Do not use `any` for that data.
- A local `as` cast needs a one-line comment naming the invariant that makes it safe.

## Modules
- Use the import style the surrounding files use.
- Do not add a dependency for a helper that fits in a few lines of the file you are editing.

## Checks
- Typecheck with the repo's script before you finish. If the script is missing, run npx tsc --noEmit --pretty false.
- Run the test script when the change touches behavior.
- Report the exact command and the first diagnostic on failure.

## Leave alone
- Do not reformat files you did not change.
- Do not edit generated types, lockfiles, or the tsconfig strict flags unless the task says to.
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.

  • Typecheck. npx tsc --noEmit --pretty false
  • Tests, when the repo uses node:test via tsx. pnpm test
  • Lint, when eslint is the project's linter. pnpm lint
FAQ

Questions

What is the TypeScript AGENTS.md for?

It keeps a TypeScript agent on the project's compiler settings and on the typecheck command the repository already uses.

Should an agent turn off strict mode to finish a type error?

Leave strict mode on. Fix the error at the boundary where the unknown value enters, or ask before changing tsconfig. Silencing the compiler hides the next caller's bug.

Which TypeScript command belongs in AGENTS.md?

The script the repository already runs in CI. If you have not found it, look in package.json. A guessed command that is not the project's will pass locally and still fail the pull request.

Keep going

Related on MCPpedia