Automate Argy Code with argy run
Run Argy Code without the interface: argy run, flags, JSON output, machine mode, headless server, ACP, missions, deployment and run tracking.
argy run sends a request to Argy Code without opening the terminal interface. It is the entry point for scripts, CI and workflows. This page covers autonomous execution, machine mode, the headless server, missions and the deploy/runs cycle.
Prerequisites
- Argy Code installed (Install Argy Code).
- Non-interactive authentication: the
ARGY_PATvariable holding a personal access token (see Authentication and IAM), or a session opened withargy auth login.
First call
In a CI job, the token is injected as a job secret named ARGY_PAT. Check authentication before sending the request:
argy auth status
argy run --cwd ./my-repo --max-turns 20 "Explain the structure of this repository"
argy run starts a temporary local server, runs the request with the chosen agent, then exits. It sets autonomous mode: if the agent stops while tasks remain incomplete, Argy Code automatically prompts it to continue.
Permissions in a run
No person answers permission prompts during argy run. A deny rule and the confinement to the run workspace are final refusals; an ask rule is approved automatically and traced in the session. A run is therefore not a human review of the changes it makes. For an action that requires a human decision, plan a separate approval step before launching the run. Details are in Permissions and security.
argy run flags
| Flag | Type | Default | Description |
|---|---|---|---|
[message..] | text | — | Message to send. |
--command | string | — | Slash command to run; the message is used as its arguments. |
-c, --continue | boolean | — | Continues the last session. |
-s, --session | string | — | Session ID to continue. |
--replay | string | — | Replays an existing session in read-only mode. |
--share | boolean | — | Shares the session. |
-m, --model | string | — | Model in provider/model format. |
--cwd | string | — | Working directory for the run. |
--org | string | — | Organization ID for this run. |
--agent | string | — | Agent to use. |
--skill | string | — | Loads a skill (SKILL.md) before running. |
--machine | boolean | false | Isolated workflow runtime (see below). |
--format | default, json | default | json outputs raw JSON events. |
-f, --file | array | — | Files attached to the message. |
--title | string | — | Session title. |
--attach | URL | — | Connects to an already running Argy server. |
--port | number | random | Port of the local server. |
--variant | string | — | Model variant (reasoning effort: high, max, minimal…). |
--max-turns | number | — | Maximum number of agent turns before stopping. |
--thinking | boolean | false | Shows reasoning blocks. |
The global options --env, --log-level and --print-logs also apply; see CLI reference.
Examples
Attach files and get script-friendly output:
argy run -f src/index.ts --format json "Review this file and list the risks"
Pick an agent and a model, and cap the number of turns:
argy run --agent reviewer -m provider/model --max-turns 20 "Review the uncommitted changes"
Resume a session, or replay it without changing anything:
argy run -c "Continue with the tests"
argy run --replay <sessionId>
Load a skill before running (see Extensions):
argy run --skill my-skill "Apply the procedure"
Run a custom slash command defined in the configuration:
argy run --command changelog "v1.4.0"
Machine mode
argy run --machine is an isolated runtime designed for workflow-driven executions. It requires run-specific inference authority and rejects the presence of ARGY_PAT. Plugins, MCP, LSP, formatters, sharing and automatic update are disabled in this mode, and custom tools from the repository are ignored. Details are in Permissions and security. This mode is meant for platform integration, notably the modules and runs described in Portal projects and modules; for a regular script or CI job, use argy run without --machine.
Headless server and attaching
| Command | Role |
|---|---|
argy serve | Starts an Argy server without interface (--port, --hostname, --mdns, --mdns-domain, --cors). |
argy attach <url> | Opens the interface on a running server (--dir, -s, -p/--password, default ARGY_SERVER_PASSWORD). |
argy run --attach <url> | Sends a request to an already running server instead of launching a new one on each call. |
The server listens on 127.0.0.1 by default. To expose it, protect it with ARGY_SERVER_USERNAME and ARGY_SERVER_PASSWORD (see Permissions and security).
IDE integration with ACP
argy acp starts an ACP (Agent Client Protocol) server for compatible editors. It accepts the same network options as argy serve, plus --cwd for the working directory. See your editor's documentation to register the argy acp command as an agent.
Missions
A mission is a persistent objective that guides the actions of the session. It is managed with the /mission slash command (set, confirm, clear, done, fail, report); it is handled locally and is not sent to the model. Missions have terminal states (done or failed). See Slash commands and interface and Agents and modes.
Deploy modules and track runs
Once a module is published (see Extensions), the CLI deploys it and tracks its runs.
| Command | Description |
|---|---|
argy deploy <module> | Deploys a module by name or ID; --no-logs skips log streaming after deployment. |
argy runs list | Lists runs (--format, -n/--limit). Alias ls. |
argy runs logs <runId> | Shows a run's logs; -f/--follow streams them. |
argy runs cancel <runId> | Cancels a running deployment. |
argy deploy my-module
argy runs list --limit 10
argy runs logs <runId> --follow
The same cycle is available in the portal; see Portal projects and modules and, on the API side, Platform API.
GitHub integration
argy pr <number> fetches the branch of a GitHub pull request and opens Argy Code on it. argy github install sets up the GitHub agent, and argy github run runs it (--event, --token).
Diagnostics
argy doctor prints an environment diagnostic. argy debug config shows the resolved configuration, and --print-logs --log-level DEBUG sends detailed logs to stderr. argy stats summarizes usage and costs.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| An action is refused during a run | A deny rule, or a path outside the run workspace | Adjust the deny rules in the configuration (they can also be injected with ARGY_PERMISSION), or move the work inside the workspace. |
| An action you expected to be blocked went through | ask rules are approved automatically in a run | Use deny, or add a separate approval before launch (Permissions and security). |
--machine is rejected | ARGY_PAT is set | Unset ARGY_PAT: machine mode requires run-specific authority. |
| Output mixes text and data | --format missing | Add --format json; it is a run option, not a global one. |
argy runs logs returns nothing | Wrong ID or finished run | List runs with argy runs list. |