본문 바로가기
C.W.K.
Stream
Lesson 08 of 11 · published

Codex로 코드 리뷰하기

~14 min · codex, review, diff, pr-review

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

Codex를 변경 사항을 읽는 두 번째 눈으로 써

git diff main...HEAD | codex exec로 변경분을 바로 검토할 수 있어. 자동화에서는 --sandbox read-only --ask-for-approval never를 함께 써 Codex가 파일을 바꾸지 못하는 순수 검토자로 고정해.

빠른 diff 검토는 patch 안의 뚜렷한 버그를 찾는 데 좋고, 더 깊은 검토는 전체 파일과 주변 구현까지 읽어 문맥 속 문제를 찾아. 결과를 CI에서 다룰 때는 JSON으로 받아 jq로 심각도를 나누고, 자유 텍스트를 억지로 해석하지 마.

검토 깊이는 1) patch만 읽는 빠른 diff 검토와 2) 주변 파일까지 읽는 문맥 포함 검토로 나뉘어.

직접 확인할 항목: --ask-for-approval never --sandbox read-only.

Code

명령 하나로 Diff 검토하기·bash
# Fast: review the patch alone
git diff main...HEAD | codex exec \
  --ask-for-approval never --sandbox read-only \
  "Review for bugs, security, and missing tests. Format:
   [SEVERITY] desc (file:line)" \
  --output-last-message > review.md

# In-context: full file + diff
codex exec --ask-for-approval never --sandbox read-only \
  "Read src/auth.ts in full, then review the staged changes
   in context. Flag any newly-introduced inconsistencies." \
  > review.md
GitHub Action에서 리뷰 게시하기·yaml
name: Codex 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 @openai/codex
      - name: Run review
        env: { OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} }
        run: |
          git diff origin/main...HEAD | codex exec \
            --ask-for-approval never --sandbox read-only \
            "PR review: bugs, security, perf, style." \
            --output-last-message > 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: '## Codex Review\n' + review
            });

External links

Exercise

Codex 리뷰를 실제 저장소의 작업 흐름에 연결해. push 전 셸 스크립트나 GitHub Action 중 하나를 골라 구성하고, 실제 PR에서 시험한 뒤 리뷰 댓글을 캡처해.

Progress

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

댓글 0

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

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