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
| Default | Value |
|---|---|
| On by default | yes, as hook-bypass |
| Fail mode | closed |
| Timeout | 2000 ms |
| Events | PreToolUse |
| Tools | Bash |
| Agent types | every agent, or as its options set |
Options
| Option | Type | Default | Description |
|---|---|---|---|
disableEnvs | object[] | [{"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). |
hooksPath | boolean | true | Whether core.hooksPath set on the command line, through git's config variables, or with git config in a line that commits is refused. |
noVerify | boolean | true | Whether --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',
},
],
});self-protection
The built-in Policy self-protection, against the agent switching its own guardrails off: its defaults, its options and a configuration that writes it.
command-policy
The built-in Policy command-policy, against dangerous command lines: production kubectl, the wrong package manager, a subagent that should only read: its defaults, its options and a configuration that writes it.