Skip to Content
harness-kit

Introduction

What harness-kit is, what it refuses, and where to start.

A coding agent such as Claude Code runs commands and edits files on its own. A hook is a check Claude Code runs around those actions: before and after each tool call, at a session's start, on each prompt and when the agent wants to stop.

harness-kit is that check. You describe your rules once in harness.config.ts; it refuses the calls that break them and tells the agent what to do instead.

See what a refusal looks like

This configuration keeps kubectl read-only, guards git the way most teams work, and formats every edited TypeScript file:

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

/**
 * A team's first configuration: the git conventions preset, kubectl kept read-only by a command preset, and every
 * edited TypeScript file formatted with Prettier.
 */
export default defineConfig({
  policies: [
    ...GIT_CONVENTIONS,
    {
      id: 'kubectl',
      options: {
        preset: 'kubectl',
        production: ['^prod-'],
      },
      use: 'command-policy',
    },
    {
      id: 'format',
      options: {
        formatters: [
          {
            glob: '**/*.ts',
            preset: 'prettier',
          },
        ],
      },
      use: 'format-on-edit',
    },
  ],
});

When the agent then runs kubectl delete pod web-1, the hook refuses the call, and the agent reads:

What the agent reads
`kubectl delete pod web-1` is refused: `delete` is on the deny list of the kubectl command table.
Fix: Do not run it; if it is needed, ask the developer to run it by hand.

Why use it

Guardrails you configure, not write

Around thirty built-in Policies: protect the harness's own files, keep kubectl read-only, guard shared branches, lint before the agent stops, format edits.

A hook that fails closed

If a Policy crashes or times out, its fail mode decides what happens. The hook never lets a call through by accident.

Answers the agent can act on

Every refusal says why and what to do instead, so the agent changes course instead of retrying.

Your own rules, in any language

Write a Policy in TypeScript beside the built-in ones, or an executable in any language that speaks a small JSON protocol.

Shared configurations that only tighten

Each repository extends a team's central configuration. It can make rules stricter, never looser.

Find your way through the docs

The Guides teach you harness-kit by doing. The API reference, the second tab of the sidebar, lists every command, key, Policy and message. Follow the guides in this order:

Install it and see a first refusal

Install the package, then follow the quick start: one configuration and one command, and you see the agent's first refused call.

Copy a recipe

Each recipe solves one real task, such as stopping force-pushes or running lint before the agent stops, with a tested configuration you paste in.

Pick the Policies you need

The Built-in Policies guides show what each guardrail catches and what the agent reads when it fires.

Understand how it decides

The concepts explain Policies and Decisions, how a hook call is decided, and how configurations extend each other. Read them after your first configuration runs.

Connect, extend and operate

Connect GitHub or Jira, write your own Policy, and test and debug your configuration.

Requirements

macOS or Linux, Node.js 26 or newer, Claude Code, and a project installed with npm, pnpm or bun. Yarn is not supported. The reference is generated from the repository's main branch, so it can name something your installed version lacks.

On this page