---
title: "Drive a Space with the Cohub AI agent CLI from terminal"
description: "Use the Cohub AI agent CLI to sign in, run shell commands, send prompts with --wait, and inspect Space files from your terminal or scripts."
lang: "en"
canonical: "https://cohub.live/guides/ai-agent-cli"
image: "https://cohub.live/_seo/covers/ai-agent-cli/og.webp"
updated: "2026-12-02"
---

# Use the Cohub AI agent CLI to run commands and prompt Spaces from your terminal

The Cohub CLI is a terminal for Cohub Spaces. It does not run a model by itself: it sends prompts to the agent in a Space and lists or runs what the Space holds. A Local Runtime on your computer can run a harness such as Codex or Claude Code.

- **Who:** Developers who want to send work to an agent from a terminal or a script, instead of the web app.
- **When:** You already have a Space with an agent, and the next step is a command you can repeat or script.
- **Why:** The same Space, Chats and files are reachable from the shell, so a script can check, send and read back without a browser.

![One vermilion-handled tool lies on a charcoal workbench, next to a row of identical pale tool handles in a canvas roll.](https://cohub.live/_seo/covers/ai-agent-cli/hero.webp)

![A terminal runs the Cohub CLI, which calls one Space. From there, commands list files and sessions, send prompts, run shell commands, or use a Local Runtime on your computer.](https://cohub.live/_seo/covers/ai-agent-cli/flow-en.svg)

The CLI is the terminal side. The agent runs in the Space, or in a Local Runtime on your computer.

When your next step in a Space is a repeatable command or a shell script rather than a browser session, the Cohub CLI connects your terminal straight to that workspace. The tool itself does not host a model or hold API keys: it calls the agent running inside a Space, or routes work to a local harness you already have signed in on your machine.

## Install and sign in
The CLI requires Node.js 24 or later. Follow the install command in the [CLI reference](https://cohub.live/docs/developers/cli), then verify your account and binary:

```bash
cohub auth login
cohub auth whoami
```

Run `cohub --version` (or `cohub version`) to confirm the install; the terminal output below was captured on version `10.34.0`. Every Space command accepts `-s` with a Space ID or slug—for example, inspecting files in `northwind-atlas-demo`:

```bash
cohub -s northwind-atlas-demo spaces files ls
```

```text
Name        │ Type   │ Size    │ Modified
.cohub      │ dir    │ 4096    │ 2026-11-17 14:03:09 +00:00
site        │ dir    │ 4096    │ 2026-11-17 17:23:13 +00:00
data.json   │ file   │ 35724   │ 2026-11-17 14:03:37 +00:00
README.md   │ file   │ 397     │ 2026-11-17 14:03:44 +00:00
```

Pass `--json` to any list command when a script needs structured output, and use `cohub -s <space> spaces sessions ls` to inspect existing Chats in the same Space.

## Run a command in a Space
When you only need a shell command inside `/workspace`—with no agent reasoning turn—use `run`:

```bash
cohub -s <space> run -- git status
cohub -s <space> run --async --command "pnpm build"
```

The first form executes synchronously in the Space's Linux sandbox and returns the command result. Adding `--async` queues the job and hands control back to your shell right away, which fits longer builds you do not want blocking a script.

## Send a prompt and read the reply
To ask the Space's agent to act and optionally block until the turn finishes, send a prompt from the terminal:

```bash
cohub -s <space> spaces prompt "Summarise README.md in three lines." --json
cohub -s <space> prompt "Summarise README.md in three lines." --wait --json
```

Without `--wait`, the CLI returns immediately with the new Chat and turn IDs. With `--wait`, the terminal stays attached until the agent writes its final reply, so downstream shell steps can parse the answer. Keep one timing detail in mind: a waiting command can time out locally while the cloud turn keeps executing in the Space—pass `--abort-on-timeout` if you want the cloud turn stopped on timeout too.

If you want the turn executed by an agent already installed on your own computer instead of the cloud sandbox, bind a local folder with Local Runtime and select its harness:

```bash
cohub runtime up ./project --harness codex
cohub -s <space> spaces prompt "Continue" --harness codex
```

Claude Code, Codex, and the other harnesses listed in the [CLI reference](https://cohub.live/docs/developers/cli) must already be installed and signed in locally on that machine.

## What the terminal and the web Chat share
The CLI and the browser open the exact same Space rather than two separate workspaces. A prompt dispatched from your shell creates or appends a real Chat turn visible in the web app, reads and writes the same `/workspace` files, shares the same per-Space Linux sandbox, and respects the same `host`, `builder`, and `guest` permissions.

Start small before wiring the CLI into automation: check `cohub version`, list one Space's files, and send one short `--wait` prompt so you can see the resulting turn appear in both places.

## When the web is the better place
Stay in the browser when you need visual feedback or human sign-off rather than scriptable stdout:

- **Inspecting live port previews, Apps, or visual diffs.** Live previews from the Space's sandbox and multi-file review threads are faster to judge on screen than through terminal logs.
- **Working interactively with teammates.** Multi-person Chats, private threads, and quick follow-ups read more clearly in the web Chat view.
- **Destructive or permission-changing actions.** As the CLI safety notes state, confirm explicitly before deleting files, toggling recurring prompts, or changing access—when a step carries risk, reviewing it in the UI or confirming before running prevents silent script mistakes.

## Reference in the docs

**This page:** Whether to script your Space work from a terminal with the Cohub CLI, or keep it in the web app.

- [CLI](https://cohub.live/docs/developers/cli): installing the CLI, signing in, and the commands for Spaces, prompts, files and runs
- [Chats](https://cohub.live/docs/workspace/chats): how a prompt sent from the terminal shows up as a Chat turn

## Related

- [Run Claude Code from your phone while execution stays on your computer](https://cohub.live/use-cases/claude-code-from-phone): To use Claude Code from your phone, install the Cohub CLI and Claude Code on your computer and sign in to both, run cohub runtime up --harness claude in the project folder, check that cohub runtime status lists claude, then open that Space in your phone's browser, choose Claude Code and send the task; the edits land in your local repository, where git diff shows them.
- [How to run Claude Code in the cloud inside a Cohub Space](https://cohub.live/guides/run-claude-code-in-cloud): To run Claude Code in the cloud on Cohub, install it in a Space's sandbox with a startup script. The walkthrough checks CLI authentication with placeholder keys, then shows how to publish a server and recover project files with Saves.

## Sources

- [Cohub CLI reference: installation, sign in, commands, runs](https://cohub.live/docs/developers/cli)
- [Cohub docs: Chats](https://cohub.live/docs/workspace/chats)

Updated Dec 2, 2026
