harness-docs
Generate an agent-first documentation layout for an existing repository, following the "repository knowledge as the system of record" pattern described in OpenAI's Harness engineering: leveraging Codex in an agent-first world (Feb 2026).
The output is a docs/ tree plus root-level AGENTS.md and ARCHITECTURE.md that together form a map, not an encyclopedia — agents start from a short entry point (~100 lines) and descend into deeper, verifiable documents only when needed.
Core philosophy
Four ideas drive every decision in this skill. Internalize them before generating anything:
- AGENTS.md is a table of contents, not a manual. One giant instruction file fails in predictable ways: context is scarce and gets crowded out, everything marked "important" becomes non-guidance, rules rot, and a single blob can't be mechanically verified. Keep the entry point short (~100 lines) and make it point outward.
- Progressive disclosure. The agent starts with a stable, small entry point and is taught where to look next. Deep information lives in
docs/, reached only when relevant.
- Repo-local, versioned artifacts only. Anything that isn't in the repository effectively does not exist for the agent. Slack threads, Google Docs, and tacit knowledge must be encoded as markdown/schemas/plans in the repo.
- Mechanical verifiability. Structure the docs so linters and CI can check freshness, cross-links, and ownership. Prefer many small indexed files over one giant one.
If a design decision in this skill seems to contradict these four, the four win.
When to run this skill
Trigger on requests like:
- "Set up docs for this repo so Claude Code / Codex / Cursor can work on it"
- "Bootstrap an AGENTS.md / CLAUDE.md for this project"
- "Document the architecture of this codebase"
- "I want agent-first / harness engineering style docs"
- "Scaffold a docs/ folder following the OpenAI harness pattern"
- Any case where the user has a working repo but documentation is sparse, scattered, or stale, and they want agents to navigate it reliably.
Also trigger when the user shares a link to the harness engineering article and asks to apply it.
Do NOT trigger for:
- Single-file README generation (too small — just write a README)
- User API documentation for external consumers (that's a different audience)
- Merely updating an existing well-structured docs/ (unless the user wants a full restructure)
Workflow
The skill runs in five phases. Do them in order; don't skip ahead.
Phase 1 — Discover the repository
Build a mental model of what the codebase is before writing anything.
- Read the root listing. List the top of the repo (depth 1–2). Note the language, package manager, framework, monorepo vs single-package, test setup, CI config.
- Find entry points. Look for
main.*, index.*, app.*, cmd/, bin/, src/, apps/, packages/, cli.*, server/router files. These reveal the runtime shape.
- Identify domains. Scan for top-level directories under
src/ or similar that look like business domains (auth/, billing/, onboarding/, etc.) vs infrastructure concerns (db/, http/, telemetry/).
- Detect layering. Look for signs of a layered architecture (types → config → repo → service → runtime → UI, or similar). Note the direction of imports if visible.
- Inventory cross-cutting concerns. Authentication, feature flags, logging, telemetry, connectors — these become "providers" in the ARCHITECTURE map.
Time-box this. For a medium repo, ~5–10 tool calls is enough. Don't read every file; sample.
Phase 2 — Read existing documentation
Before writing anything new, harvest what's already there.
- Find all markdown. Search for
*.md, *.mdx, *.rst, AGENTS.md, CLAUDE.md, CONTRIBUTING.md, README*, docs/**, .github/, and any architecture/ADR folders.
- Read them in priority order: root README → any AGENTS.md/CLAUDE.md → existing docs/ → CONTRIBUTING → ADRs.
- Extract three things from each:
- Facts about the system — architecture claims, component names, flows. These are raw material for the new docs.
- Stated principles or conventions — become candidates for
docs/design-docs/core-beliefs.md.
- Staleness signals — references to removed code, TODO markers, outdated version numbers. Flag these; don't propagate them.
- Preserve, don't rewrite. If an existing doc is accurate and well-placed, the new scaffold should reference it, not duplicate it. The goal is consolidation, not replacement.
Phase 3 — Plan the docs layout
Decide what to create before creating it. The canonical layout is in references/example-structure.md — read that file now. Adapt it to the repo:
- Always create:
AGENTS.md, ARCHITECTURE.md, docs/design-docs/index.md, docs/design-docs/core-beliefs.md, docs/exec-plans/tech-debt-tracker.md, docs/PLANS.md, docs/QUALITY_SCORE.md.
- Create if the repo has a UI:
docs/FRONTEND.md, docs/DESIGN.md.
- Create if there's a data layer:
docs/generated/db-schema.md (with a note that it's auto-generated — leave content as a placeholder or extract from migrations/schema files if available).
- Create if there are product flows:
docs/product-specs/index.md + one spec per major flow you identified.
- Create if there are notable external dependencies:
docs/references/ with *-llms.txt placeholders for each major framework/SDK the project uses.
- Skip anything that doesn't apply. Empty scaffolding is worse than no scaffolding — it rots faster.
Present the planned tree to the user in a single message before writing files. This is a checkpoint: the user may want to add, remove, or rename sections.
Phase 4 — Generate the files
Now read references/file-templates.md for the content shape of each file. Key rules when filling them in:
- AGENTS.md stays under ~120 lines. If it grows past that, move content into
docs/ and leave a pointer.
- Every index file lists its siblings with a one-line summary each. No index file should be longer than one screen.
- Include a verification status at the top of every design doc:
Status: draft | verified | deprecated + Last reviewed: YYYY-MM-DD. This is what lets future lint jobs find stale docs.
- Core beliefs are short and declarative. "We parse data shapes at the boundary." "We prefer shared utility packages over bespoke helpers." Not essays.
- ARCHITECTURE.md is a map, not a tutorial. Domains × layers, dependency direction, cross-cutting providers. Diagrams are fine (mermaid works); walls of prose are not.
- Cross-link everything. Any mention of a domain or concept in one file should link to its authoritative doc. This is how agents navigate.
- Match the repo's language. If the existing README is in Japanese, write the docs in Japanese. If it's mixed, match the dominant language per-file. Code identifiers stay in their original form regardless.
Write files one by one, not in a single batch. After each, briefly confirm with the user or proceed if they've said to go ahead.
Phase 5 — Wire up mechanical enforcement (optional, recommend it)
The original article emphasizes that docs only work if CI enforces them. Offer the user, as a follow-up, to add any of:
- A
.github/workflows/docs.yml (or equivalent CI job) that runs the mechanical lint on PRs touching docs/ or code referenced by docs. The companion doc-gardener skill ships a ready-made scripts/docs_lint.py that checks metadata validity, Last reviewed freshness, internal link resolution, code-fence path references, and index coverage. Don't reimplement it here — point the user at the doc-gardener skill.
- A "doc gardener" prompt file at
docs/design-docs/doc-gardening-prompt.md that an agent can be pointed at periodically to scan for drift and open fix PRs. (Essentially, a saved invocation of the doc-gardener skill.)
Don't build these unprompted — they're scope creep for the initial run. Just mention them at the end.
Output structure (canonical)
<repo-root>/
├── AGENTS.md # ~100 lines — table of contents / map
├── ARCHITECTURE.md # Top-level map: domains × layers × providers
└── docs/
├── design-docs/
│ ├── index.md # List of all design docs w/ verification status
│ ├── core-beliefs.md # Agent-first operating principles
│ └── <topic>.md # One per significant design decision
├── exec-plans/
│ ├── active/ # In-progress plans (checked in)
│ ├── completed/ # Finished plans w/ decision logs
│ └── tech-debt-tracker.md # Known debt, versioned
├── generated/ # Auto-generated docs — header says DO NOT EDIT
│ └── db-schema.md # (if applicable)
├── product-specs/
│ ├── index.md
│ └── <flow>.md # One per major user-facing flow
├── references/ # External library refs, often *-llms.txt
│ └── <lib>-llms.txt # (one per major dependency)
├── DESIGN.md # Design-system / visual-design summary (if UI)
├── FRONTEND.md # Frontend conventions (if UI)
├── PLANS.md # Index into exec-plans/
├── PRODUCT_SENSE.md # Product principles (optional)
└── QUALITY_SCORE.md # Grades per domain × layer; tracks gaps
Details and full templates for each file are in references/file-templates.md. Read it before Phase 4.
References
references/example-structure.md — Annotated canonical tree with rationale for each node. Read during Phase 3.
references/file-templates.md — Concrete templates for every file the skill produces, including front-matter conventions. Read during Phase 4.
references/analysis-guide.md — Heuristics for extracting domains, layers, and providers from a codebase. Read during Phase 1 if the repo is large or unfamiliar.
Common mistakes to avoid
- Writing a giant AGENTS.md. If you catch yourself putting conventions, rules, examples, and history all in AGENTS.md, stop. That's the failure mode the article explicitly warns against. Move content into
docs/ and leave a one-line pointer.
- Copying the canonical layout literally. The layout is a starting point. A CLI tool with no UI doesn't need
FRONTEND.md. A prototype with no users doesn't need product-specs/. Omit what doesn't apply.
- Inventing architecture. If you can't tell from the code whether layer X depends on layer Y, write "Unverified — needs review" rather than guessing. Fabricated architecture docs are worse than missing ones because agents will act on them.
- Skipping the existing-docs read. Phase 2 is non-optional. Users whose docs you silently ignore will (rightly) be annoyed.
- Forgetting verification status. Every design doc needs
Status: and Last reviewed: at the top. Without these, the docs rot invisibly.
- Scaffolding empty directories.
docs/exec-plans/active/ with no content is clutter. Either put a placeholder README.md explaining what goes there, or skip the directory until it's needed.
Source: Keito654/harness-docs — distributed by TomeVault.
1---2name: harness-docs3description: Analyze an existing codebase and generate an agent-first "system of record" docs/ directory following OpenAI's Harness Engineering pattern. Use this skill whenever the user asks to bootstrap documentation, scaffold a docs/ folder, set up AGENTS.md, make the repository more legible to coding agents (Claude Code, Codex, Cursor), or "document the architecture" of an existing project — even if they don't explicitly mention Harness Engineering. Also use when the user has an under-documented repo and wants agents to operate on it reliably. Reads the codebase and any existing markdown files first, then produces AGENTS.md + ARCHITECTURE.md + a structured docs/ tree with progressive-disclosure entry points. Use when this capability is needed.4---56# harness-docs78Generate an **agent-first documentation layout** for an existing repository, following the "repository knowledge as the system of record" pattern described in OpenAI's *Harness engineering: leveraging Codex in an agent-first world* (Feb 2026).910The output is a `docs/` tree plus root-level `AGENTS.md` and `ARCHITECTURE.md` that together form a **map, not an encyclopedia** — agents start from a short entry point (~100 lines) and descend into deeper, verifiable documents only when needed.1112## Core philosophy1314Four ideas drive every decision in this skill. Internalize them before generating anything:15161. **AGENTS.md is a table of contents, not a manual.** One giant instruction file fails in predictable ways: context is scarce and gets crowded out, everything marked "important" becomes non-guidance, rules rot, and a single blob can't be mechanically verified. Keep the entry point short (~100 lines) and make it point outward.172. **Progressive disclosure.** The agent starts with a stable, small entry point and is taught where to look next. Deep information lives in `docs/`, reached only when relevant.183. **Repo-local, versioned artifacts only.** Anything that isn't in the repository effectively does not exist for the agent. Slack threads, Google Docs, and tacit knowledge must be encoded as markdown/schemas/plans in the repo.194. **Mechanical verifiability.** Structure the docs so linters and CI can check freshness, cross-links, and ownership. Prefer many small indexed files over one giant one.2021If a design decision in this skill seems to contradict these four, the four win.2223## When to run this skill2425Trigger on requests like:26- "Set up docs for this repo so Claude Code / Codex / Cursor can work on it"27- "Bootstrap an AGENTS.md / CLAUDE.md for this project"28- "Document the architecture of this codebase"29- "I want agent-first / harness engineering style docs"30- "Scaffold a docs/ folder following the OpenAI harness pattern"31- Any case where the user has a working repo but documentation is sparse, scattered, or stale, and they want agents to navigate it reliably.3233Also trigger when the user shares a link to the harness engineering article and asks to apply it.3435Do NOT trigger for:36- Single-file README generation (too small — just write a README)37- User API documentation for external consumers (that's a different audience)38- Merely updating an existing well-structured docs/ (unless the user wants a full restructure)3940## Workflow4142The skill runs in five phases. Do them in order; don't skip ahead.4344### Phase 1 — Discover the repository4546Build a mental model of what the codebase is before writing anything.47481. **Read the root listing.** List the top of the repo (depth 1–2). Note the language, package manager, framework, monorepo vs single-package, test setup, CI config.492. **Find entry points.** Look for `main.*`, `index.*`, `app.*`, `cmd/`, `bin/`, `src/`, `apps/`, `packages/`, `cli.*`, server/router files. These reveal the runtime shape.503. **Identify domains.** Scan for top-level directories under `src/` or similar that look like business domains (`auth/`, `billing/`, `onboarding/`, etc.) vs infrastructure concerns (`db/`, `http/`, `telemetry/`).514. **Detect layering.** Look for signs of a layered architecture (types → config → repo → service → runtime → UI, or similar). Note the direction of imports if visible.525. **Inventory cross-cutting concerns.** Authentication, feature flags, logging, telemetry, connectors — these become "providers" in the ARCHITECTURE map.5354Time-box this. For a medium repo, ~5–10 tool calls is enough. Don't read every file; sample.5556### Phase 2 — Read existing documentation5758Before writing anything new, harvest what's already there.59601. **Find all markdown.** Search for `*.md`, `*.mdx`, `*.rst`, `AGENTS.md`, `CLAUDE.md`, `CONTRIBUTING.md`, `README*`, `docs/**`, `.github/`, and any architecture/ADR folders.612. **Read them in priority order:** root README → any AGENTS.md/CLAUDE.md → existing docs/ → CONTRIBUTING → ADRs.623. **Extract three things from each:**63 - **Facts about the system** — architecture claims, component names, flows. These are raw material for the new docs.64 - **Stated principles or conventions** — become candidates for `docs/design-docs/core-beliefs.md`.65 - **Staleness signals** — references to removed code, TODO markers, outdated version numbers. Flag these; don't propagate them.664. **Preserve, don't rewrite.** If an existing doc is accurate and well-placed, the new scaffold should reference it, not duplicate it. The goal is consolidation, not replacement.6768### Phase 3 — Plan the docs layout6970Decide what to create before creating it. The canonical layout is in `references/example-structure.md` — read that file now. Adapt it to the repo:7172- **Always create**: `AGENTS.md`, `ARCHITECTURE.md`, `docs/design-docs/index.md`, `docs/design-docs/core-beliefs.md`, `docs/exec-plans/tech-debt-tracker.md`, `docs/PLANS.md`, `docs/QUALITY_SCORE.md`.73- **Create if the repo has a UI**: `docs/FRONTEND.md`, `docs/DESIGN.md`.74- **Create if there's a data layer**: `docs/generated/db-schema.md` (with a note that it's auto-generated — leave content as a placeholder or extract from migrations/schema files if available).75- **Create if there are product flows**: `docs/product-specs/index.md` + one spec per major flow you identified.76- **Create if there are notable external dependencies**: `docs/references/` with `*-llms.txt` placeholders for each major framework/SDK the project uses.77- **Skip** anything that doesn't apply. Empty scaffolding is worse than no scaffolding — it rots faster.7879Present the planned tree to the user in a single message before writing files. This is a checkpoint: the user may want to add, remove, or rename sections.8081### Phase 4 — Generate the files8283Now read `references/file-templates.md` for the content shape of each file. Key rules when filling them in:8485- **AGENTS.md stays under ~120 lines.** If it grows past that, move content into `docs/` and leave a pointer.86- **Every index file lists its siblings with a one-line summary each.** No index file should be longer than one screen.87- **Include a verification status** at the top of every design doc: `Status: draft | verified | deprecated` + `Last reviewed: YYYY-MM-DD`. This is what lets future lint jobs find stale docs.88- **Core beliefs are short and declarative.** "We parse data shapes at the boundary." "We prefer shared utility packages over bespoke helpers." Not essays.89- **ARCHITECTURE.md is a map, not a tutorial.** Domains × layers, dependency direction, cross-cutting providers. Diagrams are fine (mermaid works); walls of prose are not.90- **Cross-link everything.** Any mention of a domain or concept in one file should link to its authoritative doc. This is how agents navigate.91- **Match the repo's language.** If the existing README is in Japanese, write the docs in Japanese. If it's mixed, match the dominant language per-file. Code identifiers stay in their original form regardless.9293Write files one by one, not in a single batch. After each, briefly confirm with the user or proceed if they've said to go ahead.9495### Phase 5 — Wire up mechanical enforcement (optional, recommend it)9697The original article emphasizes that docs only work if CI enforces them. Offer the user, as a follow-up, to add any of:9899- A `.github/workflows/docs.yml` (or equivalent CI job) that runs the mechanical lint on PRs touching `docs/` or code referenced by docs. The companion `doc-gardener` skill ships a ready-made `scripts/docs_lint.py` that checks metadata validity, `Last reviewed` freshness, internal link resolution, code-fence path references, and index coverage. Don't reimplement it here — point the user at the `doc-gardener` skill.100- A "doc gardener" prompt file at `docs/design-docs/doc-gardening-prompt.md` that an agent can be pointed at periodically to scan for drift and open fix PRs. (Essentially, a saved invocation of the `doc-gardener` skill.)101102Don't build these unprompted — they're scope creep for the initial run. Just mention them at the end.103104## Output structure (canonical)105106```107<repo-root>/108├── AGENTS.md # ~100 lines — table of contents / map109├── ARCHITECTURE.md # Top-level map: domains × layers × providers110└── docs/111 ├── design-docs/112 │ ├── index.md # List of all design docs w/ verification status113 │ ├── core-beliefs.md # Agent-first operating principles114 │ └── <topic>.md # One per significant design decision115 ├── exec-plans/116 │ ├── active/ # In-progress plans (checked in)117 │ ├── completed/ # Finished plans w/ decision logs118 │ └── tech-debt-tracker.md # Known debt, versioned119 ├── generated/ # Auto-generated docs — header says DO NOT EDIT120 │ └── db-schema.md # (if applicable)121 ├── product-specs/122 │ ├── index.md123 │ └── <flow>.md # One per major user-facing flow124 ├── references/ # External library refs, often *-llms.txt125 │ └── <lib>-llms.txt # (one per major dependency)126 ├── DESIGN.md # Design-system / visual-design summary (if UI)127 ├── FRONTEND.md # Frontend conventions (if UI)128 ├── PLANS.md # Index into exec-plans/129 ├── PRODUCT_SENSE.md # Product principles (optional)130 └── QUALITY_SCORE.md # Grades per domain × layer; tracks gaps131```132133Details and full templates for each file are in `references/file-templates.md`. Read it before Phase 4.134135## References136137- `references/example-structure.md` — Annotated canonical tree with rationale for each node. Read during Phase 3.138- `references/file-templates.md` — Concrete templates for every file the skill produces, including front-matter conventions. Read during Phase 4.139- `references/analysis-guide.md` — Heuristics for extracting domains, layers, and providers from a codebase. Read during Phase 1 if the repo is large or unfamiliar.140141## Common mistakes to avoid142143- **Writing a giant AGENTS.md.** If you catch yourself putting conventions, rules, examples, and history all in AGENTS.md, stop. That's the failure mode the article explicitly warns against. Move content into `docs/` and leave a one-line pointer.144- **Copying the canonical layout literally.** The layout is a starting point. A CLI tool with no UI doesn't need `FRONTEND.md`. A prototype with no users doesn't need `product-specs/`. Omit what doesn't apply.145- **Inventing architecture.** If you can't tell from the code whether layer X depends on layer Y, write "Unverified — needs review" rather than guessing. Fabricated architecture docs are worse than missing ones because agents will act on them.146- **Skipping the existing-docs read.** Phase 2 is non-optional. Users whose docs you silently ignore will (rightly) be annoyed.147- **Forgetting verification status.** Every design doc needs `Status:` and `Last reviewed:` at the top. Without these, the docs rot invisibly.148- **Scaffolding empty directories.** `docs/exec-plans/active/` with no content is clutter. Either put a placeholder `README.md` explaining what goes there, or skip the directory until it's needed.149150---151> Source: [Keito654/harness-docs](https://github.com/Keito654/harness-docs) — distributed by [TomeVault](https://tomevault.io).152<!-- tomevault:4.0:skill_md:2026-06-16 -->