# Command line

The ferry command routes links, explains routes and inspects your config from a terminal or a script.

## Install

The tool ships inside the app. Choose **Install command-line tool** in **Settings › Advanced** to link it into `~/.local/bin`, or run it in place:

```bash
/Applications/Ferry.app/Contents/Helpers/ferry --help
```

Or install it on its own with Cargo. The binary is still called `ferry`:

```bash
cargo install ferry-router
```

## Commands

| Command | Does |
| --- | --- |
| `ferry open <url>…` | Route and open links |
| `ferry explain <url>` | Show where a link would go, without opening it |
| `ferry clean <url>` | Print the cleaned link and what was removed |
| `ferry intents` | List intents and what they open on this device |
| `ferry rules` | List rules in the order they're tried |
| `ferry browsers` | List installed browsers and their profiles |
| `ferry check` | Validate `ferry.toml` |
| `ferry mcp` | Run the [MCP server](/agents) |
| `ferry completions <shell>` | Print a completion script for bash, zsh, fish, elvish or PowerShell |

`explain`, `clean`, the listings and `check` read your config directly and work while the app is quit. `open` talks to the running app and starts it if it isn't running.

Links typed without a scheme, like `linear.app/acme`, get `https://` (`http://` for `localhost`).

## open

```bash
ferry open "https://linear.app/acme/issue/APP-142"
```

| Flag | Effect |
| --- | --- |
| `--intent NAME` | Skip the rules and use this intent |
| `--browser ID` | Open in this browser (a bundle ID) |
| `--profile DIR` | With `--browser`: this profile directory |
| `--private` | With `--browser`: a private window |
| `--ask` | Show the picker |

Pass several links and each is routed separately. Cleaning still runs when you name a destination.

## explain

```bash
ferry explain "https://linear.app/acme/issue/APP-142?utm_source=slack" --from com.tinyspeck.slackmacgap
```

```
Slack → ✂ utm_source → rule 2 "Linear" → @work → Chrome · Work (dry run)
```

`--from` sets the app the link pretends to come from, so you can test `from` rules. `--json` prints the full [trace](/traces#as-json).

The line stays under 80 characters, so long routes fold their middle steps into `… +2 steps`. Add `-v` to list every step with its detail below the line:

```
Slack → ✂ utm_source → rule 2 "Linear" → @work → Chrome · Work (dry run)

↘ Slack                  com.tinyspeck.slackmacgap
✂ utm_source             https://linear.app/acme/issue/APP-142
✓ rule 2 "Linear"
→ @work → Chrome · Work  com.google.Chrome
```

## check

```bash
ferry check
```

```
~/.config/ferry/ferry.toml is valid: 4 intents, 2 rules.
```

When something is wrong, `check` names the line:

```
ferry: ferry.toml has an error on line 14, column 7: expected `=`
```

It exits with code `3`, so a script can stop there.

## Listings

```bash
ferry intents
```

```
@work      Work      W  Chrome · Work
@personal  Personal  P  Safari
@meeting   Meeting   -  zoom.us app
@default   Default   -  no binding on this Mac
```

Add `--json` to `intents`, `rules` or `browsers` for machine-readable output. The shapes are the same ones the MCP tools return.

## Exit codes

| Code | Meaning |
| --- | --- |
| `0` | Success |
| `2` | Invalid arguments |
| `3` | Config error |
| `4` | The app couldn't be reached within 3 seconds |
| `5` | The target isn't available: a missing browser or an unsupported mode |

## In scripts

```bash
# Open every link in a file in the work profile
xargs ferry open --intent work < links.txt

# Fail a script early if the config is broken
ferry check || exit 1
```
