Xpersona
C

Cursor CLI Headless

CLAWHUB · Unverified

Execute coding tasks using the Cursor CLI in headless print mode. Use when delegating code writing, refactoring, analysis, or review tasks to a headless Curs... Skill: Cursor CLI Headless Owner: daxingplay Summary: Execute coding tasks using the Cursor CLI in headless print mode. Use when delegating code writing, refactoring, analysis, or review tasks to a headless Curs... Tags: latest:1.1.0 Version history: v1.1.0 | 2026-02-18T16:08:20.542Z | user - Added .DS_Store file to the repository. - Updated documentation to recommend using only the wrapper script (scripts/run-task.s

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17c8np6jtmbs0fq3753vs60s186vc9w:cursor-cli-headless
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-daxingplay-cursor-cli-headless/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

21,704 characters of source documentation, loaded on request.

Extracted files

3 files captured from the source.

SKILL.md

---
name: cursor-cli-headless
description: Execute coding tasks using the Cursor CLI in headless print mode. Use when delegating code writing, refactoring, analysis, or review tasks to a headless Cursor agent process, running automated code changes, or batch-processing files with the agent CLI.
---

# Cursor CLI Headless

Execute coding tasks using the Cursor CLI in non-interactive (print) mode via the wrapper script for scripts, automation, and batch processing.

## Prerequisites

- **Cursor CLI installed**: Run `agent --version`. If missing, install: `curl https://cursor.com/install -fsS | bash` (macOS/Linux/WSL) or see [Installation](https://cursor.com/docs/cli/installation).
- **Authenticated**: Set `CURSOR_API_KEY` in the environment for scripts, or run `agent login` interactively once. Check if already logged in with `agent status` or `agent whoami`.

## Quick start

Use `scripts/run-task.sh` with either an inline prompt or a prompt file:

```bash
# Prompt from file (stream progress by default)
./scripts/run-task.sh -f prompt.txt

# Inline prompt, run in a specific project directory
./scripts/run-task.sh -p "Add tests for auth module" -d /path/to/project
```

## Wrapper script: run-task.sh

`scripts/run-task.sh` runs the Cursor agent in headless mode. **Recommended:** keep file modifications and stream progress **on** (default). Use `--no-force` only with tmux for interactive mode (agent proposes changes for review). Use `--no-stream` for plain output.

**Arguments:**

- `-p "prompt"` — inline prompt (mutually exclusive with `-f`)
- `-f prompt-file.txt` — read prompt from file (for long prompts)
- `-d dir` — working directory (default: current directory)
- `-o format` — `text`, `json`, or `stream-json` (with default streaming, format is stream-json)
- `-m model` — model name
- `--mode mode` — `agent`, `plan`, or `ask`
- `--force` — allow file modifications (default)
- `--no-force` — do not modify files; agent only proposes changes
- `--stream` — stream-json with progress display (default; requires `jq` for progress)
- `--no-stream` — plain output only; use with `-o text` or `-o json`

**Output formats:**

| Format | Use when |
|--------|----------|
| (default stream) | Live progress (model, tool calls, chars); NDJSON on stdout, progress on stderr |
| `-o text --no-stream` | Only the final assistant message |
| `-o json --no-stream` | Single JSON object with `result`, `duration_ms`, etc.; parse with `jq -r '.result'` |

**Examples:**

```bash
# Task from file, apply changes, stream progress (default)
./scripts/run-task.sh -f tasks/refactor-auth.txt

# Inline prompt, specific project, JSON result only
./scripts/run-task.sh -p "Summarize README.md" -d /path/to/repo --no-stream -o json

# Plain text output, no progress
./scripts/run-task.sh -f tasks/review.txt --no-stream -o text
```

## Working directory

The agent runs in the script’s working directory. Use `-d /path/to/project` so the agent sees that project as the root.

## Error handling

_meta.json

{
  "ownerId": "kn79yres364wtdabck9g87vqx581dmyf",
  "slug": "cursor-cli-headless",
  "version": "1.1.0",
  "publishedAt": 1771430900542
}

reference.md

# Output Format Reference

Detailed schemas for Cursor CLI headless output. Use with `--output-format json` or `--output-format stream-json`.

## JSON format (single object on success)

Use `--output-format json`. One JSON object (one line) when the run completes successfully.

### Success response

```json
{
  "type": "result",
  "subtype": "success",
  "is_error": false,
  "duration_ms": 1234,
  "duration_api_ms": 1234,
  "result": "<full assistant text>",
  "session_id": "<uuid>",
  "request_id": "<optional request id>"
}
```

| Field | Description |
|-------|-------------|
| `type` | Always `"result"` |
| `subtype` | Always `"success"` for success |
| `is_error` | Always `false` for success |
| `duration_ms` | Total execution time (ms) |
| `duration_api_ms` | API time (ms); currently same as `duration_ms` |
| `result` | Full assistant response text (all text deltas concatenated) |
| `session_id` | Session identifier |
| `request_id` | Optional request id |

On failure: process exits non-zero, error on stderr, no JSON object emitted.

---

## Stream-JSON format (NDJSON)

Use `--output-format stream-json`. Each line is one JSON object (NDJSON). Optionally use `--stream-partial-output` for character-level text deltas.

### Event types

#### 1. System initialization (once per run)

```json
{
  "type": "system",
  "subtype": "init",
  "apiKeySource": "env|flag|login",
  "cwd": "/absolute/path",
  "session_id": "<uuid>",
  "model": "<model display name>",
  "permissionMode": "default"
}
```

#### 2. User message

```json
{
  "type": "user",
  "message": {
    "role": "user",
    "content": [{ "type": "text", "text": "<prompt>" }]
  },
  "session_id": "<uuid>"
}
```

#### 3. Assistant message

One event per complete message segment (between tool calls). With `--stream-partial-output`, multiple events per segment with small text deltas; concatenate `message.content[].text` to get full text.

```json
{
  "type": "assistant",
  "message": {
    "role": "assistant",
    "content": [{ "type": "text", "text": "<message text>" }]
  },
  "session_id": "<uuid>"
}
```

#### 4. Tool call — started

```json
{
  "type": "tool_call",
  "subtype": "started",
  "call_id": "<string id>",
  "tool_call": { "<tool type>": { "args": { ... } } },
  "session_id": "<uuid>"
}
```

#### 5. Tool call — completed

```json
{
  "type": "tool_call",
  "subtype": "completed",
  "call_id": "<string id>",
  "tool_call": {
    "<tool type>": {
      "args": { ... },
      "result": { "success": { ... } }
    }
  },
  "session_id": "<uuid>"
}
```

#### 6. Terminal result (end of stream on success)

```json
{
  "type": "result",
  "subtype": "success",
  "duration_ms": 1234,
  "duration_api_ms": 1234,
  "is_error": false,
  "result": "<full assistant text>",
  "session_id": "<uuid>",
  "request_id": "<optional request id>"
}
```

---

## Tool call types

### readToolCall

- **Started**: `tool_call.readToolCall.args` → `{ "path": "file.txt" }`
- **Completed**: `tool_call.readToolCall.re

Sponsored

Ads related to Cursor CLI Headless and adjacent AI workflows.