매번 PR마다 꼼꼼히 리뷰하기 어렵다면? Claude Code를 GitHub Actions에 연결해 자동 리뷰어를 붙일 수 있다. 이 글에서는 인증 방식 선택부터 워크플로우 구성, 비용 관리까지 실제 구현 기준으로 정리한다.
flowchart LR
A["PR Open / Sync"] --> B["GitHub Actions 트리거"]
B --> C["claude-code-action"]
C --> D["OAuth Token으로 Anthropic 인증"]
D --> E["Claude가 diff 분석"]
E --> F["PR에 리뷰 코멘트 작성"]💡 인증 방식에 따라 과금 구조가 완전히 달라진다. 먼저 자신의 상황에 맞는 방식을 고르자.
| 방식 | 대상 | 과금 | 설정 난이도 |
|---|---|---|---|
| OAuth Token | 개인 Pro/Max 구독자 | 구독 한도 내 포함 | 쉬움 |
| API Key | 팀 / 조직 | 토큰 종량제 | 쉬움 |
| AWS Bedrock / GCP Vertex | 엔터프라이즈 | 클라우드 계약 포함 | 복잡 |
✅ Claude Code Pro/Max 구독자라면 OAuth Token을 쓰면 추가 과금 없다.
claude_code_oauth_token은 구독 계정에 묶인 세션 토큰이라 API 종량제와 별개다.
터미널에서 토큰을 발급한다:
claude setup-token발급된 토큰은 ~/.claude/.credentials.json에 저장된다. 이 값을 GitHub Secrets에 등록한다:
CLAUDE_CODE_OAUTH_TOKEN 이름으로 New secret 추가⚠️ API Key는 호출마다 토큰이 소모된다. Sonnet 기준 PR 1회에 $0.5~$15 수준이며, 설정 실수 시 예상치 못한 청구가 발생할 수 있다.
console.anthropic.com에서 API Key 발급 후 ANTHROPIC_API_KEY로 Secrets에 등록한다.
name: Claude Code Review
on:
pull_request:
types: [opened, synchronize]
jobs:
claude-review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
id-token: write
actions: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Run Claude Code Review
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
prompt: |
이 Pull Request를 리뷰하고 다음 항목에 대한 피드백을 제공해주세요:
- 코드 품질 및 모범 사례
- 잠재적 버그
- 성능 고려사항
- 보안 우려사항
스타일과 컨벤션은 CLAUDE.md를 참고하세요.
반드시 한국어로 답변해주세요.
claude_args: >-
--allowed-tools
"Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"@claude 멘션 시 실행)name: Claude Code
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && contains(github.event.issue.body, '@claude'))
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
id-token: write
actions: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}| 패턴 | 트리거 | 언제 적합한가 |
|---|---|---|
| 자동 리뷰 | PR open/sync | 모든 PR에 일관된 리뷰 기준 적용 |
| 대화형 | @claude 멘션 | 특정 상황에서만 온디맨드로 활용 |
두 패턴을 함께 사용하는 것도 가능하다. 자동 리뷰로 기본 체크를 하고, 추가 질문은 @claude로 대화하는 방식이다.
모델을 지정하지 않으면 기본값인 claude-sonnet 계열이 사용된다. claude_args로 명시적으로 지정할 수 있다:
claude_args: '--model claude-opus-4-7 --allowed-tools "..."'| 모델 | 특징 | 권장 용도 |
|---|---|---|
| claude-sonnet-4-6 | 기본값, 속도/품질 균형 | 일반적인 PR 리뷰 |
| claude-opus-4-7 | 최고 품질, 느림 | 복잡한 아키텍처 리뷰 |
| claude-haiku-4-5 | 빠름, 저비용 | 간단한 스타일 체크 |
# floating tag — 자동 업데이트, breaking change 위험
uses: anthropics/claude-code-action@v1
# 버전 고정 — 안정적, 수동 업데이트 필요
uses: anthropics/claude-code-action@v1.0.120⚠️ 프로덕션 환경에서는 버전을 고정하는 것이 일반적으로 권장된다.
@v1은 편리하지만 Anthropic이 breaking change를 포함한 업데이트를 올릴 경우 워크플로우가 갑자기 깨질 수 있다.
CLAUDE.md는 프로젝트 루트에 두면 Claude가 자동으로 읽는 컨텍스트 파일이다. 워크플로우 prompt와 역할을 분리하면 관리가 쉬워진다:
| 위치 | 담을 내용 |
|---|---|
CLAUDE.md | 기술 스택, 코딩 컨벤션, 폴더 구조, 개발 명령어 |
워크플로우 prompt | 리뷰 관점, 출력 언어, 코멘트 작성 방식 |
claude_args: '--max-turns 5 --allowed-tools "..."'--max-turns를 설정하지 않으면 기본값 10회 반복이 허용된다. 복잡한 PR에서 예상보다 많은 토큰이 소모될 수 있다.
⚠️ 외부 기여자의 PR에서 Claude가 민감한 Secrets에 접근하지 못하도록 트리거 조건을 제한하는 것이 권장된다. 악의적인 프롬프트 인젝션 가능성이 있다.
# 외부 PR은 리뷰 제외
on:
pull_request:
types: [opened, synchronize]
jobs:
claude-review:
if: github.event.pull_request.head.repo.full_name == github.repositoryCLAUDE_CODE_OAUTH_TOKEN 또는 ANTHROPIC_API_KEY 등록permissions에 pull-requests: write, issues: write 포함CLAUDE.md에 프로젝트 컨벤션 정의--max-turns 설정으로 비용 제한@v1 vs @v1.0.120)