# CLI quick start

Source: https://docs.testnet.mog.xyz/api/quick-start/

Markdown: https://docs.testnet.mog.xyz/api/quick-start.md

Reviewed protocol version: 11.0.0

Protocol review date: 2026-10-30

Scope: reviewed public documentation. Numerical examples use illustrative or launch settings; they are not live quotes or a guarantee of current deployed parameters. Consult the app for current market and position values.

The `mog` CLI trades from a terminal. A person can use it by hand, and an agent or a strategy can use it unattended. It never prompts: every input is a flag or an environment variable.

## Install

| Platform     | Command                                                                                      |
| ------------ | -------------------------------------------------------------------------------------------- |
| macOS, Linux | `brew install mog-xyz/tap/mog`                                                               |
| Windows      | `scoop bucket add mog-xyz https://github.com/Mog-xyz/homebrew-tap`, then `scoop install mog` |

A new install starts on testnet. `mog network mainnet` switches to mainnet.

## Connect

```bash
mog connect
```

The CLI makes a session key and opens the app's connect page. Your wallet signs one grant there. The private key stays on your machine. The CLI stores it with owner-only permissions. Set `MOG_PASSPHRASE` to encrypt it.

For an agent that has no browser, `mog session new --account 0xYOUR_WALLET` prints the request for your wallet to sign. Your wallet key never reaches the machine that trades.

## Fund and trade

```bash
mog deposit                      # your deposit address and a QR code
mog markets
mog price BTC
mog long BTC 10 --lev 50 --dry-run
mog long BTC 10 --lev 50
mog positions
mog close BTC <posId> --fraction 50%
```

An order fills at the next attested price, not the price you see when you send it. A market order usually fills within a few seconds. See [Positions and leverage](https://docs.testnet.mog.xyz/trading/positions-and-leverage/#from-order-to-fill).

`--dry-run` signs and sends nothing. It shows the order the CLI would sign.

## Machine output

Add `--json` to any command. The output is one object:

```json
{ "ok": true, "data": { } }
{ "ok": false, "error": { "code": "…", "message": "…", "retryable": false, "exit": 4 } }
```

Progress goes to stderr. `mog schema` prints every command and exit code as JSON. Read the exit code before you retry: see [Errors](https://docs.testnet.mog.xyz/api/reference/errors/#cli-exit-codes). Exit code 6 means a signed instruction may already be on chain.

## Agents

`mog skill install` adds the agent guide for Claude Code. `mog skill show` prints it for any other agent.

## Next

- Run `mog doctor` when something fails. It checks the network, the keys and the endpoints.
- Learn the [fees](https://docs.testnet.mog.xyz/trading/fees/) and the [close curve](https://docs.testnet.mog.xyz/trading/pnl-and-closing/) before you automate. A strategy that trades often pays the open fee every time.
