# Hand it to your AI

_For tartan 0.9.36._

Let your AI drive the tartan CLI for you.

Let your AI drive the `tartan` CLI for you. It runs the commands; your passkey stays with you.

The CLI describes itself for AIs: every command, its flags, who may run it, and where a person has to act. Your AI
reads that from the CLI itself, so it always matches the version you run.

## 1. Install the CLI and sign in yourself

Your AI works through your sign-in on your computer: [Install and sign in to the tartan CLI](install-cli.md). The sign-in,
the passkey and any SSO password are yours, never the AI's.

## 2. Give your AI the reference

Point your AI at these guides and the command reference at tartannetworks.com/docs. Every page there has a Markdown
twin for AIs: add `.md` to its address, such as `tartannetworks.com/docs/first-device.md`.

For the CLI you run, the AI asks the command itself, with its flags in JSON:

```sh
tartan device approve --help --json
```

Each command says `steps_up` (whether it can ask for your passkey) and `person_acts` (what a person does by hand). A
flag marked `secret` is never the AI's to fill. `--accept-terms` on sign-up and `--yes` on a join are your answers:
the AI gives them only when you say so for that exact command.

## 3. Give your AI the Tartan skill

From version 0.9.35, the CLI carries a skill for AI tools: the tasks, the order to run them in and where your AI
stops for you. It matches the CLI it came with. See which skill your CLI carries (`version`; compare it with the
`metadata.version` of any copy your AI already has):

```sh
tartan skill show --json
```

Then choose the folder your AI tool loads skills from, and write the skill there:

```sh
tartan skill export --out <folder>
```

Both run on your computer only: no passkey, nothing sent. After each CLI update, run `skill show` again and export
when the CLI's skill is newer. A folder that isn't empty needs `--force`, and even then only a folder holding nothing but a skill's files is
replaced.

## 4. Tell it how to work

Give your AI these rules with the task:

- Add `--json` to every command and read `{ok, result, error, code}`. Two exceptions: `tartan skill show --json`
  prints the skill's fields bare, and `tartan skill export` takes no `--json` but prints the envelope anyway.
- Exit codes: `0` ok, `1` other or usage, `2` refused, `3` pending (someone has to approve), `4` not found or this CLI
  is older than control (Tartan's control plane), `5` conflict.
- Run a write with `--dry-run` first when it has one, fix what the dry run refuses, then run it for real.
- Put 2 to 20 changes in one file and run them together. When it steps up, one passkey prompt approves them all:

  ```sh
  tartan batch run --file job.txt --dry-run --json
  tartan batch run --file job.txt --json
  ```

  One ordinary command per line, without `--org`: the file runs in your profile's organization and stops at the first
  refusal.
- A join code or invite link goes to the one person it is for, and nowhere else.

## 5. Your passkey prompts

When a command steps up, the CLI shows what it approves, and Windows asks you for your passkey. Read what it shows,
then touch it. Your AI waits. A pending answer (exit 3) is not a failure: it names the approval that holds it.

## Check it worked

Ask your AI to run:

```sh
tartan version --server --json
tartan me show --json
```

`missing_here` empty means the CLI matches your control. `me show` names you, your organizations and your roles.

## Next

- [Reading the CLI's answers](cli-answers.md)
- [Your first device](first-device.md)
- [Admins and passkeys](admins-passkeys.md)
