# Serena CLI

Canonical URL: https://withserena.ai/docs/integrations/cli
Markdown URL: https://withserena.ai/docs/integrations/cli.md

> Install the Serena command line with npm, sign in, and manage tasks, notes, and workspace context from your terminal or a script.

## Install

The CLI is an npm package and needs Node.js `^20.19.0 || >=22.12.0`. Install it globally, or run it once with `npx`.

```bash
npm install -g @serena-ai/cli
serena --version

# or run it without installing
npx @serena-ai/cli --help
```

A standalone download that needs no Node.js is not available yet. Use npm.

## Sign in

`serena login` opens your browser, asks you to approve access, and stores a token for later commands.

```bash
serena login
serena status
```

On a machine with no browser, run `serena login --device` and approve from another device. `serena logout` removes the stored credentials.

## Choose a workspace

Most commands act on one workspace. The CLI picks it in this order: the `--workspace <id>` flag, the `SERENA_WORKSPACE_ID` environment variable, then the default you stored. With none of them set, a command that needs a workspace fails and tells you to set one.

```bash
serena workspace list
serena workspace use "<workspace-id>"
```

## Everyday commands

```bash
serena task list --due today
serena task list --status to_do
serena task add "Draft the launch note"
serena task resolve MKT-42
serena task done "<task-id>"
serena note add "Retro notes" --content "What we changed"
serena search "billing migration"
serena dashboard
```

Commands that act on one record take its ID. Use `serena task resolve MKT-42` to get the ID for a reference such as that. Add `--due 2027-01-15` to `task add` for a due date in ISO format. `--due today` uses your local day, and `--timezone` sets a different IANA zone.

Every command and subcommand takes `--help`. Commands for routines and custom fields work only in workspaces where those features are enabled.

## Read work context

`serena work-context` prints the Active Plan, accepted decisions, and related records as prompt-ready text. Use one of `--task`, `--project`, or `--goal`. A task takes its ID or a reference such as `DEV-123`; a project or goal takes its ID. Use `--query` to ask a question. Add `--json` for the raw response.

```bash
serena work-context --task DEV-123
```

## Scripts and CI

Every command accepts `--json` and writes structured output to stdout. Listing commands are paginated: `--cursor` resumes from a page and `--all` follows every page.

```bash
serena task list --status to_do --json | jq -r '.data[].title'
```

Where there is no browser, such as CI, the CLI reads an API key from the `SERENA_API_KEY` environment variable. Inject it from your CI secret store or a secret manager. Do not type the key into a command, a script, or a shell profile, and do not store it with the `--key` option of `serena login`, which writes it to disk. With the variable set, the command is the plain one:

```bash
serena task list --json
```

API keys are a limited rollout: create one in Settings, then API Keys, if that page appears in your account.

## Connect an AI client

`serena mcp install --client <client>` adds the hosted Serena server to an AI client. You approve access in your browser, so no API key is written to disk.

| Client | Command | What it does |
| --- | --- | --- |
| Claude Code | serena mcp install --client claude-code | Writes .mcp.json in the current folder. Then run /mcp in Claude Code to sign in. |
| Cursor | serena mcp install --client cursor | Writes .cursor/mcp.json in the current folder. |
| Codex | serena mcp install --client codex | Writes ~/.codex/config.toml. Then run codex mcp login serena to sign in. |
| Claude Desktop | serena mcp install --client claude | Prints the steps to add a custom connector in Claude. |

The [AI client guide](https://withserena.ai/docs/integrations/mcp) covers each client, the local server for headless machines, and toolset profiles. To install the bundled Serena skills for Claude Code or Codex, run `serena skill install --agent claude`.
