Agent Loop Docs

Dashboard

Overview

Agent Loop — Manage autonomous AI coding agents from web or CLI. Runs on Mac or VPS. Supports Claude Code, OpenAI Codex, and Cursor runtimes. Modes for development, planning, project management, and custom tasks. CodeRabbit integration for code reviews. Real-time log streaming. One-command VPS deployment.

Key Features

Quick Start

1. Clone & Install

git clone https://github.com/dekadem/agentloop
cd agentloop
npm install

2. Configure Environment

cp .env.example .env
# Edit .env with your keys

3. Run the Dashboard

# Development (auto-reload)
npm run dev

# Production
npm start

Open http://localhost:3000 — log in with the AUTH_TOKEN you set in .env.

4. Run the Agent (CLI)

# Auto-detect runtime, default prompt
./agent-loop.sh

# Specific runtime + model
./agent-loop.sh --runtime claude -m claude-opus-4.6

# Process a remote repo
./agent-loop.sh --runtime claude --repo https://github.com/user/repo

Environment Variables

VariableRequiredDescription
AUTH_TOKENYesBearer token for dashboard auth. Pick any random string.
ANTHROPIC_API_KEYYes*API key for the Claude Code CLI runtime. Starts with sk-ant-.
OPENAI_API_KEYYes*API key for the OpenAI Codex CLI runtime. Starts with sk-.
GITHUB_TOKENYesGitHub Personal Access Token with repo scope.
CODERABBIT_API_KEYNoCodeRabbit API key for pre-PR code reviews. Starts with cr-.
PORTNoDashboard server port. Default: 3000.

Web Dashboard

The dashboard is a mobile-first single-page app at the server root. It supports:

API Reference

All /api/* endpoints require authentication. Pass your token as:

Authorization: Bearer <AUTH_TOKEN>
# or query param:
?token=<AUTH_TOKEN>
GET /api/agents

List all agent instances.

Response

[{
  "id": "1",
  "pid": 12345,
  "repo": "https://github.com/user/repo",
  "model": "claude-opus-4.6",
  "runtime": "claude",
  "startedAt": "2026-02-22T10:00:00.000Z",
  "status": "running",
  "exitCode": null
}]
POST /api/agents

Start a new agent instance.

Request Body

FieldTypeRequiredDescription
repostringYesGitHub repo URL
modelstringNoModel name (default: claude-opus-4.6)
runtimestringNoclaude, codex, or cursor (default: claude)
modestringNodev, dev-custom, plan, or pm
issuestringNoSpecific issue number to work on (dev mode only)
instanceIdstringNoCustom instance ID
maxIterationsnumberNoMax iterations, 0 = unlimited
promptstringNoCustom prompt text

Response (201)

{
  "id": "1",
  "pid": 12345,
  "repo": "https://github.com/user/repo",
  "model": "claude-opus-4.6",
  "runtime": "claude",
  "status": "running"
}
DELETE /api/agents/:id

Stop a running agent. Kills the entire process group.

Response

{ "id": "1", "status": "stopped" }
GET /api/agents/:id/logs

Retrieve agent log files.

Query ParamDescription
fileOptional. Return a specific log file by name.

Without file, returns the 20 most recent log files and the content of the latest one.

GET /api/agents/:id/logs/stream

Server-Sent Events stream of the latest log file. Events:

EventData
log{ text, file } — new log content
status{ status, pid } — agent status
heartbeatStatus update (every 2 s)
GET /api/repos

List GitHub repos accessible to the authenticated user.

Response

[{ "nameWithOwner": "user/repo", "url": "https://github.com/user/repo" }]
GET /api/repos/issues?repo=URL

List open issues for a repo, excluding WIP/DONE/NEEDS_HUMAN labels.

Response

[{ "number": 5, "title": "Fix login bug" }]
GET /api/settings

Get current environment variables (values masked).

GET /api/settings/status

Validate API keys against their respective services. Returns { ok, message } per key.

PUT /api/settings

Update environment variables. Values containing •••• are ignored (keeps existing). The service auto-restarts after saving.

GET /api/dashboard

Collects status.md dashboards from all known repos in .repos/.

CLI Options

./agent-loop.sh [options]
FlagDefaultDescription
--runtime <rt>autoRuntime: claude, codex, copilot, cursor, or auto
--repo <url>GitHub repo URL to clone (server use)
--id <id>autoInstance ID (lock-file based)
-n <count>0Max iterations (0 = unlimited)
-m <model>per runtimeModel to use
-p <file>prompt.txtPrompt file path
-d <seconds>60Delay between iterations
-t <seconds>2700Timeout per agent run (45 min)
--max-failures <n>3Max consecutive failures before stopping
--webhook <url>Slack/Discord webhook URL
--dry-runPrint the command without executing
-h, --helpShow help

Examples

# Desktop with Cursor
./agent-loop.sh --runtime cursor -m claude-4.6-opus

# Server, 5 iterations, custom prompt
./agent-loop.sh --runtime claude --repo https://github.com/user/repo \
  -n 5 -p prompts/prompt_qa.txt

# Second parallel instance with webhook
./agent-loop.sh --id 2 --webhook https://hooks.slack.com/services/XXX

Runtimes

RuntimeCLIDefault ModelUse Case
claudeclaudeclaude-opus-4Server or desktop. Uses ANTHROPIC_API_KEY. Default from dashboard.
codexcodexgpt-5.2-codexServer or desktop. Uses OPENAI_API_KEY.
copilotcopilotgpt-5.2-codexServer or desktop. Uses GitHub Copilot subscription via gh. Multi-model.
cursorcursorautoDesktop only. Uses Cursor subscription.
autoAuto-detectTries cursor first, falls back to claude.

Prompt System

Prompts define what the agent does each iteration. They live in the prompts/ directory and are plain text files passed to the AI runtime.

FileRoleDescription
prompt.txt Developer Default. Picks the highest-priority GitHub issue, implements a fix, runs CodeRabbit review, creates a PR, waits for CI, addresses review comments, and labels the issue DONE.
prompt_custom_task.txt Developer (custom) Template for custom tasks. Wraps the user's task description with the PR/CI/review workflow. Used by the "Developer (custom task)" mode.
prompt_productplanner.txt Product Planner Browses the codebase and goal.md, identifies improvements, and creates new GitHub issues.
prompt_projectmanager.txt Project Manager Reviews open issues, assigns priority labels, and closes non-applicable issues.
prompt_qa.txt QA Tester Opens the PR preview URL, performs UI tests, and reports results as a PR comment.

Default Workflow (prompt.txt)

  1. Pick issue — lists open issues excluding WIP/DONE/NEEDS_HUMAN; prioritises by label then age (or uses a specific issue if selected)
  2. Implement — fetches full issue with comments, labels WIP, creates a plan, writes code
  3. Pre-review — runs CodeRabbit on uncommitted changes, fixes critical findings
  4. Open PR — runs tools/create-pr.sh --issue N
  5. Wait for CIgh pr checks --watch; labels NEEDS_HUMAN on failure
  6. Address reviews — fetches review comments, pushes fixes, re-checks CI
  7. Done — labels DONE, removes WIP

Dashboard Modes

ModeDescription
DeveloperAuto-selects or uses a specific issue, runs the full dev workflow
Developer (custom task)User describes the task, agent implements it with PR/CI/review workflow
PlanBrowses codebase, creates new GitHub issues for improvements
Project ManagerReviews issues, assigns priority labels, closes irrelevant ones

tools/create-pr.sh

Creates a branch, commits staged changes, pushes, and opens a GitHub PR.

./tools/create-pr.sh [options] <branch> <commit-msg> [pr-title] [base-branch]
OptionDescription
--issue <N>Link PR to GitHub issue (adds "Closes #N")
--auto-mergeEnable squash auto-merge after creation

tools/setup-branch-protection.sh

Configures a GitHub repo for safe auto-merge:

./tools/setup-branch-protection.sh [owner/repo]

tools/pr-review-comments.sh

Fetches and formats PR review comments (top-level reviews + inline file comments). Requires jq.

./tools/pr-review-comments.sh [pr-number]

Deployment

One-command Linode deploy

python3 deploy-linode.py \
  --linode-token YOUR_LINODE_API_TOKEN \
  --anthropic-key sk-ant-... \
  --github-token ghp_... \
  --repo https://github.com/user/repo

Creates a Nanode ($5/mo), installs everything, starts the dashboard. Optional: --region, --coderabbit-key.

Update production

./update-production.sh root@YOUR_SERVER_IP

Manual setup (any Ubuntu/Debian VPS)

sudo ./setup-server.sh

What it installs

  1. Node.js 22 — from NodeSource
  2. Git and GitHub CLI (gh)
  3. Claude Code CLI, OpenAI Codex CLI
  4. CodeRabbit CLI
  5. Caddy — reverse proxy with automatic HTTPS

What it configures

API keys via UI After deployment, you can manage all API keys from the Settings page in the dashboard — no SSH needed.

Architecture

                       ┌─────────────────────────────────┐
                       │         Your Phone / Browser     │
                       └────────────────┬────────────────-┘
                                        │ HTTPS
                       ┌────────────────▼─────────────────┐
                       │        Caddy (reverse proxy)      │
                       └────────────────┬─────────────────-┘
                                        │ :3000
                 ┌──────────────────────▼──────────────────────┐
                 │             Hono Server (Node.js)            │
                 │  ┌──────────┐  ┌──────────┐  ┌───────────┐  │
                 │  │ REST API │  │ SSE Logs │  │ Static UI │  │
                 │  └────┬─────┘  └────┬─────┘  └───────────┘  │
                 └───────┼─────────────┼───────────────────────-┘
                         │  spawn      │  read
               ┌─────────▼─────────┐   │
               │   agent-loop.sh   │   │
               │  ┌──────────────┐ │   │
               │  │ Claude Code  │ │   │
               │  │ Codex/Cursor │ │   │
               │  └──────┬───────┘ │   │
               │         │ gh CLI  │   │
               └─────────┼────────-┘   │
                         │             │
          ┌──────────────▼──┐   ┌──────▼───────┐
          │  GitHub (repos, │   │  Log files   │
          │  issues, PRs)   │   │  (.repos/)   │
          └─────────────────┘   └──────────────┘

Directory Structure

agentloop/
├── server/
│   ├── index.ts              # Hono API server
│   └── public/
│       ├── index.html        # Dashboard UI
│       └── docs.html         # This documentation
├── prompts/
│   ├── prompt.txt            # Default developer prompt
│   ├── prompt_custom_task.txt # Custom task template
│   ├── prompt_productplanner.txt
│   ├── prompt_projectmanager.txt
│   └── prompt_qa.txt
├── tools/
│   ├── create-pr.sh          # PR creation + auto-merge
│   ├── setup-branch-protection.sh
│   └── pr-review-comments.sh
├── lib/
│   └── common.sh             # Shared shell utilities
├── agent-loop.sh             # Main orchestration script
├── setup-server.sh           # VPS provisioning
├── deploy-linode.py          # One-command Linode deploy
├── update-production.sh      # Update production server
├── Caddyfile                 # Reverse proxy config
├── .env.example              # Environment template
├── package.json              # Node.js dependencies
└── .repos/                   # Cloned repos (runtime)
    └── <owner>/<repo>/
        ├── logs/agent/       # Agent logs + status
        └── .worktrees/       # Git worktrees per worker