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

# CLI setup

> Preview workflow changes, open a pull request, and connect an agent.

## Before you start

* Install Node.js 22.13 or newer and Git.
* Open your repository folder.
* Check that your GitHub remote is named origin.
* Check that you can push a branch.
* Install and sign in to the GitHub CLI to open pull requests from your terminal.
* Complete [GitHub setup](/github).

## Preview changes

Run a dry run to review the plan without signing in or creating a branch.

```bash theme={null}
npx -y @peakinc/init@latest --dry-run
```

Review changes against the remote default branch.
Commit and push any work you want included in that base first.

## Open a pull request

```bash theme={null}
npx -y @peakinc/init@latest
```

Open the sign-in link if asked.
Match the code in your terminal with the code in your browser.
Approve access.
Review the diff and approve the change.
Open the pull request link.

If the GitHub CLI is missing or fails, open the compare link to create the pull request.
Review skipped jobs before you merge.

## Choose setup flags

Add these flags to either setup command.

| Flag              | Use it to                                              |
| ----------------- | ------------------------------------------------------ |
| --dry-run         | Show the plan and diff without creating a branch.      |
| --yes             | Accept the default answer to each setup question.      |
| --json            | Read one JSON event per line.                          |
| --no-browser      | Read the sign-in link in the terminal.                 |
| --no-pr           | Create a local commit without pushing.                 |
| --repo owner/name | Set the GitHub repository when remote detection fails. |
| --runner label    | Choose the runner label for the change.                |
| --ci-mode none    | Add a workflow without using existing workflows.       |
| --plain           | Read plain text output.                                |
| --ascii           | Use ASCII characters.                                  |
| --no-art          | Hide terminal art.                                     |
| --no-motion       | Stop terminal animation.                               |

Approve sign-in in your browser even when you use the flag below.

```text theme={null}
--yes
```

## Connect a coding agent

Run setup with JSON events and a sign-in link.

```bash theme={null}
npx -y @peakinc/init@latest --yes --json --no-browser
```

Relay the sign-in URL to the person who can approve access.
Wait for approval, then read the pull request URL from the output.

To answer each question yourself, omit the automatic-answer flag.
Read the question ID from each event.
Send your answer on stdin.

```json theme={null}
{"answer":"apply","value":"yes"}
```

Check the exit code after setup.

| Code | What to do                                                  |
| ---- | ----------------------------------------------------------- |
| 0    | Review the result or dry-run plan.                          |
| 2    | Run setup again if you stopped it or let a question expire. |
| 3    | Fix the failed check, then retry.                           |
| 4    | Read the error from the failed step, then retry.            |

## Undo setup

Switch away from the setup branch first.
Run the undo command from the same repository.

```bash theme={null}
npx -y @peakinc/init@latest --undo
```

For Peak agent setup, use its undo command.

```bash theme={null}
npx -y @peakinc/wizard@latest --undo
```

Follow the printed command to delete a pushed branch if needed.
Close an open pull request on GitHub if needed.
To undo a merged change, revert its commit on GitHub.
Do not use setup undo to revert a merge.

## Use the Peak CLI

Sign in and check your workspace.

```bash theme={null}
npx -y @peakinc/cli@latest login
npx -y @peakinc/cli@latest status
```

Revoke the active CLI token when you no longer need it.

```bash theme={null}
npx -y @peakinc/cli@latest logout
```

Use [API access](/api-access) for token scopes and unattended agents.
