Susan

harnessctl

All setups

harnessctl guards a Claude Code installation on your workstation. It covers three areas:

It applies to every setup, the workstation one included. Messages and confirmation windows are written in French.

Install

From the root of a clone of the repository:

make install

The target builds and tests the commands, links nexusctl, nexusadm, nexushelm and harnessctl into ~/.local/bin (PREFIX chooses another prefix), then runs harnessctl hook install sandbox and harnessctl hook install nexus. Each registration opens a confirmation window. The links point to the clone, so a git pull updates the commands.

make uninstall removes the links and the nexus hook. It keeps harnessctl and the sandbox hook: a registered hook whose command is missing blocks every tool call. To remove them, run harnessctl hook install sandbox --remove, then delete the harnessctl link.

The confirmation windows use zenity on your graphical session.

Synopsis

harnessctl edit <path> --old <text> --new <text> [--replace-all] [--reason <text>]
harnessctl hook sandbox
harnessctl hook nexus
harnessctl hook install sandbox|nexus [--remove]
harnessctl allow <folder> --reason <text> [--days 1..30] [--project <name>]
harnessctl revoke <folder>
harnessctl list [--json]
harnessctl import

Without arguments, or with an unknown subcommand, harnessctl prints this usage on standard error and exits with code 2.

Confirmation window

edit, allow, import and hook install show what they are about to do in a window with two buttons, Autoriser (allow) and Refuser (deny). Only a click on Autoriser lets the command write. Clicking Refuser or closing the window exits with code 3. When zenity is missing, no display is reachable, or two minutes pass without an answer, the command exits with code 4; no decision is recorded as an approval. Every request and its decision go to the journal of the clone (see the last section). When the journal cannot be written, the command exits with code 1 before doing anything.

edit

harnessctl edit <path> --old <text> --new <text> [--replace-all] [--reason <text>]

Replaces text in a harness file, the same way as the Edit tool of Claude Code, after confirmation.

OptionDescription
--old <text>Text to replace. It must appear exactly once, unless --replace-all is given. An empty value on a missing file creates the file with the --new text.
--new <text>Replacement text. It must differ from --old.
--replace-allReplaces every occurrence.
--reason <text>Reason shown in the window.

A value that starts with @ is read from a file of the project: --new @draft.md reads draft.md. A file outside the project exits with code 1. Start the value with @@ to pass a text that begins with a single @.

The window shows the file, the working folder, the reason, the number of occurrences, the removed lines (prefixed with -) and the added lines (prefixed with +). After you allow it, harnessctl reads the file again: if the file changed in the meantime, nothing is written and the command exits with code 1. The write goes through a temporary file and a rename, and keeps the file mode.

The harness files are:

PathContent
~/.claude/rules/, ~/.claude/skills/, ~/.claude/hooks/, ~/.claude/commands/Folders, with all they contain.
~/.claude/CLAUDE.md, ~/.claude/settings.json, ~/.claude/settings.local.jsonAccount-wide instructions and settings.
CLAUDE.md, openspec/config.yamlFiles at the root of the project.
.claude/, .agents/, .vibe/Folders at the root of the project, with all they contain.

Symbolic links are followed before the check. Any other path exits with code 1: edit it directly. The project is the clone that harnessctl runs from.

harnessctl edit CLAUDE.md --old "Node 20" --new "Node 22" --reason "Runtime upgrade"

hook sandbox

harnessctl hook sandbox

Guard for Claude Code that keeps tool calls inside the project folder. Claude Code runs it before Bash, Read, Write, Edit, MultiEdit, NotebookEdit, Glob, Grep, EnterWorktree, Agent and Task. The command reads the tool call as JSON on standard input.

A path is allowed when it falls in one of these places:

For file tools, the guard checks the file_path, path, notebook_path and directory fields. For Bash, it reads the text of the command: absolute paths, paths starting with ~ or $HOME, and the targets of cd and pushd, relative ones included. A guarded path quoted in a string or a comment is blocked too.

The guard also blocks the creation of a worktree under .claude/worktrees/: EnterWorktree with a name or without a path, a sub-agent with isolation: "worktree", and a git worktree add command that targets .claude/worktrees. Worktrees go under <project>/.worktrees/<name>.

Each block, and each use of an exception, adds a line to the audit log, sandbox-audit.log next to the exceptions registry ($XDG_CONFIG_HOME/harnessctl/, mode 600); the former ~/.claude/sandbox-audit.log is no longer written and stays as the archive: date, kind (DENIED, DENIED-WORKTREE or exception-used), working folder, tool, path and details.

hook nexus

harnessctl hook nexus

Guard for Claude Code that keeps cluster commands on nexusctl, nexushelm and nexusadm, which log every call, mask Secret values and ask for confirmation. Claude Code runs it before Bash, Read, Write, Edit, MultiEdit, NotebookEdit, Glob and Grep. It blocks:

The project root is CLAUDE_PROJECT_DIR, or the working folder of the call. Each block adds a line to infra/.nexusctl/guard.log of the project when that folder exists.

The guard reads the text of commands. A path built at run time, a script written then started, or another scripting language gets past it. The content of a file written by Write or Edit is not read.

Hook output and exit status

Both guards exit with code 0. When the call is allowed, they print nothing. When it is blocked, they print the PreToolUse decision of Claude Code on standard output, with the reason:

{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"..."}}

Input that is not valid JSON produces no decision. hook with a missing or unknown guard name exits with code 2.

hook install

harnessctl hook install sandbox|nexus [--remove]

Registers a guard in the settings of Claude Code, or removes it with --remove, after confirmation.

GuardSettings fileTools matched
sandbox~/.claude/settings.json (whole account)Bash|Read|Write|Edit|MultiEdit|NotebookEdit|Glob|Grep|EnterWorktree|Agent|Task
nexus.claude/settings.json of the cloneBash|Read|Write|Edit|MultiEdit|NotebookEdit|Glob|Grep

The registered hook runs harnessctl hook <guard> || exit 2 with a 10-second timeout: when the guard is missing or crashes, Claude Code blocks the call. Registration replaces earlier registrations of the same guard, including the former Python guards, and keeps the order of the other keys. When the guard is already registered as expected, or absent for --remove, the command prints inchangé and exits with code 0 without opening a window. Before the first change, the original file is saved next to it with the suffix .avant-harnessctl. A settings file that is not a JSON object exits with code 1 and nothing is written.

harnessctl hook install sandbox

allow

harnessctl allow <folder> --reason <text> [--days 1..30] [--project <name>]

Opens a folder outside the project to the agent, after confirmation.

OptionDescription
--reason <text>Required. Reason shown in the window and stored in the registry.
--days NValidity, from 1 to 30 days. Default: 30. The grant ends on today’s date plus N days.
--project <name>Project name stored in the registry. Default: the name of the folder of the clone.

The folder must exist. The command exits with code 1 for your home folder or one of its parents, for a folder of secrets or a folder that contains one (.kube, .ssh, .gnupg, .config/nexus, .config/harnessctl, .local/share/keyrings, .claude in your home), and for a folder already inside the project. When an exception already covers the folder, the window says so and the grant renews it. After you allow it, the command adds a grant to the registry and prints the expiry date.

harnessctl allow ../shared-fixtures --reason "Read the shared test fixtures" --days 7

revoke

harnessctl revoke <folder>

Closes an open folder: it adds a revocation to the registry. It removes a right, so it opens no window. A folder with no exception in force exits with code 1.

list

harnessctl list [--json]

Prints the exceptions in force, sorted by folder: one line per folder with the folder, the expiry date, the project and the reason, separated by tabs. Without any exception, the output is Aucune exception en vigueur. With --json, each exception is a JSON object on its own line, and no exception prints nothing.

import

harnessctl import

Copies the former registry into an empty registry, after confirmation. It reads two legacy files of ~/.claude/: sandbox-exceptions.md, whose lines become archive entries that grant nothing, and sandbox-allow.txt, whose lines YYYY-MM-DD /path that have not expired become grants. The command exits with code 1 when neither file exists or when the registry already holds events.

Exceptions registry

The registry is harnessctl/exceptions.jsonl in your user configuration directory ($XDG_CONFIG_HOME, by default ~/.config). It holds one JSON object per event: octroi (grant), revocation or archive, with the date, the project, the folder, the reason, who granted it and the expiry date (YYYY-MM-DD). The state of a folder is its last event. A grant applies until the end of its expiry date; after that, it opens nothing until you grant it again. The file is created in mode 600 in a folder in mode 700. The sandbox guard reads it on each call; a registry that cannot be read opens nothing.

The registry is under ~/.config, which the sandbox guard keeps out of reach of the agent: only harnessctl, after your confirmation, writes there.

Exit codes

CodeMeaning
0Success, or nothing to change. The hook sandbox and hook nexus guards always exit with 0.
1Failure: path outside the harness, text not found or ambiguous, file changed during the confirmation, folder that cannot be opened, registry or journal that cannot be read or written.
2Wrong usage.
3You clicked Refuser or closed the window.
4The window could not open or got no answer within two minutes.

Files and environment variables

NameRole
$XDG_CONFIG_HOME/harnessctl/exceptions.jsonlExceptions registry. By default under ~/.config.
HARNESSCTL_REGISTREPath of the registry, instead of the default one.
$XDG_CONFIG_HOME/harnessctl/sandbox-audit.logAudit log of the sandbox guard, in the registry folder. By default under ~/.config.
infra/.nexusctl/journal.jsonl of the cloneJournal of the commands: start, decision and end of each request.
NEXUSCTL_JOURNALPath of the journal, instead of the default one.
infra/.nexusctl/guard.log of the projectBlocks of the nexus guard, when the folder exists.
CLAUDE_PROJECT_DIRProject root for the guards, set by Claude Code.
~/.claude/settings.json, .claude/settings.jsonSettings where hook install registers the guards.