Use Cursor CLI in GitHub Actions and other CI/CD systems to automate development tasks.

GitHub Actions integration

Basic setup:
- name: Install Cursor CLI
  run: |
    curl https://cursor.com/install -fsS | bash
    echo "$HOME/.cursor/bin" >> $GITHUB_PATH

- name: Run Cursor Agent
  env:
    CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
  run: |
    cursor-agent -p "Your prompt here" --model gpt-4

Cookbook examples

See our cookbook examples for practical workflows: auto-updating documentation and fixing CI issues.

Other CI systems

Use Cursor CLI in any CI/CD system with:
  • Shell script execution (bash, zsh, etc.)
  • Environment variables for API key configuration
  • Internet connectivity to reach Cursor’s API

Autonomy levels

Choose your agent’s autonomy level:

Full autonomy approach

Give the agent complete control over git operations, API calls, and external interactions. Simpler setup, requires more trust. Example: In our Auto Update Documentation cookbook, the first workflow lets the agent:
  • Analyze PR changes
  • Create and manage git branches
  • Commit and push changes
  • Post comments on pull requests
  • Handle all error scenarios
- name: Update docs (full autonomy)
  run: |
    cursor-agent -p "You have full access to git, GitHub CLI, and PR operations. 
    Handle the entire docs update workflow including commits, pushes, and PR comments."

Restricted autonomy approach

We recommend using this approach with permission-based restrictions for production CI workflows. This gives you the best of both worlds: the agent can intelligently handle complex analysis and file modifications while critical operations remain deterministic and auditable.
Limit agent operations while handling critical steps in separate workflow steps. Better control and predictability. Example: The second workflow in the same cookbook restricts the agent to only file modifications:
- name: Generate docs updates (restricted)
  run: |
    cursor-agent -p "IMPORTANT: Do NOT create branches, commit, push, or post PR comments. 
    Only modify files in the working directory. A later workflow step handles publishing."

- name: Publish docs branch (deterministic)
  run: |
    # Deterministic git operations handled by CI
    git checkout -B "docs/${{ github.head_ref }}"
    git add -A
    git commit -m "docs: update for PR"
    git push origin "docs/${{ github.head_ref }}"

- name: Post PR comment (deterministic)  
  run: |
    # Deterministic PR commenting handled by CI
    gh pr comment ${{ github.event.pull_request.number }} --body "Docs updated"

Permission-based restrictions

Use permission configurations to enforce restrictions at the CLI level:
{
  "permissions": {
    "allow": [
      "Read(**/*.md)",
      "Write(docs/**/*)",
      "Shell(grep)",
      "Shell(find)"
    ],
    "deny": [
      "Shell(git)",
      "Shell(gh)", 
      "Write(.env*)",
      "Write(package.json)"
    ]
  }
}

Authentication

Set your CURSOR_API_KEY environment variable:
env:
  CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
You can obtain your API key from the Cursor settings.