Harness Run
Use this skill for long-running work that must survive fresh contexts, background relaunches, or planned handoffs. Do not use it for one-shot Q&A.
When To Use
- Unattended improve-verify loops
- Overnight debugging, fixing, auditing, or shipping work
- Resume from durable state after a fresh Codex session
- Background runs that should relaunch fresh
codex exec sessions
- Scoped multi-agent inspection, verification, or review
What This Skill Owns
- Persistent run control through
scripts/harness_run_ctl.py
- Durable state under
.harness-run/
- Run-local collaboration docs under
.harness-run/docs/
- Per-round evidence, generated knowledge, and design notes under
.harness-run/evidence/, .harness-run/generated/, and .harness-run/design/
- Foreground and background parity
- Resume, status, stop, and handoff behavior
- One-round-at-a-time improve-verify loops
User Entry
run-task: start a durable run with one natural-language goal; --verify is optional
status: inspect the current run in human-readable form
stop: stop the current run cleanly
Normal users should not have to operate internal commands or design a full launch contract. When this skill triggers, accept a goal-only request, infer the plan, scope, metric, and verification approach from project evidence, run the helper script yourself, and report the durable state paths plus the current status. Only mention internal commands when debugging or when a fresh Codex session must reconstruct the runtime prompt manually.
Every run initializes a mini collaboration record under .harness-run/docs/. This record is the run-local equivalent of a project docs system: architecture snapshot, run plan, constraints, validation pipeline, progress, decisions, handoff, completion, and sync policy. If the target repo has its own docs/, keep .harness-run/docs/ as the execution layer and sync only concise summaries when the run's sync-policy.md allows it.
Launch Contract
Only Goal is required from the user. Infer these fields before starting:
Goal
Scope
Metric
Direction
Verify
Optional fields:
Guard
Iterations
Stop condition
Run mode
Execution policy
If a field can be inferred safely, infer it. If scope is unclear, default to the current repo or current working directory and narrow it after reading evidence. If verification is unclear, do not block launch; use plan/checklist completion with concrete evidence. Ask only when continuing would likely produce work opposite to the user's intent.
If the user explicitly says to follow a directory, plan file, roadmap, issue list, checklist, or existing project plan, treat that plan as authoritative scope and sequence. Read it, follow it, and do not renegotiate the plan unless it contradicts safety, repo instructions, or executable evidence.
Default execution policy is workspace_write. Do not use danger_full_access unless the user explicitly requests or accepts that elevated background risk; that mode injects Codex's dangerous bypass argument into nested codex exec sessions.
Default stop behavior:
- when
direction=pass, the run stops once verification passes
- when
direction=complete, the run stops once the recorded metric reaches completion
- when
verify is provided and metric is omitted, the verify command itself is used as the tracked metric label
- when
verify is omitted, use metric=planned work checklist, direction=complete, stop_condition=complete, and record complete only after the inferred or user-specified plan is satisfied with evidence
- background runs default to an iteration cap of 25 when no explicit cap is provided
Quick Start
Background:
- Start with
run-task.
- Use
status to inspect the runtime and stop to end it.
- If the process stops on
needs_human, read .harness-run/runtime.log, .harness-run/state.json, and .harness-run/rounds.tsv before continuing.
- Read
.harness-run/docs/handoff.md, .harness-run/docs/run-plan.md, and .harness-run/docs/constraints.md before resuming work.
Foreground:
run-task --foreground prepares the durable run in the current Codex session.
- Read the repo
AGENTS.md, current source, build/test config, and recent logs.
- Measure the baseline.
- Initialize state after the baseline exists.
- Run one focused change, verify with the command or evidence checklist, and record the result.
- Update
.harness-run/docs/handoff.md every round; update progress, decisions, constraints, and architecture only when facts change.
- Repeat from persisted state.
Common commands:
python <skill-root>/scripts/harness_run_ctl.py run-task --goal "<goal>"
python <skill-root>/scripts/harness_run_ctl.py run-task --foreground --goal "<goal>"
python <skill-root>/scripts/harness_run_ctl.py run-task --goal "<goal>" --verify "<command>"
python <skill-root>/scripts/harness_run_ctl.py run-task --foreground --goal "<goal>" --verify "<command>"
python <skill-root>/scripts/harness_run_ctl.py status
python <skill-root>/scripts/harness_run_ctl.py stop
Durable State
All normal run artifacts live under:
<workspace_root>/.harness-run/
Files:
launch.json: confirmed launch manifest
state.json: primary recovery snapshot
rounds.tsv: append-only audit trail
runtime.json: background controller pid, status, and last decision
runtime.log: controller and nested Codex output
context.json: canonical path map for the active run
docs/: run-local collaboration docs and handoff records
evidence/: concise per-round evidence notes
generated/: generated knowledge snapshots with source commands
design/: design notes too large for the decision log
Each managed git repo may also get a git-local pointer at:
git rev-parse --git-path harness-run/pointer.json
That pointer resolves back to the workspace-owned context.json.
The run-local docs are initialized from templates in references/templates/. They are not a replacement for target repo docs. They are the durable execution record that lets fresh Codex sessions continue without hidden conversation state.
Core run docs:
project-architecture.md
product-context.md
run-plan.md
constraints.md
change-inventory.md
validation-pipeline.md
operability.md
security-boundary.md
sync-policy.md
progress.md
decisions.md
handoff.md
completion.md
Round Rules
- Rebuild context from source files, logs, tests, and durable state.
- Read
.harness-run/docs/constraints.md, run-plan.md, project-architecture.md, validation-pipeline.md, and handoff.md before editing.
- Establish or refresh the baseline before mutating anything.
- If verification is unclear, create or infer an execution checklist and evidence checklist before editing.
- Make one focused change or one falsifiable diagnosis.
- Verify mechanically when a command exists; otherwise verify by concrete evidence such as file inventory, diff review, build feasibility, sample output, screenshots, generated reports, or checklist completion.
- Keep, discard, block, or mark no-op.
- Record exactly one outcome before the next round.
- For partial goal-only rounds, use
refine, search, or pivot with metric=incomplete; do not use keep until the metric is actually complete.
- Update
handoff.md every round. Update at least one progress/evidence artifact each recorded round: progress.md, decisions.md, change-inventory.md, run-plan.md, completion.md, or .harness-run/evidence/round-XXXX.md.
- Keep raw logs and secrets out of Markdown docs; summarize only redacted facts.
- Never leave the next round dependent on hidden conversation state.
Internal Control Plane
The skill keeps the heavier runtime protocol in references/runtime-loop.md and the helper script.
run-task is the user entry. It creates or resumes the durable run and starts the background controller by default.
create-launch, launch, start, controller, init-state, record, and resume-prompt are internal or advanced commands.
- The controller loop survives Codex context limits by relaunching fresh
codex exec sessions from .harness-run/.
needs_human means the controller stopped on a real blocker, inconsistent state, missing run artifacts, stale controller process, or stagnation, not that the user should keep waiting.
Typical flow:
- Use
run-task.
- Check
status if you need a progress summary.
- Use
stop when you want to end the run. For a prepared foreground run, stop clears the prepared state even when no background controller exists.
- If a fresh Codex session must continue manually, use the internal
resume-prompt command or read .harness-run/state.json.
Repeated starts:
- running
run-task again with the same goal, scope, and verify command reuses the existing run
- running goal-only again with the same goal and scope reuses the existing plan/checklist run
- running it with a different behavior contract stops with
needs_human instead of mixing state; contract comparison includes goal, scope, verify, metric, direction, guard, iterations, stop condition, execution policy, and codex args
- advanced fresh starts can pass
--force, which archives existing .harness-run files before creating the new run
--force refuses to archive while a background controller is still active; run stop first
Multi-Agent Mode
- Delegate only independent side work.
- Use one agent for bounded source inspection, one for log or test verification, or one for review when those paths do not overlap.
- Do not duplicate the same investigation in multiple agents.
- Merge useful findings into durable state before the next round.
Resume Discipline
- Resume from
.harness-run/state.json, .harness-run/rounds.tsv, and .harness-run/launch.json, not from conversation memory.
- Re-read the state file, latest rounds, latest logs,
docs/handoff.md, docs/run-plan.md, docs/constraints.md, and docs/project-architecture.md before changing anything.
- If evidence is missing, collect it first.
- If the harness state is inconsistent, stop as
needs_human rather than inventing a recovery path.
Boundary
harness-run makes runs resumable and can keep relaunching Codex while the Python controller and machine stay alive. It does not auto-restart after reboot, logout, or process termination. That is acceptable for this skill: after a reboot, manually start a fresh Codex session, read .harness-run/state.json, .harness-run/rounds.tsv, and .harness-run/launch.json, then continue with run-task using the same goal. It also does not prove semantic task completion by itself; completion still requires run-plan.md, completion.md, verification output, and evidence artifacts to support the final complete metric.
References
- references/runtime-loop.md: launch contract, state files, round protocol, supervisor decisions, and prompt template
- references/collaboration-protocol.md: run-local collaboration discipline and update cadence
- references/run-docs-protocol.md:
.harness-run/docs/ file roles and sync boundaries
- references/recovery-runbook.md:
needs_human, stale runtime, and recovery rules
- references/persistence-and-redaction.md: local-only files, redaction, and repo-sync safety
1---2name: harness-run3description: Persistent docs-backed harness for long Codex coding tasks that need goal-only autonomous execution, inferred planning/verification, unattended improve-verify-resume loops, durable state, run-local collaboration records, background relaunch, status/stop control, or scoped multi-agent side work. Use only for explicit long-running, overnight, resumable, or autonomous execution requests, not for ordinary one-shot help or casual Q&A.4license: MIT5---67# Harness Run89Use this skill for long-running work that must survive fresh contexts, background relaunches, or planned handoffs. Do not use it for one-shot Q&A.1011## When To Use1213- Unattended improve-verify loops14- Overnight debugging, fixing, auditing, or shipping work15- Resume from durable state after a fresh Codex session16- Background runs that should relaunch fresh `codex exec` sessions17- Scoped multi-agent inspection, verification, or review1819## What This Skill Owns2021- Persistent run control through `scripts/harness_run_ctl.py`22- Durable state under `.harness-run/`23- Run-local collaboration docs under `.harness-run/docs/`24- Per-round evidence, generated knowledge, and design notes under `.harness-run/evidence/`, `.harness-run/generated/`, and `.harness-run/design/`25- Foreground and background parity26- Resume, status, stop, and handoff behavior27- One-round-at-a-time improve-verify loops2829## User Entry3031- `run-task`: start a durable run with one natural-language goal; `--verify` is optional32- `status`: inspect the current run in human-readable form33- `stop`: stop the current run cleanly3435Normal users should not have to operate internal commands or design a full launch contract. When this skill triggers, accept a goal-only request, infer the plan, scope, metric, and verification approach from project evidence, run the helper script yourself, and report the durable state paths plus the current status. Only mention internal commands when debugging or when a fresh Codex session must reconstruct the runtime prompt manually.3637Every run initializes a mini collaboration record under `.harness-run/docs/`. This record is the run-local equivalent of a project docs system: architecture snapshot, run plan, constraints, validation pipeline, progress, decisions, handoff, completion, and sync policy. If the target repo has its own `docs/`, keep `.harness-run/docs/` as the execution layer and sync only concise summaries when the run's `sync-policy.md` allows it.3839## Launch Contract4041Only `Goal` is required from the user. Infer these fields before starting:4243- `Goal`44- `Scope`45- `Metric`46- `Direction`47- `Verify`4849Optional fields:5051- `Guard`52- `Iterations`53- `Stop condition`54- `Run mode`55- `Execution policy`5657If a field can be inferred safely, infer it. If scope is unclear, default to the current repo or current working directory and narrow it after reading evidence. If verification is unclear, do not block launch; use plan/checklist completion with concrete evidence. Ask only when continuing would likely produce work opposite to the user's intent.5859If the user explicitly says to follow a directory, plan file, roadmap, issue list, checklist, or existing project plan, treat that plan as authoritative scope and sequence. Read it, follow it, and do not renegotiate the plan unless it contradicts safety, repo instructions, or executable evidence.6061Default execution policy is `workspace_write`. Do not use `danger_full_access` unless the user explicitly requests or accepts that elevated background risk; that mode injects Codex's dangerous bypass argument into nested `codex exec` sessions.6263Default stop behavior:6465- when `direction=pass`, the run stops once verification passes66- when `direction=complete`, the run stops once the recorded metric reaches completion67- when `verify` is provided and `metric` is omitted, the verify command itself is used as the tracked metric label68- when `verify` is omitted, use `metric=planned work checklist`, `direction=complete`, `stop_condition=complete`, and record `complete` only after the inferred or user-specified plan is satisfied with evidence69- background runs default to an iteration cap of 25 when no explicit cap is provided7071## Quick Start7273Background:74751. Start with `run-task`.762. Use `status` to inspect the runtime and `stop` to end it.773. If the process stops on `needs_human`, read `.harness-run/runtime.log`, `.harness-run/state.json`, and `.harness-run/rounds.tsv` before continuing.784. Read `.harness-run/docs/handoff.md`, `.harness-run/docs/run-plan.md`, and `.harness-run/docs/constraints.md` before resuming work.7980Foreground:81821. `run-task --foreground` prepares the durable run in the current Codex session.832. Read the repo `AGENTS.md`, current source, build/test config, and recent logs.843. Measure the baseline.854. Initialize state after the baseline exists.865. Run one focused change, verify with the command or evidence checklist, and record the result.876. Update `.harness-run/docs/handoff.md` every round; update progress, decisions, constraints, and architecture only when facts change.887. Repeat from persisted state.8990Common commands:9192```bash93python <skill-root>/scripts/harness_run_ctl.py run-task --goal "<goal>"94python <skill-root>/scripts/harness_run_ctl.py run-task --foreground --goal "<goal>"95python <skill-root>/scripts/harness_run_ctl.py run-task --goal "<goal>" --verify "<command>"96python <skill-root>/scripts/harness_run_ctl.py run-task --foreground --goal "<goal>" --verify "<command>"97python <skill-root>/scripts/harness_run_ctl.py status98python <skill-root>/scripts/harness_run_ctl.py stop99```100101## Durable State102103All normal run artifacts live under:104105```text106<workspace_root>/.harness-run/107```108109Files:110111- `launch.json`: confirmed launch manifest112- `state.json`: primary recovery snapshot113- `rounds.tsv`: append-only audit trail114- `runtime.json`: background controller pid, status, and last decision115- `runtime.log`: controller and nested Codex output116- `context.json`: canonical path map for the active run117- `docs/`: run-local collaboration docs and handoff records118- `evidence/`: concise per-round evidence notes119- `generated/`: generated knowledge snapshots with source commands120- `design/`: design notes too large for the decision log121122Each managed git repo may also get a git-local pointer at:123124```bash125git rev-parse --git-path harness-run/pointer.json126```127128That pointer resolves back to the workspace-owned `context.json`.129130The run-local docs are initialized from templates in `references/templates/`. They are not a replacement for target repo docs. They are the durable execution record that lets fresh Codex sessions continue without hidden conversation state.131132Core run docs:133134- `project-architecture.md`135- `product-context.md`136- `run-plan.md`137- `constraints.md`138- `change-inventory.md`139- `validation-pipeline.md`140- `operability.md`141- `security-boundary.md`142- `sync-policy.md`143- `progress.md`144- `decisions.md`145- `handoff.md`146- `completion.md`147148## Round Rules149150- Rebuild context from source files, logs, tests, and durable state.151- Read `.harness-run/docs/constraints.md`, `run-plan.md`, `project-architecture.md`, `validation-pipeline.md`, and `handoff.md` before editing.152- Establish or refresh the baseline before mutating anything.153- If verification is unclear, create or infer an execution checklist and evidence checklist before editing.154- Make one focused change or one falsifiable diagnosis.155- Verify mechanically when a command exists; otherwise verify by concrete evidence such as file inventory, diff review, build feasibility, sample output, screenshots, generated reports, or checklist completion.156- Keep, discard, block, or mark no-op.157- Record exactly one outcome before the next round.158- For partial goal-only rounds, use `refine`, `search`, or `pivot` with `metric=incomplete`; do not use `keep` until the metric is actually `complete`.159- Update `handoff.md` every round. Update at least one progress/evidence artifact each recorded round: `progress.md`, `decisions.md`, `change-inventory.md`, `run-plan.md`, `completion.md`, or `.harness-run/evidence/round-XXXX.md`.160- Keep raw logs and secrets out of Markdown docs; summarize only redacted facts.161- Never leave the next round dependent on hidden conversation state.162163## Internal Control Plane164165The skill keeps the heavier runtime protocol in `references/runtime-loop.md` and the helper script.166167- `run-task` is the user entry. It creates or resumes the durable run and starts the background controller by default.168- `create-launch`, `launch`, `start`, `controller`, `init-state`, `record`, and `resume-prompt` are internal or advanced commands.169- The controller loop survives Codex context limits by relaunching fresh `codex exec` sessions from `.harness-run/`.170- `needs_human` means the controller stopped on a real blocker, inconsistent state, missing run artifacts, stale controller process, or stagnation, not that the user should keep waiting.171172Typical flow:1731741. Use `run-task`.1752. Check `status` if you need a progress summary.1763. Use `stop` when you want to end the run. For a prepared foreground run, `stop` clears the prepared state even when no background controller exists.1774. If a fresh Codex session must continue manually, use the internal `resume-prompt` command or read `.harness-run/state.json`.178179Repeated starts:180181- running `run-task` again with the same goal, scope, and verify command reuses the existing run182- running goal-only again with the same goal and scope reuses the existing plan/checklist run183- running it with a different behavior contract stops with `needs_human` instead of mixing state; contract comparison includes goal, scope, verify, metric, direction, guard, iterations, stop condition, execution policy, and codex args184- advanced fresh starts can pass `--force`, which archives existing `.harness-run` files before creating the new run185- `--force` refuses to archive while a background controller is still active; run `stop` first186187## Multi-Agent Mode188189- Delegate only independent side work.190- Use one agent for bounded source inspection, one for log or test verification, or one for review when those paths do not overlap.191- Do not duplicate the same investigation in multiple agents.192- Merge useful findings into durable state before the next round.193194## Resume Discipline195196- Resume from `.harness-run/state.json`, `.harness-run/rounds.tsv`, and `.harness-run/launch.json`, not from conversation memory.197- Re-read the state file, latest rounds, latest logs, `docs/handoff.md`, `docs/run-plan.md`, `docs/constraints.md`, and `docs/project-architecture.md` before changing anything.198- If evidence is missing, collect it first.199- If the harness state is inconsistent, stop as `needs_human` rather than inventing a recovery path.200201## Boundary202203`harness-run` makes runs resumable and can keep relaunching Codex while the Python controller and machine stay alive. It does not auto-restart after reboot, logout, or process termination. That is acceptable for this skill: after a reboot, manually start a fresh Codex session, read `.harness-run/state.json`, `.harness-run/rounds.tsv`, and `.harness-run/launch.json`, then continue with `run-task` using the same goal. It also does not prove semantic task completion by itself; completion still requires `run-plan.md`, `completion.md`, verification output, and evidence artifacts to support the final `complete` metric.204205## References206207- [references/runtime-loop.md](references/runtime-loop.md): launch contract, state files, round protocol, supervisor decisions, and prompt template208- [references/collaboration-protocol.md](references/collaboration-protocol.md): run-local collaboration discipline and update cadence209- [references/run-docs-protocol.md](references/run-docs-protocol.md): `.harness-run/docs/` file roles and sync boundaries210- [references/recovery-runbook.md](references/recovery-runbook.md): `needs_human`, stale runtime, and recovery rules211- [references/persistence-and-redaction.md](references/persistence-and-redaction.md): local-only files, redaction, and repo-sync safety