Skip to content

Loading the guide…

    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.

    LayerSwitched on byCatchesBefore or after
    Agent hook (Claude Code)houndwatch hooks install --agent claude-codethe agent's edits, shell commands and end of turnbefore most actions; some checks right after
    Git hookshoundwatch hooks installevery commit, merge and rewrite made through git, by anyonebefore a commit or merge; after a rebase or amend
    Watcherhoundwatch onfile saves by any tool, commits that skipped the hooks, model checksafter
    Hook guard (part of the watcher)houndwatch onhooks and rule files changed outside HoundWatchafter, then puts its hook back
    Login agent (optional)houndwatch on --loginnothing 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.

    The agent hook

    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's config.worktree, ~/.gitconfig and ~/.config/git/config. Change those yourself, or with git 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 block problem. 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 block problems 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, bat or sed -n) counts as a read. A read in a chained or piped command does not.
    • End of turn: see Day-to-day use.

    Shell commands

    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 to core.hooksPath, GIT_CONFIG_* and similar variables, a new alias that hides --no-verify, and an editor or rebase command that hides it. Also include.path and includeIf.*.path, however they're set, because they can load settings that change core.hooksPath, git config --edit, because an editor can change any setting, and --git-dir on 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 uninstall and pre-commit install --allow-missing-config.

    • HoundWatch's control commands, such as houndwatch off or findings --waive. Faking a terminal with script, unbuffer, expect or pty.spawn is 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 houndwatch command 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 launchctl or systemctl commands 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 follows cd, 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 as rules-edited. clean -fdx also 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 through eval, 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.

    The git hooks

    houndwatch hooks install installs six hooks:

    HookWhat it does
    pre-commitchecks the changed files and the commit; a block refuses the commit
    commit-msgchecks the message; a block refuses the commit
    post-commitrecords the commit as checked; never blocks
    pre-merge-commitchecks a clean merge, as pre-commit does for a commit
    post-mergerecords the merge
    post-rewriteafter 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.

    The watcher

    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 block finding 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-skipped finding. It never rewrites history.
    • Runs llm rules 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:

    text
    [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-checked

    If its watcher-expected marker (.houndwatch/watcher.expected) 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

    The hook guard runs inside the watcher. When HoundWatch's hooks or agent-hook entries are removed or edited outside the houndwatch command, it:

    1. records a hook-tampered finding saying what changed;
    2. puts HoundWatch's own entry back, only where you approved it at install. Turn this off with guard_reinstall: false in your user config.
    text
    [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.

    The login agent

    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).

    What is not caught

    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 pytest runs. 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-verify is 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 block stops 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.