Format every edited file
Run the project's own Prettier on each file the agent edits, right after the edit, without ever blocking it.
You'll: format every file the agent edits with your project's Prettier, the moment the edit lands. No formatting noise in diffs, no lint failure at the end of the turn.
Before you start
You need the kit installed and your hooks synced; see Quick start. Prettier must be installed in the project. This recipe never blocks: format-on-edit allows every call and formats once the call is answered.
Add the configuration
import { defineConfig } from '@microeinhundert/harness-kit';
/**
* Every file the agent edits is formatted with the project's own Prettier, right after the edit.
*/
export default defineConfig({
policies: [
{
id: 'format',
options: {
formatters: [
{
preset: 'prettier',
},
],
},
use: 'format-on-edit',
},
],
});Then run npx harness-kit settings sync.
Try it
Ask the agent to change src/cart.ts. The file is formatted in place after the edit, and the agent reads nothing: allow
If it does not work
A formatter that fails or takes more than 10 seconds only leaves a note; the edit stands. When Prettier is not installed, the file stays as it was and a note says why:
format-on-edit: node_modules/.bin/prettier is missing, so the edited file was not formatted; run `npm ci`; a fresh worktree has no node_modules.Run npm ci, and the next edit is formatted. If nothing is formatted and no note appears, run npx harness-kit config check and npx harness-kit settings sync.
Use another formatter
| Preset | Takes |
|---|---|
prettier | every file |
biome | files where biome.json is |
oxfmt | every file |
standardrb | Ruby files, where .standard.yml is |
rubocop | Ruby files, where .rubocop.yml is |
gofmt | Go files |
ruff | Python files |
List several: the first that takes the edited file runs. Formatting shows how to write your own, such as vp fmt.
Related
- Formatting: every option.
- Run lint before the agent stops: catch what formatting cannot.
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.
Issue keys in branch names, status synced
Require every branch to name its Jira issue, refuse commits on main, and keep each issue's status in step with its pull request.