Skip to content
FunCoding

agentrun-cli

Onboard and manage AgentRun agents from a shell. Connect existing Claude Code or Codex setups locally or remotely, import selected history, or create a new agent. Start runs, inspect results and use checked learning. Use when asked to connect, run or manage AgentRun agents from a terminal or script, or for anything the server's MCP tools do not cover (files, triggers, webhooks, revisions, learning).

Star
1,286
License
Apache-2.0
Last commit
Dec 1, 2026

packages/agentrun/skills/agentrun-cli/SKILL.md

View on GitHub

AgentRun CLI

agentrun drives an AgentRun server (the open platform's server for agents) through its API. It is the command npm install -g @parcha/agentrun puts on the PATH; without it, write npx @parcha/agentrun in its place. Each command prints the server's JSON answer on stdout, one line when piped, and an error's JSON on stderr. agentrun help lists the commands, agentrun GROUP COMMAND --help gives one's flags, and references/commands.md has every command with its flags and route.

A list command (agentrun agents list, agentrun runs list and the others with --cursor) prints one page, with the next_cursor to pass as --cursor for the next; --all reads every page and prints them as one list, its next_cursor null.

Choose the onboarding path

For general setup, first establish whether the user wants to start a new agent or bring an existing Claude Code/Codex setup. Ask only when intent is missing: Build an agent already chose new; Connect agent already chose existing. Reuse the named instance and read its matching /skills/agentrun-serve/SKILL.md; do not start a replacement. A new agent starts from a suitable template or custom definition after clarifying its job, inputs and expected result. Inspect configured models before asking for a key. Existing-agent connection and selected history import need no destination model key; live jobs use the source runtime's existing sign-in. Finish with the first requested run's result and console link, or the imported history and counts; offer self-improvement separately.

The server and the token

The first of these that is set wins:

  1. --base-url URL (the API, ending /v2), else AGENTRUN_BASE_URL, with the token in AGENTRUN_API_KEY.
  2. The config file $XDG_CONFIG_HOME/agentrun/config.json (else ~/.config/agentrun/config.json), written by agentrun login, which checks the token first. The CLI refuses the file if anyone else can read it.
  3. The server started on this machine with npx @parcha/agentrun, whose data directory (~/.agentrun, or --data DIR) says where it listens and holds its token: nothing to set.

The token goes on stdin, never on the command line:

agentrun login --base-url "$AGENTRUN_BASE_URL" < token.txt

Never print, echo or log the token, and never pass it as an argument; the CLI never prints it. agentrun logout removes the config file. Keys and other secrets are set in the console, signed in: the token can't write one, so no command does (agentrun tool-keys list names the keys and fields, and whether each is set, never a value).

Connect agent

First clarify whether the user wants a live connection, historical import, or both; then establish the source machine, destination instance and selected project/agent/profile. Do not infer history import or learning consent from a connection request. Read the target server's matching /skills/agentrun-serve/SKILL.md for the complete flow.

On the machine with the existing Claude Code or Codex setup, use npx @parcha/agentrun native discover --project /absolute/project to inspect supported project defaults, named Claude agents and Codex profiles without a model call. Then run npx @parcha/agentrun native connect --project /absolute/project --runtime claude-code (or codex), adding --agent NAME or --profile NAME for a discovered selector. The local server uses --data DIR; --url http://127.0.0.1:PORT selects its loopback address. For another machine, use the Python connector's agentrun-connector remote command from the same reviewed build, with the matching agentrun-serve remote-bridge runtime. Pair using the console's one-use code entered into the secure CLI prompt; never send a broad server token or put the code in a command argument. Source configuration and sign-in stay on that machine. For completed project history, preview with the matching connector’s agentrun-connector remote history-preview --project /absolute/project --runtime claude-code (or codex). Select History only or Both when creating the owner’s code; the source must also explicitly pass --history-only or --history to remote connect. History-only starts no worker or learning and needs no native sign-in. History flags reject named-agent/profile selectors because native logs cannot attribute sessions to them reliably. Re-import the approved target with agentrun-connector remote import-history --state-dir /private/connector; duplicates are skipped. Historical records never become live jobs or automatic learning. Local-store imports still use the separate maintenance-window flow in the server skill.

For an authorized live connection, open the connected agent, verify its native sign-in, and turn Self-improving On only when requested to use the existing checked learning pipeline. Native projects keep their original instructions, tools, hooks, permissions and login. AgentRun adds the owner's corrections (corrections.md) to the run's context without rewriting those files. Native dollar caps, interactive approvals, learned workflows and attachment to an already-running desktop conversation are unavailable; never bypass native permissions to make a run work. Off supplies and creates no AgentRun learning on subsequent runs. The end-of-run step makes additional model calls using native sign-in.

The Python connector is the PyPI package parcha-agentrun-connector (pipx install parcha-agentrun-connector or uv tool install parcha-agentrun-connector); its command is agentrun-connector (or python -m agentrun_connector), separate from this CLI's agentrun. The PyPI package agentrun-cli is a different company's product, not this project. Until the connector is on PyPI, and always for remote execution, install it from the same reviewed checkout as the server after building its Node runtime (Python 3.12+ and Node 24.22.3+): uv tool install ./connector. A checkout build does not put agentrun-serve on PATH: pass --bridge /absolute/path/to/checkout/packages/serve/dist/native/remote-worker-bridge.js to discovery and connection. Keep its source worker online for live jobs. Inspect the corrections in Learning Dojo, then verify a fresh run uses them; imported history never supplies that learning automatically.

Recipes

Run them in order, in one working directory: each writes out.json, the run as its command printed it, and the next reads it. The last line of each block says how its last command exits.

1. Make an agent from a definition file

cat > agent.json <<'EOF'
{"definition": {"id": "notes", "version": 1, "name": "Notes", "instructions": "Do what you are asked, and write what you make to a file.", "skills": [], "tools": ["write", "ask_person"]}}
EOF
agentrun agents create --body @agent.json
# exit 0: the agent; exit 1 with error.code agent_exists: agentrun agents update notes --body @agent.json makes its next revision

Ask the person before you create or change an agent. agentrun server capabilities lists the harnesses, models and tools this server has.

2. Start a run with a spend cap and wait for it

agentrun runs start notes --max-cost-usd 5 --body '{"input": {"content": "Write notes.md with three facts about the Moon."}}' --wait > out.json
# exit 0 completed (result.final_answer); 1 failed or cancelled (error says why); 8 it waits on a person (recipe 3)

--wait follows the run until it ends or needs a person, and --timeout SECONDS stops waiting (exit 1, the run goes on). agentrun runs wait RUN_ID waits again; agentrun runs timeline RUN_ID --follow prints each step as it comes.

3. Answer a run that asks

agentrun runs start notes --max-cost-usd 5 --body '{"input": {"content": "Ask me which region to cover, then write region.md about it."}}' --wait > out.json
# exit 8: it waits on a person; out.json has pending.kind question and pending.question, what it asks

Answer only what the person told you, or ask them. Then:

run=$(node -p 'require("./out.json").run_id')
agentrun runs message "$run" --content "Europe" --wait > out.json
# exit 0 completed, as in recipe 2

runs message --wait waits for the turn of the message it sent, never the turn before it, which a server can go on answering for a few seconds after it takes a message. To wait for a message sent earlier, agentrun runs wait RUN_ID --message MESSAGE_ID, with the message_id runs message answered.

4. Read what it wrote and what it cost

run=$(node -p 'require("./out.json").run_id')
agentrun runs files "$run"
agentrun runs read-file "$run" region.md
agentrun runs get "$run" > out.json && node -p 'JSON.stringify(require("./out.json").cost)'
# exit 0: files lists each path, read-file prints one file, cost.usd is what it spent and cap_usd its cap

cost.usd is null while the cost is unknown: never report it as $0. Tell the person the outcome and give them the run's console_url.

5. Raise a cap or approve a call

A run paused at its spend cap, or waiting for a tool call to be approved, exits 8 with pending.kind budget or approval in out.json.

A cap too small for the task stops the run before a request it cannot pay for. No request is sent that the cap cannot cover, a cache miss included:

agentrun runs start notes --max-cost-usd 0.05 --body '{"input": {"content": "Write moon.md with everything known about the Moon."}}' --wait > out.json
# exit 8 once it pauses at its cap: out.json has pending.kind budget, with cap_usd, spent_usd and suggested_cap_usd; 0 if the cap was enough

Only the person who set the cap raises it: ask them for the new cap (pending.suggested_cap_usd is one that lets it go on). Then the run goes on from where it stopped:

run=$(node -p 'require("./out.json").run_id')
agentrun runs raise-cap "$run" --max-cost-usd 1
agentrun runs wait "$run" > out.json
# exit 0 completed, as in recipe 2

A tool call waiting for approval (pending.kind approval) is answered by the person in the console (the run's console_url): the server takes that answer only from their own session there, never from a token, so the CLI has no command for it. Tell them, then agentrun runs wait "$run" once they have.

A year of the person's own coding-agent work (tokens, cost, models, harnesses, when they work) is agentrun wrapped --year 2025: numbers and names only, read from the session files on the machine the server runs on, and answered only by a server on loopback with no public URL (any other is 403). The console shows it at #/wrapped.

Exit codes

  • 0: done; for runs wait and runs start --wait, the run completed.
  • 1: the server refused (its error JSON on stderr); for a wait, the run failed or was cancelled, or --timeout passed.
  • 2: bad usage, nothing sent: a bad flag or argument, or a base URL that is not http or https or has a query, a fragment, a user or a password.
  • 3: the server cannot be reached.
  • 4: no token, the token was refused, or the config file, the local server's record or its token file was refused (open to others, or not what it should hold).
  • 5: the server does not offer the command here: a 501, unsupported_here, its error saying why (a capability this server has off, say).
  • 8: the run waits on a person: a question, its spend cap, a stopped turn, or a paused workflow. stderr says what to run next.

From a program

Two clients call the same API from code, with the same server and token. @parcha/agentrun-client is the TypeScript one, new AgentRun({ baseUrl, apiKey }); npm install @parcha/agentrun-client installs it. parcha-agentrun (python/) is the Python one, AgentRun(base_url=..., api_key=...) from the agentrun module; pip install parcha-agentrun installs it. Both default to AGENTRUN_BASE_URL and AGENTRUN_API_KEY and read no config file. Each command is a method, grouped the same way: agentrun runs start is client.runs.start, and client.runs.wait and client.runs.follow do what --wait and --follow do.

Commands

Every command, by group with its flags and route, is in references/commands.md; agentrun api METHOD PATH [--body JSON|@FILE|-] calls any route, PATH under the base URL.

Similar Skills

blender-motion-state-inspection

AFaffaan-m/ECC314k3,503 new stars in the last 7 days

Official

slack-gif-creator

ANanthropics/skills203k2,822 new stars in the last 7 days

Featured

algorithmic-art

Generate flow fields and particle systems with p5.js, using seeded randomness for original algorithmic art.

ANanthropics/skills203k2,822 new stars in the last 7 days

moneyprinterturbo-video

HAharry0703/MoneyPrinterTurbo147k1,401 new stars in the last 7 days

thinking-out-loud

SHShubhamsaboo/awesome-llm-apps146k818 new stars in the last 7 days

design-motion

GAgarrytan/gstack143k524 new stars in the last 7 days