claude-code-action
애플리케이션anthropics/claude-code-action
GitHub Action으로 Claude Code를 통합하여 코드 리뷰와 자동 수정을 구현합니다.
개요
범용 GitHub Action으로, Claude Code를 PR 및 issue 워크플로에 통합하여 질문에 답변하고, 코드를 리뷰하며, 수정 사항을 직접 구현할 수 있습니다. 워크플로 컨텍스트에 따라 실행 모드를 자동으로 선택하며, Anthropic API, Amazon Bedrock, Google Vertex AI 및 Microsoft Foundry를 지원하고, 자체 Runner에서 완전히 실행되며, 구조화된 JSON 결과를 출력할 수 있습니다.
README 미리보기
\n\n# Claude Code Action\n\nA general-purpose [Claude Code](https://claude.ai/code) action for GitHub PRs and issues that can answer questions and implement code changes. This action intelligently detects when to activate based on your workflow context—whether responding to @claude mentions, issue assignments, or executing automation tasks with explicit prompts. It supports multiple authentication methods including Anthropic direct API (API key or workload identity federation), Amazon Bedrock, Google Vertex AI, and Microsoft Foundry.\n\n## Features\n\n- 🎯 **Intelligent Mode Detection**: Automatically selects the appropriate execution mode based on your workflow context—no configuration needed\n- 🤖 **Interactive Code Assistant**: Claude can answer questions about code, architecture, and programming\n- 🔍 **Code Review**: Analyzes PR changes and suggests improvements\n- ✨ **Code Implementation**: Can implement simple fixes, refactoring, and even new features\n- 💬 **PR/Issue Integration**: Works seamlessly with GitHub comments and PR reviews\n- 🛠️ **Flexible Tool Access**: Access to GitHub APIs and file operations (additional tools can be enabled via configuration)\n- 📋 **Progress Tracking**: Visual progress indicators with checkboxes that dynamically update as Claude completes tasks\n- 📊 **Structured Outputs**: Get validated JSON results that automatically become GitHub Action outputs for complex automations\n- 🏃 **Runs on Your Infrastructure**: The action executes entirely on your own GitHub runner (Anthropic API calls go to your chosen provider)\n- ⚙️ **Simplified Configuration**: Unified `prompt` and `claude_args` inputs provide clean, powerful configuration aligned with Claude Code SDK\n\n## 📦 Upgrading from v0.x?\n\n**See our [Migration Guide](./docs/migration-guide.md)** for step-by-step instructions on updating your workflows to v1.0. The new version simplifies configuration while maintaining compatibility with most existing setups.\n\n## Quickstart\n\n
FAQ (5)
문제 해결Claude Code Action이 리뷰를 실행하기 전에 "subtype: success"와 "is_error: true"로 간헐적으로 실패하는 이유는 무엇인가요?
일반적으로 이는 코드 리뷰가 완료된 후 실패한 것이 아니라 Claude 프로세스가 시작 중에 실패했음을 의미합니다. claude-execution-output.json을 확인하고 result 필드를 읽어 보세요. 보고된 사례에서는 해당 필드에 Credit balance is too low가 포함되어 있었습니다. Anthropic API 계정의 결제/크레딧 잔액을 확인하고 크레딧을 추가한 후 워크플로우를 다시 실행하여 문제를 해결하세요. 시작 실패는 일반적으로 리뷰 집계나 결과 없이 is_error: true로 표시되며, 예를 들어 spawned: 0과 같이 나타납니다. 이는 결과를 보고하는 완료된 리뷰와는 구분됩니다.
문제 해결Claude Code Action 태그 모드에서 files와 paths 매개변수 불일치로 발생하는 delete_files 스키마 유효성 검사 오류는 어떻게 수정하나요?
mcp__github_file_ops__delete_files 도구 스키마는 paths를 받지만, 태그 모드 프롬프트 예제에서는 잘못되게 files를 사용하고 있습니다. 이로 인해 use_commit_signing: true가 활성화된 경우 Zod 검증이 첫 번째 삭제 시도를 거부하게 됩니다.
src/create-prompt/index.ts에서 프롬프트 예제를 수정하세요 (827행 근처):
- mcp__github_file_ops__delete_files: {"files": ["path/to/old.js"], "message": "chore: remove deprecated file"}
+ mcp__github_file_ops__delete_files: {"paths": ["path/to/old.js"], "message": "chore: remove deprecated file"}
그런 다음 액션을 다시 빌드/릴리스하거나 해당 수정이 포함된 릴리스를 사용하세요. 기존 실행에서는 paths를 사용하여 도구 호출을 재시도하면 실패한 호출을 우회할 수 있습니다:
{"paths": ["path/to/old.js"], "message": "chore: remove deprecated file"}
commit_files는 여전히 files를 사용한다는 점에 유의하세요. delete_files만 paths를 사용합니다. 회귀 테스트에서는 MCP 도구 스키마를 가져와(import) 프롬프트 예제의 매개변수 이름이 해당 스키마와 일치하는지 확인해야 합니다.
문제 해결Claude 풀 리퀘스트 검토 중에 claude_args를 통해 전달된 사용자 정의 Bash 도구가 무시되는 이유는 무엇인가요?
pull_request 이벤트의 경우, action은 tag 모드를 자동으로 감지하며, 이 모드에서는 mcp__github_로 시작하는 사용자 제공 MCP 도구만 기본 allowlist에 병합됩니다. Bash(npx markdownlint:*) 또는 Bash(gh pr:*)와 같은 사용자 정의 규칙은 파싱되지만 필터링되어 제외됩니다.
사용자 정의 Bash 도구를 사용하려면 워크플로우에서 mode: agent를 명시적으로 설정하세요:
- uses: anthropics/claude-code-action@v1
with:
mode: agent
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
prompt: |
Run `npx markdownlint *.md` to check markdown files.
claude_args: |
--allowedTools "Bash(npx markdownlint:*),Read,Glob"
camel-case 플래그인 --allowedTools를 사용하세요. --allowed-tools는 인식되지 않을 수 있습니다. 이 동작은 claude-code-action v1.0.22에서 관찰되었습니다.
문제 해결브랜치 이름에 `#`가 포함될 때 GitHub 브랜치 링크가 깨지는 문제를 어떻게 해결하나요?
GitHub tree 또는 비교 URL에 삽입하기 전에 브랜치 이름의 각 경로 세그먼트를 URL 인코딩하되, /는 경로 구분자로 그대로 유지하세요:
const encodedBranch = branchName
.split("/")
.map(encodeURIComponent)
.join("/");
예를 들어, claude/fix#123은 claude/fix%23123이 되며, 생성된 링크는 다음과 같습니다:
https://github.com/owner/repo/tree/claude/fix%23123n브랜치 URL이 생성되는 모든 곳(tracking-comment 및 branch-cleanup 코드 포함)에 이 인코딩을 적용하세요. 임시 해결 방법으로, 생성되는 브랜치 이름에
#를 사용하지 않거나 링크에서 #를 %23으로 수동으로 교체하세요.문제 해결GitHub Actions에서 Claude Opus 5 또는 Sonnet 5가 1M 대신 200k 컨텍스트 윈도우로 확인되는 문제를 어떻게 해결하나요?
워크플로 구성의 모델 ID에 [1m] 컨텍스트 선택자를 추가하세요:
env:
ANTHROPIC_MODEL: claude-opus-5[1m]
ANTHROPIC_SMALL_FAST_MODEL: claude-sonnet-5[1m]
ANTHROPIC_BASE_URL 게이트웨이로 인해 Claude Code가 네이티브 1M 컨텍스트 지원을 자동으로 감지하지 못하는 경우 이 설정이 필요합니다. 이 해결 방법은 action v1.0.185와 Claude Code 2.1.222에서 검증되었습니다: claude-opus-5[1m]은 modelUsage.contextWindow가 1000000으로 확인되지만, claude-opus-5는 200000으로 확인되어 조기 자동 압축이 발생합니다.
적용된 제한 값을 확인하려면 show_full_output: true를 활성화하고 작업 로그에서 modelUsage 객체를 살펴보세요:
"contextWindow": 1000000
참고: [1m] 접미사를 사용하더라도 maxOutputTokens는 여전히 64000으로 표시될 수 있습니다. 이 값은 컨텍스트 윈도우 선택자와는 별도로 결정됩니다.