---
title: "Install, authenticate, then one command that works"
description: "CLI onboarding for AI agents is three commands in order: an install that exits, auth with no browser, and one read that returns data."
canonical: "https://www.agentrail.co/blog/cli-onboarding-for-ai-agents?h=FXTK4MQ03J1BX00J"
author: "Vivek Mittal"
published: "2026-12-01T04:30:00Z"
last_updated: "2026-11-30T12:59:39.293Z"
---

# Install, authenticate, then one command that works

CLI onboarding for AI agents is three commands in order: an install that exits, auth with no browser, and one read that returns data.

CLI onboarding for AI agents is an order. Install the binary, authenticate, then run one read that returns data. The first session is those three commands. When auth opens a browser, the read never runs.

CLI onboarding for AI agents is that ordered first session. Flags, JSON on stdout, pagers, and exit codes stay on [a CLI an agent can run without a prompt](https://www.agentrail.co/blog/non-interactive-cli-for-ai-agents?h=FXTK4MQ03J1BX01G).

> **Key Takeaways**
>
> • The first session is install, then auth, then one successful read.
>
> • Install exits. A question, a GUI, or a browser means the step is still running.
>
> • Auth returns a credential or a refusal the agent can read. A browser on the agent's machine leaves the step unfinished.
>
> • The first product command is a read. Writes belong in a later task.
>
> • A hang in auth is an auth failure. Renaming flags will not store a credential.

## The first session is three commands

The first session is three commands, in order, and then a stop. Install puts a binary on the path. Auth makes a credential available to the next command, or returns a refusal. One read returns a resource the credential can see.

Publish those three lines in the quickstart, in that order. An agent treats the first block it can run as the task. A sentence that says "then log in" is not a command.

| Step | What the command does | The session can continue when |
| --- | --- | --- |
| Install | Puts the binary on the path | A version command exits and prints a version |
| Auth | Stores a credential, or returns a refusal | The next command can send that credential, or the refusal tells the agent to stop |
| Read | Fetches one documented resource | The result names a resource, or an empty list the account actually has |

Leave the tour, the changelog, and the second product out of this session. The session is done when the read returns. Later tasks can add writes.

An HTTP call that runs before the resource it needs is a different order. That failure stays on [setup steps the agent hits out of order](https://www.agentrail.co/blog/api-onboarding-steps-for-ai-agents?h=FXTK4MQ03J1BX02E). This page stays on the CLI session that has to exist before those calls.

Use one binary name in all three lines. `acme version`, then `acme auth`, then `acme widgets list` is one session. Mixing `acme`, `acme-cli`, and a dashboard URL asks the agent to invent the missing step.

Install and auth can live in the same binary and still be two steps. The version command has to succeed before auth runs. Auth has to return before the list runs. Write the page so that dependency is the order of the blocks, not a hint in a paragraph.

Here is the shape to publish. The names are yours. The order is the contract.

`acme version`

`acme auth --from-env ACME_TOKEN`

`acme widgets list`

Each line has to exit. The next line runs only after the previous one has returned. A quickstart that wraps the three lines in "open the app and follow the prompts" has cancelled the order.

## Install must finish without a prompt

Install is finished when the binary is on the path and a version command exits. A prompt, a GUI, or a browser means install is still waiting.

These installs fail a first session:

- A shell script that asks the operator to accept a license.
- A package script that opens a graphical installer.
- A command that waits for a password on stdin and offers no other path.
- A post-install step that launches a login in the system browser.

Publish one install line for a shell, because that is the environment the agent already has. Pin a version in that line. "Latest" is a choice the agent will guess, and a target you cannot rerun next week.

The proof is the version command, not a completed download. A tarball on disk is not a binary on the path. Say the directory you expect, or install onto a path the next command will search. When the binary lands in a folder the shell cannot see, the session dies between step one and step two and looks like a missing product.

When install cannot finish, state the correction and include one command that would work. Anthropic's 11 September 2025 note on tools asks a validation error to state the specific correction and include one correct example ([Writing tools for agents](https://www.anthropic.com/engineering/writing-tools-for-agents)). An install failure can be that short. Name the missing privilege or the missing package, then one invocation.

Keep the human download page for people. The first block on the agent page is the line that exits.

## Auth must finish without a browser

Auth is finished when a later command can send a credential, or when the command returns a refusal the agent can act on. A browser opened on the agent's machine means auth did not finish.

How a credential is issued stays on [an API key an agent can get without a dashboard](https://www.agentrail.co/blog/ai-agent-api-key?h=FXTK4MQ03J1BX03C). This page owns where that step sits. It comes after install and before the read. The quickstart must not say "log in through the browser, then return."

A token already in the environment is a finished auth step. The command confirms the variable is set. It does not replace the variable with a browser login. Name the variable in the quickstart. The read should send it, or read the file the auth command just wrote.

Say where the credential lives. A path the next process can read is a location. A keychain dialog is a person. If the auth command writes a file, print that path in the result so the read does not search the home directory.

These are the same stall:

- `acme login` blocks until a person clicks a hosted page.
- The process starts the system browser and waits.
- The command prints a URL, exits successfully, and stores nothing.
- A magic link is the only way to continue.

The third case is easy to miss. A successful exit with no stored credential makes the read look like a bad flag. The read is fine. Step two reported success for a login that never happened. Treat a missing credential after auth as an auth failure.

A person approving on another device is a signup problem. It stays on [CAPTCHA, inbox codes, and a card form](https://www.agentrail.co/blog/ai-agent-signup-blockers?h=FXTK4MQ03J1BX04A). Until that approval returns a credential to this process, the first session is still on step two.

If you refuse agent login on purpose, return the refusal from the auth command. Name who may create credentials, and tell the agent to stop. A URL with no refusal sends the agent to fetch HTML.

## The first successful command is a read

The third command reads one resource the new credential can see. Create, update, delete, and send belong in a later task.

A read proves the binary, the host, and the credential together. A write mixes that proof with a mutation. A created row can land in the wrong project. A failed write can look like a bad install when the real gap is an id the agent never received.

Pick one read and publish only that read as step three. Listing projects, or fetching the account, works when the agent has no id yet. A get-by-id fails the session when the id was never returned. If the auth response includes a default project id, the read may use it. Show that field in the auth result, then the read that consumes it.

An empty list is a success when the account is empty and the result says the list is empty. HTML is not a success. A stack trace is not a success. A result the next task can quote is a success.

If the read is rejected because no credential was accepted, auth did not finish. Go back to step two. Leave the list command alone until auth returns. If the read is rejected for a missing permission on a credential that was stored, the credential exists. That failure stays on [the right key and the wrong scope](https://www.agentrail.co/blog/api-scope-errors-for-ai-agents?h=FXTK4MQ03J1BX058).

After this read succeeds, later tasks may write. Those writes are not the first session. Put them on a different page. When a write can destroy a record, give it a preview on that later page.

## A failure in step two is not a failure of the flags

When auth opens a browser or waits, the failure is auth. Renaming a flag, changing the output format, or editing an exit code will not store a credential.

Walk the session in order and stop at the first gap.

- The version command did not exit. Fix install. Do not debug auth yet.
- The version command exited, and no credential was stored. Fix auth.
- The process spawned a browser, a GUI, or a wait on stdin. That is the auth gap.
- The process printed a URL and stored nothing. That is the auth gap, even if the process exited successfully.
- A credential was stored, and the read returned data. The first session finished.
- A credential was stored, and the read rejected a permission. Move to the scope failure. The session order held.

Changing an output flag will not close a browser. A yes-flag will not store a key the command never requested. Ship an auth command that exits with a credential or a refusal. Then rerun the same three lines.

Change one step in a release. If auth and the read both change, you cannot tell which edit moved the session. Change auth. Rerun install, auth, and the read. Leave the read's flags in place until auth exits cleanly.

The flag contract remains the other page. Use it after a command exits and the result is the wrong shape. Use this page when the command never produces a credential.

## What a later journey should show

A finished first session shows three steps in order. Install exited. Auth returned a credential or a refusal. One read returned a usable result. How those steps sit on one task stays on [agent journey analytics](https://www.agentrail.co/blog/agent-journey-analytics?h=FXTK4MQ03J1BX066).

On a stalled journey, look for a browser URL between install and the read. That URL is the auth failure. The read may be absent. Score the session as an auth stop when the list command never ran.

On a finished journey, the read comes after auth, and the first product call is not a write. A create as the first product call means the published order skipped the proof. Fix the quickstart, then look for the read on the next session.

If many journeys list widgets before any auth call, the list block is probably above the auth block. Swap them. The agent followed the page.

A refusal finishes auth when the agent can read it and the journey stops there. You told it to stop. Keep that session apart from one that fetched a login page and ended with no result. The login-page session is the bug. The refusal session did what the command asked.

## Frequently Asked Questions

### Can the first product command be a write?

Keep the first product command a read. A write belongs in a later task, after one read has succeeded with the same credential. The read is the proof that install and auth finished.

### Is a shell install acceptable?

A shell install is acceptable when it exits without a question and leaves the binary on the path. A script that asks for a license, a password, or a browser click is still a prompt. Pin the version in the line you publish.

### What if the credential is already in the environment?

Then auth is a check, not a login. Confirm the variable and send it on the read. A browser login that replaces a working variable undoes a step that had already finished.

### Where do flags and exit codes belong?

They belong on the non-interactive CLI contract. This page orders install, auth, and one read. When auth waits on a person, fix auth before you debug a flag.

## Run the three lines before you add a fourth

Publish install, auth, and one read, in that order. Run them with stdin closed. The version command exits, auth stores a credential or returns a refusal, and the read returns a resource. When a browser opens in the middle, the session stopped at auth.

The public checker reads the docs and API surface an agent can fetch. Start with the [agent readiness checker](https://www.agentrail.co/agent-readiness/checker?h=FXTK4MQ03J1BX074).
