Skip to Content
harness-kit

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

DefaultValue
On by defaultyes, as self-protection
Fail modeclosed
Timeout2000 ms
EventsPreToolUse
ToolsBash, Edit, MultiEdit, NotebookEdit, Write
Agent typesevery agent, or as its options set

Options

OptionTypeDefaultDescription
configbooleantrueWhether every file of the harness configuration, the ones it extends and the allow files of its overrides included, is guarded.
pluginHooksbooleantrueWhether a plugin's hook registration, any hooks/hooks.json, is guarded.
settingsbooleantrueWhether Claude Code's .claude/settings.json and settings.local.json, in any .claude folder, is guarded.
statebooleantrueWhether 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',
    },
  ],
});

On this page