Skip to content
EN · PT

anchors install-hooks

Install the git pre-commit that runs the gates over staged files.

Writes .git/hooks/pre-commit to run 'anchors check --changed <file>
--no-record' on each staged file. A blocking gate that fails bars the commit.
What passes and what is barred, when the file is not in the map:
• NOT GOVERNED (matches no layer of 'layers:' — package.json, lockfile, CI):
ignored. Anchors has no jurisdiction over it.
• GOVERNED but outside the map (new file, 'map build' did not run): BARS. Outside the
map no gate confronts it — the unit is not charged and the commit would go on to
certify work that nobody verified. Run 'anchors map build'.
Incremental: it validates only what the commit touches. It does not write to the map nor open issues
(--no-record). Idempotent — reinstalling is safe; use --force to overwrite an
existing pre-commit that was not written by this command.
With --agent it installs, instead, the agent's hook in the project's Claude Code settings
(.claude/settings.json): before and after each command of the agent it records the long
ones, so 'anchors monitor' follows them and says how they ended. The rest of the settings is
kept, and installing again adds nothing. With --agent --user it goes into the user's own
settings (~/.claude/settings.json) instead — for a project whose settings are not to be
written —, and records nothing outside a project with an anchors.yaml.
Terminal window
anchors install-hooks [flags]
Flag Default What it does
--agent install the agent’s hook (Claude Code) that records its long commands for anchors monitor
--force overwrite an existing pre-commit not managed by anchors
--root . project root
--user with –agent: write the hook into the user’s own Claude Code settings, not the project’s

Commands of the same family — what tells each apart:

Command What it does
anchors init Configure the project (anchors.yaml) through questions and answers
anchors new Emit the skeleton of an artifact (spec, feature, test, plan…) per the ruler
anchors code Generate a unique identity code for a new unit
anchors guide Print the Anchors guides for AI agents
anchors docs Compile the documentation from the templates in doct/
anchors install-hooks Install the git pre-commit that runs the gates over staged files
anchors migrate Bring the Anchors files up to the current format
anchors settings This agent’s LOCAL configuration — what is its own, not the project’s
anchors touch Bump updated_at in the @anchors header of the files that changed