AI agents
Let agents write the code. Keep the architecture.
Agents write code faster than you can review it. CAITS gives them a map, a shape to copy, and a harness that rejects what doesn't fit. Its errors are precise enough to fix without you.
The problem
Why agents drift, and what holds them.
An agent knows every way to write your app. Without rules it can't skip, it picks a new one each session. Here is what goes wrong, and what CAITS puts in the way.
Every session invents its own structure.
One shape, checked on every run. The agent copies an existing context. Anything else fails.
Exploring the codebase eats the context window.
Predictable paths, and an
AGENTS.mdthat maps them. The agent knows where to look before it looks.The tests pass, and check nothing.
Every mutant must die. A test without a real assertion lets one live, and the check fails.
A failing check gets fixed by loosening the check.
AGENTS.mdforbids it: fix the code, not the rule. And any change toquality/shows in your diff."Done" means it compiles.
Done means
npm run checkpasses. All six checks. Nothing less.
The map
What your agent reads first.
init writes an AGENTS.md at the root of every project: the commands, where each file goes, and the rules. Most coding agents read it on their own.
Short, and always true.
It holds what the agent can't guess from the code. And when the agent forgets a rule, the check reminds it.
AGENTS.md
# AGENTS.md
A CAITS project (Clean Architecture In TypeScript): a Marko app with a backend and a frontend. A harness checks every change.
## Commands
- npm run check: all the checks at once: types, lint, architecture rules, unit tests (100% coverage), mutation tests (100% score), end-to-end tests. The work is done only when it passes. It prints only the output of the checks that fail.
- npm run tdd: the unit tests, then at each save the tests of the changed files. In an AI agent, Vitest runs them once and stops: run it again after a change.
- npm run lint:architecture: the architecture rules alone, fast.
- npx caits mutation-summary --survivors: the mutants that survived the last mutation run.
## Where the code goes
- … nine lines: where each kind of file goes, how the contexts talk, the shortcuts of the imports, and what the routes hold.
## Rules
- Write the test first. The coverage and the mutation score stay at 100%.
- A test reads only its own context and shared: no test crosses contexts.
- A check that fails names the file and the rule: fix the code, not the rule.
- No comment turns off a check (eslint-disable, @ts-ignore, v8 ignore, Stryker disable), and no test is skipped. An exception lives in quality/, as narrow as it can be.
- Do not change quality/ (the rules, the thresholds, the configuration of the tools) without asking.
Documentation: https://caits.dev/docs
The loop
The loop that keeps it honest.
The agent writes, runs npm run check, reads what failed, and fixes it. Until every check is green.
- Cheap to pass. A check that passes costs one line of context.
- Clear when it fails. A check that fails names the file, the line and the rule, and says how to fix it. Only its output shows, not a wall of logs.
- No one to ask. No screenshot, no guessing, no question for you: the agent knows what to change, and the next run tells it whether it worked.
Your agent, at work
$ npm run check
6 checks at once: typecheck, lint:code, lint:architecture, test:coverage, test:mutation, test:e2e
✗ lint:architecture 0s
✓ typecheck 3s
✓ lint:code 4s
✓ test:coverage 4s
✓ test:e2e 9s
✓ test:mutation 23s
── lint:architecture ──
src/backend/messages/command/add-message/add-message.handler.ts:2 [application-imports-no-infra] The application layer must not import the infra layer (src/backend/messages/infra/message-repository/file-message-repository.js). Depend on its port, MessageRepository (src/backend/messages/domain/port/message-repository/MessageRepository.ts), instead, and bind the adapter in src/backend/messages/di.ts.
1 architecture violation.
1 of 6 checks failed: lint:architecture.
● The handler takes the port, MessageRepository, in place of the file adapter. di.ts already binds it.
$ npm run check
6 checks at once: typecheck, lint:code, lint:architecture, test:coverage, test:mutation, test:e2e
✓ lint:architecture 0s
✓ typecheck 3s
✓ lint:code 4s
✓ test:coverage 4s
✓ test:e2e 9s
✓ test:mutation 23s
All 6 checks passed in 23s.Prompts
Prompts that work.
Keep prompts short: the shape and the rules live in the project, not in the prompt. Each one ends the same way, because npm run check defines done. They build on the example app and its context, messages.
Add a context
Add orders next to messages, in the backend and the frontend, with the use case place-order. Follow the shape of messages. Run npm run check until it passes.
Add a use case
In the backend context orders, add the command cancel-order, test first. The domain refuses to cancel a shipped order, with an error of its own. Run npm run check until it passes.
Add a port
When an order is placed, orders must send an email. Add the port Mailer to its domain, with its contract, an in-memory adapter for the tests, and an SMTP adapter for production. Run npm run check until it passes.
Kill the survivors
Run npx caits mutation-summary --survivors. For each mutant that survived, write the test that kills it. Change the production code only if the mutant reveals code that does nothing. Run npm run check until it passes.
Your review
Review less. Trust more.
When the check is green, the tedious questions are answered: the types hold, the files are in place, every line is tested, every mutant is dead, and the app works in a browser. You review what only you can judge.
The intent
The names of the tests read like a spec: “the domain refuses an empty text, and the message keeps its text”. Read them first.
The domain
The business rules live in small, plain classes. That's where a wrong idea would hide.
The diff of
quality/It should be empty. If the agent touched a rule or a threshold, you'll see it there.
Works with your agent.
The harness is plain npm scripts, and AGENTS.md is plain Markdown. Any agent that edits files and runs commands can use them.
- Claude Code
- Codex
- Cursor
- Qwen
- and the next one
npx @ingenioz-it/caits init my-app --exampleThen open the project in your agent, and give it the first prompt above.