---
title: "Fast TypeScript type checking for coding agents"
description: "Why running tsc after every agent edit is slow, and how vetd checks only the files an edit affects."
url: http://localhost:4173/fast-typecheck
updated: 2026-11-11
---

# Fast TypeScript type checking for coding agents

> Agents run `tsc` after every edit. Each run checks the whole project. vetd keeps one TypeScript 7 checker loaded per repository and checks only the files an edit affects.

## Why is it slow?

- Each `tsc --noEmit` or `next build` checks every file, even for a one-line edit.
- An agent runs it many times per session.
- Each agent starts its own compiler, so parallel agents use more CPU and memory.
- A `tsc --watch` in each git worktree keeps a full copy of the project in memory.
- The agent must write the edit to disk before checking it, and undo it if it fails.

## What does vetd do?

- Runs one process per repository. All agents, worktrees and terminals share it.
- Loads the project once and reuses it for every check.
- Checks only the files the edit affects. If it can't tell, it checks more and says why.
- Checks the edit in memory. Nothing is written until the agent calls `commit`.
- Uses `tsgo`, the TypeScript 7 compiler from `@typescript/native-preview`.
- Stops `tsgo` after 5 idle minutes, and exits 10 minutes after the last client disconnects.

Measured results: [benchmarks](http://localhost:4173/benchmarks.md).

## vetd compared with tsc

| | `tsc --noEmit` | `tsc --watch` | vetd |
| --- | --- | --- | --- |
| Startup | Full load every run | Full load once | Loaded once, shared |
| Checks unsaved edits | No | No | Yes |
| Processes for 3 worktrees | One per run | Three | One |
| When idle | Exits | Keeps its memory | Stops, then exits |
| Next.js and React rules | No | No | [Yes](http://localhost:4173/rules.md) |
| Finds affected Vitest tests | No | No | Yes |
| Use in CI | Yes | Yes | No |

## Setup

```sh
npm install -D /absolute/path/to/vetd @typescript/native-preview
npx vetd init
```

Without MCP:

```sh
git diff | npx vetd check --patch -
```

Setup per agent: [MCP setup](http://localhost:4173/mcp.md).

## FAQ

### Why is tsc slow in my project?

`tsc` checks the whole project on every run. Large unions, deep generics and big barrel files make it slower. `.tsbuildinfo` helps, but each run still loads the whole project.

### How do I stop my agent from running tsc after every edit?

Run `npx vetd init`. It adds the vetd MCP server and tells the agent in `AGENTS.md` to call `check` instead of `tsc`.

### Do I still need tsc in CI?

Yes. Keep a full typecheck and build in CI.

### Does it work without Next.js?

Yes. It works on any TypeScript project with a `tsconfig.json`. The Next.js rules only run in Next.js projects.

### Can I trust the result?

A failed or unsupported check is never `ok`. `fallback` tells you when vetd checked the whole project. `verify` rechecks the result in a separate `tsgo`.

### Which platforms are supported?

macOS and Linux, with Node.js 22.18+ and `@typescript/native-preview` installed in the project.
