Harness init
Use when initializing a new project, making a repo agent-ready, or adding architectural layer boundaries — produces AGENTS.md, docs/ system of record, boundary tests, linter rules, CI pipeline, and GC scriptsFrom its SKILL.md
npx -y skills add Gizele1/harness-init --skill harness-initAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
15.2 KB, as published. Nobody here has run it
Harness Init
<Purpose> Bootstrap a repository with OpenAI's harness engineering scaffolding: AGENTS.md orientation map, docs/ system of record, architectural layer enforcement, golden principles, garbage collection, and static/dynamic context strategy.This is the repo initialization subset of harness engineering. Runtime feedback loops, agent review loops, and observability stack setup are out of scope. If the repo already has observability (logs, metrics, tracing), this skill reads it as dynamic context but does not build it.
Source: OpenAI "Harness engineering: leveraging Codex in an agent-first world" (2026-02-11) </Purpose>
<Why_This_Exists> AI agents can only work with what they can see. Without structured documentation, mechanical constraints, and clear layer boundaries, agents make inconsistent architectural decisions, introduce import violations, and produce code that drifts from conventions. This skill front-loads the environment design so every subsequent agent session starts with a map, not a blank slate. </Why_This_Exists>
<Use_When>
- Creating a new project from scratch
- Making an existing repo agent-ready for the first time
- Adding architectural layer boundaries to a codebase
- User says "harness", "init harness", "make this agent-ready", "set up architecture"
- Before any major feature work in a repo that lacks AGENTS.md + docs/ </Use_When>
<Do_Not_Use_When>
- Repo already has AGENTS.md + docs/architecture/LAYERS.md + boundary tests — use existing harness
- User wants hierarchical AGENTS.md per directory — use a per-directory init tool instead
- User wants runtime observability / agent review loops — out of scope for this skill
- Quick bug fix or small feature — just do the work directly
- User wants to explore ideas or brainstorm — this skill is for structured scaffolding, not ideation </Do_Not_Use_When>
<Execution_Policy>
- Phase 0 (Discovery) is MANDATORY — never skip, never assume the stack
- Argument parsing:
full= all phases.N= single phase.N-M= phase range. No argument = interactive (asks user what to set up). Phase 0 always runs regardless of argument. - Read before you write — match existing code style and patterns
- Use
git mvfor doc restructuring to preserve history - New lint rules warn first if pre-existing violations exist — don't break the build
- Delegate phases in parallel where independent (e.g., Phase 5 CI + Phase 7 hooks)
- Run long operations (npm install, test suites) in background
- Use a feature branch (
feat/harness-engineering) if the repo has existing work - Phase checkpoints: After each phase, verify output exists (file created + test/lint passes where applicable). Log completed phases so work can resume if interrupted.
- Failure handling: If a phase fails, skip it, report what failed and why, and continue to the next independent phase. Do not halt the entire run for a single phase failure.
- Verification evidence: "Phase complete" = output file exists AND relevant test/lint passes. File existence alone is not sufficient. </Execution_Policy>
-
Phase 1 — AGENTS.md (~100 lines, orientation map)
Read references/agents-md-template.mdfor the template- Fill in from Phase 0 discovery — don't invent, reflect what exists
- Point to docs/ for details, don't inline them
-
Phase 2 — docs/ system of record Required:
- Create:
ARCHITECTURE.mdat repo root (top-level domain map, ~30 lines, points to LAYERS.md) - Create:
docs/architecture/LAYERS.md(definitive layer hierarchy + remediation guide) - Create:
docs/golden-principles/—Read references/golden-principles-guide.mdfor how to write these - Create:
docs/SECURITY.md—Read references/security-template.mdfor template and exclusion rules Recommended: - Create:
docs/guides/(setup, testing, deployment — only what's relevant) - Create:
docs/exec-plans/—Read references/exec-plan-template.mdfor the standard (active/ + completed/ subdirs) - Create:
docs/design-docs/withindex.md(ADR index) andcore-beliefs.md(non-negotiable decisions) - Create:
docs/references/(external library docs reformatted for LLM consumption, e.g.{library}-llms.txt) - Create:
docs/DESIGN.md,docs/PLANS.md,docs/QUALITY_SCORE.mdConditional (by project type): docs/RELIABILITY.md— for services (SLA, error budgets, resilience patterns)docs/STACK.md— stack-specific conventions (replaces OpenAI's FRONTEND.md)docs/product-specs/— for product-driven projectsdocs/generated/— auto-generated docs (db-schema.md, api-spec.md)
- Create:
-
Phase 3 — Architecture boundary test
Read references/boundary-test-template.mdfor test skeletons, KNOWN_VIOLATIONS format, and ratchet logicRead references/stack-routing.mdfor import parser and test file path per stack- Scan all source files, parse imports, validate against layer rules
- Error format:
VIOLATION: {file}:{line} imports {target} — {layer} cannot import {target_layer}. See docs/architecture/LAYERS.md - Ratchet:
KNOWN_VIOLATIONSstored intests/architecture/known-violations.json, can only shrink - For existing repos: establish baseline first, then ratchet
-
Phase 4 — Linter boundary enforcement
Read references/stack-routing.mdfor linter rule name and config location per stack- Use linter's native import restriction rules
- Every error message MUST include remediation — error output IS agent context
-
Phase 5 — CI pipeline
Read references/ci-templates.mdfor starter YAML templates and command validation rulesRead references/stack-routing.mdfor CI job matrix per stack- Adapt to stack — not every stack needs all 4 jobs (lint, typecheck, test, build)
- Validate discovered commands before embedding in CI — reject shell metacharacters, stop and ask if suspicious
-
Phase 6 — Garbage collection
Read references/gc-patterns.mdfor scan types, safety rules, and migration strategyRead references/stack-routing.mdPhase 6 table for per-stack GC toolingRead references/ci-templates.mdGC Workflow section forgc.ymltemplate- Prioritize entropy scans (doc drift, architecture violations) over style scans
- Single
gccommand + scheduled GitHub Action (weekly cron, report-only)
-
Phase 7 — Pre-commit hooks (optional)
Read references/stack-routing.mdfor framework and config per stack- Phase 7 is optional — CI (Phase 5) is the authoritative gate </Steps>
<Tool_Usage>
Delegate by intent — platform routes the call. Read references/tool-routing.md for platform-specific mappings.
- Explore (lightweight model) — directory mapping, file discovery in Phase 0
- Architect (heavyweight model) — architecture analysis, layer identification in Phase 0
- Write (lightweight model) — AGENTS.md + docs generation in Phases 1-2
- Execute (standard model) — boundary test, linter config, CI, GC scripts in Phases 3-7
- Verify (standard model) — final checklist validation
- Read
references/*.mdfiles on demand per phase — don't load all at once </Tool_Usage>
<Escalation_And_Stop_Conditions>
- Stop and ask if stack detection is ambiguous (multiple package managers, unclear framework)
- Stop and ask if no clear directory structure exists (flat repo with no src/ or lib/)
- Stop and ask if existing AGENTS.md or docs/ conflict with harness structure
- Stop and report if linter/test runner cannot be installed (permissions, incompatible versions)
- Graceful degradation if
ghCLI, LSP, or session state unavailable — skip those dynamic context signals, note what was skipped - Never force a layer structure that doesn't fit the actual codebase </Escalation_And_Stop_Conditions>
<Final_Checklist>
- Phase 0 discovery completed (stack detected, layers identified, user confirmed)
- AGENTS.md exists at repo root (~100 lines, index not encyclopedia)
- docs/architecture/LAYERS.md exists with layer diagram + remediation guide
- At least 2-3 golden principles docs exist with DO/DON'T examples
- Architecture boundary test exists and passes (with KNOWN_VIOLATIONS if existing repo)
- Linter rules enforce import boundaries with remediation in error messages
- CI pipeline runs lint + test (at minimum)
- GC runner command exists (
npm run gc/make gc/ equivalent) - All new files committed on feature branch
- Test suite, linter, and GC scripts verified to run successfully </Final_Checklist>
project-root/
├── AGENTS.md # ~100 lines, orientation map [Required]
├── ARCHITECTURE.md # Top-level domain map [Required]
├── docs/
│ ├── architecture/
│ │ └── LAYERS.md # Layer hierarchy + enforcement [Required]
│ ├── golden-principles/ # DO/DON'T patterns, 30-60 lines each [Required]
│ ├── SECURITY.md # Auth, secrets, threat model [Required]
│ ├── guides/ # Setup, testing, deployment [Recommended]
│ ├── exec-plans/ # ExecPlan lifecycle [Recommended]
│ │ ├── active/
│ │ ├── completed/
│ │ └── tech-debt-tracker.md
│ ├── design-docs/ # ADRs [Recommended]
│ │ ├── index.md
│ │ ├── core-beliefs.md
│ │ └── {NNNN-title}.md
│ ├── references/ # External docs for LLMs [Recommended]
│ │ └── {library}-llms.txt
│ ├── DESIGN.md # Design philosophy [Recommended]
│ ├── PLANS.md # Exec-plans overview [Recommended]
│ ├── QUALITY_SCORE.md # Per-domain quality grades [Recommended]
│ ├── RELIABILITY.md # SLA, error budgets (services) [Conditional]
│ ├── STACK.md # Stack conventions [Conditional]
│ ├── product-specs/ # Product specs [Conditional]
│ └── generated/ # Auto-generated docs [Conditional]
│ └── {db-schema,api-spec}.md
├── scripts/gc/ # Garbage collection scripts
├── tests/architecture/
│ └── boundary.test.* # Mechanical layer enforcement
└── .github/workflows/
├── ci.yml # lint + typecheck + test + build
└── gc.yml # Weekly entropy scan
Reference Files
Detailed templates and guides are in references/ — read on demand per phase:
references/layer-templates.md— 5 layer models (4 tech stacks + OpenAI original)references/agents-md-template.md— AGENTS.md templatereferences/context-strategy.md— Static vs dynamic context tablesreferences/exec-plan-template.md— ExecPlan (docs/exec-plans/) standardreferences/golden-principles-guide.md— How to write golden principlesreferences/gc-patterns.md— GC scan types + migration strategy for existing reposreferences/security-template.md— SECURITY.md template with exclusion rulesreferences/boundary-test-template.md— Test skeletons, KNOWN_VIOLATIONS format, ratchet logicreferences/tool-routing.md— Platform-specific tool delegation mappingsreferences/stack-routing.md— Stack → tooling decision tables for Phases 3-7references/ci-templates.md— Starter CI YAML for GitHub Actions, GitLab, Makefile </Advanced>