harness-anchor
CLAUDE.md13 starsChanged 4 months agoMITView on GitHub
Stop. Read this before doing anything. harness-anchor is behaviour-shaping infrastructure — its skills and hooks govern how OTHER agents behave in OTHER repositories. Edits here have outsized impact. A poorly tuned SKILL.md description will fail to trigger in real sessions; a too-fat SessionStart injection wastes context budget on every conversation; an over-eager PostToolUse hook blocks productive work. Your job is to protect the user from your own enthusiasm. Do not: 1. Warn-only hooks. No PostToolUse / Stop / UserPromptSubmit hook…
In this repository14 other files it gives its agents.
- anti-hallucination-gatesSkill
- capturing-golden-rulesSkill
- context-budget-disciplineSkill
- cpp-build-systemsSkill
- cpp-formattingSkill
- cpp-sanitizersSkill
- cpp-static-analysisSkill
- docs-lookupSkill
- feature-state-keeperSkill
- init-verificationSkill
- project-indexingSkill
- self-correction-loopSkill
- test-coverage-designSkill
- using-harness-anchorSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
13 rules. About 0 are common, 8 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 5
Stop. Read this before doing anything.
- Distinctive: line 9
Your job is to protect the user from your own enthusiasm: Do not:
- Very specific: line 11
Add features that aren't in the maintainer's approved plan (kept locally under ~/.claude/plans/)
- Distinctive: line 13
Add MCP server dependencies — this plugin is zero-dependency by design (bash + git)
- Very specific: line 14
Add block behavior to hooks — the entire design is warn-only (see plan §"决策")
- Distinctive: line 21
Subagents are single-level: Every subagent prompt must end with: *"Do not invoke other subagents from this one."*
- Distinctive: line 54
Do not "close the gap" with a static check on the description text.
- Distinctive: line 60
Default-FAIL evaluation contracts, both directions: No skill or agent should mark anything "done" without an evidence path — and none …
- Very specific: line 108
Add at least one adversarial prompt under tests/skill-triggering/prompts/ proving the skill triggers on a naive user message that *doesn't* …
- Very specific: line 109
Update scripts/validate-anchor.sh checklist if needed.
- Very specific: line 118
Add a contract test under tests/hook-contracts/.
- Distinctive: line 133
Before any commit that touches skills/hooks:
- Distinctive: line 140
If validate-anchor fails, fix the failure or revert.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
harness-anchor — Contributor & AI Collaborator Guidelines
If You Are an AI Agent Editing This Plugin
Stop. Read this before doing anything.
harness-anchor is behaviour-shaping infrastructure — its skills and hooks govern how OTHER agents behave in OTHER repositories. Edits here have outsized impact. A poorly tuned SKILL.md description will fail to trigger in real sessions; a too-fat SessionStart injection wastes context budget on every conversation; an over-eager PostToolUse hook blocks productive work.
Your job is to protect the user from your own enthusiasm. Do not:
- Add features that aren't in the maintainer's approved plan (kept locally under
~/.claude/plans/) - Rewrite skill descriptions to "comply with Anthropic best practices" without evals proving improvement
- Add MCP server dependencies — this plugin is zero-dependency by design (bash + git)
- Add
blockbehavior to hooks — the entire design is warn-only (see plan §"决策") - Bundle changes to unrelated layers in one commit
Design Invariants (do not break)
- Warn-only hooks. No PostToolUse / Stop / UserPromptSubmit hook may produce JSON with
"permissionDecision": "deny"or"stopReason". PostToolUse / UserPromptSubmit / SessionStart surfaceadditionalContextfor self-correction; the Stop event has noadditionalContextchannel, so its reminder usessystemMessage(still non-blocking — neverdecision: "block"). PreCompact likewise reaches only the user (a marker file +systemMessage) — the agent gets no turn before compaction runs, so the actionable pre-compaction warning lives in the PostToolUse watermark stages. - SessionStart token budget ≤ 3000 tokens. Roughly 12000 chars of injected content. Hard-truncate with a pointer to the on-disk file. The meta-skill body is injected slimmed (frontmatter stripped; conditional regions dropped when their gate doesn't match —
cpp-onlyby project type,os-<name>by HA_OS platform) — headroom belongs to the project-specific TOC/handoff, not to a fatter generic body. - Subagents are single-level. Every subagent prompt must end with: "Do not invoke other subagents from this one."
- State files are git-tracked by default.
.harness-anchor/(error log dir) is the only gitignored runtime path. C/C++ components stay dormant in non-C/C++ projects — through two different gates, and only one of them is
cpp-detect.sh. That script is the mechanical gate: it sets the banner's project type, decides whether the meta-skill'scpp-onlyregions are injected at all, and makes/cpp-init(exit 3) and/sanitizerefuse outright. It does not gate skill loading — skills are selected by description matching, and nothing consultscpp-detect.shat the moment one loads. So the gate on the skills is their own frontmatter: everyskills/cpp-*description must scope itself to C/C++ within its first 80 characters, the window invariant #6 says carries the load. That string is the only thing between a clang-tidy skill and a Python repo. Enforced byvalidate-anchor[3-4/12].The earlier wording of this invariant ("must include a frontmatter trigger condition referencing the detected build system") described neither what the files do — three of the four name no build system, and clang-format has no reason to — nor what actually gates them, and nothing enforced it. An unenforced entry in this list contradicts what the section below promises about it.
Skill descriptions front-load distinctive trigger keywords. First ~80 chars carry the load — Anthropic's skill listing budget is tight (see learn-harness
gotchas.md#12). Enforced by eval, not by grep, in two tiers. Every model-pulled skill ships a prompt that never names it (§"Authoring a New Skill" #4);using-harness-anchoris exempt, because SessionStart injects it and nothing has to trigger it.tests/skill-triggering/check-coverage.shruns on the non-Windows CI legs and asserts three things — the case is registered, its prompt file exists, and the prompt does not name its own skill in either spelling (docs-lookupordocs lookup).run-all.shis the second tier: it puts those prompts through a live session and is where triggering is actually measured, but it is run manually before a release, so treat it as a ritual you owe the release, not a gate that will stop you.Do not "close the gap" with a static check on the description text. Whether a keyword is distinctive is a property of whether the skill fires, not of the string; any grep approximating it would pass descriptions the eval rejects and fail ones it accepts. Reading the absence of a grep as an absence of enforcement is a mistake already made once against this entry.
- Hooks must time out in ≤ 5 seconds and fail silent on missing tools.
- Default-FAIL evaluation contracts, both directions. No skill or agent should mark anything "done" without an evidence path — and none should assert that something is absent (not installed / not available / no such symbol) without stating the search scope it actually covered and when it looked. A scope-less negative is wrong about where someone looked; a date-less one is wrong about when. This is the anti-hallucination invariant — do not soften it. Judgement-shaped negatives ("this is impossible", "that won't work") are deliberately out of scope: they carry no evidence path, and admitting them would turn the contract into unverifiable moralising.
- docs-lookup is the canonical procedure for unfamiliar tools/APIs/errors/library behavior. New skills MUST reference it rather than inlining Context7 → WebSearch waterfalls — the failure-mode detection and calibrated-uncertainty fallback live in one place by design.
- Windows/Git-Bash is a supported surface.
tests/windows-compat.shmust pass: no directpython3invocation in hooks (JSON goes throughscripts/lib/portable.sh's engine chain: python3 → python → py -3 → node → narrow bash); externally supplied paths are normalized at hook entry (ha_normalize_path); walk-up loops terminate by fixed point (ha_find_project_root), never by comparing against"/"; bash-consumed files carryeol=lfgitattributes (run-hook.cmddeliberately excluded — polyglot).
Shell hazards no tool in this repo catches
These are conventions, deliberately not invariants: the list above is mechanically enforced by a test, and these cannot be. Putting an unenforceable rule in that list would imply a check that does not exist.
Under
set -u, a barelocal xis UNSET, not empty. Reading it —[ -n "$x" ],"$x",${x}— aborts the script withx: unbound variable. Initialise everylocalyou might read before assigning:local x="". The dangerous shape is narrow and easy to miss: a name whose assignments all sit inside a loop orif, read after that block. It fires only on the path where the block never runs — the least-exercised branch, which is usually the not-found / empty / error path.Shipped instance:
scripts/cpp-tool-discovery.sh's versioned-variant search aborted on its true-NOT_FOUNDpath, i.e. the path the script exists to report correctly.Neither grep nor shellcheck finds this — both were tried against the real instance. Deciding it needs to know whether an assignment happens on every path, which line order does not tell you: a line-order scanner reports clean on code that crashes. ShellCheck at
--severity=styleemitted SC2034 and SC2043 for that function and nothing about the unbound read. The only detector is executing the path, so the real mitigation is a test that covers the not-found / empty case — which is what caught this one.
Authoring a New Skill (when explicitly asked)
- Decide if it's generic (language-agnostic) or C/C++ specific. The frontmatter description must make this clear.
- SKILL.md keeps the main flow in ≤200 lines. Heavy reference → sibling
.mdfiles. Platform-specific content splits by decision weight: facts an agent needs to judge correctly (availability, verdict rules) stay inline; operational depth (substitute tools, commands, workarounds) goes toplatform/<os>.md(os ∈ the HA_OS taxonomy) behind an inline "On<OS>, read …" pointer using a same-skill relative path (cross-skill mentions name the skill, never a path). Don't create a platform file for <10 lines of pure decision facts. - Frontmatter description: ≤500 chars, front-load with "Use when X" trigger.
- Add at least one adversarial prompt under
tests/skill-triggering/prompts/proving the skill triggers on a naive user message that doesn't mention the skill name. - Update
scripts/validate-anchor.shchecklist if needed.
Authoring a New Hook (very rarely)
Hooks are the most dangerous component because they fire automatically. Before adding one:
- State why this can't be a skill instead.
- Provide a concrete failure mode being prevented.
- Implement timeout, silent fail, and bounded output.
- Add a contract test under
tests/hook-contracts/. - State the observation-point. Name the failure's manifestation surface (Y — where the bad outcome actually appears) and the signal the hook observes (X). Assert X ⊇ Y; where it can't, document the residual blind spot in the hook header so a silent warn-only pass is not mistaken for coverage. A guardrail keyed on a proxy narrower than its target failure is silently blind — e.g. a scope check reading only the prompt misses agent-initiated scope creep (issue #6).
Authoring a Subagent
- frontmatter:
tools: Read, Bash, Grep, Globis the read-only default. AddWrite/Editonly with explicit justification. - Last paragraph of system prompt MUST contain: "Do not invoke other subagents from this one."
- Output a fixed structure (e.g., diagnosis / evidence / recommendation) so the calling agent can parse reliably.
Versioning
Bump version in .claude-plugin/plugin.json AND .claude-plugin/marketplace.json together. Semver: PATCH for fixes / content tweaks to existing components; MINOR for any new backward-compatible capability — new skill/agent/command/template/hook check, anything that belongs in a CHANGELOG ### Added section; MAJOR for breaking hook contract. (The old "new skill/agent/command" wording was an incomplete enumeration and once caused an Added-bearing release to be mislabeled PATCH.)
Tests
Before any commit that touches skills/hooks:
bash scripts/validate-anchor.sh
# Phase 5+: bash tests/skill-triggering/run-test.sh <skill> <prompt-file>If validate-anchor fails, fix the failure or revert. Do not commit broken plugin metadata.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

