# CLI quickstart

Install @recruitaffiliates/cli, sign in with an API key, and run a first search from a terminal or from Claude Code.

A **CLI** (command-line tool) is a program you run by typing its name in a terminal. This one is called `recruit`. It does what the app does, one command at a time. It's built for AI agents such as Claude Code as much as for people. Every answer is JSON, every error says what to do next, and nothing spends or sends until a person says yes.

## Install

```bash
npm install -g @recruitaffiliates/cli
```

Or run one command without installing: `npx @recruitaffiliates/cli brands list`. It needs Node 20 or later. If another program on your computer already uses the name `recruit`, type `recruitaffiliates` instead. It works the same.

## Sign in

Make an API key in the app: **Settings**, then the API tab ([Get a key](/api#get-a-key) has the details). Then run:

```bash
recruit login
```

It asks for the key (nothing you type shows), checks it, and saves it to `~/.recruitaffiliates/config.json`, which only you can read. A script can set `RECRUIT_API_KEY` instead. The `--api-key` flag wins, then the variable, then the saved key.

Working for more than one company? `recruit login --profile client-a` saves a second key, and `--profile client-a` on any command uses it. `recruit whoami` shows which account the next command would use. It also shows what the key can do: read, change things, send email. A key made without "Can send email" says so there, before a send is refused.

## A first run

```bash
recruit guide                                   # the whole loop, in about 40 lines
recruit week                                    # what needs you
recruit setup --country US --seed "best tools for Shopify stores"
recruit searches wait fsc_abc123                # a first search takes 10 to 25 minutes
recruit affiliates list --fit strong --fields id,name,fit,url --limit 25
recruit affiliates save --ids fdi_1,fdi_2
recruit emails find fdi_1
recruit campaigns build --name "Shopify bloggers"
```

Every command is `recruit <area> <action>`. `recruit --help` lists the areas, `recruit <area> --help` lists the actions, and the [command reference](/cli-reference) has every one.

## Cards: nothing spends or sends without a yes

A search, an email lookup and anything that sends email cost something or reach real people. So the command prints a **card** and stops with exit code 2. The card says what will happen and what it uses:

```json
{"confirmation_required":true,"applied":false,"summary":"Find the email address for fdi_1. It uses 1 email lookup, only when no address is on file yet and one is found.","preview_token":"cfm_...","run":"recruit emails find fdi_1 --confirm cfm_..."}
```

Nothing has happened yet. Show the card to the founder. If they say yes, run the command in `run`. The token works only for those exact arguments, for 15 minutes, and running it twice does the work once.

Sending needs a key that can send email (`finder:send`). A confirmed campaign launch waits 10 minutes before anything leaves, and a reply waits 2. Undo inside that time with `recruit agent-actions undo`.

`--yes` skips the card. It exists for a script you wrote yourself, where you already decided. An agent should never add it.

## Output

An answer is JSON on one line, so an agent reads few characters. These flags change it:

- `--fields id,name,fit` keeps only those fields. A dot reaches inside: `score.fit`.
- `--quiet` prints ids only, one per line.
- `--pretty` prints a table for people.
- `--all` reads every page of a list, up to 500 items.

Errors go to standard error with `message`, `fix` and, when one helps, `next_command`.

## Exit codes

| Code | Meaning |
|---|---|
| 0 | Done |
| 1 | Failed: the API or the network had a problem |
| 2 | Needs a yes: a card was printed and nothing was done |
| 3 | Key problem: missing, refused, or without the access this needs |
| 4 | Your plan doesn't include this |
| 5 | A limit: too many requests, or out of searches or email lookups |
| 6 | Not found: check the id |
| 7 | The request was wrong: a missing flag, or the API refused it as written |
| 8 | Still running when the wait ran out: run the same command again |

## From Claude Code and other agents

Have the agent run `recruit guide` first. It prints the loop: what to run, in what order, and where to stop for the founder's yes. An agent with a terminal does better with the CLI than with the [MCP server](/mcp), because it only reads what it asks for. Chat apps such as Claude.ai and ChatGPT have no terminal, so they use the MCP server.

`recruit mcp` connects an AI app that can only start a local program to the hosted MCP server, with your saved key.

## Your key stays safe

- The key only ever goes to our API. The CLI refuses any other address and never follows a redirect.
- It never prints your key: anything that looks like one is shown as `rail_live_…1234`.
- It sends no usage data and has no runtime dependencies.

Writing code instead? The [SDK](/sdk) does the same from TypeScript.
