GitHub Actions 및 기타 CI/CD 시스템에서 Cursor CLI로 개발 작업을 자동화해봐.

GitHub Actions 연동

기본 설정:
- 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-5

요리책 예시

실무 워크플로우는 요리책 예시를 참고해봐: 문서 업데이트CI 문제 해결.

다른 CI 시스템

다음 요건을 갖춘 어떤 CI/CD 시스템에서도 Cursor CLI를 사용할 수 있어:
  • 셸 스크립트 실행(bash, zsh 등)
  • API 키 구성을 위한 환경 변수
  • Cursor API에 접근할 인터넷 연결

자율성 수준

에이전트의 자율성 수준을 골라줘:

완전 자율 방식

에이전트에게 git 작업, API 호출, 외부 상호작용에 대한 전권을 맡겨. 설정은 더 간단하지만 신뢰가 더 필요해. 예시: 우리 Update Documentation 쿠크북의 첫 번째 워크플로에서는 에이전트가 다음을 수행해:
  • PR 변경 사항 분석
  • git 브랜치 생성 및 관리
  • 변경 사항 커밋 및 푸시
  • Pull Request에 댓글 작성
  • 모든 에러 시나리오 처리
- 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."

제한적 자율 방식

프로덕션 CI 워크플로에서는 이 방식을 권한 기반 제한과 함께 쓰는 걸 추천해. 이렇게 하면 두 가지를 모두 얻을 수 있어: 에이전트가 복잡한 분석과 파일 수정을 똑똑하게 처리하는 동시에, 중요한 작업은 결정론적이고 감사 가능하게 유지돼.
중요 단계는 별도의 워크플로 스텝에서 처리하면서 에이전트의 권한을 제한해. 더 나은 제어와 예측 가능성을 확보할 수 있어. 예시: 같은 쿠크북의 두 번째 워크플로는 에이전트를 파일 수정에만 제한해:
- 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: |
    # 결정론적인 git 작업은 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: |
    # 결정론적인 PR 댓글 작성은 CI가 처리
    gh pr comment ${{ github.event.pull_request.number }} --body "Docs updated"

권한 기반 제한

permission configurations를 사용해 CLI 수준에서 제한을 강제해:
{
  "permissions": {
    "allow": [
      "Read(**/*.md)",
      "Write(docs/**/*)",
      "Shell(grep)",
      "Shell(find)"
    ],
    "deny": [
      "Shell(git)",
      "Shell(gh)", 
      "Write(.env*)",
      "Write(package.json)"
    ]
  }
}

인증

API 키 생성

먼저 Cursor 대시보드에서 API 키를 만들어.

리포지토리 시크릿 구성

리포지토리에 Cursor API 키를 안전하게 보관해:
  1. GitHub 리포지토리로 이동
  2. SettingsSecrets and variablesActions 클릭
  3. New repository secret 클릭
  4. 이름을 CURSOR_API_KEY로 지정
  5. 값에 API 키 붙여넣기
  6. Add secret 클릭

워크플로에서 사용

CURSOR_API_KEY 환경 변수를 설정해:
env:
  CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}