Skip to Content
harness-kit

hook-bypass

The built-in Policy hook-bypass, against the agent switching its own guardrails off: its defaults, its options and a configuration that writes it.

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

Defaults

DefaultValue
On by defaultyes, as hook-bypass
Fail modeclosed
Timeout2000 ms
EventsPreToolUse
ToolsBash
Agent typesevery agent, or as its options set

Options

OptionTypeDefaultDescription
disableEnvsobject[][{"name":"HUSKY","onlyIfExists":".husky","value":"0"}]The variables that turn a hook manager's hooks off, each { name, value, onlyIfExists? }, refused when set before the command or in the session's environment (only where onlyIfExists exists, when given).
hooksPathbooleantrueWhether core.hooksPath set on the command line, through git's config variables, or with git config in a line that commits is refused.
noVerifybooleantrueWhether --no-verify, and -n on a commit (also inside -nm), is refused.

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: 'hook-bypass',
      // The constructor's options, which it decodes.
      options: {
        // The variables that turn a hook manager's hooks off, each
        // `{ name, value, onlyIfExists? }`, refused when set before the command or in the session's
        // environment (only where `onlyIfExists` exists, when given).
        disableEnvs: [
          {
            // The name of the environment variable that turns a hook manager's hooks off.
            name: 'HUSKY',
            // A path relative to the working copy; the variable is refused only where it exists,
            // and always when absent.
            onlyIfExists: '.husky',
            // The value of the variable that turns the hooks off.
            value: '0',
          },
        ],
        // Whether `core.hooksPath` set on the command line, through git's config variables, or with
        // `git config` in a line that commits is refused.
        hooksPath: true,
        // Whether `--no-verify`, and `-n` on a commit (also inside `-nm`), is refused.
        noVerify: true,
      },
      // The name of the kit's Policy constructor that builds the Policy.
      use: 'hook-bypass',
    },
  ],
});

On this page