Global, Project, and Scoped Prompts
How prompt authority narrows from shared agent culture to local ownership
Every prompt rule needs the lowest stable owner.
If the rule applies everywhere, keep it global. If it describes the repository, keep it at the project root. If it only becomes true inside one app, package, or docs surface, put it there. This is how Harness keeps prompts small without hiding context.
Here, global means the repo-distributed quality baseline: .agents/AGENTS.md, which hi copies verbatim from the Harness source on every hi update.
Placement Table
| Layer | Belongs Here | Does Not Belong Here |
|---|---|---|
| Global | Quality criteria, validation posture, source inspection habits, interaction norms, and rules the agent should respect in every repo. | Consumer-repo business logic, app maps, package invariants, or product requirements. |
| Project | Repo identity, app/package boundaries, root commands, source-of-truth rules, and conventions that apply across the repository. | Detailed implementation guidance for one app, framework, package, or docs surface. |
| Scoped | Local ownership, scoped skill activation, source examples, dependency inspection targets, and invariants that become true near the files. | Company-wide quality criteria, broad repo orientation, or lifecycle sequencing that belongs in skills. |
Run Path
During a run, the agent should move down the tree until the rule becomes specific enough to act. It starts from the shared .agents/AGENTS.md, reads the project root for repository identity, then loads scoped guidance near the files it will change. Scoped guidance points to the Codebase Rule Registry in .agents/rules/index.md; the agent activates every rule whose path or task trigger matches.
That path is what activates the right skills and examples without loading the whole harness into every task. A CLI edit should discover CLI ownership guidance and relevant upstream examples. A wiki edit should discover routed MDX ownership and docs workflow skills.
Generation Path
hi init and hi update write Built prompt specs, .devpunks/AGENT-HANDOFF.md, and .devpunks/AGENT-SYSTEM-PROMPT.md. The Packs come from the settings packs, not from a new detection. The agent uses those inputs plus repository evidence to write the root and scoped AGENTS.md files.
| Prompt spec | Target the agent writes | Packs it lists |
|---|---|---|
.devpunks/specs/prompts/shared-agents.md | none; it describes the house structure of the shared prompt | every default Pack |
.devpunks/specs/prompts/root.md | root AGENTS.md | every installed Pack, plus the installed workflow entrypoints in routing order |
.devpunks/specs/prompts/<workspace>/prompt.md | <workspace>/AGENTS.md | no default Pack; surface Packs whose signal the workspace shows (a technology-only backend match is a candidate); every Pack whose technology or language matches the workspace |
.devpunks/specs/prompts/docs.md | docs/AGENTS.md, only with the docs Pack and a non-ignored root docs/ | Packs whose promptSurfaces include docs-prompt-spec (today docs) |
Workspace specs list only framework skills: detected, language, and surface Packs. Default-Pack skills (debug, planning, quality, research, requirements, security, subagents, misc, verification, docs, and the infra core Pack) live in the root prompt and .agents/AGENTS.md. The docs builder reads docs-prompt-spec; the workspace builder reads workspace-prompt-spec for default Packs only. The other values (shared-agents, root-prompt-spec, subagent-manifest) and promptDetails are published metadata that no builder reads; for example, the misc Pack declares only shared-agents, but it still appears in the root spec.
The backend surface Pack is listed directly only for a backend-named workspace path or package name. When it matches only through better-auth, drizzle, elysia, or trpc, the spec shows its skills as Candidate skills, and the agent adds a row only when the scope owns that concern. The final ## Skills table holds exactly the listed skills plus accepted candidate skills; the agent deletes every other row. Scoped skill rows exclude phase skills and Finder wrappers, and scoped specs also link opensrc/README.md.
The written prompts should preserve app/package boundaries, keep local examples current, activate scoped skills where they are useful, and avoid copying consumer-repo business logic into the Harness Baseline.
hi update never regenerates an AGENTS.md. When the Packs or workspaces change, it re-renders the specs; the agent re-reads them and edits the AGENTS.md files. If a rule belongs at a different layer, move it there in the AGENTS.md files or into .agents/rules/.
Handoff step 1 activates writing-for-agents, then rule-authoring, before the follow-up agent writes these surfaces. A context pointer names the deeper document and the condition that should load it. For example, a wiki-scoped pointer should trigger for routed MDX or docs-ingest work, while a CLI-scoped pointer should trigger for Registry or installer work. Clear triggers keep the root prompt small and make the relevant detail available at the scope where it becomes true.