herdhound
GitHubInstall
New in 0.4.1: a lighter session startRead more
esc

↑↓ move↵ openherdhound.dev

Harness

Guardrails from ontologies you write, checked on every tool call by Claude Code hooks, with a live log of what goes in and comes out.

The harness puts guardrails on your agents, built from ontologies you write. Every tool call in every container goes through Claude Code hooks. HerdHound:

  1. matches the call to concepts in your ontologies,
  2. applies the rules on those concepts: deny the call, ask you, or warn the agent,
  3. logs what went in and what came out.

New to ontologies? Ontologies and taxonomies explains what they are and why the harness uses them.

Agents are told about the harness and the names of its rules at the start of every session, briefly, so a large set of ontologies does not crowd their context. When a rule fires, they are pointed at the concept to look up, so they follow the rule instead of working around it.

Turn it on

Open Settings with ctrl+b S:

  • Switch on Harness, and the Harness view if you want to see it.
  • Views switch on at once. Harness changes apply after a restart, and R in Settings restarts HerdHound (containers keep running).
  • Running containers pick up the hooks within seconds.

Or set it in the config file:

[harness]
enabled = true
fail_closed = false      # ontologies with errors: false allows calls with a warning, true denies them
log_output_bytes = 4000  # how much of each call's input and output the log keeps

[views]
harness = true           # ctrl+b o
skills = true            # ctrl+b A

Ontologies and taxonomies

Ontologies are Turtle files in harness/ontologies next to the config file (/harness/ontologies in containers). They sync both ways with every running session, so a change takes effect on the next tool call.

Taxonomy

HerdHound reads the standard terms:

  • rdfs:subClassOf, skos:broader and skos:narrower for the hierarchy,
  • rdfs:label and skos:prefLabel for names,
  • rdfs:comment and skos:definition for definitions.

A call that matches a concept is also an instance of every concept above it.

Matching tool calls

Three terms from the HerdHound vocabulary tie a concept to tool calls:

Term Matches
hh:matchTool regex on the whole tool name: Bash, Read|Write|Edit, mcp__.*
hh:matchInput regex on the Bash command, or on the tool input as JSON
hh:matchPath glob on file_path, path or notebook_path: **/.env, src/*.rs

A concept matches when its tool regex matches (if it has one), and at least one of its input or path matchers matches (if it has any). Put matchers on narrow concepts and rules on broad ones.

Patterns use ASCII rules: (?i), \w, \s and \b ignore non-ASCII letters, which keeps every tool call fast. Start a pattern with (?u) for full Unicode.

Rules

A hh:Rule has these terms:

  • hh:appliesTo a concept,
  • hh:severity "deny", "ask" or "warn",
  • hh:message for the agent: what to do instead,
  • optionally hh:seeAlso, where to look next,
  • optionally hh:requires: the rule fires only if the session did not do that first. Use it for “tests before a commit”.

When several rules fire, the strictest wins.

@prefix hh:   <https://herdhound.dev/ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix :     <https://example.org/ops#> .

:RiskyAction rdfs:label "Risky action" ; rdfs:comment "Anything that is hard to undo." .
:Destructive rdfs:subClassOf :RiskyAction ;
    hh:matchTool "Bash" ; hh:matchInput "rm\\s+-rf|git\\s+push\\s+--force" .
:SecretFile rdfs:subClassOf :RiskyAction ;
    hh:matchTool "Read|Write|Edit" ; hh:matchPath "**/.env" .
:Testing a skos:Concept ; hh:matchTool "Bash" ; hh:matchInput "cargo test|npm test" .
:Commit skos:broader :VersionControl ; hh:matchTool "Bash" ; hh:matchInput "git commit" .

:NoDestroy a hh:Rule ; hh:appliesTo :Destructive ; hh:severity "deny" ;
    hh:message "Never delete recursively or force-push; ask the user." ; hh:seeAlso :RiskyAction .
:TestFirst a hh:Rule ; hh:appliesTo :Commit ; hh:requires :Testing ; hh:severity "ask" ;
    hh:message "Run the tests before committing." .

Built-in ontologies

HerdHound ships with seven ontologies and a matching skill for each. They are installed the first time the harness is on:

File Covers Rules
acid.ttl transactions that stay atomic, consistent, isolated and durable, across SQL, document and key-value stores, queues and files 13 (5 deny, 3 ask, 5 warn)
appsec.ttl OWASP-style flaws in any language: injection, unsafe deserialisation, disabled TLS checks, open redirects 20 (6 deny, 14 warn)
clean-code.ttl SOLID, KISS, YAGNI and DRY smells in new code 21 warn
code-comments.ttl which comments belong in code; no TODO/FIXME markers or commented-out code 7 (4 deny, 3 warn)
harness-protection.ttl agents changing their own guardrails: harness files, Claude Code settings and hooks, git hooks, permission bypasses 4 ask
iac.ttl Bicep/ARM, Terraform, Kubernetes/Helm, Pulumi, CloudFormation and Ansible: agents write templates but never change real infrastructure 21 (7 deny, 14 warn)
secrets.ttl files, commands, commits and logs that expose credentials 5 deny
  • A new release updates a built-in file only if you left it exactly as installed.
  • A file you edited, deleted or removed is never touched again.

The Harness view

Press ctrl+b o, or click Harness in the navbar. Its four tabs:

  • Ontologies: your files, with parse errors and rules that can never fire. e edits a file, n creates one, d deletes one.
  • Rules: each rule with its severity and how often it fired.
  • Activity: every prompt, tool call (→) and result (←), live, with the concepts it matched and the decision. Enter shows the full input and output; f filters.
  • Graph: concepts and their taxonomy, rules, and the tools seen calling them.

Ask AI

Press a or click ✦ Ask AI to open Claude in a new tab. It helps you write ontologies and taxonomies, starting from whatever is selected. Claude interviews you about your domain first, then writes the Turtle files and checks them.

  • With the harness on, Claude runs in your container session and uses the built-in harness-author skill.
  • Otherwise it runs claude on your machine.

Commands

Command Does
herdhound harness concepts the taxonomy as a tree, with matchers and rules
herdhound harness explain <concept> definition, parents, narrower concepts, matchers, rules
herdhound harness rules every rule with its severity
herdhound harness classify <tool> '<json>' what a call would match, and the decision
herdhound harness check syntax errors and rules that can never fire; exits 1 when it finds any
herdhound harness log [--session S] [-n N] recent events

Limits

  • The harness is a guardrail for cooperative agents, not a sandbox. A regex sees the command text, not what a script it runs does.
  • The log keeps the first log_output_bytes of every input and output, in each container (/harness/log.jsonl) and on your machine. Tool output can contain secrets. Lower log_output_bytes, or leave the harness off where that matters.
  • Plain shell sessions get no hooks.