YAML config, durable state, task-file mode, presets/history, pause/resume, and stats for OpenCode, Codex, Claude, and more.
Docs: GitHub Pages Β· docs/index.md
By: Diego Marinho Β· LinkedIn
ailoop is a small CLI for repeatable AI terminal loops with durable state, task-file mode, pause/resume controls, and machine-friendly output.
It is built for people who want a simple way to run AI terminal tools like OpenCode, Codex, and Claude Code in safe repeatable loops instead of brittle one-off shell snippets.
Most AI terminal workflows start as a quick while true loop, then grow messy fast.
ailoop gives you:
- β repeatable loop runs
- β YAML config + CLI overrides
- β durable local state
- β pause / resume / stop controls
- β strict Markdown task-file mode
- β saved presets + replayable history
- β workspace-aware TUI follow-ups + prompt history
- β stats, logs, and tail commands
- β JSON output for automation
Install:
uv syncRun from this repo:
uv run ailoop init-config
uv run ailoop run "Do exactly 3 iterations." --steps 3Or download the wheel from the latest GitHub release, then install it:
pipx install ./ai_loop-*-py3-none-any.whl
ailoop --helpStart:
ailoop init-config
ailoop run "Review the repo and iterate for 3 steps." --runner opencode --agent orchestrator --steps 3
ailoop run "Work this repo." --workspace-root . --steps 3
ailoop run "Do exactly 5 iterations." --steps 5Task file mode:
ailoop init-task-file ./loop_tasks.md
ailoop check-task-file ./loop_tasks.md
ailoop run "Work the task list." --runner opencode --agent orchestrator --task-file ./loop_tasks.md --until-tasks-completeWatch:
ailoop ps
ailoop list --active
ailoop tail <loop-id>
ailoop --json psControl:
ailoop pause <loop-id>
ailoop resume <loop-id>
ailoop stop <loop-id>Inspect:
ailoop status <loop-id>
ailoop stats <loop-id>
ailoop logs <loop-id>
ailoop --json status <loop-id>Presets + replay:
ailoop memory save "Quick review" "Review the repo." --runner opencode --agent orchestrator
ailoop memory list
ailoop memory show <memory-id>
ailoop replay <memory-id>Generate a valid task file:
ailoop task-template
ailoop task-template --with-rules
ailoop init-task-file ./loop_tasks.md
ailoop check-task-file ./loop_tasks.md
ailoop --json check-task-file ./loop_tasks.mdFormat:
# Loop Tasks
## To do
- [ ] First task
## Doing
- None
## Done
- NoneRules:
- use only
To do,Doing,Done To do: only- [ ] taskor- NoneDoing: only- [ ] taskor- NoneDone: only- [x] taskor- None- keep max 1 task in
Doing - move task
To do -> Doingwhen start - move task
Doing -> Doneand mark[x]when done
Exit codes:
0: valid and done10: valid but still open (--state-exit-code)1: invalid file
Core:
ailoop run "Prompt"
ailoop resume <loop-id>
ailoop pause <loop-id>
ailoop stop <loop-id>
ailoop replay <memory-id>Memory:
ailoop memory save "Title" "Prompt"
ailoop memory save "Recent run" "Prompt" --kind history
ailoop memory list --kind preset
ailoop memory show <memory-id>
ailoop memory edit <memory-id> --title "New title"
ailoop memory favorite <memory-id>
ailoop memory delete <memory-id>Watch + inspect:
ailoop ps
ailoop tui
ailoop tui --tmux
ailoop list --active
ailoop status <loop-id>
ailoop stats <loop-id>
ailoop logs <loop-id>
ailoop tail <loop-id>TUI follow-up workflow:
- set Root directory to the repo/workspace you want to run
- type the base prompt in AI LOOP CONFIG and start or continue the loop
- press
Ctrl+Lto search persisted loop IDs, states, modes, runners, agents, prompts, workspaces, and task files - press
Enterto open a search result;Escclears the focused loop search - combine search with
grunning,aactive, orlall without changing the selected loop or unsaved form edits - type a one-shot instruction in Follow-up for next iteration and queue it with the button or
Ctrl+Enter - use
Shift+Nfor one unchanged next iteration andCtrl+J/Ctrl+Kto switch loops Ctrl+J/Ctrl+Kleave an editor on the first press, then switch visible loops without changing editor text- the
6 historypanel now shows recent workspace prompt/follow-up/result history plus loop iteration history
TUI memory smoke:
bash ./scripts/tui_memory_smoke.sh
tmux attach -t ailoop-tui-smokeTask files:
ailoop init-task-file ./loop_tasks.md
ailoop check-task-file ./loop_tasks.md
ailoop check-task-file ./loop_tasks.md --state-exit-codeJSON + output modes:
ailoop --json ps
ailoop --json status <loop-id>
ailoop --json logs <loop-id>
ailoop --quiet check-task-file ./loop_tasks.md
ailoop --verbose check-task-file ./loop_tasks.md
ailoop --color always status <loop-id>Default config path:
~/.config/ailoop/config.yaml
Example:
default_runner: opencode
default_agent: orchestrator
paths:
agent_file: ~/Codes/Projects/agents_md/AGENTS.md
state_dir: ~/.config/ailoop/state
prompt:
pre_prompt_enabled: true
attach_agent_file: true
pre_prompt: |
Work in small validated slices.
Review current context before starting new work.
Leave concise progress, blockers, and next action at the end.
loop:
steps: null
pause_seconds: 30
continue_on_error: true
retry_count: 0
runners:
opencode:
command: opencode
args: ["run", "--agent", "{agent}", "{prompt}"]
codex:
command: codex
args: ["{prompt}"]
claude:
command: claude
args: ["{prompt}"]Each iteration prompt is assembled in this order:
- pre-prompt if enabled
- agent file contents if enabled
- user prompt
- loop context block with iteration and previous result summary
Prompt and run logs are stored under the loop log directory for inspection.
If ailoop saves you time, you can support ongoing maintenance and future releases here:
By Diego Marinho:
- GitHub: Diego Marinho
- LinkedIn: Diego Marinho
More: docs/support.md
MIT