Lesson 12 · 10 dk okuma

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_KEY repo 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:

  1. GitHub Marketplace’ten App’i kur
  2. Repo’ya yetki ver
  3. Settings → permission’ları daralt
  4. Her PR’da otomatik comment

App vs custom Action karşılaştırma:

BoyutAppCustom Action
Setup süresi5 dk30+ dk
ÖzelleştirmeDüşükTam kontrol
API key yönetimiAnthropic taraflıSenin secret’ın
Maliyet görünürlüğüApp dashboardAnthropic 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 otomasyonuGitHub App
Özel prompt + kurum stiliCustom GH Actions
GitLab/BitbucketCustom CI script
Slack üzerinden tetikSlack entegrasyonu + RemoteTrigger
Daily standup oluşturma/schedule routine
Build artifact analizCustom action
Branch protection rule olarakGH 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.