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.
To learn what it guards against and see it at work, read the guide: Protection.
Defaults
| Default | Value |
|---|---|
| On by default | yes, as self-protection |
| Fail mode | closed |
| Timeout | 2000 ms |
| Events | PreToolUse |
| Tools | Bash, Edit, MultiEdit, NotebookEdit, Write |
| Agent types | every agent, or as its options set |
Options
| Option | Type | Default | Description |
|---|---|---|---|
config | boolean | true | Whether every file of the harness configuration, the ones it extends and the allow files of its overrides included, is guarded. |
pluginHooks | boolean | true | Whether a plugin's hook registration, any hooks/hooks.json, is guarded. |
settings | boolean | true | Whether Claude Code's .claude/settings.json and settings.local.json, in any .claude folder, is guarded. |
state | boolean | true | Whether harness-kit's session state is guarded. |
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: 'self-protection',
// The constructor's options, which it decodes.
options: {
// Whether every file of the harness configuration, the ones it extends and the allow files
// of its overrides included, is guarded.
config: true,
// Whether a plugin's hook registration, any `hooks/hooks.json`, is guarded.
pluginHooks: true,
// Whether Claude Code's `.claude/settings.json` and `settings.local.json`, in any `.claude`
// folder, is guarded.
settings: true,
// Whether harness-kit's session state is guarded.
state: true,
},
// The name of the kit's Policy constructor that builds the Policy.
use: 'self-protection',
},
],
});