| description | argument-hint |
|---|---|
Review AI comments on a GitHub PR, apply fixes when appropriate, resolve threads, and notify on Ubuntu |
REPO="<owner/repo|.>" PR_NUMBER=<number> [MODE="<apply|dry-run>"] |
You are an autonomous coding agent working against a GitHub repository.
Inputs:
- REPO: $REPO
- If ".", assume the current working directory is the target repo.
- Otherwise clone the repository using existing credentials (gh auth or GITHUB_TOKEN).
- PR_NUMBER: $PR_NUMBER
- MODE: $MODE
- Default is "apply".
- When MODE is "dry-run": do not modify files, commit, push, or resolve review threads.
Task:
-
Prepare the repository and PR branch.
- If $REPO is not ".", clone it as needed.
- Check out the PR branch for PR #$PR_NUMBER.
Prefer
gh pr checkout $PR_NUMBER.
-
Fetch PR metadata and review comments.
- Retrieve PR #$PR_NUMBER.
- List all review threads and their comments.
-
For each review thread:
- Skip the thread entirely if it is already marked as resolved.
- Extract referenced file path, line numbers, diff hunk, etc.
- Because reviewers may reference outdated commits, file paths and line numbers may not match HEAD.
- Attempt to locate corresponding code via:
- File path or rename detection
- Diff hunk context search
- Fuzzy/text search
- If the location cannot be reliably determined, classify the comment as obsolete.
-
Determine whether the unresolved comment is appropriate:
- Appropriate: real bug, correctness, safety, style-consistency, performance issue, or clear improvement.
- Inappropriate: outdated, incorrect, conflicting with conventions, or unsafe.
-
If MODE is "dry-run":
- Do not change files, commit, push, or resolve threads.
- Output classification and intended actions.
- Summarize and stop.
-
If MODE is "apply":
-
Strict rule: “1 review thread = 1 commit”.
Do NOT merge fixes across multiple threads. -
For each unresolved & appropriate thread:
-
Apply the minimal fix.
-
Run tests or linters if reasonable.
-
Stage only the changes related to this thread.
- 1行目: 修正内容を簡潔に記す
- 2行目: 空行
- 3行目: 該当レビューコメントの GitHub パーマリンク URL
Example:
Fix incorrect null check https://github.com/<owner>/<repo>/pull/<pr>/#discussion_r123456789Before committing, Codex MUST set:
export GIT_AUTHOR_DATE="$(date -R --date='TZ=\"Asia/Tokyo\" now')" export GIT_COMMITTER_DATE="$(date -R --date='TZ=\"Asia/Tokyo\" now')"or equivalently ensure both timestamps use UTC+9 (JST).
All commits must have timestamps in UTC+9. -
Create exactly one commit for this thread.
-
Push commit if appropriate.
-
Resolve the review thread via GitHub API or gh CLI.
-
Prefix all replies with
[Codex].
Example:
[Codex] Addressed via commit <sha>.
-
-
For each unresolved & inappropriate/obsolete thread:
- Do not modify code.
- Resolve the thread.
- Reply with
[Codex]prefix:
[Codex] This comment refers to outdated code and no longer applies.
-
-
After all threads are processed:
- Ensure a clean working tree.
- Optionally leave a PR summary comment (prefixed with
[Codex]):- Threads processed
- Number of commits (1 per thread)
- Threads resolved without changes
-
Ubuntu completion notification:
- If MODE is apply:
- Execute
canberra-gtk-play --id=complete. - If unavailable, print a fallback note.
- Execute
- If MODE is apply:
Avoid unnecessary force-push. Always keep changes minimal, localized to each thread, and safe.