Run lint before the agent stops
Run the project's lint when the agent ends a turn that changed code, and keep the turn going until it passes.
You'll: run npm run lint whenever the agent wants to stop after changing code. A failing lint keeps it working, with the problems in front of it.
Before you start
You need the kit installed and your hooks synced; see Quick start. Your project needs an npm run lint script. It runs only when the agent changed a file: a turn that changed none, or only read, ends without running
lint.
Add the configuration
import { defineConfig } from '@microeinhundert/harness-kit';
/**
* Lint runs before the agent ends a turn that changed code, and the turn goes on until it passes.
*/
export default defineConfig({
policies: [
{
id: 'lint',
options: {
require: {
file: 'node_modules/.bin/eslint',
hint: 'npm ci',
},
run: 'npm run --silent lint',
},
use: 'stop-command',
},
],
});require names a file lint needs; while it is missing, the agent is told to run npm ci first. Then run npx harness-kit settings sync.
Try it
The agent edits src/cart.ts in /work/shop and wants to end its turn. Lint finds an unused variable, so the stop is blocked:
`npm run --silent lint` failed (exit 1). Fix these issues:
src/cart.ts
1:7 error 'total' is assigned a value but never used no-unused-vars
✖ 1 problem (1 error, 0 warnings)
The full output is in /work/shop/.git/harness-kit/session-1/stop-output/lint.log.
Fix: Fix these issues, then end the turn again; `npm run --silent lint` in /work/shop checks them.The agent fixes the file and stops again. Lint passes, and the turn ends: allow
What it catches
| The turn | Answer |
|---|---|
| changed a file, lint fails | block-stop |
| changed a file, lint passes | allow |
| changed no file, or only read | allow |
If it does not work
- The agent is blocked again and again. A check blocks only once for the same output, so a loop ends by itself; it blocks again only when the output changes. See A stop check blocks again and again.
- Lint cannot run because a file is missing. The agent is told to run
npm ci; do it, or ask the agent to. - The message is too long. Shorten it with
output.maxLines; see the last accordion.
Related
- Sessions and stop checks: how a session tracks what it touched.
- Stop checks and hand-off:
work-saved, pull requests and issue status.