GitHub Actions ve Code Review GitHub App
Claude Code'u CI'ye bağla, otomatik PR review yaptır, headless mode ile pipeline'ları zenginleştir.
Öğreneceklerin
- GitHub Actions içinde Claude Code'u headless çalıştır
- Code Review GitHub App'i kurmayı bil
- Hangi tür otomasyon CI'ye, hangisi local'e ait, kararını ver
Claude Code sadece terminal aracı değil — CI’de --headless modda çalışıp PR yorumu, otomatik review, scheduled task, ve “policy enforcement” yapabilir.
Headless mode
claude --headless --prompt "PR diff'ini review et" --output json
İnteraktif değil; girdiyi bir prompt olarak alır, çıktıyı stdout’a JSON/text döker. CI işleri için ideal.
GitHub Actions örneği — auto PR review
name: claude-pr-review
on:
pull_request:
types: [opened, synchronize]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- run: npm install -g @anthropic-ai/claude-code
- name: Run review
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
DIFF=$(git diff origin/main...HEAD)
claude --headless --prompt "Şu diff'i review et: $DIFF" > review.md
- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const body = fs.readFileSync('review.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
});
Bu pattern’in kritik noktaları:
ANTHROPIC_API_KEYrepo secret’ında- Diff’i prompt’a inline geçirmek yerine dosyaya yazıp referans ver (büyük PR’lar için)
- Allowlist allowlist allowlist — CI’de auto mode + sıkı
permissions.deny
Code Review GitHub App
Anthropic’in resmi App’i (claude-code-review veya benzeri) PR’lara otomatik yorum bırakır. Workflow yazmadan kurulum:
- GitHub Marketplace’ten App’i kur
- Repo’ya yetki ver
- Settings → permission’ları daralt
- Her PR’da otomatik comment
App vs custom Action karşılaştırma:
| Boyut | App | Custom Action |
|---|---|---|
| Setup süresi | 5 dk | 30+ dk |
| Özelleştirme | Düşük | Tam kontrol |
| API key yönetimi | Anthropic taraflı | Senin secret’ın |
| Maliyet görünürlüğü | App dashboard | Anthropic Console |
| Branding | ”Claude” | Senin botun |
Webhook + RemoteTrigger
Daha gelişmiş: GitHub webhook → senin endpoint → Claude Code’u routine olarak tetikle.
/schedule create "deploy success notification" "node notify.js"
RemoteTrigger API ile dış sistemler routine’i tetikleyebilir — Slack komutu, GitLab webhook, monitoring alert vs.
GitLab CI eşdeğeri
claude_review:
image: node:20
script:
- npm install -g @anthropic-ai/claude-code
- claude --headless --prompt "$CI_COMMIT_MESSAGE diff review" > review.md
artifacts:
paths: [review.md]
Aynı pattern, farklı CI.
Karar matrisi
| İhtiyaç | Çözüm |
|---|---|
| Hızlı PR review otomasyonu | GitHub App |
| Özel prompt + kurum stili | Custom GH Actions |
| GitLab/Bitbucket | Custom CI script |
| Slack üzerinden tetik | Slack entegrasyonu + RemoteTrigger |
| Daily standup oluşturma | /schedule routine |
| Build artifact analiz | Custom action |
| Branch protection rule olarak | GH App + required check |
Pratik (bu repo)
claudenews’te zaten .github/workflows/sync-and-deploy.yml Claude’la değil ama benzer pattern: cron + push trigger → script çalıştır → deploy branch güncelle. Üzerine bir Claude review katmanı eklemek için yukarıdaki YAML’i .github/workflows/ altına koymak yeter.
Sıradaki
Bu path bitti — ileride agent teams ve workflows sayfasından açık-kaynak pipeline koleksiyonlarına gözat.