The layers
Updated
HoundWatch™ checks your project at several points. Each layer catches things the others can't. All of them use the same rules and the same findings.
| Layer | Switched on by | Catches | Before or after |
|---|---|---|---|
| Agent hook (Claude Code) | houndwatch hooks install --agent claude-code | the agent's edits, shell commands and end of turn | before most actions; some checks right after |
| Git hooks | houndwatch hooks install | every commit, merge and rewrite made through git, by anyone | before a commit or merge; after a rebase or amend |
| Watcher | houndwatch on | file saves by any tool, commits that skipped the hooks, model checks | after |
| Hook guard (part of the watcher) | houndwatch on | hooks and rule files changed outside HoundWatch | after, then puts its hook back |
| Login agent (optional) | houndwatch on --login | nothing itself: it starts the watcher at login | - |
At session start, the agent is told which layers are active (Day-to-day use).
houndwatch status and houndwatch hooks status show the same to you.
For Claude Code only, so far. It adds five hook entries to Claude Code's settings.
Its refusals of hook bypasses, control commands and changes to HoundWatch's own files don't need the config, rules or database, so they still work if any of those is broken. If one of its other checks before an edit or command fails, the agent gets a warning and carries on.
If the hook's own code can't load, or one of its refusals fails, a small fallback answers
instead. Until HoundWatch is reinstalled, it refuses every shell command, and every edit that may
touch a protected file. It can't read the exact list of those files, so it also refuses edits
under .git/, .claude/, .husky/ or any hooks/ folder, and of files whose name appears in a
HoundWatch config. In a linked working copy (git worktree), it can't see documents that only
the main copy's config names. Other edits only get a warning. If Claude Code can't start the hook
at all (its Python or __main__.py is missing), nothing can be refused, so the agent carries on.
The git hooks and watcher are separate checks, but they use the same HoundWatch install.
In a linked working copy with no .houndwatch/ folder of its own, HoundWatch uses the main
copy's config and rules, checks that copy's own files, and keeps its database and locks in that
copy's own git directory. A copy with its own folder uses that instead. Running houndwatch init
in a copy that uses the main copy's setup keeps it: init adds no config of its own there. Every
commit checked in any copy is also noted in git's shared folder, so when a branch from another
copy is merged, the watcher doesn't report those commits as skipped. Wherever the agent works,
every copy's setup is protected. Known gap: a branch with a different, valid project config
can turn off rule sets that only the project turned on. It can't turn off your user-level rules.
- Session start: gives the agent the session briefing.
- Your prompt: passes on messages that were waiting for the agent. It also notes whether you asked it to stop.
- Before an edit (Edit, Write, MultiEdit, NotebookEdit):
- refuses a change to a protected file: rules, config, rule documents or hook files. That includes husky and pre-commit files that run HoundWatch, and git's own config files, which can turn the hooks off: the repo's
.git/config, each working copy'sconfig.worktree,~/.gitconfigand~/.config/git/config. Change those yourself, or withgit config <name> <value>, which the hook checks like any other command. Another project's.houndwatch/folder, set-up marker, git hooks and git config are refused too, whichever project the agent is working in; - runs the session rules, such as "read this first" and the guide map;
- checks the new content against the instant file rules, and refuses content with a new
blockproblem. A file must be written compliant in one go, not as a skeleton filled in later.
- Before a shell command (Bash): see below.
- After an edit: checks the file again and sends
blockproblems back for the agent to fix now. Finished model checks come back here too. - After a read: records which files the agent has read. A shell command that is exactly one simple read (
cat,head,tail,less,batorsed -n) counts as a read. A read in a chained or piped command does not. - End of turn: see Day-to-day use.
Before a shell command runs, the hook reads the command without running it. It refuses:
Skipping the git hooks:
--no-verify,git commit -n,git -c core.hooksPath=..., changes tocore.hooksPath,GIT_CONFIG_*and similar variables, a new alias that hides--no-verify, and an editor or rebase command that hides it. Alsoinclude.pathandincludeIf.*.path, however they're set, because they can load settings that changecore.hooksPath,git config --edit, because an editor can change any setting, and--git-diron a command that makes commits, because git then runs another folder's hooks.GIT_DIR=is refused for the same reason.Skipping a hook manager's hooks:
HUSKY=0,SKIP=naming a HoundWatch hook,PRE_COMMIT_ALLOW_NO_CONFIG,pre-commit uninstallandpre-commit install --allow-missing-config.HoundWatch's control commands, such as
houndwatch offorfindings --waive. Faking a terminal withscript,unbuffer,expectorpty.spawnis refused too.Code that loads HoundWatch's own modules, inline, on stdin or in a script, because it could get round the human-only commands. Use the
houndwatchcommand instead. Reading HoundWatch's source as text is fine. If you develop HoundWatch itself, run such scripts in your own terminal.Stopping the watcher: signals sent to it, and
launchctlorsystemctlcommands that stop its login agent.Writing to protected files through the shell, replacing one with a named pipe, device or folder (
mkfifo,mknod,mkdir), or removing or disabling a hook. It followscd,pushd, subshells,git -C,$PWD, simple variables, globs and links. Deleting or moving a folder that holds protected files is refused too. Git commands that change the whole working copy (checkout <branch>,switch,stash,reset --hard,clean -fdx) are allowed, although they can replace or remove project files. While the watcher runs, it records each config or rule file they change asrules-edited.clean -fdxalso deletes the database and the watcher's record of those files, so nothing is recorded, but the missing database then blocks commits until a person restores it. Rule files that weren't in git are gone too; restore them from a backup. It can't see what an archive unpacks outside a protected folder, or values only known when the command runs.A command with a NUL byte, which it can't check.
A commit whose message breaks a commit-message rule, before the commit runs.
Running code it can't see:
curl ... | sh, downloading or decoding a script and then running it, or the same througheval, variables or copies:text HoundWatch refused this command (a script it runs): sh stdin: HoundWatch can't see what this script will run; save it, show it, then run it
A program in front of a command, such as timeout 5 or uv run, hides nothing. The hook looks
inside scripts the command runs, including one it writes first and then runs, sh -c
strings, find -exec, command substitutions and git rebase --exec commands. It reads the
first 64 KB of each script and follows scripts up to 4 levels deep.
Files written by a shell command (sed -i, redirects, heredocs, tee, cp, git apply,
patch and so on) go through the same protection and session rules as the Edit tool. When the
content is a literal heredoc or printf, the instant file rules run on it first as well. The
agent is also told to prefer Edit or Write.
Editing a file that controls what git ignores (.gitignore, .git/info/exclude or the file
named in core.excludesFile) is allowed. It is recorded as ignore-rules-edited, because
HoundWatch doesn't check files git ignores.
houndwatch hooks install installs six hooks:
| Hook | What it does |
|---|---|
pre-commit | checks the changed files and the commit; a block refuses the commit |
commit-msg | checks the message; a block refuses the commit |
post-commit | records the commit as checked; never blocks |
pre-merge-commit | checks a clean merge, as pre-commit does for a commit |
post-merge | records the merge |
post-rewrite | after an amend or rebase, checks and records the new commits; never blocks |
Anyone who runs git goes through these hooks: you, any agent, or any tool that calls git.
An existing hook is wrapped, never overwritten. If core.hooksPath points outside the
repository, HoundWatch asks before installing there
(Your first project).
If HoundWatch can't finish a check, pre-commit, pre-merge-commit and commit-msg block the
commit or merge. This covers a missing .houndwatch/ folder or config in a project that was
set up, a damaged set-up marker, a broken config or rule file, a check that crashes, a database
that is missing from a copy that had one, damaged, locked, from version 0.1 or otherwise can't be used, and a HoundWatch module that can't be loaded. The message says
what is wrong, how to fix it, the next command, and who must do it. If HoundWatch hits an
unexpected error, its details are saved in ~/.houndwatch/errors.log, or printed if that can't
be written. Hooks that run after a commit never block. If the fix can't wait, you can let one
commit through (Troubleshooting).
If a hook can't get an answer from HoundWatch, it blocks too, in a project that was set up.
For example, the Python it was installed with may be missing, not start, or crash. The hook script
itself says how to fix it (Troubleshooting).
In a project you have left, or a repository that was never set up, it only prints a message
ending in check skipped. Hooks installed by an earlier version still let these commits through
until you run houndwatch hooks install. If husky or the pre-commit framework runs HoundWatch,
this script isn't used, so you won't see its message.
git commit --no-verify skips pre-commit and commit-msg. Git always allows that. The agent
hook refuses it from Claude Code. For anyone else, the watcher notices afterwards.
houndwatch on starts one watcher per project, in the background. Only one can run at a time.
- Checks each file as it is saved, with the instant rules, whichever tool saved it. A
blockfinding on a file blocks any commit that includes the file. - Spots commits that skipped the hooks, within a few seconds. It checks the commit and records a
hook-skippedfinding. It never rewrites history. - Runs
llmrules in the background. Without the watcher, model checks wait in a queue (Local models). - Runs the hook guard (below) and answers hook calls quickly over a local socket.
- Pauses if
.houndwatch/goes missing, and never recreates it (Troubleshooting). - Keeps the inventory current (
houndwatch inventory). - Notifies you when a finding needs you (Day-to-day use).
It skips files git ignores, and paths in the config's ignore list.
When the watcher starts, it catches up on changes and commits made while it was off. If it
was killed or crashed, rather than stopped with houndwatch off, it records a
watcher-down finding and re-checks the commits made in the gap:
[warn] watcher-down: the watcher was not running from 2026-11-30T01:35:47Z until 2026-11-30T01:36:21Z and `houndwatch off` was not used (killed or crashed); commits made in that time were re-checkedIf its watcher-expected marker (.houndwatch/) is deleted while it runs, the
watcher puts it back within a few seconds and records a watcher-down finding. A normal stop
signal is also recorded, even if the marker was deleted first. Only a recorded
houndwatch off counts as stopping it on purpose. kill -9 can't be recorded at the time.
The next hook check or watcher start can report it.
Times in findings are in UTC.
The hook guard runs inside the watcher. When HoundWatch's hooks or agent-hook entries are
removed or edited outside the houndwatch command, it:
- records a
hook-tamperedfinding saying what changed; - puts HoundWatch's own entry back, only where you approved it at install. Turn this off with
guard_reinstall: falsein your user config.
[warn] hook-tampered: .git/hooks/commit-msg was deleted; HoundWatch's hook reinstalled (.git/hooks/commit-msg)It also notices when git will no longer run an installed hook, for example after a change to
core.hooksPath.
It records rules-edited when a rule file, config, architecture file or guide-map document
changes outside the CLI. It can't tell your hand edit from an agent's, so you acknowledge your
own edits (Day-to-day use).
Files shared by every project (a global hooks folder, ~/.claude/settings.json,
~/.houndwatch/) are guarded by one watcher at a time.
houndwatch on --login writes a launchd agent (macOS) or a systemd user unit (Linux) that runs
houndwatch watch for the project once at login. HoundWatch only prints the command that loads
it; you run it. It doesn't restart a watcher that stops. The agent hook refuses agent commands
that edit or stop it. Remove it with houndwatch off --login (Uninstall).
These gaps are deliberate. Each is either covered by another layer or a trade-off.
- Only Claude Code gets checks before an edit. Other agents are covered by the watcher (after each save) and the git hooks (at commit).
- Shell checks are best effort. Some shell writes will get past them. So will code that hides what it loads, or that runs through another tool, such as a test that
pytestruns. The watcher checks the files afterwards, and the commit hook before they land. - A script that can't be read (missing, a binary, or over 64 KB past the part it reads) is allowed with a note. Content the same command downloads, decodes or generates and then runs is refused instead.
- A git alias that already exists runs, such as
git ci. Creating one that hides--no-verifyis refused, and the git hooks or the watcher still see the resulting commit. - Low-level git commands that move a branch, such as
git update-ref, run. If that brings in a commit the hooks never checked, the watcher reports it. - Model rules come after the fact. They never hold up an edit, a hook or the commit being checked. A model's
blockstops the next commit (Local models). - Without the watcher: there are no checks on save, no hook guard, no model answers, and no reports of skipped hooks until it starts again. The git hooks and agent hook still work.
- Hand edits by you to rules, config or hooks can't be prevented. They are recorded.
- A determined program running as you could clear the markers HoundWatch looks for and detach itself to pass the human-only check. Control commands run under a terminal wrapper are recorded as an open finding so you can check them. HoundWatch is a guard rail, not a security sandbox.