> ## Documentation Index
> Fetch the complete documentation index at: https://agentrail.co/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Coding agents

> Set up Claude Code, Codex and Cursor to use Agentrail with one command, and let an agent run the CLI for you.

## Set up your agents

```sh theme={null}
agentrail agent setup
```

For each of Claude Code, Codex and Cursor whose command (`claude`, `codex`, `cursor` or `cursor-agent`) is on your `PATH`, it:

* installs the Agentrail skill, which tells the agent what Agentrail can do and when to use it. Claude Code reads it from `~/.claude/skills/agentrail`, and Codex and Cursor share the copy in `~/.agents/skills/agentrail`.
* adds Agentrail's MCP server, named `agentrail`, for every project of yours.

It prints each agent's result: installed, already set up, skipped because the agent is not installed, or failed with the reason. Run it again after you update the CLI to install that version's skill.

Each agent then signs in to Agentrail itself. The CLI never hands its own sign-in to an agent.

| Agent | How it signs in |
| - | - |
| Claude Code | Run `/mcp` in Claude Code and choose **Authenticate**. |
| Codex | Run `codex mcp login agentrail`, or `codex mcp login agentrail-readonly` after `--read-only`. |
| Cursor | It asks you to sign in the first time it uses Agentrail. |

A connected agent appears in **Settings · Agents** under **Your connections**, and you can disconnect it there.

### Options

| Option | What it does |
| - | - |
| `--only <agents>` | Only these agents, comma-separated: `claude`, `codex`, `cursor`. |
| `--project` | Into the current directory instead, for everyone who works in it, so run it at the root of your repository: the skill in `.claude/skills` and `.agents/skills`, and the server in Claude Code's project servers and `.cursor/mcp.json`. Codex keeps MCP servers per user, so its server is skipped. |
| `--read-only` | The read-only server, named `agentrail-readonly`, which offers only the tools that read. Nothing an agent does through it changes your workspace. |

### Without the CLI

* **Settings · Agents** shows the command or entry that adds Agentrail's MCP server to Claude Code, Codex, Cursor or another MCP host.
* In Claude Code, `/plugin marketplace add agentrail-co/agentrail-cli`, then `/plugin install agentrail@agentrail`, installs the Agentrail skill.
* Any agent that reads Agent Skills can install the skill with `npx skills add agentrail-co/agentrail-cli`.

## When an agent runs the CLI

The skill tells an agent to use the `agentrail` command, and the CLI is built for it:

* Inside a coding agent the CLI recognises, such as Claude Code, Codex, Gemini CLI, GitHub Copilot CLI or Goose, output is JSON. Setting the `AGENT` environment variable does the same for any other agent.
* Data goes to stdout and messages to stderr. Exit codes say what went wrong: see [Exit codes](https://agentrail.co/docs/cli/reference.md#exit-codes).
* Every command and its inputs come from `agentrail tools` and `--help`, so the agent can find the one it needs.

### Sign in without a terminal

An agent's commands have no terminal for you to confirm a sign-in in. Run `agentrail login` there and it prints the sign-in page and a code, then stops:

```json theme={null}
{
  "status": "pending",
  "verificationUrl": "https://…",
  "userCode": "ABCD-EFGH",
  "expiresAt": "2026-11-17T12:05:00.000Z",
  "next": "agentrail login"
}
```

The agent shows you the URL and the code. Open the URL, check that it shows the same code, and confirm it before `expiresAt`. The agent then runs `agentrail login` again, which finishes signing in:

```json theme={null}
{ "status": "signed_in", "environment": "prod", "email": "you@example.com" }
```

Where the keychain cannot keep a sign-in, as in some containers, the CLI says so and stops. It never falls back to a file on its own: run `agentrail login --insecure-storage` to keep the sign-in in a file only you can read.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.