Install the Cursor CLI in GitHub Actions and run cursor-agent in CI.
- Add a repository secret named
CURSOR_API_KEY. - Use the action in a workflow job.
- Read
steps.<id>.outputs.summaryfor the model response.
- name: Run Cursor Agent
id: cursor
uses: PunGrumpy/cursor-action@main
with:
api-key: ${{ secrets.CURSOR_API_KEY }}
prompt: "Review this PR for security issues and summarize your findings."
- name: Print summary
run: echo "${{ steps.cursor.outputs.summary }}"Pre-release note: this repository has not published a stable release tag yet.
Useuses: PunGrumpy/cursor-action@main(or a pinned commit SHA) until the firstv1release is published.
| Input | Required | Default | Description |
|---|---|---|---|
api-key |
✅ | — | Cursor API key (store in GitHub Secrets). |
prompt |
✅ | — | Prompt passed to cursor-agent. |
cursor-version |
❌ | latest |
Cursor lab build to install (latest or exact build id like 2026.03.20-44cb435). |
model |
❌ | auto |
Model name for cursor-agent. |
working-directory |
❌ | . |
Working directory used when running the agent. |
permissions |
❌ | read-only |
Agent permissions: read-only, read-write, or full. |
timeout |
❌ | 300 |
Timeout in seconds for each agent invocation attempt. |
| Output | Description |
|---|---|
summary |
Agent text output (used for step-to-step handoff). |
exit-code |
Exit code returned by cursor-agent. |
cache-hit |
"true" when CLI install came from cache. |
name: Cursor Code Review
on:
pull_request:
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Run Cursor Agent
id: review
uses: PunGrumpy/cursor-action@main
with:
api-key: ${{ secrets.CURSOR_API_KEY }}
permissions: read-only
prompt: |
Review the staged changes in this repository.
Focus on correctness, security, and performance.
Be concise.
- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## 🤖 Cursor Review\n\n${{ steps.review.outputs.summary }}`
})- uses: PunGrumpy/cursor-action@main
with:
api-key: ${{ secrets.CURSOR_API_KEY }}
prompt: "Generate a changelog entry for the latest commit."
cursor-version: "2026.03.20-44cb435"- uses: PunGrumpy/cursor-action@main
with:
api-key: ${{ secrets.CURSOR_API_KEY }}
prompt: "Fix TypeScript type errors in src/."
permissions: read-write
working-directory: ./srccursor-version: latestresolves to a concrete Cursor lab build before download.- Resolution order:
https://downloads.cursor.com/lab/latest-version- Fallback to parsing
https://cursor.com/install
- For reproducible installs, pin an exact lab build id.
- Primary invocation:
cursor-agent chat ... - If chat fails with a likely CLI mismatch (for example
unknown command) or empty output, the action retries with headless print mode (-p --output-format text). - A preflight print probe is also run to improve auth/entitlement diagnostics in job summary output.
- The extracted CLI package is cached by platform, architecture, and resolved version.
- Using
lateststill hits cache after it resolves to a concrete build. - Pinning a build id gives stable cache keys across runs.
- Node.js 24 (matches CI and release workflows)
- Bun
bun install
bun run typecheck
bun run test
bun run buildIf you changed source files, commit updated dist/ as well (CI fails when dist/ is out of date).
export CURSOR_API_KEY='your-key'
export GITHUB_STEP_SUMMARY="$(mktemp)"
export GITHUB_OUTPUT="$(mktemp)"
export RUNNER_TOOL_CACHE="$(mktemp -d)"
export RUNNER_TEMP="$(mktemp -d)"
env "INPUT_API-KEY=$CURSOR_API_KEY" \
"INPUT_PROMPT=Say 'smoke test passed' and nothing else." \
"INPUT_CURSOR-VERSION=latest" \
"INPUT_MODEL=auto" \
"INPUT_PERMISSIONS=read-only" \
"INPUT_TIMEOUT=60" \
node dist/index.jsCIworkflow runstypecheck,test, andbuildon pushes and pull requests.- On pushes to
main, CI also runs a smoke test job using this action (uses: ./). Releaseworkflow runs on pushes tomain, executes tests/build, then uses Changesets to open/update a release PR or publish.- After the first stable release, major tags (
v1,v2, ...) are managed by the release flow so@v1tracks the latestv1.x.x.
- Confirm
CURSOR_API_KEYis present and valid. - If you set
model, verify your account can access it (tryautofirst). - Check the job summary for:
cursor-agent --version- invocation mode used (
chator fallbackprint) - preflight/auth diagnostics and merged stderr
This repository's smoke test uses CURSOR_SMOKE_TEST_MODEL (default: auto) in .github/workflows/ci.yml. If smoke tests fail due to model access, set it to a known-good model for your account.
This project uses Changesets. See .changeset/README.md for contribution workflow details.