Skip to main content

Running with Agents

This guide walks through giving an AI coding agent — Claude Code, Codex, Cursor, or Aider — the ability to submit and monitor anycloud jobs on its own, with spend caps that contain a runaway loop.

For the surface this builds on, see Agents.

1. Install and connect a cloud account

If you haven't already:

curl -fsSL https://get.anycloud.sh | sh
anycloud setup aws # or azure / gcp / lambda

The agent will use the same credentials and CLI you do — no separate config.

2. Set per-session spend caps

Before the agent runs, cap how much it can burn. Each session gets its own cap:

anycloud throttle set 20 --agent-session       # max $20/hr per session
anycloud budget set 200 --per day --agent-session # max $200/day per session

If the agent overshoots, new submits queue with a visible reason and auto-dispatch once the cap clears (running VMs end, the calendar resets, or you raise the cap). Running jobs are never killed by a cap. See Spend Controls for the full surface.

3. Let the agent submit

In Claude Code (or Codex / Cursor / Aider), ask it to use the anycloud CLI directly. Anycloud auto-detects the agent and stamps each deployment with the session id — no extra wiring.

A useful prompt prefix:

Use anycloud submit to run jobs. Use anycloud list --json, anycloud status <id> --json, and anycloud cost <id> --json for structured output. If a submit is queued, use anycloud status <id> to read the blocked-by reason. Run anycloud docs to see what topics exist and anycloud docs --all to pull the full markdown corpus when you need product context.

4. Monitor the run

From your own shell, filter by agent or session:

anycloud list --agent claude                   # everything this agent submitted
anycloud list --session <id> --json # one session, structured
anycloud cost --json # aggregate spend

For ad-hoc questions ("which of this agent's jobs failed today?"), use db query:

anycloud db query "SELECT id, state, image FROM deployments WHERE agent='claude' AND state='Failed' AND started_at > (strftime('%s','now','-1 day') * 1000)" --json

5. Cleanup

anycloud list --only-ids --agent claude --status running | xargs anycloud terminate

Or remove the caps when you're done:

anycloud throttle unset --agent-session
anycloud budget unset --per day --agent-session