# Ably CLI
The [Ably CLI](https://github.com/ably/ably-cli) brings the full power of Ably to your terminal. You can use it to manage your Ably account and its resources, and to explore Ably's APIs and features.
It's a quick and easy way to simulate additional clients when testing how Ably works.
The Ably CLI interacts with:
* The [Control API](https://ably.com/docs/platform/account/control-api.md?source=llms.txt) to manage your Ably account and applications.
* [Pub/Sub](https://ably.com/docs/basics.md?source=llms.txt) to publish and subscribe to messages in realtime.
* [Chat](https://ably.com/docs/chat.md?source=llms.txt) to send messages, display typing indicators and react to what's happening in a chat room.
* [Spaces](https://ably.com/docs/spaces.md?source=llms.txt) to enter spaces and register member locations.
## Installation
Get started in a single command:
### Shell
```
npx -p @ably/cli ably init
```
[`ably init`](https://ably.com/docs/cli/init.md?source=llms.txt) installs the Ably CLI globally, authenticates you, and installs the Ably [Agent Skills](https://github.com/ably/agent-skills) into any AI coding tools it detects on your machine, such as Claude Code, Cursor, VS Code, and Windsurf.
To install the CLI manually first, use npm and then run `ably init`:
### Shell
```
npm install -g @ably/cli
ably init
```
## Usage
During `ably init`, the CLI authenticates using an [OAuth Device Authorization](https://datatracker.ietf.org/doc/html/rfc8628) flow: it displays an authorization code and opens your browser to approve it. Once approved, the CLI receives an [access token](https://ably.com/docs/platform/account/access-tokens.md?source=llms.txt) that is stored locally and refreshed automatically, so there is no manual token management.
If you only need to authenticate, without installing Agent Skills, run [`ably login`](https://ably.com/docs/cli/login.md?source=llms.txt) instead.
After authenticating and selecting your app and API key, you can interact with Ably resources directly from your terminal.
For example, open two terminal windows. In the first, subscribe to a channel:
### Shell
```
# Attach to channel `channel-1` and start receiving new messages
ably channels subscribe channel-1
```
In the second, publish messages to the same channel:
### Shell
```
# To publish 1 message:
ably channels publish channel-1 Hi!
```
### Shell
```
# To publish 5 messages:
ably channels publish --count 5 channel-1 "Message number {{.Count}}"
```
To list all available commands, run:
### Shell
```
ably help
```
## Global options
The following options can be used with any command for programmatic usage and debugging:
* [`--json`](https://ably.com/docs/cli.md?source=llms.txt#json) or [`--pretty-json`](https://ably.com/docs/cli.md?source=llms.txt#pretty-json) — JSON output. Mutually exclusive options.
* [`--verbose`](https://ably.com/docs/cli.md?source=llms.txt#verbose) — Enable verbose logging. Can be combined with `--json` or `--pretty-json`.
## Feature set
You can use the Ably CLI for undertaking operations such as:
| Operation | Description |
| --------- | ----------- |
| **Ably Accounts** ||
| [List accounts](https://ably.com/docs/cli/accounts/list.md?source=llms.txt) | List the accounts you have access to. |
| [Switch accounts](https://ably.com/docs/cli/accounts/switch.md?source=llms.txt) | Switch between multiple Ably accounts. |
| [Account statistics](https://ably.com/docs/cli/stats/account.md?source=llms.txt) | Query your account statistics. |
| **Ably Apps** ||
| [List apps](https://ably.com/docs/cli/apps/list.md?source=llms.txt) | List all apps in your account. |
| [Switch apps](https://ably.com/docs/cli/apps/switch.md?source=llms.txt) | Switch between multiple apps. |
| [Manage apps](https://ably.com/docs/cli/apps.md?source=llms.txt) | Create and delete apps. |
| [Manage API keys](https://ably.com/docs/cli/auth.md?source=llms.txt) | Create, update and revoke API keys in an app. |
| [App statistics](https://ably.com/docs/cli/stats/app.md?source=llms.txt) | Query app statistics. |
| [Manage rules](https://ably.com/docs/cli/apps.md?source=llms.txt) | Create, update and delete rules in an app. |
| [Logs](https://ably.com/docs/cli/logs.md?source=llms.txt) | Query and subscribe to logs. |
| **Integrations and Queues** ||
| [Manage integrations](https://ably.com/docs/cli/integrations.md?source=llms.txt) | List, create and delete integrations. |
| [Manage queues](https://ably.com/docs/cli/queues.md?source=llms.txt) | List, create and delete queues. |
| **Pub/Sub** ||
| [List channels](https://ably.com/docs/cli/channels/list.md?source=llms.txt) | List active channels in an app. |
| [Publish](https://ably.com/docs/cli/channels/publish.md?source=llms.txt) | Publish and batch publish messages. |
| [Subscribe](https://ably.com/docs/cli/channels/subscribe.md?source=llms.txt) | Subscribe to messages on channels. |
| [Presence](https://ably.com/docs/cli/channels.md?source=llms.txt) | Enter and subscribe to the presence set of channels. |
| [History](https://ably.com/docs/cli/channels/history.md?source=llms.txt) | Query message history. |
| [Occupancy](https://ably.com/docs/cli/channels.md?source=llms.txt) | Fetch and subscribe to channel occupancy. |
| **Chat** ||
| [List rooms](https://ably.com/docs/cli/rooms/list.md?source=llms.txt) | List chat rooms in an app. |
| [Messages](https://ably.com/docs/cli/rooms.md?source=llms.txt) | Send and subscribe to messages. |
| [Presence](https://ably.com/docs/cli/rooms.md?source=llms.txt) | Enter and subscribe to the presence set of chat rooms. |
| [History](https://ably.com/docs/cli/rooms/messages/history.md?source=llms.txt) | Query chat message history. |
| [Occupancy](https://ably.com/docs/cli/rooms.md?source=llms.txt) | Fetch and subscribe to chat room occupancy. |
| [Reactions](https://ably.com/docs/cli/rooms.md?source=llms.txt) | Send and subscribe to message-level and room-level reactions. |
| [Typing indicators](https://ably.com/docs/cli/rooms.md?source=llms.txt) | Send and subscribe to typing indicators. |
| **Spaces** ||
| [List spaces](https://ably.com/docs/cli/spaces/list.md?source=llms.txt) | List spaces in an app. |
| [Members](https://ably.com/docs/cli/spaces.md?source=llms.txt) | Enter and subscribe the list of members. |
| [Locations](https://ably.com/docs/cli/spaces.md?source=llms.txt) | Set and subscribe to member locations. |
| [Cursors](https://ably.com/docs/cli/spaces.md?source=llms.txt) | Set and subscribe to member cursors. |
| [Locks](https://ably.com/docs/cli/spaces.md?source=llms.txt) | Acquire and subscribe to locks. |
## Auto-completion
The Ably CLI supports shell auto-completion for bash, zsh, and PowerShell. This helps you discover and use commands more efficiently.
To set up auto-completion, run:
### Shell
```
ably autocomplete
```
This displays installation instructions specific to your shell. Follow them to enable tab completion for commands, subcommands, and options.
For more details, see the auto-completion [CLI reference](https://ably.com/docs/cli/autocomplete.md?source=llms.txt) and [auto completion usage documentation](https://github.com/ably/ably-cli/blob/main/docs/Auto-completion.md).
## Interactive mode
The Ably CLI includes an interactive shell mode that provides a more convenient way to work with multiple commands:
### Shell
```
ably-interactive
```
Interactive mode provides the following features:
* **Command history**: Previous commands are saved and can be accessed with up/down arrows.
* **Tab completion**: Full support for command and option completion.
* **Ctrl+C handling**: A single Ctrl+C interrupts the current command and returns to the prompt. A double Ctrl+C (within 500ms) force quits the shell.
* **No "ably" prefix needed**: Commands can be typed directly, for example `channels list` instead of `ably channels list`.
## CLI reference
See the [CLI reference](https://ably.com/docs/cli.md?source=llms.txt), for detailed documentation on every CLI command, including options, arguments, and usage examples.
## Documentation Index
To discover additional Ably documentation:
1. Fetch [llms.txt](https://ably.com/llms.txt?source=llms.txt) for the canonical list of available pages.
2. Identify relevant URLs from that index.
3. Fetch target pages as needed.
Avoid using assumed or outdated documentation paths.