Linux command
cursor 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Start an interactive agent session
cursor-agent
Start with an initial prompt
cursor-agent "[fix the auth bug in login.ts]"
Run a one-off prompt
cursor-agent -p "[add tests for api.js]"
Run non-interactively with a specific model
cursor-agent -p "[review changes]" --model [gpt-5]
Resume the previous session
cursor-agent --continue
Resume a specific chat
cursor-agent --resume [chat-id]
Start in plan mode
cursor-agent --plan "[migrate from Redux to Zustand]"
Emit structured JSON
cursor-agent -p "[task]" --output-format [json]
Auto-approve file edits
cursor-agent -p "[task]" --force --trust
List previous chat sessions
cursor-agent ls
说明
cursor-agent is Cursor's terminal-native AI coding assistant. It mirrors the same agent loop the Cursor editor uses, but in a plain terminal so it can live alongside Vim, Neovim, Emacs, JetBrains IDEs, or CI pipelines. Sessions are persistent and resumable. Print mode makes the agent scriptable — combine `--output-format json` with shell tooling to pipe agent output into other programs. The CLI uses the same subscription and model quota as the Cursor editor. Cloud Agent (triggered in-session) offloads long-running tasks to Cursor's servers so the local shell stays responsive.
参数
- -p, --print
- Print mode: run the prompt non-interactively, stream the response, then exit.
- --output-format _FORMAT_
- `text` (human readable, default), `json` (single result object), or `stream-json` (NDJSON event stream).
- --stream-partial-output
- Emit incremental token deltas rather than complete messages.
- --model _NAME_
- Model to use (run `cursor-agent models` for the current list).
- --mode _MODE_
- `agent` (default), `plan`, or `ask`.
- --plan
- Shorthand for `--mode plan`.
- --continue
- Continue the most recent session (shorthand for `--resume` with no id).
- --resume _chat-id_
- Resume a specific chat.
- -f, --force, --yolo
- Run all tool calls without prompting (except explicitly denied ones).
- --sandbox _MODE_
- Sandbox behavior: `enabled` or `disabled`.
- --trust
- Trust the workspace without prompting (required for headless runs).
- --approve-mcps
- Automatically approve all configured MCP servers.
- --workspace _PATH_
- Working directory to use instead of the current one.
- --worktree
- Create a new Git worktree under `~/.cursor/worktrees` and run there.
- --api-key _KEY_
- API key (env: `CURSOR_API_KEY`).
- -H, --header _"Name: Value"_
- Add a custom header to requests.
- -v, --version
- Print the version.
- -h, --help
- Show help for the command.
FAQ
What is the cursor command used for?
cursor-agent is Cursor's terminal-native AI coding assistant. It mirrors the same agent loop the Cursor editor uses, but in a plain terminal so it can live alongside Vim, Neovim, Emacs, JetBrains IDEs, or CI pipelines. Sessions are persistent and resumable. Print mode makes the agent scriptable — combine `--output-format json` with shell tooling to pipe agent output into other programs. The CLI uses the same subscription and model quota as the Cursor editor. Cloud Agent (triggered in-session) offloads long-running tasks to Cursor's servers so the local shell stays responsive.
How do I run a basic cursor example?
Run `cursor-agent` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -p, --print do in cursor?
Print mode: run the prompt non-interactively, stream the response, then exit.