C.W.K.
Stream
Lesson 13 of 13 · published

자동화, CI/CD, Headless 패턴

~22 min · automation, ci-cd, headless, github-actions, scripting

Level 0🌱 입문자
0 XP0/70 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

터미널에서 파이프라인까지

Claude Code 가 -p + --allowedTools + --output-format json 으로 돌릴 수 있게 되면 인간 전용 도구가 아니라 파이프라인 primitive 가 돼. 코드 작성 도와주던 같은 모델이 이제 CI 에서 PR 리뷰하고, 매일 밤 release notes 생성하고, 사람이 보기 전에 에러 triage 해.

패턴들: TDD 루프 (failing test 먼저 요청, 그 다음 implement, 그 다음 refactor — Claude 가 red/green/refactor 잘함), diff 리뷰 (CI 단계에서 git diff main...HEAD | claude -p), downstream 용 JSON (jq 로 Claude 의 구조화 output 파싱, 발견사항으로 파이프라인 게이팅), 최소 권한 자동화 (--allowedTools 가 Claude 한테 일에 필요한 거만 주고 다른 거 X).

Anthropic 이 공식 GitHub Action 출하 — anthropics/claude-code-action@v1 — 흔한 케이스용 (PR 의 @claude mention 이 에이전트 run 트리거). 그 외에는 같은 primitive 직접 오케스트레이션.

Code

Headless review in shell·bash
#!/bin/bash
# scripts/ai-review.sh
set -euo pipefail

DIFF=$(git diff origin/main...HEAD)
[ -z "$DIFF" ] && { echo "no changes"; exit 0; }

REVIEW=$(echo "$DIFF" | claude -p \
  "Review this diff. Format: [SEVERITY: HIGH|MEDIUM|LOW] desc (file:line)" \
  --output-format text \
  --allowedTools "Read,Bash(git log *)")

echo "$REVIEW" > "review-$(date +%Y%m%d-%H%M%S).md"
echo "$REVIEW"

# Gate the pipeline
if echo "$REVIEW" | grep -q "SEVERITY: HIGH"; then
  echo "high-severity findings, blocking"
  exit 1
fi
GitHub Actions PR review·yaml
# .github/workflows/claude-review.yml
name: Claude PR Review
on:
  pull_request:
    types: [opened, synchronize]

permissions:
  contents: read
  pull-requests: write

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }

      - uses: actions/setup-node@v4
        with: { node-version: '22' }

      - run: npm install -g @anthropic-ai/claude-code

      - name: Run Claude review
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
        run: |
          git diff origin/main...HEAD | claude -p \
            "Review for bugs, security, missing tests. Markdown output." \
            --output-format text \
            --allowedTools "Read,Bash(git log *),Bash(git show *)" \
            > review.md

      - uses: actions/github-script@v7
        with:
          script: |
            const fs = require('fs');
            const review = fs.readFileSync('review.md', 'utf8');
            github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              body: '## Claude Code Review\n\n' + review
            });

External links

Exercise

실제 Claude review 단계를 repo 에 wire — push 전 로컬 스크립트, 또는 PR 의 GitHub Action. --allowedTools 로 최소 권한 부여. 실제 PR 에 테스트. 게시되는 댓글 캡처.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.