AI Automation

Claude Code GitHub Action: gõ @claude trong PR để review, sửa bug, trả lời câu hỏi

Tóm tắt

anthropics/claude-code-action (MIT) đưa Claude Code vào GitHub: phản hồi khi được @claude, khi được assign issue, hoặc chạy theo prompt cố định trong workflow. Cài nhanh bằng lệnh /install-github-app trong Claude Code (cần quyền admin repo). Hỗ trợ API Anthropic, Bedrock, Vertex AI, Foundry.

Các kiểu dùng

KiểuVí dụ
Tương tácComment “@claude giải thích vì sao test này flaky” trong PR
Review tự độngMỗi PR mở → review theo checklist team
Theo đường dẫnChỉ review kỹ khi đổi src/payments/**
Định kỳHằng tuần kiểm tra dependency, docs lệch code
TriageTự gắn label, phân loại issue mới

Workflow tối giản

name: Claude
on:
  issue_comment: { types: [created] }
  pull_request_review_comment: { types: [created] }
jobs:
  claude:
    if: contains(github.event.comment.body, '@claude')
    runs-on: ubuntu-latest
    permissions: { contents: write, pull-requests: write, issues: write }
    steps:
      - uses: actions/checkout@v4
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

Khuyến nghị

  • Key để trong GitHub Secrets, dùng key riêng cho CI có spend limit.
  • Đặt checklist review trong CLAUDE.md để kết quả nhất quán.
  • Với PR từ contributor bên ngoài: giới hạn quyền, không tự động merge.