Skip to Content
harness-kit

worktree-health

The built-in Policy worktree-health, against a checkout that loads another checkout’s packages, a stale worktree, a full disk: its defaults, its options and a configuration that writes it.

To learn what it guards against and see it at work, read the guide: Session start.

Defaults

DefaultValue
On by defaultno: an entry turns it on
Fail modeopen
Timeout9000 ms
EventsSessionStart, PreToolUse
ToolsBash, Edit, MultiEdit, NotebookEdit, Write
Agent typesevery agent, or as its options set

Options

OptionTypeDefaultDescription
deadlineMillisinteger—How long the whole check may take, in milliseconds, before it says why it could not finish (6000 when absent).
lowDiskstring—The free space below which the disk counts as low, a size with its unit such as "1.5 GB"; "10 GiB" when absent.
measureMillisinteger—How long measuring the other worktrees' node_modules with du may take, in milliseconds, before they are listed without sizes (4000 when absent).
worktreesFolderstring—The folder below the main checkout where worktrees are made, searched beside the worktrees git registers; .claude/worktrees when absent.

Example

A configuration that writes every option, a comment above each:

import { defineConfig } from '@microeinhundert/harness-kit';

export default defineConfig({
  // The Policy entries, in the order their Decisions merge in.
  policies: [
    {
      // The Policy's name, unique in the configuration; messages and logs name the Policy by it.
      id: 'worktree-health',
      // The constructor's options, which it decodes.
      options: {
        // How long the whole check may take, in milliseconds, before it says why it could not
        // finish (6000 when absent).
        deadlineMillis: 1,
        // The free space below which the disk counts as low, a size with its unit such as
        // `"1.5 GB"`; `"10 GiB"` when absent.
        lowDisk: '10 GiB',
        // How long measuring the other worktrees' `node_modules` with `du` may take, in
        // milliseconds, before they are listed without sizes (4000 when absent).
        measureMillis: 1,
        // The folder below the main checkout where worktrees are made, searched beside the
        // worktrees git registers; `.claude/worktrees` when absent.
        worktreesFolder: 'tmp/worktrees',
      },
      // The name of the kit's Policy constructor that builds the Policy.
      use: 'worktree-health',
    },
  ],
});

On this page