• Tech Dev NotesTech Dev Notes
Apps
  • App lookup
  • App compare
Market movement
  • App charts
  • App rankings
Visual proof
  • App screens
  • App listing screenshots
  • App icons
Build intelligence
  • App tech stacks
  • Tool releases
  • Developers
More
  • X feature flags
  • Grokipedia
  • Blog
  • Follow on X
Skip to content
All content/ filesChangelog

cursor-docs/latest/content · Jun 26, 20:20 UTC

pages/cli/headless.txt

TXT·4 KB·93 lines

content/

  • pages

    • api.txt
    • approval-agents.txt
    • bugbot.txt
    • cloud-agent.txt
    • customize-cursor.txt
    • enterprise.txt
    • evals.txt
    • extension-api.txt
    • hooks.txt
    • mcp.txt
    • models-and-pricing.txt
    • plugins.txt
    • rules.txt
  • pages/account

    • regions.txt
    • update-access.txt
  • pages/account/enterprise

    • billing-groups.txt
    • cyber-safeguards.txt
    • service-accounts.txt
  • pages/account/organizations

    • organization-admin-api.txt
  • pages/account/pricing

    • request-based-legacy.txt
  • pages/account/teams

    • admin-api.txt
    • ai-code-tracking-api.txt
    • analytics-api.txt
    • analytics.txt
    • dashboard.txt
    • members.txt
    • pricing.txt
    • scim.txt
    • setup.txt
    • sso.txt
  • pages/agent

    • agent-review.txt
    • agents-window.txt
    • debug-mode.txt
    • design-mode.txt
    • overview.txt
    • plan-mode.txt
    • prompting.txt
    • security.txt
  • pages/agent/security

    • run-modes.txt
  • pages/agent/tools

    • browser.txt
    • canvas.txt
    • search.txt
    • terminal.txt
  • pages/cli

    • acp.txt
    • changelog.txt
    • github-actions.txt
    • headless.txt
    • installation.txt
    • mcp.txt
    • overview.txt
    • shell-mode.txt
    • using.txt
  • pages/cli/reference

    • authentication.txt
    • configuration.txt
    • output-format.txt
    • parameters.txt
    • permissions.txt
    • slash-commands.txt
    • terminal-setup.txt
  • pages/cloud-agent

    • automations.txt
    • best-practices.txt
    • capabilities.txt
    • choose-runtime.txt
    • my-machines.txt
    • private-workers.txt
    • security-network.txt
    • self-hosted-cloud-run.txt
    • self-hosted-k8s.txt
    • self-hosted-pool.txt
    • settings.txt
    • setup.txt
  • pages/cloud-agent/api

    • endpoints.txt
    • webhooks.txt
  • pages/configuration

    • worktrees.txt
  • pages/configuration/migrations

    • vscode.txt
  • pages/cursor-review

    • merge-queue.txt
    • overview.txt
    • pr-inbox.txt
    • pr-page.txt
  • pages/cursor-review/cli

    • authentication.txt
    • parameters.txt
    • stacking.txt
  • pages/customizing

    • aws-bedrock.txt
  • pages/enterprise

    • baa.txt
    • compliance-and-monitoring.txt
    • deployment-patterns.txt
    • endpoint-security.txt
    • identity-and-access-management.txt
    • llm-safety-and-controls.txt
    • model-and-integration-management.txt
    • network-configuration.txt
    • organization-groups.txt
    • organizations.txt
    • pooled-usage.txt
    • privacy-and-data-governance.txt
    • private-connectivity.txt
    • security-hardening.txt
  • pages/get-started

    • quickstart.txt
  • pages/integrations

    • azure-devops.txt
    • bitbucket.txt
    • cursor-blame.txt
    • github.txt
    • gitlab.txt
    • jetbrains.txt
    • jira.txt
    • linear.txt
    • microsoft-teams.txt
    • notion.txt
    • slack.txt
    • xcode.txt
  • pages/mcp

    • install-links.txt
  • pages/models

    • claude-4-5-haiku.txt
    • claude-4-5-sonnet.txt
    • claude-4-6-sonnet.txt
    • claude-4-sonnet-1m.txt
    • claude-4-sonnet.txt
    • claude-fable-5.txt
    • claude-opus-4-5.txt
    • claude-opus-4-6-fast.txt
    • claude-opus-4-6.txt
    • claude-opus-4-7-fast.txt
    • claude-opus-4-7.txt
    • claude-opus-4-8.txt
    • cursor-composer-1-5.txt
    • cursor-composer-1.txt
    • cursor-composer-2-5.txt
    • cursor-composer-2.txt
    • gemini-2-5-flash.txt
    • gemini-3-1-pro.txt
    • gemini-3-5-flash.txt
    • gemini-3-flash.txt
    • gemini-3-pro-image-preview.txt
    • gemini-3-pro.txt
    • glm-5-2.txt
    • gpt-5-1-codex-max.txt
    • gpt-5-1-codex-mini.txt
    • gpt-5-1-codex.txt
    • gpt-5-2-codex.txt
    • gpt-5-2.txt
    • gpt-5-3-codex.txt
    • gpt-5-4-mini.txt
    • gpt-5-4-nano.txt
    • gpt-5-4.txt
    • gpt-5-5.txt
    • gpt-5-codex.txt
    • gpt-5-fast.txt
    • gpt-5-mini.txt
    • gpt-5.txt
    • grok-4-20.txt
    • grok-4-3.txt
    • grok-build-0-1.txt
    • kimi-k2-5.txt
  • pages/reference

    • deeplinks.txt
    • ignore-file.txt
    • keyboard-shortcuts.txt
    • permissions.txt
    • plugins.txt
    • sandbox.txt
    • third-party-hooks.txt
  • pages/sdk

    • python.txt
route: /docs/cli/headless
title: Using Headless CLI
description: Run Cursor CLI in headless mode for automation and CI/CD pipelines. Configure non-interactive usage with API keys and scripting support.

Using Headless CLI
Use Cursor CLI in scripts and automation workflows for code analysis, generation, and refactoring tasks.
How it works
Use print mode (-p, --print) for non-interactive scripting and automation.
File modification in scripts
Combine --print with --force (or --yolo) to modify files in scripts:
# Enable file modifications in print mode
agent -p --force "Refactor this code to use modern ES6+ syntax"
# Without --force, changes are only proposed, not applied
agent -p "Add JSDoc comments to this file" # Won't modify files
# Batch processing with actual file changes
find src/ -name "*.js" | while read file; do
agent -p --force "Add comprehensive JSDoc comments to $file"
done
The --force flag allows the agent to make direct file changes without
confirmation
Setup
See Installation and Authentication for complete setup details.
# Install Cursor CLI (macOS, Linux, WSL)
curl https://cursor.com/install -fsS | bash
# Install Cursor CLI (Windows PowerShell)
irm 'https://cursor.com/install?win32=true' | iex
# Set API key for scripts
export CURSOR_API_KEY=your_api_key_here
agent -p "Analyze this code"
Example scripts
Use different output formats for different script needs. See Output format for details.
Searching the codebase
By default, --print uses text format for clean, final-answer-only responses:
#!/bin/bash
# Simple codebase question - uses text format by default
agent -p "What does this codebase do?"
Automated code review
Use --output-format json for structured analysis:
#!/bin/bash
# simple-code-review.sh - Basic code review script
echo "Starting code review..."
# Review recent changes
agent -p --force --output-format text \
"Review the recent code changes and provide feedback on:
- Code quality and readability
- Potential bugs or issues
- Security considerations
- Best practices compliance
Provide specific suggestions for improvement and write to review.txt"
if [ $? -eq 0 ]; then
echo "✅ Code review completed successfully"
else
echo "❌ Code review failed"
exit 1
fi
Real-time progress tracking
Use --output-format stream-json for message-level progress tracking, or add --stream-partial-output for incremental streaming of deltas:
$55
Working with images
To send images, media files, or other binary data to the agent, include file paths in your prompts. The agent can read any files through tool calling, including images, videos, and other formats.
Including file paths in prompts
Simply reference file paths in your prompt text. The agent will automatically read the files when needed:
# Analyze an image
agent -p "Analyze this image and describe what you see: ./screenshot.png"
# Process multiple media files
agent -p "Compare these two images and identify differences: ./before.png ./after.png"
# Combine file paths with text instructions
agent -p "Review the code in src/app.ts and the design mockup in designs/homepage.png. Suggest improvements to match the design."
How it works
When you include file paths in your prompt:
The agent receives your prompt with the file path references
The agent uses tool calling to read the files automatically
Images are handled transparently
You can reference files using relative or absolute paths
Example: Image analysis script
#!/bin/bash
# analyze-image.sh - Analyze images using the headless CLI
IMAGE_PATH="./screenshots/ui-mockup.png"
agent -p --output-format json \
"Analyze this image and provide a detailed description: $IMAGE_PATH" | \
jq -r '.result'
Example: Batch media processing
#!/bin/bash
# process-media.sh - Process multiple media files
for image in images/*.png; do
echo "Processing $image..."
agent -p --output-format text \
"Describe what's in this image: $image" > "${image%.png}.description.txt"
done
File paths can be relative to the current working directory or absolute paths.
The agent will read files through tool calls, so ensure the files exist and
are accessible from where you run the command.
Previouspages/cli/github-actions.txtNextpages/cli/installation.txt

© 2026 Tech Dev Notes

RSSAboutAPIPrivacyTermsSitemap@techdevnotes