Skip to Content
harness-kit

rules

The built-in Policy rules, against a session on the wrong tool versions, rules missing from the agent’s context: its defaults, its options and a configuration that writes it.

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

Defaults

DefaultValue
On by defaultno: an entry turns it on
Fail modeopen
Timeout9000 ms
Eventsset by its options
Toolsevery tool, or as its options set
Agent typesevery agent, or as its options set

Options

OptionTypeDefaultDescription
deadlineMillisinteger—How long the sync may take, in milliseconds, before it says why it could not finish (6000 when absent).
ignore"info-exclude" | "warn" | "none"—What it does when git does not ignore the target: info-exclude adds it to the repository's info/exclude and warns only if git still does not ignore it, warn only warns, none does neither; info-exclude when absent.
sourcesobject[]requiredThe folders to copy *.md rules from, each { from, scope, into? }, scope being always, stack ({stack} in the path) or group ({group}).
targetstring—The folder below .claude/rules/, relative to the session's folder, that the sync owns and refills at each start; .claude/rules/harness 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: 'rules',
      // The constructor's options, which it decodes.
      options: {
        // How long the sync may take, in milliseconds, before it says why it could not finish (6000
        // when absent).
        deadlineMillis: 1,
        // What it does when git does not ignore the target: `info-exclude` adds it to the
        // repository's `info/exclude` and warns only if git still does not ignore it, `warn` only
        // warns, `none` does neither; `info-exclude` when absent.
        ignore: 'info-exclude',
        // The folders to copy `*.md` rules from, each `{ from, scope, into? }`, `scope` being
        // `always`, `stack` (`{stack}` in the path) or `group` (`{group}`).
        sources: [
          {
            // The folder of `*.md` rules to copy, absolute or relative to the folder of the
            // configuration the hook loaded; it may name `{stack}` and `{group}`.
            from: 'rules/{stack}',
            // The folder below the target the rules are copied into; the target itself when absent.
            // It may name `{stack}` and `{group}`.
            into: '{stack}',
            // Where the source applies: `always`, in a repository of any stack (`stack`), or in a
            // repository of a project of any group (`group`).
            scope: 'always',
          },
        ],
        // The folder below `.claude/rules/`, relative to the session's folder, that the sync owns
        // and refills at each start; `.claude/rules/harness` when absent.
        target: '.claude/rules/harness',
      },
      // The name of the kit's Policy constructor that builds the Policy.
      use: 'rules',
    },
  ],
});

On this page