AGENTS.md
The checked-in prompt contract agents read before touching a scope
Each AGENTS.md answers the same question at a different point in the tree: what should the agent know here?
At the root, the answer is repo identity, ownership boundaries, commands, and source-of-truth rules. Near an app or package, the answer is local ownership, skill activation, examples, and invariants. The file is the checked-in prompt contract agents read before touching that scope.
Every AGENTS.md file is project-owned. hi writes only one of them: the root AGENTS.md starter, as an Authored Artifact, and only when the file is absent. It never compares or overwrites that file again, even with hi update --yes. The agent writes the real root prompt and every scoped AGENTS.md from the Built prompt specs in .devpunks/specs/prompts/** and repository evidence. They are repo-tailored, but they are not personal scratchpads: they are reviewed like code.
Contract
Each file should answer only the local questions:
- what this scope owns
- what this scope must not own
- which skills activate here
- which examples or sources guide the work
- where the Codebase Rules are
It should avoid long tutorials. If a rule needs full explanation, link to a wiki page, runbook, spec, or skill contract.
Root Prompt
Root AGENTS.md is repo orientation. It gives the agent the repository identity, app/package boundaries, root command conventions, and source-of-truth rules that apply everywhere. Its prompt spec, .devpunks/specs/prompts/root.md, lists every installed Pack and the workflow entrypoints, such as requirements-phase and delivery-phase, in routing order.
It should route the agent into the right part of the tree. It should not absorb app-specific implementation detail that belongs under a scoped file.
Scoped Prompts
Scoped AGENTS.md files are activation points. They name the local skills, examples, source inspection targets, and invariants that matter near the files being changed. Each one has a prompt spec at .devpunks/specs/prompts/<workspace>/prompt.md. Scoped skill lists exclude phase skills and Finder wrappers: those run from the parent goal, not from a scope.
For example, a CLI scope can point the agent toward Registry and installer behavior and relevant upstream command implementations. A wiki scope can point toward routed MDX ownership and docs workflow skills. The guidance lives near the code because that is where it becomes true.
Codebase Rule Registry
Detailed project patterns live in the Codebase Rule Registry, not in prompts. .agents/rules/index.md lists each rule by id, scope, path trigger, task trigger, tags, and file. Each rule file holds one positive requirement, its authority, triggers, verification, and exceptions.
Each scoped AGENTS.md keeps exactly one pointer to .agents/rules/index.md. Before editing or reviewing, the agent matches every touched path and the task against the triggers, activates each matching rule, and records pass, fail, or not-applicable with evidence in the handoff or work log. Tags help discovery; they never activate a rule.
The Registry is project-owned. No Registry Item writes .agents/rules/**, and hi never reads it.
Mirrors
The neutral AGENTS.md is the source. Harness mirrors point to it as symlinks:
| Mirror | Target | Writer |
|---|---|---|
Root CLAUDE.md | AGENTS.md | hi (prompts item) |
CLAUDE.md beside each scoped AGENTS.md | the sibling AGENTS.md | the agent, from the handoff |
.claude/CLAUDE.md | ../.agents/AGENTS.md | hi (harness item) |
.codex/AGENTS.md | ../.agents/AGENTS.md | hi (harness item) |
.opencode/AGENTS.md | ../.agents/AGENTS.md | hi (harness item) |
.claude/skills | ../.agents/skills | hi (harness item) |
Cursor reads AGENTS.md files, including the shared .agents/AGENTS.md, and .agents/skills natively, so it has no prompt or skill link. Codex and OpenCode also read .agents/skills natively. No harness link points at a scoped prompt. Harnesses load scoped files through their own nested-file lookup; that is why each scoped AGENTS.md gets a sibling CLAUDE.md.
Runtime mirrors must not drift into separate instruction sets. Edit the AGENTS.md, never a mirror.
Change Path
hi update never rewrites an AGENTS.md. When the repository changes, hi update re-renders the prompt specs from the settings packs and the Recorded Shape. The agent then re-reads the specs and edits the AGENTS.md files to match.
- If a scope needs a different local rule, edit that
AGENTS.mdor the matching Codebase Rule. - If the spec is wrong for every repository, change the template or builder in the Harness source and ship it in a new Baseline.
- If the prompt needs different product truth, change the owning repo source, spec, wiki page, or runbook.
Post-Command Authoring
hi init or hi update installs the Baseline
-> .devpunks/AGENT-HANDOFF.md step 1: activate writing-for-agents, then rule-authoring
-> agent writes root and scoped AGENTS.md from the prompt specs
-> agent adds a CLAUDE.md symlink beside each AGENTS.md
-> agent keeps detailed patterns in .agents/rules/, one pointer per scoped AGENTS.mdwriting-for-agents governs the agent-authored prose: prompts, scoped guidance, subagent instructions, and rule text. rule-authoring maintains .agents/rules/ and is used only from these post-command handoffs. Copied and Built files stay under hi control; the agent does not edit them. The follow-up agent uses repository evidence to write the scoped guidance without moving product truth into the Harness Baseline.