Skip to Content
harness-kit

Toolchain and rules

toolchain checks the tools and versions a session runs on; rules copies your team's rules into the session where Claude Code reads them.

Start every session on the right tools and with your team's rules in the agent's context. Two checks run when a session starts:

  • toolchain: the tools the project needs, on the versions it pins. A session cannot be refused, so it refuses the prompts instead: deny
  • rules: the rules your team wrote for the agent, copied into its context: context

API reference

The defaults and every option, with its type: toolchain, rules.

Configure both checks

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

/**
 * Rules copied in at every session start (the team's always-on rules, then those of the repository's stack), and the
 * toolchain checked: `jq` installed, and Node on the major version `.nvmrc` pins.
 */
export default defineConfig({
  policies: [
    {
      id: 'rules',
      options: {
        sources: [
          {
            from: 'rules',
            scope: 'always',
          },
          {
            from: 'rules/stacks/{stack}',
            into: '{stack}',
            scope: 'stack',
          },
        ],
      },
      use: 'rules',
    },
    {
      id: 'toolchain',
      options: {
        pins: [
          {
            expectFromFile: '.nvmrc',
            match: 'major',
            name: 'node',
            versionCommand: ['node', '-v'],
          },
        ],
        required: [
          {
            hint: 'brew install jq',
            name: 'jq',
          },
        ],
      },
      use: 'toolchain',
    },
  ],
});

toolchain

Names each required tool missing from the session's PATH, with its install hint, and checks each pinned version. A pin runs versionCommand without a shell and compares the first version it prints with expect, or with the nearest expectFromFile (.nvmrc, .ruby-version) up to the repository root.

  • match is exact (the default), prefix (3.3 takes 3.3.6, not 3.30.1) or major.
  • A tool that is not installed, a missing pin file or one that names no version (lts/jod) adds nothing.

At the session start the agent reads:

What the agent reads
`jq` is not installed: no program of that name is on PATH. Install it: brew install jq

node 26.13.1 is installed, but /work/repository/.nvmrc pins node 22. This session refuses every prompt: install node 22, then start a new session.

A mismatch of a blocking pin (the default) is remembered for the session, and every prompt is then refused until a session starts on the pinned version:

What the agent reads
node 26.13.1 is installed, but /work/repository/.nvmrc pins node 22. This session refuses every prompt: install node 22, then start a new session.
Fix: Start a new session on the pinned version. If your shell sets the version up in its init file and the check misread it, start Claude Code with HARNESS_ALLOW_ENV_SKEW=1 to go on.

API reference

Every option of toolchain, with its type and default.

Turn it off by removing the entry. To go on anyway for one session, start Claude Code with HARNESS_ALLOW_ENV_SKEW=1; to only warn, set blocking: false on the pin.

rules

Copies your team's rules, Markdown files Claude Code reads from .claude/rules/, into the session's folder at every start, so every repository gets the current version without committing a copy.

  • A from is relative to the configuration file that names it, so a central configuration can ship its rules beside it.
  • {stack} and {group} are the repository's stack and project group.
  • Sources are copied in order (always, then stack, then group), so a group's rule replaces the stack rule of the same name.
  • Each start empties the target first, so a rule dropped from its source disappears; nothing outside the target is touched.

No message of its own is quoted here: the rules appear in the agent's context.

API reference

Every option of rules, with its type and default.

Turn it off by removing the entry.

If a central configuration sets them

A repository that extends a central configuration may not drop a required tool or a pin, change a pin, stop it blocking or change overrideEnv.

On this page