Agent loops
how to set up your first ai agent loop
TL;DR
An agent loop is one agent that runs your workspace: it picks up work, creates a pane per feature, opens review and QA tabs in it, checks their output, answers their prompts and tells you what needs review. Pane gives that agent what it needs through the runpane CLI: saved repos, worktree-backed panes, terminals it can drive, an event stream, and short output reads that don't flood its context. It works with Codex, Claude Code, Aider, Goose or any CLI, on Windows, WSL, macOS and Linux. This page has a first-loop recipe and a starter prompt.
Instead of babysitting terminals, you have one agent that manages the workspace. It picks up work, creates a pane per feature, opens review and QA tabs in it, checks their output, sends follow-up input and tells you what needs review. Pane makes that work with any agent, on any OS.
Any agent
Codex, Claude Code, Aider, Goose, OpenCode or any terminal CLI.
Any OS
Windows, WSL, macOS, Linux, VMs and remote hosts.
Open source
AGPL-3.0. The app, CLI and orchestrator skills are all public.
The shape of a loop
Not a magic prompt: a small operating cycle of inspect, spawn, drive, watch, validate, report.
| Step | What the agent does | What Pane gives it |
|---|---|---|
| Inspect | Read issues, pull requests, CI or repo state | Saved repositories and existing panes |
| Spawn | Create a pane for each feature and tabs for its reviews and QA | Worktree-backed panes and agent tabs |
| Drive | Start agents, answer prompts, send input | Terminal-backed panels |
| Watch | Wake up when an agent finishes or gets stuck | An event stream: ready, blocked, stuck |
| Validate | Read recent output before claiming success | Short, limited terminal reads |
| Report | Summarize what needs human review | Visible panes, diffs, branches and statuses |
First loop recipe
Install, discover, add the repo, create a pane per feature, check, continue.
1Install or update Pane
Use the package-manager path so you and your agents rely on the samerunpanecommand. Inside Pane's own terminals, runpane is already on the PATH.npx --yes runpane@latest pnpm dlx runpane@latest pipx run runpane2Let the agent find Pane
Have the agent check what commands exist. The summary is short by default; full details for one command load only when needed.curl -fsSL https://runpane.com/runpane-cli-contract.json runpane doctor --json runpane agent-context --json runpane agent-context --command "panes create" --json3Add the repo if needed
Don't assume Pane knows the repo. Check, then add it if it's missing.runpane repos list --json runpane repos add --path "$PWD" --yes --json runpane agents doctor --agent codex --repo active --json4One pane per feature
1 feature = 1 worktree = 1 branch = 1 Pane; reviews, audits, fixes and QA for it are tabs in that Pane. A pane is a git worktree, and creating one installs dependencies and often builds, so create one only when the work's branch has no pane yet. To find the pane for a PR, get its head branch, then check each pane'sworktreePathfrompanes list:gh pr view <number> --json headRefName runpane panes list --repo active --json git -C <worktreePath> branch --show-currentIf no pane owns the branch, create one. Use a built-in agent or pass any terminal command.
runpane panes create \ --repo active \ --name "issue-51-login" \ --agent codex \ --prompt "Implement issue #51. Open a PR when checks pass." \ --source agent \ --wait-ready \ --yes \ --jsonEvery later agent for that feature opens as a new tab in its pane. Tabs share one checkout: only the implementer moves HEAD, and review, audit and QA tabs never run
git checkout,resetorstash.runpane panels create \ --pane <pane-id> \ --agent codex \ --initial-input "Review the PR from this branch. Run checks, summarize findings, and stop before merging." \ --source agent \ --no-focus \ --wait-ready \ --yes \ --json5Check what actually happened
After creating a pane or tab, or sending input, verify it.screenshows what's on screen now;outputgives scrollback;watchstreams ready, blocked and stuck events so the loop wakes only when needed.runpane panes list --repo active --json runpane panels wait --panel <panel-id> --for ready --timeout-ms 30000 --json runpane panels screen --panel <panel-id> --limit 80 --json runpane panels output --panel <panel-id> --limit 200 --json runpane watch --follow --json6Answer prompts and continue
Usepanels submitfor ordinary follow-ups,panels submit-composerfor Codex or Claude composer boxes, andpanels inputonly for exact bytes such as Ctrl-C.runpane panels submit --panel <panel-id> --text "Continue with the review pass." --yes --json runpane panels submit-composer --panel <panel-id> --strategy auto --yes --json printf '\003' | runpane panels input --panel <panel-id> --input-file - --yes --json runpane panels wait --panel <panel-id> --for idle --timeout-ms 300000 --json
A starter prompt for your orchestrator
Give any shell-capable agent this prompt and it becomes your loop runner.
Give this to Codex, Claude Code or any agent that can run shell commands:
You are running an agent loop for this repo.
Every cycle:
1. Inspect GitHub issues and PRs that need action.
2. Fetch the public contract if needed, then run runpane doctor --json and runpane agent-context.
3. Make sure this repository is saved in Pane and the requested agent is runnable.
4. 1 feature = 1 worktree = 1 branch = 1 Pane; reviews, audits, fixes and QA for it are tabs in that Pane. Create a Pane only when the work's branch has no Pane yet. Find an existing Pane with runpane panes list --repo <repo> --json by matching the PR's head branch against git -C <worktreePath> branch --show-current.
5. Start the right terminal agent with a clear initial prompt. For a new Pane use runpane panes create --source agent --wait-ready. For a tab use runpane panels create --pane <id> --agent <agent> --initial-input "<prompt>" --source agent --no-focus --wait-ready --yes --json. Tabs share one checkout: only the implementer moves HEAD, and review, audit and QA tabs never git checkout, reset or stash.
6. Use panels wait and panels screen before claiming a pane or tab started correctly.
7. Send follow-up input with panels submit or submit-composer; use panels input only for exact bytes.
8. Report the panes and tabs created, what each is doing, and what needs human review.
Keep output brief. Do not merge without explicit human approval.Or use a built-in loop
Pane Chat and Sessions are loop agents that ship with Pane.
If you don't want to set up your own runner, use Pane's. Pane Chat is a chat with Claude Code, Codex or Cursor that already knows the runpane commands and the orchestrator skill. Sessions are named, persistent versions with their own workspace. Both stop and ask before merging or deploying. Ask for unattended mode to let them resume a pane whose turn died from a sleep or network error.
Windows and WSL
From inside WSL, reach the Windows Pane through PowerShell.
Pane can run as a Windows app while your loop agent lives inside WSL. A Linux shell may not see the Windows Pane directly, so call runpane through PowerShell and pick the saved repo by name or id:
powershell.exe -NoProfile -Command \
'Set-Location $env:TEMP; runpane repos list --json'
powershell.exe -NoProfile -Command \
'Set-Location $env:TEMP; runpane panes create --repo "Pane" --name "loop-smoke" --agent codex --prompt "Say hello from this loop and wait." --source agent --wait-ready --yes --json'Pane handles the workspace, not the world
Your agent still uses GitHub, MCP and trackers directly.
Pane gives your loop the workspace commands. Your agent still uses the GitHub CLI, MCP servers, Linear, Jira or anything else for the outside world, so you're not locked into one model, editor or host.
来源
- 勘误
- 如果这里有任何错误或过时的内容,请告诉我们,我们会修正并更新顶部的日期。 在 GitHub 上提交 issue
- 来源
常见问题
作者 Parsa Khazaeepoul,Pane 联合创始人。 .