Examples
Real-world loops you can copy, paste, and adapt.
Copy-paste loops for common workflows. Each example is a single command; adapt the interval and the inner command to your setup.
GitHub issue autopilot
Let a coding agent work through your issue backlog, one issue at a time, every 30 minutes:
loop-task new 30m -- opencode run "take the next github issue, add the tag implementing and implement it, then create a pr and remove the tag"What happens on each run:
- The agent picks the next open issue from the repository.
- It tags the issue
implementingso parallel runs (or humans) skip it. - It implements the change and opens a pull request.
- It removes the tag, leaving the PR ready for review.
The tag acts as a simple lock: if a run is interrupted, the tag shows which issue was in flight. Requirements: opencode installed and authenticated, and gh (or the agent's GitHub access) set up in the repository.
Real-world: a self-refining backlog
The examples below are the actual loops that keep this project moving. Two chained agent pipelines run every 30 minutes, unattended, and the whole thing is monitored and paused from the board. This is loop engineering in production: async AI agents that refine and implement the GitHub backlog on a cadence, while a human just watches the board.
Pipeline 1, Refinement
Every 30 minutes, pick the next raw issue, then let an agent refine it and ask clarifying questions. The steps are chained on exit code, so the agent only runs when there is something to refine.
The trick that makes chaining work is the --jq projection {number,title,body}: it flattens the picked issue to top-level keys, which loop-task parses into the shared context so the next step can reference them as {{number}}, {{title}}, and {{body}}.
# Step 1: find the next issue that needs refining
loop-task new 30m -- gh issue list --label "refine:pick" \
--json number,title,body --jq 'sort_by(.number) | .[0] | {number,title,body}'
# Step 2 (chained on success): let the agent refine it and post questions
loop-task new 30m --on-success <step-1-id> -- \
opencode run "Refine this issue: clarify scope, list open questions, and label it ready. Issue title: {{title}} Issue body: {{body}} Issue id: {{number}}"
# On failure (nothing to refine), fall through to a no-op
loop-task new 30m --on-failure <step-1-id> -- echo "No issues to refine"A second short pipeline re-checks refined issues: it verifies the open questions were answered and reviews the owner's comments before the issue is allowed into implementation.
Pipeline 2, Implementation
Once an issue is labelled ready, a separate loop picks it up, implements it in a feature branch with an agent, commits the work, and opens the pull request, each step chained to the next.
# Step 1: grab the next ready-to-build issue
loop-task new 30m -- gh issue list --label "code:pick" \
--json number,title,body --jq 'sort_by(.number) | .[0] | {number,title,body}'
# Step 2 (on success): implement it in a feature branch, no pushes
loop-task new 30m --on-success <step-1-id> -- \
opencode run "Implement this issue in a feature branch. Plan, execute, and archive on the same branch. Issue title: {{title}} Issue body: {{body}} Issue id: {{number}}"
# Step 3 (on success): commit the implemented work
loop-task new 30m --on-success <step-2-id> -- git add -A && git commit -m "feat: implement #{{number}}"
# Step 4 (on success): open the pull request
loop-task new 30m --on-success <step-3-id> -- gh pr create --fill --head "$(git branch --show-current)"Both pipelines share one property that makes them safe to leave running: every step reacts to the previous step's exit code, so an agent never fires unless there is real work waiting. And because each loop is live on the board, you can pause implementation, watch a run's logs, or stop the whole chain with a single keypress.
More examples coming
This page is growing. If you have a loop worth sharing, open an issue on GitHub.