Your task: set up a self-perpetuating **AGENT LOOP** in the current repo, modeled after a story-driven loop pattern. ## Outcome Create the minimal files + GitHub Actions workflow so the loop can run one iteration at a time: - read state from files - choose exactly one story - implement minimal change - enforce guard constraints - commit + push - push re-triggers the workflow until no todo stories remain or PAUSED is true ## Non-negotiables - One story per run. Small commits. - Never commit if guard fails. - Keep `AGENTS.md` short (~70 lines). Only include repeated-footgun info. - Persistent memory is ONLY repo files + git commits (no hidden memory). - Prefer docs-only scaffolding first; don't add deps unless a story requires it. ## Create these files (if missing) - `AGENTS.md` - `.opencode/opencode.json` - `scripts/loop/prd.json` - `scripts/loop/progress.txt` - `scripts/loop/constraints.json` - `scripts/loop/failure.json` - `scripts/loop/guard.sh` (diff guard enforcing constraints) - `.github/workflows/loop.yml` - `README.md` (briefly explains the AGENT LOOP + how to run) ## AGENT LOOP rules (how to operate each iteration) 1) Load `AGENTS.md` and state files in `scripts/loop/` 2) If `- PAUSED: true` → exit immediately 3) In `prd.json`, pick the first story with `"status": "todo"` (or highest priority todo) 4) Mark it `"doing"` 5) Implement minimal changes to satisfy the story acceptance criteria 6) Run verification (if the story specifies commands; otherwise keep docs-only) 7) Run `bash scripts/loop/guard.sh scripts/loop/constraints.json` 8) If green: - mark story `"done"` in `prd.json` - append learnings to `progress.txt` - commit + push with a bot identity 9) If failure: - update `failure.json` (increment consecutiveFailures, store run URL + timestamp) - if failures exceed `MAX_FAILURE_RETRIES`, set `- PAUSED: true` in `AGENTS.md` - commit + push failure state so the next run can retry (unless paused) ## Initial PRD requirements Initialize `scripts/loop/prd.json` with 3-6 tiny stories: - S1: Boot the loop automation scaffold (files + workflow) - S2: Add/verify diff guard in CI - S3: Make README describe how to run (keep them small enough for one run each) ## Workflow requirements - Trigger on `workflow_dispatch` AND on pushes to `AGENTS.md` and `scripts/loop/**` - Auto-run only on bot pushes (manual dispatch always allowed) - Use a PAT secret for checkout/push (do not hardcode tokens) - Install Node + jq + OpenCode - Run exactly one agent iteration with OpenCode using: `AGENTS.md`, `prd.json`, `progress.txt`, `constraints.json`, `failure.json` - Validate JSON, run guard, then commit + push Now implement the scaffold in this repo.
Agent Loop Bootstrap
Set up a self-perpetuating AGENT LOOP with GitHub Actions, state files, and guard constraints.
Agent Loop Updated Jan 15, 2026 ~677 tokens
0.3% of 200k
How to use this prompt
- Copy the prompt using the button above
- Paste it into your preferred AI coding assistant
- Adjust any placeholders or context as needed
- Let the agent implement the changes
Related prompts
- Agent Loop Shepherd Agent Loop
Once the loop runs, use these commands to steer it through gates.
- Agent Loop Practice Agent Loop
Practice the loop by hand before you wire up GitHub Actions.
- Effect PRD Architect Agent Loop
Give the loop a PRD with constraints and gates to work toward.
- Avoid Feature Creep Product
Guard rails for the loop's backlog, so it doesn't build everything it can.
- Build Backwards Operating Docs
The thinking behind the loop: each run's output becomes the next run's input.