Skip to Content
harness-kit

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

harness.config.ts
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:

What the session shows
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

PresetTakes
prettierevery file
biomefiles where biome.json is
oxfmtevery file
standardrbRuby files, where .standard.yml is
rubocopRuby files, where .rubocop.yml is
gofmtGo files
ruffPython files

List several: the first that takes the edited file runs. Formatting shows how to write your own, such as vp fmt.

On this page