Skip to content
Back to skills

C9watch Cli

CSecurity

Use c9watch CLI to monitor and query coding-agent sessions (Claude Code, Codex, Cursor Agent, Pi, and OpenCode). Trigger when the user asks about other running agent sessions, wants to check what agents are doing, needs to find past session work, asks about agent costs or spending, wants to stop or coordinate sibling sessions, or mentions "c9watch". Also trigger when the user says things like "check on my other sessions", "what's running", "any sessions stuck", "find that conversation where I...

  • 139 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
ai-agentsgobashnodegitdatabase

Works with

  • claude code
  • cursor
  • cli

Security analysis

C71/100
  • criticalPipes output to a shell interpreter
  • mediumUses curl or wget to download content
  • criticalDownloads and executes remote scripts — classic supply chain attack

Pro shows the line behind each finding and how to fix it

Scanned December 4, 2026

npx -y skills add minchenlee/c9watch --skill c9watch-cli --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of C9watch Cli?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for C9watch Cli
[![Security: C — Skills Directory](https://www.skillsdirectory.com/api/skills/minchenlee-c9watch-cli/badge)](https://www.skillsdirectory.com/skills/minchenlee-c9watch-cli)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: c9watch-cli
description: >
  Use c9watch CLI to monitor and query coding-agent sessions (Claude Code,
  Codex, Cursor Agent, Pi, and OpenCode).
  Trigger when the user asks about other running agent sessions,
  wants to check what agents are doing, needs to find past session work,
  asks about agent costs or spending, wants to stop or coordinate
  sibling sessions, or mentions "c9watch". Also trigger when the user
  says things like "check on my other sessions", "what's running",
  "any sessions stuck", "find that conversation where I...",
  "how much have I spent", or "what did I work on yesterday".
---

# c9watch CLI

c9watch is a CLI tool that lets you monitor the coding-agent sessions running on the machine: **Claude Code**, **Codex**, **Cursor Agent**, **Pi**, and **OpenCode**. Every command outputs JSON. Use it to see what other sessions are doing, search past work, track costs, and coordinate with sibling agents.

Every session carries a `provider` (`claudeCode`, `codex`, `cursor`, `pi`, `opencode`) and a provider-scoped `sessionKey` (`provider:id`, e.g. `pi:01a06659-...`). Use the `sessionKey` with `view` whenever an ID could collide across providers.

## Provider support

| Command | Claude Code | Codex | Cursor Agent | Pi | OpenCode |
|---|---|---|---|---|---|
| `list`, `status`, `watch`, `wait`, `view` | yes | yes | yes | yes | yes |
| `history`, `search` | yes | yes | yes | yes | no |
| `cost` | yes | yes | no | yes | no |
| `tasks`, `stop`, `self` | yes | no | no | no | no |

**OpenCode needs no setup.** c9watch reads OpenCode 2's own database (`~/.local/share/opencode/opencode.db`, or under `$XDG_DATA_HOME`) read-only, while an `opencode` process runs. If `C9WATCH_OPENCODE_URL` is set, c9watch reads that OpenCode 1 server instead.

- OpenCode sessions show `Working`, `WaitingForInput` or `Connecting`. They never show `NeedsAttention`: a permission wait looks like `Working`, because OpenCode does not write it to its database.
- A finished session is listed for 30 minutes after its last write. A child session is a subagent of its parent. A turn with nothing written for 10 minutes shows `Connecting` with `statusCertainty: "uncertain"`.
- c9watch opens the database only while OpenCode runs, and never when that would create a file next to it.
- If the database is locked or has a layout c9watch does not know, it is named in `diagnostics.unreadableSources` and no OpenCode status is shown: an empty result then does not mean no OpenCode session is running.
- `view opencode:<session-id>` reads the conversation. `history`, `search`, `cost` and `tasks` have no OpenCode data.
- They cannot be opened, stopped or renamed (`pid` is 0).

## Before you start

Verify `c9watch` is available:

```bash
which c9watch && c9watch --version
```

If not installed, tell the user:
```
c9watch CLI is not installed. Install it with:
curl -fsSL https://raw.githubusercontent.com/minchenlee/c9watch/main/install-cli.sh | bash
```

## Commands reference

### List active sessions

```bash
c9watch list                                    # all sessions
c9watch list --compact                          # minimal fields (saves tokens)
c9watch list --project myapp                    # filter by project path
c9watch list --provider codex                   # read only these providers (claudeCode, codex, cursor, pi, opencode; repeat or comma-separate)
c9watch list --status NeedsAttention            # filter by status
```

Status values (the same four as `docs/cli.md`; no other value is ever printed):

| Status | Meaning |
|---|---|
| `Working` | The agent runs tools or thinks. |
| `NeedsAttention` | The agent waits for the user: a permission prompt or a question. |
| `WaitingForInput` | The agent finished its turn and waits for the next prompt (idle). |
| `Connecting` | The session is starting, or has had no activity yet. |

`NeedsAttention` is reported for Claude Code and Codex (for Codex, the approval of an escalated command shows after about 35 seconds). Cursor Agent, Pi and OpenCode sessions do not report it.

Compact output keeps identity and state and drops the conversation text. Main fields: `id`, `pid`, `status`, `projectPath`, `sessionName`, `sessionKey`, `provider`, `canOpen`, `canStop`, `canRename`, `sourceHealth`, `pendingToolName`, plus parent/subagent and title fields when set (full list in `docs/cli.md`).

Full output adds: `firstPrompt`, `messageCount`, `modified`, `customTitle`, `gitBranch`, `summary`, `latestMessage`, `pendingToolInput`, `taskProgress`

### Status overview

```bash
c9watch status                                  # counts by status and project
c9watch status --project myapp                  # filtered
```

Returns `total`, `byStatus`, `byProject`, and `needsPermission`: the sessions whose status is `NeedsAttention` (the field keeps its old name). This is the fastest way to answer "is anything stuck?" — check `needsPermission` first.

### Identify yourself

```bash
c9watch self
```

Walks the PID tree to find the calling Claude Code process and returns your own session object. Use this to discover your own session ID, project path, git branch, or task progress without the user telling you.

### View a conversation

```bash
c9watch view <session-id>                       # full conversation
c9watch view <session-id> --last 5              # last 5 messages (saves tokens)
```

Session IDs support prefix matching — `c9watch view abc` resolves to the full UUID if unambiguous. Prefix with the provider when ambiguous: `c9watch view pi:abc`. System XML tags are automatically stripped from output.

When viewing conversations, prefer `--last N` to avoid loading thousands of tokens from long sessions. Start with `--last 5` and go larger only if needed.

### Browse history

```bash
c9watch history                                 # all past sessions
c9watch history -n 20                           # most recent 20
```

Returns a JSON array of entries: `sessionId`, `firstPrompt`, `display`, `date` (ISO 8601), `project`, `projectName`, `customTitle`. Covers Claude Code, Codex, Cursor Agent and Pi; not OpenCode. `--envelope` prints `{"schema": 1, "items": [...]}` instead of the bare array.

Sessions whose transcript was deleted stay listed from c9watch's local index with `"sourceGone": true` and no prompt (`display` and `firstPrompt` are empty); `cost` and `activity` mark them the same way. Their conversation cannot be viewed or searched. The index is filled by the desktop app or by `c9watch index update`; `c9watch index status` shows what it holds.

### Search past sessions

```bash
c9watch search "implement auth middleware"
c9watch search "fix bug" --project myapp -n 10
```

Multi-word queries use AND logic — all words must appear somewhere in the session. Returns `hits[]` with `sessionId`, `snippet`, `projectPath`, `modified`, `provider`. Covers Claude Code, Codex, Cursor Agent and Pi; not OpenCode.

### View tasks

```bash
c9watch tasks <session-id>
```

Returns `total`, `completed`, `inProgress`, `pending`, and the full `tasks[]` array. Tasks are only available for Claude Code sessions.

### See what a session did

```bash
c9watch activity <session-key>                  # e.g. claudeCode:<id> or codex:<id>
c9watch activity <session-key> --compact        # without command text (saves tokens)
```

Returns one object with `schema: 1`, a `summary` (`filesChanged`, `fileEdits`, `commands`, `subagents`, `waits`, `waitMs`, `waitingSince`, `activeMs`, `cost`) and time-ordered `events` (`prompt`, `fileEdit`, `command`, `subagent`, `wait`, `turnEnd`). Claude Code and Codex only; Cursor, Pi and OpenCode return an error. It reads only and writes nothing. For a session whose transcript was deleted, the full key returns the summary kept in the local index with `"events": []` and `"sourceGone": true`.

Use it to answer "what did that session change or run?" without reading the whole conversation. Add `--compact` when you only need which files changed, counts, times or cost: it drops command text and subagent descriptions. `cost` is `null` when the model has no price; the token counts are still there.

### Stop a session

```bash
c9watch stop <pid>
c9watch stop claudeCode:<session-id>
```

Takes the PID or the whole session key from `c9watch list` (`pid`, `sessionKey`). Only Claude Code sessions can be stopped (`canStop` is `true` in `list`); a key of another provider is refused. c9watch also refuses when the PID now belongs to another process. Always confirm with the user before stopping a session — this is destructive and irreversible.

### Watch for changes

```bash
c9watch watch                                   # stream all events
c9watch watch --changes-only --compact           # only changes, minimal fields
c9watch watch --project myapp --interval 5       # filtered, slower poll
```

Streams NDJSON (one JSON object per line). Events: `started`, `status_changed`, `stopped`. This is a long-running command — run it in the background if you need to monitor while doing other work.

### Wait for one session

```bash
c9watch wait <session> --until needs-input      # NeedsAttention or WaitingForInput
c9watch wait <session> --until done --timeout 600
```

Blocks until one live session meets the condition (`needs-input`, `done`, `ended`, `any-change`), prints that event, and exits. Exit codes: `0` met, `1` error, `2` usage error, `3` stopped before `needs-input`, `4` no single live session matches (it was `2` up to v0.12.0), `124` timeout. Use it in place of polling `list` in a loop.

## Output contract

Every JSON object on stdout has `"schema": 1` (contract v1, `docs/cli-contract.md`). Read fields by name and ignore fields you do not know: new fields can appear without a new number. `c9watch schema <command>` prints the JSON Schema of a command's output. Errors are `{"error": "..."}` on stderr with exit code 1; an unknown command, or an unknown flag after a command, is a usage error with exit code 2 (an unknown command never opens the app).

### See who started whom

```bash
c9watch tree --compact                                   # one JSON tree of the live sessions
c9watch wait <session> --children --until done --timeout 600   # wait for the session and all its children
```

`tree` returns `{schema: 1, roots: [...]}`. Each node has `key`, `type` (`session` or `subagent`), `status` (sessions) or `subagentStatus` (`running`, `completed`; `stale: true` when the call has no result but the parent went on past it), and `children`; a child also has `relation` (`subagent`, `teammate`, `thread`) and `via` (the recorded field). Claude Code subagents and agent-team teammates hang under their lead, Codex threads under their parent thread. Pi sessions and sessions across providers are never linked. `wait --children` keeps waiting while any session under the addressed one works or any of its subagents runs (not stale ones); it takes `--until done` or `--until ended`, prints one `tree_done` / `tree_ended` line, and exits `4`, like plain `wait`, when no single live session matches. Always pass `--timeout`: a parent that hangs mid-call leaves its subagent `running`.

## Choosing the right command

| User wants to know... | Command |
|----------------------|---------|
| "What's running right now?" | `c9watch list --compact` |
| "Is anything stuck/waiting?" | `c9watch status` then check `needsPermission` |
| "What's session X doing?" | `c9watch view <id> --last 3` |
| "What did I work on recently?" | `c9watch history -n 20` |
| "Find that conversation where..." | `c9watch search "<keywords>"` |
| "How far along is that task?" | `c9watch tasks <id>` |
| "What did session X change or run?" | `c9watch activity <key> --compact` (drop `--compact` for command text) |
| "Which agents did session X start? Are they all done?" | `c9watch tree --compact`; `c9watch wait <key> --children --until done` |
| "Who am I?" | `c9watch self` |
| "Stop that other session" | `c9watch list` to find PID, confirm, then `c9watch stop <pid>` |

## Tips for effective use

- Always use `--compact` on `list` when you only need status info. Full output includes conversation content which wastes tokens.
- Use `--last N` on `view` to avoid loading entire long conversations.
- Pipe through `jq` for filtering: `c9watch list | jq '.sessions[] | select(.status == "NeedsAttention")'`
- The `self` command only works when called from within a Claude Code session (it needs a claude parent process in the PID tree).
- Codex, Cursor Agent, Pi and OpenCode sessions are read-only in c9watch: they cannot be opened, stopped, or renamed. See the Provider support table for what each command covers.
- `--pretty` on any command gives indented JSON for human-readable output, but costs more tokens. Skip it when parsing programmatically.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.