CAITSGet started

The harness

Green means done.

The harness is every check your code must pass. One command, npm run check, runs all six at once. If one fails, the change isn't done, whoever wrote it.

The checks

Six checks, one command.

Each check runs a standard tool, set up for you. Each one catches what the others miss.

  • Types

    typecheck

    TypeScript, strict, and Marko's type checker

    A type is wrong, in the code or in a template.

  • Lint

    lint:code

    ESLint, with the types

    A promise floats, an any slips in, an import goes unused.

  • Architecture

    lint:architecture

    caits architecture

    A file is in the wrong place, or an import goes the wrong way: one of the 77 rules breaks.

  • Coverage

    test:coverage

    Vitest

    A line, a branch or a function runs in no test. Coverage stays at 100%.

  • Mutants

    test:mutation

    Stryker

    A test runs the code, but checks nothing. Every mutant must die.

  • End-to-end

    test:e2e

    Playwright

    A page breaks in a real browser, on the production build.

A run

Only what failed.

npm run check starts the six checks in parallel. You get one line per check, then the output of the checks that failed, and only theirs.

The file, the line, the fix.

Here, a use case imported the domain with ../../ instead of #context/. The code works, and its tests pass. The architecture check doesn't.

Its message is enough to fix it, for you or for your agent. On a fresh project, a green run takes under half a minute.

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:1 [imports-by-shortcut] This file imports ../../domain/entity/Message.js, which goes up a folder: the import breaks when the file moves. Import it as #context/domain/entity/Message.js.

1 architecture violation.

1 of 6 checks failed: lint:architecture.

Mutation testing

Tests that really test.

100% coverage proves that every line ran, not that a test checked it. So Stryker breaks your code on purpose, and your tests must notice.

Every mutant must die.

Stryker turns > into >=, true into false, removes a call. Each change is a mutant. If every test still passes, the mutant survived: a test is missing, and the check fails.

Here, we removed one test of the example app. Coverage stayed at 100%, but no test sent a message of exactly the maximum length any more. The fix is a test, not a lower threshold.

npx caits mutation-summary --survivors

Mutation score: 91.7%  (11 killed of 12 valid mutants)

  92%  src/backend/messages/domain/entity/Message.ts  (killed 11, survived 1, no coverage 0)
        L16 [survived] EqualityOperator: if ([...trimmed].length > Message.MAX_LENGTH) throw new InvalidMessageError(`A message has  →  [...trimmed].length >= Message.MAX_LENGTH
Kill a survivor

No way around it

Strict, in the open.

No check can be turned off in the code: no eslint-disable, no @ts-ignore, no v8 ignore, no Stryker disable, no skipped test. A rule refuses them.

  • Exceptions live in quality/. Each one names the rule and the file it lets go, where your review sees it.
  • Your files have the last word. The setup of each tool starts from CAITS's defaults: change a threshold, drop a check, add a rule of your own.
  • Updates keep your choices. npx caits update rewrites the defaults, in quality/caits/, never your files.

quality/eslint.config.js

import caits from "./caits/eslint.js";

export default [
  ...caits,
  // The PDF library has no types: only its adapter may use any.
  {
    files: [
      "src/backend/billing/infra/invoice-printer/pdf-invoice-printer.ts"
    ],
    rules: { "@typescript-eslint/no-explicit-any": "off" }
  }
];
Change the rules and the tools

The report

Your tests, as a spec.

npm run check also writes reports/test-docs/index.html: one line per test, grouped by context and use case.

Read it first.

The names of the tests say what the app does. A test named “Given …, When …, Then …” shows as three steps.

To learn what an app does, or to review what an agent built, start with this page.

reports/test-docs/index.html

Backend › Messages › Command

edit message

  • changes the text of the message: the message keeps its id and its place
  • the domain refuses an empty text, and the message keeps its text
  • refuses a message that does not exist

End-to-end › Messages

  • Given a visitor on the messages page
    When they add a message of spaces only
    Then the page tells them why the domain refuses it

While you work

Fast checks, as you go.

npm run check is the gate. While you work, run only what you need.

  • npm run tdd

    The unit tests, then, at each save, the tests of the files you changed.

  • npm run lint:architecture

    The architecture rules alone, in under a second.

  • npx caits mutation-summary --survivors

    The mutants that survived the last mutation run, each with its line.

  • npm run check

    Every check, before you call the change done.

Every command

Try to break it.

Create the example app, break a rule, and run npm run check.

npx @ingenioz-it/caits init my-app --example