Minimal shell-based harness for long-running coding agents on existing repositories.
This repo is inspired by Anthropic's "Effective harnesses for long-running agents" idea, but kept intentionally small:
- state lives inside the target repo under
.autonomous/ FEATURES.jsonis the durable source of truth- each coding session works on one unfinished feature
scripts/run.shloops until all features pass or the run stalls- if
.autonomous/FEATURES.jsonalready exists, the harness skips initialization automatically
Recommended usage is now scaffold mode:
- treat this repo as a scaffold template
- copy it into an existing repo as
./.autonomous-harness/ - run the harness from inside that existing repo
In an existing project, you should usually only need to tell another AI:
Use https://github.com/xiang-lee/autonomous-harness.
Read its README and apply the scaffold workflow in this repository.
Do not implement product features yet. Stop after creating `.autonomous-harness/`, `.autonomous/`, and `.autonomous/FEATURES.json` so I can review.
This README is intentionally written so an AI can follow it directly.
If you are an AI reading this README while working inside another existing repository, do this in the current repository:
- Copy this harness into
./.autonomous-harness/. - Copy or recreate:
AGENTS.mdFOR_AI.mdprompts/scripts/templates/
- Create:
.autonomous/PROJECT_SPEC.md.autonomous/FEATURES.json.autonomous/PROGRESS.md.autonomous/init.sh.autonomous/config.json
- Analyze the existing codebase before writing those files.
- Do not rebuild the app from scratch.
- Do not implement product features yet unless the human explicitly asks you to continue.
- Create 15-40 prioritized, verifiable features.
- Every feature must start with
"passes": false. - After the human reviews the feature list, continue by running
./.autonomous-harness/scripts/run.shfrom the current repository. - If
codex,kiro-cli, oropencodeis installed,run.shauto-detects it. Otherwise use--providerorHARNESS_AI_COMMAND.
bashgitjqorpython3- a coding AI CLI that can run non-interactively in a target repo
Current local repo state:
- shell harness created
- prompts and
.autonomous/templates created - provider scripts included for
custom,codex,kiro-cli, andopencode - install script included for scaffold mode
- local git repo initialized and published
autonomous-harness/
├── AGENTS.md
├── FOR_AI.md
├── docs/
│ └── existing-project.md
├── prompts/
│ ├── coding.md
│ └── initializer.md
├── scripts/
│ ├── providers/
│ │ ├── codex.sh
│ │ ├── custom.sh
│ │ ├── kiro-cli.sh
│ │ └── opencode.sh
│ ├── install-into-target.sh
│ └── run.sh
└── templates/
└── .autonomous/
├── FEATURES.json
├── PROJECT_SPEC.md
├── PROGRESS.md
├── config.example.json
└── init.sh
Preferred flow:
- In your existing project, ask an AI to read this repo and copy the scaffold into
./.autonomous-harness/. - In that same existing project, ask the AI to create
.autonomous/using the copied template files. - Review
.autonomous/FEATURES.json. - Run the vendored harness from inside the existing project.
Example AI instruction:
Read this repository and use it as a scaffold:
https://github.com/xiang-lee/autonomous-harness
In the current repository:
1. Copy this harness into `./.autonomous-harness/`.
Copy or recreate:
- `AGENTS.md`
- `FOR_AI.md`
- `prompts/`
- `scripts/`
- `templates/`
2. Create `.autonomous/PROJECT_SPEC.md`, `.autonomous/FEATURES.json`, `.autonomous/PROGRESS.md`, `.autonomous/init.sh`, and `.autonomous/config.json`.
3. Do not implement product features yet.
4. Create 15-40 prioritized, verifiable features.
5. Every feature must start with `"passes": false`.
Then, if you want a second AI step before implementation, use the local scaffold rather than the GitHub link:
Use the copied scaffold in `./.autonomous-harness/` as the workflow standard.
In this repository, create:
- `.autonomous/PROJECT_SPEC.md`
- `.autonomous/FEATURES.json`
- `.autonomous/PROGRESS.md`
- `.autonomous/init.sh`
- `.autonomous/config.json`
Rules:
- Do not implement product features yet.
- Analyze the existing codebase first.
- Create 15-40 prioritized, verifiable features.
- Every feature must start with `"passes": false`.
Then run the harness directly inside the target repo:
cd /absolute/path/to/existing-project
./.autonomous-harness/scripts/run.shBecause the harness is installed as ./.autonomous-harness/, run.sh automatically uses the parent repo as the target.
If codex, kiro-cli, or opencode is available, it auto-selects the matching provider.
If you want to copy the scaffold yourself instead of asking an AI to do it:
cd /absolute/path/to/autonomous-harness
./scripts/install-into-target.sh --target "/absolute/path/to/existing-project"After that:
cd /absolute/path/to/existing-project
./.autonomous-harness/scripts/run.sh- In your existing project, ask an AI to read this repo and create
.autonomous/using the template files as examples. - Review
.autonomous/FEATURES.json. - Configure the provider command.
- Run the harness once. It will keep going feature-by-feature.
Full step-by-step guide: docs/existing-project.md
Example prompt for the planning step:
Use this repository as the workflow standard:
<autonomous-harness repo link>
In this repository, create `.autonomous/` with:
- `.autonomous/PROJECT_SPEC.md`
- `.autonomous/FEATURES.json`
- `.autonomous/PROGRESS.md`
- `.autonomous/init.sh`
- `.autonomous/config.json`
Rules:
- Do not implement product features yet.
- Create 15-40 prioritized, verifiable feature entries.
- Every feature must start with "passes": false.
- Use the JSON structure shown in the harness template.
Then start the loop from the central harness checkout:
export HARNESS_AI_COMMAND='your-ai-cli --cwd "{{TARGET}}" --prompt-file "{{PROMPT_FILE}}"'
./scripts/run.sh --target "/absolute/path/to/existing-project"If the target repo does not have .autonomous/FEATURES.json yet, you can let the harness create it first:
export HARNESS_AI_COMMAND='your-ai-cli --cwd "{{TARGET}}" --prompt-file "{{PROMPT_FILE}}"'
./scripts/run.sh \
--target "/absolute/path/to/existing-project" \
--goal "Implement feature A, feature B, and feature C incrementally"Behavior:
- valid
FEATURES.jsonexists -> start coding loop immediately - missing or empty
FEATURES.json+--goal-> run initializer once, then start coding loop - missing or empty
FEATURES.jsonwithout--goal-> stop and tell you to seed the target repo first
If you do not pass --provider, run.sh auto-detects providers in this order:
codexkiro-cliopencodecustom.shwhenHARNESS_AI_COMMANDis set
The explicit fallback provider is scripts/providers/custom.sh.
It reads HARNESS_AI_COMMAND, substitutes placeholders, then executes it.
Supported placeholders:
{{TARGET}}{{PROMPT_FILE}}{{SESSION_KIND}}{{SESSION_NUM}}
Example:
export HARNESS_AI_COMMAND='your-ai-cli --cwd "{{TARGET}}" --prompt-file "{{PROMPT_FILE}}"'If your CLI reads prompts from stdin instead of a file, you can still use the same hook:
export HARNESS_AI_COMMAND='sh -lc '\''cd "{{TARGET}}" && your-ai-cli < "{{PROMPT_FILE}}"'\''' You can also pass a custom provider script:
./scripts/run.sh --target "/path/to/repo" --provider "/path/to/provider.sh"Included providers:
scripts/providers/custom.shscripts/providers/codex.shscripts/providers/kiro-cli.shscripts/providers/opencode.sh
Based on OpenAI Codex CLI non-interactive mode with codex exec.
./scripts/run.sh \
--target "/absolute/path/to/existing-project" \
--provider "./scripts/providers/codex.sh"Optional env:
export CODEX_BIN=codex
export CODEX_MODEL=gpt-5-codex
export CODEX_APPROVAL=never
export CODEX_SANDBOX=workspace-writeBased on kiro-cli chat --no-interactive.
./scripts/run.sh \
--target "/absolute/path/to/existing-project" \
--provider "./scripts/providers/kiro-cli.sh"Optional env:
export KIRO_BIN=kiro-cli
export KIRO_AGENT=
export KIRO_TRUST_MODE=allBased on opencode run with stdin prompt input.
./scripts/run.sh \
--target "/absolute/path/to/existing-project" \
--provider "./scripts/providers/opencode.sh"Optional env:
export OPENCODE_BIN=opencode
export OPENCODE_MODEL=
export OPENCODE_AGENT=
export OPENCODE_VARIANT=Short version:
- Open your existing repo on a branch.
- Ask an AI to copy this repo into
./.autonomous-harness/in that repo. - Ask the AI to create
.autonomous/using the copied harness. - Review
.autonomous/FEATURES.json. - Usually just run
./.autonomous-harness/scripts/run.shonce. - If you need a specific CLI, pass
--provider ...explicitly. - Let it continue until all features pass or the run stalls.
- Pause with
Ctrl+C, resume with the same command.
Detailed walkthrough: docs/existing-project.md
For every coding session, the prompt instructs the agent to:
- read
.autonomous/PROJECT_SPEC.md - read
.autonomous/FEATURES.json - read
.autonomous/PROGRESS.md - read
.autonomous/config.jsonif present - read recent git history
- run
.autonomous/init.sh - verify one already-completed core feature
- implement exactly one unfinished highest-priority feature
- validate it through the strongest available path
- update only the relevant
passesfield - update
.autonomous/PROGRESS.md - commit the work in a clean state
- Stop the loop with
Ctrl+C - Resume later with the same command
Because progress lives in the target repo, the harness can continue from where it left off.
- Start from a dedicated git branch in the target repo.
- Review the generated feature list before long runs when possible.
- Browser automation is ideal for web apps, but the prompts also allow fallback validation if your AI runtime does not expose browser tools.