AI 해결 노트 · 2026-09-17 · 실측 2026-09-17

커밋 전에 Codex CLI로 코드 리뷰 받기 — codex review --uncommitted 윈도우 실측

한 줄로

codex review --uncommitted는 스테이징 여부와 상관없이 아직 커밋하지 않은 변경과 추적 안 되는 새 파일까지 묶어 리뷰합니다. 일부러 버그 둘을 넣은 임시 저장소에서 돌려 보니 지적 3건이 모두 실제 테스트 실패와 맞았습니다. 다만 codex는 테스트를 직접 돌리지 못했고, --uncommitted와 리뷰 지시문은 함께 쓸 수 없었습니다.

이런 분께

실측 환경

항목
OSWindows 11 Home (10.0.26200)
Git Bash, PowerShell 7.6.6
codexcodex-cli 0.153.4
모델(실행 머리말 표시)gpt-6-astra
테스트용 PythonPython 3.12.10
저장소임시 폴더의 git 저장소(커밋 1개)

리뷰를 시도한 세 명령에는 모두 < /dev/null을 붙여 stdin이 바로 끝나게 했습니다. 관련 글: codex exec가 stdin 대기에서 안 끝날 때.

도움말에 있는 옵션

codex review --help에서 리뷰 대상을 고르는 옵션입니다.

Usage: codex review [OPTIONS] [PROMPT]

      --uncommitted
          Review staged, unstaged, and untracked changes

      --base <BRANCH>
          Review changes against the given base branch

      --commit <SHA>
          Review the changes introduced by a commit

      --title <TITLE>
          Optional commit title to display in the review summary

공식 문서의 명령 표에도 같은 설명이 있습니다. --uncommitted: "Review staged, unstaged, and untracked changes." (learn.chatgpt.com/docs/developer-commands?surface=cli, 2026-09-17 확인)

codex review --help에는 -o--json이 없습니다. 이 둘은 codex exec review --help에 있어서, 결과를 파일로 받을 때는 그쪽을 썼습니다(아래 3절).

1. 버그를 넣은 저장소 준비

정상 버전 stats.py를 커밋한 뒤, 커밋하지 않은 변경으로 버그 둘을 넣었습니다. clamp의 상한 hilo로 잘못 바꿨고, 새로 넣은 median은 짝수 길이 입력을 처리하지 않습니다. 테스트 파일 test_stats.py는 추적하지 않는 새 파일로 두었습니다.

37d0534 add stats
 M stats.py
?? test_stats.py
--- git diff ---
 def clamp(x, lo, hi):
-    return max(lo, min(x, hi))
+    return max(lo, min(x, lo))
+
+
+def median(nums):
+    s = sorted(nums)
+    mid = len(s) // 2
+    return s[mid]

리뷰 전에 테스트를 먼저 돌렸습니다. 테스트에는 「빈 목록이면 ValueError」라는 요구도 넣어 두었습니다.

PASS average([1, 2, 3]) == 2
PASS average([]) == 0.0
FAIL clamp(5, 0, 10) == 5
PASS clamp(-1, 0, 10) == 0
FAIL clamp(99, 0, 10) == 10
PASS median([3, 1, 2]) == 2
FAIL median([4, 1, 3, 2]) == 2.5
FAIL median([]) raises ValueError -> IndexError
4 failed

2. codex review --uncommitted 실행

cd review
codex review --uncommitted < /dev/null; echo "codex exit=$?"

전후 git status까지 포함한 전체 명령이 57.8초 걸렸고 종료 코드는 0이었습니다. 리뷰 본문은 표준출력으로, 실행 머리말과 codex가 돌린 명령은 표준오류로 나왔습니다. 머리말에서 저희가 지정하지 않은 값이 이렇게 찍혔습니다.

model: gpt-6-astra
approval: never
sandbox: read-only
user
current changes

표준출력에 나온 리뷰는 요약 한 문단과 우선순위가 붙은 지적 3건입니다(줄 설명은 줄였습니다).

The patch breaks clamp and fails the stated median expectations for even-length and empty inputs. Test execution was unavailable because Python was not installed on PATH; these failures are evident from inspection.

Full review comments:

- [P1] Restore the upper bound in clamp — C:/Users/User/AppData/Local/Temp/longtail_A2/review/stats.py:8-8
- [P2] Average the middle values for even-length inputs — C:/Users/User/AppData/Local/Temp/longtail_A2/review/stats.py:13-14
- [P2] Raise ValueError for an empty median input — C:/Users/User/AppData/Local/Temp/longtail_A2/review/stats.py:12-14

리뷰가 끝난 뒤 git status는 실행 전과 같았습니다( M stats.py, ?? test_stats.py). 파일을 고치지는 않았습니다.

지적을 실제 결과와 대조

지적 안의 수치를 Python으로 따로 확인했습니다.

clamp(5, 0, 10) = 0
clamp(99, 0, 10) = 0
clamp(-1, 0, 10) = 0
median([4, 1, 3, 2]) = 3
median([]) -> IndexError list index out of range
지적codex가 말한 값실제 실행테스트 실패와의 대응
P1 clamp 상한clamp(5, 0, 10), clamp(99, 0, 10) 모두 0 반환둘 다 0FAIL 2건과 맞음
P2 짝수 길이 medianmedian([4, 1, 3, 2])가 3 반환3FAIL 1건과 맞음
P2 빈 입력 medianIndexError 발생, 테스트는 ValueError 요구IndexErrorFAIL 1건과 맞음

테스트 실패 4건이 지적 3건에 모두 들어갔고, 실패와 무관한 지적은 없었습니다. P1 설명의 「보통 숫자 입력이면 clamp가 늘 lo를 돌려준다」는 문장도 세 입력 모두 0이 나와 맞았습니다.

지적대로 고친 사본(clamphi 복구, median은 빈 입력이면 ValueError, 짝수 길이면 가운데 두 값의 평균)에서 테스트를 다시 돌리자 0 failed, 종료 코드 0이었습니다.

codex는 테스트를 돌리지 못했습니다

리뷰 요약에는 "Python was not installed on PATH"라고 적혔습니다. 표준오류를 보면 codex가 PowerShell로 python -B test_stats.py를 실행했고 CommandNotFoundException이 났습니다. 오류 설명 부분은 한글이 깨져서 읽을 수 없었습니다.

    + CategoryInfo          : ObjectNotFound: (python:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

같은 PC에서 저희가 pwsh -NoProfile로 찾았을 때는 C:\Users\User\AppData\Local\Programs\Python\Python312\python.exe가 나왔습니다. codex가 명령을 실행한 환경에서만 python을 못 찾은 것입니다. 샌드박스 모드별 PowerShell 환경 비교는 Codex 샌드박스 read-only vs workspace-write에 따로 적었습니다. 결과적으로 이번 리뷰는 코드를 읽고 내린 판단이었고, 요약 문장도 "evident from inspection"이라고 밝혔습니다.

3. 결과를 파일로 받기 — codex exec review

codex exec review --uncommitted --ephemeral -o ../review_out.md < /dev/null; echo "codex exit=$?"

55.7초, 종료 코드 0. review_out.md는 1327바이트였고, 지적한 문제 3개와 우선순위(P1 1건, P2 2건)는 2절과 같았습니다. P2 제목 2개는 표현이 달랐습니다(Average the two middle values for even-length inputs, Reject empty median inputs with ValueError). 설명 문장도 조금씩 달랐고, 파일 경로가 C:\Users\...\stats.py:8-8처럼 역슬래시로 찍혔습니다. 표준출력에도 같은 리뷰가 한 번 더 나왔습니다. 이번에도 codex의 python -B test_stats.py 실행은 같은 CommandNotFoundException으로 실패했습니다.

결과

회차명령종료 코드걸린 시간결과
1codex review --uncommitted057.8초(전후 확인 포함)지적 3건, 모두 테스트 실패와 맞음
2codex review --uncommitted "Focus only on clamp."20.7초인자 충돌 오류
3codex exec review --uncommitted --ephemeral -o ../review_out.md055.7초1327바이트 파일, 지적 3건

실패한 것

2회차에서 --uncommitted에 리뷰 지시문을 붙였더니 바로 거절됐습니다.

error: the argument '--uncommitted' cannot be used with '[PROMPT]'

Usage: codex review --uncommitted [PROMPT]

도움말의 Usage 줄에는 [PROMPT]가 있지만, 0.153.4에서는 --uncommitted와 지시문을 한 번에 줄 수 없었습니다. 「clamp만 봐 달라」 같은 범위 지정은 이 조합으로는 못 했습니다.

codex가 테스트를 실행하지 못한 것도 이번 실험의 한계입니다. 그 환경에서 python을 못 찾은 원인은 밝히지 못했습니다.

확인하지 않은 것

함께 보기