Cursor IDE CLI - New Window (-n) & Agent Flags
Cursor is the VS Code-based AI editor; its CLI and cursor-agent target developers who open projects quickly, manage windows/extensions, and want editor + AI capability inside scripts. Unlike a plain editor CLI, Cursor adds in-editor AI coding and the headless-callable cursor-agent. This sheet covers opening/comparing files from the terminal, agent automation, and git editor integration.
Open Files & Folders 6
cursor .cursor /path/to/file.tscursor /path/to/file.ts:42cursor /path/to/file.ts:42:10cursor /path/to/projectcursor file1.ts file2.ts file3.tsWindow Management 6
cursor -n /path/to/projectcursor -r /path/to/filecursor -w /path/to/filecursor --mergecursor --add /path/to/foldercursor --locale zh-TWDiff & Merge 2
cursor -d file1.ts file2.tscursor -m base.ts mine.ts theirs.ts out.tsExtension Management 4
cursor --list-extensionscursor --install-extension esbenp.prettier-vscodecursor --uninstall-extension <id>cursor --disable-extensionsRendering & Performance 7
cursor --disable-gpucursor --disable-hardware-accelerationcursor --user-data-dir /path/to/datacursor --extensions-dir /path/to/extcursor --max-memory 4096cursor --verbose /path/to/filecursor --statusRemote Development 5
cursor --remote ssh-remote+hostcursor --folder-uri vscode-remote://ssh-remote+host/pathcursor --file-uri vscode-remote://.../file.tscursor --proxy-server http://proxy:8080cursor --no-proxy-serverDebug & Diagnostics 5
cursor --inspectcursor --inspect-brkcursor --log errorcursor --log-file /tmp/cursor.logcursor --enable-proposed-apiCursor Agent & Git Integration 3
cursor-agent -p "your question" --mode=ask --output-format textgit config --global core.editor "cursor --wait"cursor --goto file.py:128Tips
- Open projects fast from the terminal:
cursor .beats clicking; compare changes withcursor -d a.ts b.tsfor an instant diff view. - Set Cursor as the git editor (
core.editor "cursor --wait") and the commit editor pops up with line numbers, resuming when you close it. - In CI/scripts use
--waitwith diff or editor calls so the command blocks until the window closes, chaining steps cleanly. - Cursor Agent can be called non-interactively with
cursor-agent -p, good for ask/code automation inside pipelines.
FAQ
How do I use Cursor as the git commit message editor?
Run git config --global core.editor "cursor --wait". The --wait flag makes git launch Cursor and block until you save and close, so you can write the commit message in the editor. Similarly, core.diffeditor is useful for reviewing diffs. It is the simplest way to wire your editor into the git workflow.
When is cursor -w required?
-w / --wait blocks until the window closes before returning. Add it whenever a later step depends on work you finish inside the editor — writing a commit message, editing a rebase todo list, or confirming something in a GUI. Plain file opening does not need it, and adding it there just hangs your shell.
What is the difference between ask and code modes in cursor-agent?
ask answers questions without modifying files, which suits code analysis or proposing a plan. code actually reads and writes files and runs commands. From the CLI: cursor-agent -p "your question" --mode=ask --output-format text. Adding --output-format text yields plain text that is easy for scripts to capture.
Cursor starts slowly or uses too much memory — what can I do?
First isolate the cause with --disable-extensions to see whether an extension is responsible, and cap usage with --max-memory 4096. On large monorepos, try --disable-gpu or --disable-hardware-acceleration to rule out rendering cost. Also count how many workspaces you have open. --user-data-dir and --extensions-dir let you test an isolated profile without touching your daily configuration.
How do I open a project on a remote server?
cursor --remote ssh-remote+host attaches to a configured SSH host and opens the workspace there, so the host must already work in your SSH config. You can also target a directory with --folder-uri vscode-remote://ssh-remote+host/path or a single file with --file-uri vscode-remote://.../file.ts. If it fails, verify plain ssh host works first.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Aug 5, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us