Skip to content

feat/add ci failure handling instructions - #346

Merged
keito4 merged 9 commits into
mainfrom
feat/add-ci-failure-handling-instructions
Jan 16, 2026
Merged

feat/add ci failure handling instructions#346
keito4 merged 9 commits into
mainfrom
feat/add-ci-failure-handling-instructions

Conversation

@keito4

@keito4 keito4 commented Jan 15, 2026

Copy link
Copy Markdown
Owner
  • feat: PR作成後のCI失敗対応ルールを追加
  • feat: PR作成時にCodexレビューを必須化
  • fix: Codexレビュー指摘事項を修正
  • refactor: Codex ReviewとCI CheckをSkillsに移行

Summary

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD changes
  • Dependencies update

Related Issues

Changes Made

Testing

  • Unit tests pass (npm test)
  • Integration tests pass (npm run test:integration)
  • Linting passes (npm run lint)
  • Format check passes (npm run format:check)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • I have updated the documentation accordingly
  • My changes generate no new warnings
  • I have added tests that prove my fix/feature works
  • All existing tests still pass
  • This PR has a clear, descriptive title

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

  • Documentation

    • Added step-by-step CI troubleshooting and failure-handling guide.
    • Added guidance for automated AI review workflows and plan-review processes.
  • New Features

    • Non-blocking automated AI code reviews run after PR creation.
    • Automated execution-plan reviews before exiting, which can block if revisions are required.
    • New configuration options to enable and wire these integrated review hooks and permissions.

✏️ Tip: You can customize this high-level summary in your review settings.

keito4 and others added 4 commits January 14, 2026 08:54
PR作成後にCIが失敗した場合、そのブランチで解決できる問題は
必ず修正するよう指示するルールを追加しました。

## 変更内容

- `.claude/CLAUDE.md`: セクション2.5としてCI失敗対応ルールを追加
- `.claude/commands/create-pr.md`: Step 8としてCI失敗時のフォローアップ手順を追加

## 追加された指示

- CIが緑になるまでPRを放置しない
- 修正可能な問題は自分のブランチで解決する
- 解決不能な場合は原因と状況を明記してレビュアーに報告

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR作成ワークフローにOpenAI Codexによるコードレビューを追加しました。

## 変更内容

- `/codex-review`コマンドを新規作成
  - `codex exec`を使用した非対話モードでのレビュー実行
  - 正確性・性能・セキュリティ・保守性・DXの観点でレビュー
  - verdict(正/誤)とconfidenceスコアを出力

- `create-pr.md`にStep 5としてCodexレビューを追加
  - PR作成前にCodexレビューを実行
  - verdictが"patch is incorrect"の場合は修正を実施
  - レビュー結果をPR本文に記載

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR本文テンプレートの未定義変数を説明的なテキストに修正しました。

## 修正内容

- `${VERDICT}`、`${CONFIDENCE}`、`${ISSUES_COUNT}`を
  説明的なプレースホルダーに変更
- レビュー結果の記録方法を明確化

## Codex Review

- Verdict: patch is correct
- Confidence: 1.0
- 指摘事項: 1件(対応済み)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR作成ワークフローからCodex ReviewとCI Checkのステップを削除し、
Skillsとして分離しました。

## 変更内容

- `.claude/skills/codex-review.md`: Codex Review skillを新規作成
- `.claude/skills/ci-check.md`: CI Check skillを新規作成
- `.claude/commands/create-pr.md`: Skills参照セクションを追加
- `.claude/commands/codex-review.md`: 削除(Skillsに移行)

## 動作

PR作成後、以下のSkillsが自動的に適用されます:
1. Codex Review: コードレビューを実行
2. CI Check: CIの結果を確認し、失敗時は修正

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jan 15, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds AI review and CI-check documentation plus two new Claude hooks (post-PR and pre-exit-plan) and updates the Claude settings template to register those hooks and allow Codex/Gemini execution permissions.

Changes

Cohort / File(s) Summary
Skills / Docs
.claude/skills/ci-check.md, .claude/skills/codex-review.md
New docs: CI Check Skill (CI inspection, failure triage, remediation/reporting) and Codex Review Skill (how to run/interpret codex exec review).
Hook README
.claude/hooks/README.md
Added documentation describing two AI review hooks, prerequisites, behavior, and wiring examples.
Hook Scripts
.claude/hooks/post_pr_ai_review.py, .claude/hooks/pre_exit_plan_ai_review.py
New Python hooks: post_pr_ai_review runs non-blocking Codex/Gemini reviews after gh pr create; pre_exit_plan_ai_review runs blocking plan reviews before ExitPlanMode (exit code 2 if revision needed). Both detect tool availability, handle timeouts/errors, and print structured outputs.
Settings / Config
.claude/settings.local.json.template
Added PreToolUse and PostToolUse hook entries (block git --no-verify, quality gates, pre-exit AI review, post-PR AI review) and extended permissions.allow with Bash(codex:*), Bash(codex exec:*), Bash(gemini:*).

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Claude
    participant Bash as "Bash Tool"
    participant GitHub as "GitHub/gh"
    participant Codex
    participant Gemini

    User->>Claude: Create PR (push + request)
    Claude->>Bash: Execute: gh pr create
    Bash->>GitHub: Create PR
    GitHub-->>Bash: PR URL
    Bash-->>Claude: Tool output (stdout/stderr)
    Note over Claude: PostToolUse hook -> post_pr_ai_review.py
    Claude->>Claude: Extract PR URL, detect Codex/Gemini
    par AI reviews (non-blocking)
        Claude->>Codex: Run read-only review (codex exec)
        Codex-->>Claude: Verdict + details
    and
        Claude->>Gemini: Run diff-based review
        Gemini-->>Claude: Verdict + details
    end
    Claude-->>Claude: Emit structured outputs to stderr and exit 0
Loading
sequenceDiagram
    actor User
    participant Claude
    participant ExitPlanMode
    participant FS as "File System (~/.claude/plans)"
    participant Codex
    participant Gemini

    User->>Claude: Invoke ExitPlanMode
    Claude->>ExitPlanMode: Trigger
    Note over Claude: PreToolUse hook -> pre_exit_plan_ai_review.py
    Claude->>FS: Locate latest plan.md
    FS-->>Claude: Plan content
    Claude->>Claude: Detect Codex/Gemini, build prompts
    par AI plan reviews (blocking)
        Claude->>Codex: Run plan review
        Codex-->>Claude: Verdict
    and
        Claude->>Gemini: Run plan review
        Gemini-->>Claude: Verdict
    end
    Claude->>Claude: Aggregate verdicts
    alt Any tool => "needs revision"
        Claude-->>User: Print messages, exit 2 (block)
    else
        Claude-->>User: Print success, exit 0 (proceed)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

released

Poem

🐰 I hopped through PRs with a cheerful peep,

Codex and Gemini watch while I sleep,
Logs and diffs in a tidy row,
I nudge the plans where they need to grow,
Hopping back—CI green, and onward we go!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically summarizes the main change: adding CI failure handling instructions as documented in the new .claude/skills/ci-check.md file and related workflow updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

🧹 Recent nitpick comments
.claude/hooks/post_pr_ai_review.py (2)

113-125: Consider logging git errors for easier debugging.

If git merge-base fails (e.g., origin/main doesn't exist or isn't fetched), only a generic message is shown. Logging merge_base_result.stderr would help users diagnose the issue.

♻️ Suggested improvement
         merge_base = merge_base_result.stdout.strip()

         if not merge_base:
-            print("⚠️  マージベースの取得に失敗しました", file=sys.stderr)
+            error_msg = merge_base_result.stderr.strip() if merge_base_result.stderr else "unknown error"
+            print(f"⚠️  マージベースの取得に失敗しました: {error_msg}", file=sys.stderr)
             return

148-150: Consider warning when diff is truncated.

Large diffs are silently truncated to 50,000 characters. For very large PRs, the reviewer may miss important context at the end of the diff without realizing it.

♻️ Suggested improvement
+        max_diff_length = 50000
+        if len(diff_content) > max_diff_length:
+            print(f"⚠️  diff is large ({len(diff_content)} chars), truncating to {max_diff_length} chars", file=sys.stderr)
+
         # Gemini用のプロンプト(diffを含める)
         gemini_prompt = f"""You are acting as a reviewer for a proposed code change.
 Focus on issues that impact correctness, performance, security, maintainability, or developer experience.
@@ -147,7 +151,7 @@

 ## Git Diff to Review:

-{diff_content[:50000]}"""
+{diff_content[:max_diff_length]}"""

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bfe551a and c055f51.

📒 Files selected for processing (1)
  • .claude/hooks/post_pr_ai_review.py
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T10:08:03.062Z
Learning: Use GitHub Actions and Claude Code integration for automated issue resolution, PR review support, quality checks, and documentation synchronization
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T10:08:03.062Z
Learning: Follow the GitHub Issues workflow: create issues with clear requirements and acceptance criteria, mention claude for AI assistance, ensure quality checks pass, and conduct human code review in PRs
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml

Applied to files:

  • .claude/hooks/post_pr_ai_review.py
📚 Learning: 2026-01-12T10:08:03.062Z
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T10:08:03.062Z
Learning: Use GitHub Actions and Claude Code integration for automated issue resolution, PR review support, quality checks, and documentation synchronization

Applied to files:

  • .claude/hooks/post_pr_ai_review.py
📚 Learning: 2026-01-12T10:08:03.062Z
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T10:08:03.062Z
Learning: Follow the GitHub Issues workflow: create issues with clear requirements and acceptance criteria, mention claude for AI assistance, ensure quality checks pass, and conduct human code review in PRs

Applied to files:

  • .claude/hooks/post_pr_ai_review.py
🧬 Code graph analysis (1)
.claude/hooks/post_pr_ai_review.py (1)
.claude/hooks/pre_exit_plan_ai_review.py (2)
  • run_codex_review (91-128)
  • run_gemini_review (131-167)
🪛 Ruff (0.14.11)
.claude/hooks/post_pr_ai_review.py

29-29: Comment contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF003)


29-29: Comment contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF003)


41-41: Comment contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF003)


41-41: Comment contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF003)


54-54: String contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF001)


54-54: String contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF001)


86-86: subprocess call: check for execution of untrusted input

(S603)


102-102: String contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF001)


102-102: String contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF001)


103-103: Do not catch blind exception: Exception

(BLE001)


108-108: Docstring contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF002)


108-108: Docstring contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF002)


116-116: Starting a process with a partial executable path

(S607)


128-128: subprocess call: check for execution of untrusted input

(S603)


129-129: Starting a process with a partial executable path

(S607)


140-140: Comment contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF003)


140-140: Comment contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF003)


154-154: subprocess call: check for execution of untrusted input

(S603)


169-169: String contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF001)


169-169: String contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF001)


170-170: Do not catch blind exception: Exception

(BLE001)


186-186: Comment contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF003)


186-186: Comment contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF003)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: check-ci-status
🔇 Additional comments (7)
.claude/hooks/post_pr_ai_review.py (7)

1-13: LGTM!

Imports are appropriate and well-organized for the hook's functionality. The docstring clearly explains the purpose.


15-35: LGTM!

Input parsing and command filtering logic is solid. The prefix check for gh pr create and help exclusion are appropriate safeguards.


37-47: LGTM!

Using PR URL presence as success indicator is robust—more reliable than relying solely on exit codes.


49-55: LGTM!

Clean tool availability detection using shutil.which(). The graceful skip with warning is appropriate for optional tooling.


57-65: LGTM!

Well-crafted review prompt with clear instructions for correctness verdict and confidence scoring.


73-104: LGTM!

The Codex review function follows the established pattern from pre_exit_plan_ai_review.py. The sandbox mode, timeout, and error handling are appropriate for a non-blocking hook.


174-187: LGTM!

Sequential execution of available tools with unconditional success exit is the correct approach for a non-blocking PostToolUse hook.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.claude/skills/codex-review.md:
- Around line 18-20: The long reviewer prompt is embedded directly in the codex
exec command which is hard to maintain and escape; refactor by extracting the
prompt into a heredoc assigned to a PROMPT variable (using cat <<'EOF' ... EOF)
and then invoke codex exec --sandbox read-only "$PROMPT", or alternatively store
the prompt text in a separate file (e.g.,
.claude/prompts/codex-review-prompt.txt) and call codex exec --sandbox read-only
"$(cat .claude/prompts/codex-review-prompt.txt)"; update the invocation that
previously contained the inline prompt to use PROMPT (or the cat file
substitution) and ensure quoting preserves literal content.
🧹 Nitpick comments (1)
.claude/CLAUDE.md (1)

63-79: Consider consolidating duplicated CI failure principles.

The three principles listed here (lines 76-78) are duplicated verbatim in .claude/skills/ci-check.md (lines 58-60). This creates maintenance overhead if the guidelines need updates in the future.

💡 Recommendation to reduce duplication

Consider one of these approaches:

Option 1: Keep high-level guidance here in CLAUDE.md and reference it from ci-check.md:

 ## 原則
 
-- CIが緑になるまでPRを放置しない
-- 修正可能な問題は自分のブランチで解決する
-- 解決不能な場合は原因と状況を明記してレビュアーに報告
+詳細は [CLAUDE.md § 2.5](./../CLAUDE.md#25-pr作成後のci失敗対応) を参照。

Option 2: Keep detailed workflow in ci-check.md and link from CLAUDE.md:

-**原則**:
-
-- CIが緑になるまでPRを放置しない
-- 修正可能な問題は自分のブランチで解決する
-- 解決不能な場合は原因と状況を明記してレビュアーに報告
+詳細な対応フローは [CI Check Skill](./skills/ci-check.md) を参照。
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97dda46 and fb60327.

📒 Files selected for processing (4)
  • .claude/CLAUDE.md
  • .claude/commands/create-pr.md
  • .claude/skills/ci-check.md
  • .claude/skills/codex-review.md
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T10:08:03.062Z
Learning: Follow the GitHub Issues workflow: create issues with clear requirements and acceptance criteria, mention claude for AI assistance, ensure quality checks pass, and conduct human code review in PRs
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T10:08:03.062Z
Learning: Use GitHub Actions and Claude Code integration for automated issue resolution, PR review support, quality checks, and documentation synchronization
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml
📚 Learning: 2026-01-12T10:08:03.062Z
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T10:08:03.062Z
Learning: Use GitHub Actions and Claude Code integration for automated issue resolution, PR review support, quality checks, and documentation synchronization

Applied to files:

  • .claude/skills/codex-review.md
  • .claude/commands/create-pr.md
  • .claude/skills/ci-check.md
  • .claude/CLAUDE.md
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to {.codex/**,.devcontainer/codex*,package*.json,npm/global.json} : Use Conventional Commits format with release-triggering types (feat/fix/perf/revert/docs) for commits touching .codex/**, .devcontainer/codex*, package*.json, or npm/global.json

Applied to files:

  • .claude/skills/codex-review.md
📚 Learning: 2026-01-12T10:08:03.062Z
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T10:08:03.062Z
Learning: Follow the GitHub Issues workflow: create issues with clear requirements and acceptance criteria, mention claude for AI assistance, ensure quality checks pass, and conduct human code review in PRs

Applied to files:

  • .claude/commands/create-pr.md
  • .claude/skills/ci-check.md
  • .claude/CLAUDE.md
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml

Applied to files:

  • .claude/commands/create-pr.md
  • .claude/skills/ci-check.md
  • .claude/CLAUDE.md
📚 Learning: 2026-01-12T10:08:03.062Z
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T10:08:03.062Z
Learning: Follow the development quality standards defined in `CLAUDE.md`

Applied to files:

  • .claude/skills/ci-check.md
  • .claude/CLAUDE.md
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/ci.yml : Validate code quality in CI pipeline (.github/workflows/ci.yml) with linting, formatting, testing, and building

Applied to files:

  • .claude/skills/ci-check.md
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Use structured approach for AI prompt design with clear separation between requirements gathering and code generation phases, emphasizing test-first development practices

Applied to files:

  • .claude/CLAUDE.md
🔇 Additional comments (7)
.claude/commands/create-pr.md (2)

242-256: Good architectural separation of concerns.

Extracting the Codex Review and CI Check workflows into separate skill files (referenced here) promotes modularity and reusability. This approach allows these skills to be invoked independently from other workflows.


238-256: No duplication found—section appears only once.

The "PR作成後のフォローアップ(Skills)" section exists only at line 238 and is not duplicated. No action is needed.

Likely an incorrect or invalid review comment.

.claude/skills/codex-review.md (2)

1-13: Clear prerequisites and scope definition.

The frontmatter description and prerequisites clearly establish when and how this skill should be applied.


22-36: Well-structured verdict handling workflow.

The three-tier response strategy (correct verdict, incorrect verdict, and severity-based prioritization) provides clear actionable guidance.

.claude/skills/ci-check.md (3)

35-45: Comprehensive and actionable failure patterns.

The table covers common CI failure scenarios with specific remediation commands. The patterns are practical and the responses are concrete.


20-34: Clear three-step remediation workflow.

The structured flow (identify → fix → verify) provides a systematic approach to CI failure resolution, aligning with the principles defined in CLAUDE.md.


9-18: GitHub CLI commands are correct and complete.

All commands and flags have been verified: gh pr checks, gh run list --limit, and gh run view --log-failed are valid and work as documented.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +18 to +20
```bash
codex exec --sandbox read-only "You are acting as a reviewer for a proposed code change made by another engineer. Focus on issues that impact correctness, performance, security, maintainability, or developer experience. Flag only actionable issues introduced by the change. When you flag an issue, provide a short, direct explanation and cite the affected file and line range. Prioritize severe issues and avoid nit-level comments unless they block understanding of the diff. After listing findings, produce an overall correctness verdict ('patch is correct' or 'patch is incorrect') with a concise justification and a confidence score between 0 and 1. Review the current branch against origin/main. Use git merge-base to find the merge base, then review the diff from that merge base to HEAD."
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Refactor embedded prompt for maintainability.

The 500+ character prompt is embedded directly in the bash command, making it difficult to maintain, version, and modify. Prompt changes require careful attention to bash escaping and quoting.

♻️ Proposed refactor using heredoc
-```bash
-codex exec --sandbox read-only "You are acting as a reviewer for a proposed code change made by another engineer. Focus on issues that impact correctness, performance, security, maintainability, or developer experience. Flag only actionable issues introduced by the change. When you flag an issue, provide a short, direct explanation and cite the affected file and line range. Prioritize severe issues and avoid nit-level comments unless they block understanding of the diff. After listing findings, produce an overall correctness verdict ('patch is correct' or 'patch is incorrect') with a concise justification and a confidence score between 0 and 1. Review the current branch against origin/main. Use git merge-base to find the merge base, then review the diff from that merge base to HEAD."
-```
+```bash
+# Codexレビュー用プロンプト
+PROMPT=$(cat <<'EOF'
+You are acting as a reviewer for a proposed code change made by another engineer.
+Focus on issues that impact correctness, performance, security, maintainability, or developer experience.
+Flag only actionable issues introduced by the change.
+When you flag an issue, provide a short, direct explanation and cite the affected file and line range.
+Prioritize severe issues and avoid nit-level comments unless they block understanding of the diff.
+After listing findings, produce an overall correctness verdict ('patch is correct' or 'patch is incorrect')
+with a concise justification and a confidence score between 0 and 1.
+Review the current branch against origin/main.
+Use git merge-base to find the merge base, then review the diff from that merge base to HEAD.
+EOF
+)
+
+codex exec --sandbox read-only "$PROMPT"
+```

Alternatively, store the prompt in a separate file:

```bash
# .claude/prompts/codex-review-prompt.txt に保存
codex exec --sandbox read-only "$(cat .claude/prompts/codex-review-prompt.txt)"
🤖 Prompt for AI Agents
In @.claude/skills/codex-review.md around lines 18 - 20, The long reviewer
prompt is embedded directly in the codex exec command which is hard to maintain
and escape; refactor by extracting the prompt into a heredoc assigned to a
PROMPT variable (using cat <<'EOF' ... EOF) and then invoke codex exec --sandbox
read-only "$PROMPT", or alternatively store the prompt text in a separate file
(e.g., .claude/prompts/codex-review-prompt.txt) and call codex exec --sandbox
read-only "$(cat .claude/prompts/codex-review-prompt.txt)"; update the
invocation that previously contained the inline prompt to use PROMPT (or the cat
file substitution) and ensure quoting preserves literal content.

@keito4

keito4 commented Jan 15, 2026

Copy link
Copy Markdown
Owner Author

(aside)
@claude PRがbaseにマージする際にコンフリクトが発生しています。最新のbaseからpullし、修正してください。

@claude

claude Bot commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Claude finished @keito4's task in 3m 19s —— View job


マージコンフリクトの解決 ✅

以下のタスクを完了しました:

  • 現在のブランチ状態を確認
  • 最新のbaseブランチ(origin/main)を取得
  • origin/mainをマージしてコンフリクトを確認
  • コンフリクトを解決
  • 変更をコミット
  • リモートブランチにプッシュ

解決内容

.claude/commands/create-pr.md でコンフリクトが発生していましたが、以下のように解決しました:

コンフリクトの原因:

  • 現在のブランチ: Skills-based approach(Codex ReviewとCI Check Skillsへの参照)
  • origin/main: 詳細な「Step 8: CI失敗時のフォローアップ」

解決方法:

  • origin/mainの「Step 8: CI失敗時のフォローアップ(必須)」を採用
  • 詳細な対応フロー、コマンド例、対応パターン表を保持
  • CI失敗時の原則を明確化

コミット:

  • e3ae4ac - fix: マージコンフリクトを解決

PRのマージ準備が整いました。CIが正常に完了することをご確認ください。

--- | Branch

github-actions Bot and others added 2 commits January 15, 2026 15:04
origin/mainとのコンフリクトを解決しました。
- .claude/commands/create-pr.md: Step 8のCI失敗時フォローアップを統合

Co-authored-by: keito4 <keito4@users.noreply.github.com>
PR作成後とExitPlanMode前にCodexによる自動レビューを実行するhooksを追加しました。

## 追加ファイル
- .claude/hooks/post_pr_codex_review.py: PR作成後のCodexレビュー
- .claude/hooks/pre_exit_plan_codex_review.py: プラン作成後のCodexレビュー

## 変更ファイル
- .claude/hooks/README.md: 新しいhooksのドキュメント追加
- .claude/settings.local.json.template: hooks設定の推奨テンプレート追加

## 動作
- PR作成後: Codexがコード変更をレビューし結果を表示
- プラン作成後: Codexがプランをレビューし、問題があればブロック

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude

claude Bot commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

PR Review: Codex自動レビューHooksとSkills追加

このPRに対する詳細なレビューを実施しました。全体的に優れた実装ですが、いくつかの改善点と懸念事項があります。

✅ 良い点

1. アーキテクチャ設計

  • 関心の分離: Codex ReviewとCI CheckをSkillsとして分離し、再利用可能な構造を実現
  • 段階的なレビュー: PostToolUse(PR作成後)とPreToolUse(プラン承認前)で適切にレビューポイントを配置
  • グレースフルデグラデーション: Codex CLIが未インストールの場合は警告を出してスキップする設計

2. コード品質

  • エラーハンドリング: タイムアウト、例外、ファイル読み込みエラーなど適切にハンドリング
  • ユーザビリティ: 絵文字と罫線を使った視覚的なフィードバック
  • ドキュメント: README.mdに詳細な説明と設定例を記載

3. ワークフロー統合

  • PR作成後のCI失敗対応ルールを明確化(CLAUDE.md 2.5セクション)

⚠️ 改善提案

1. セキュリティ: コマンドインジェクションのリスク

場所: .claude/hooks/post_pr_codex_review.py:28

問題: 単純な文字列判定は脆弱です

推奨: shlex.split() を使用した適切なコマンドパース

2. エラーハンドリング: exit code の不整合

場所: .claude/hooks/pre_exit_plan_codex_review.py:111, 129

問題: 最後の sys.exit(0) がブロック判定を上書きする可能性

3. テストカバレッジの欠如

新しいPythonスクリプトに対するユニットテストが存在しません

4. タイムアウト値が長すぎる

timeout=600(10分)→ timeout=120(2分)が適切

5. permissions が過度に広い

Bash(codex:) → Bash(codex exec --sandbox read-only:) に限定すべき

6. plan_content 直接埋め込み

f-string への直接埋め込みは危険。json.dumps() でエスケープが必要

📊 全体評価

  • 機能実装: ⭐⭐⭐⭐
  • コード品質: ⭐⭐⭐
  • テストカバレッジ: ⭐
  • セキュリティ: ⭐⭐

🎯 推奨アクション

必須(マージ前):

  1. コマンド判定ロジックのセキュリティ強化
  2. plan_content のエスケープ処理追加
  3. permissions の権限範囲を限定

推奨(次のPR):

  1. ユニットテストの追加
  2. タイムアウト値の最適化
  3. エラーハンドリング修正

📝 結論

価値ある機能追加ですが、セキュリティとテストカバレッジの改善が必要です。上記の必須アクション(1-3)対応後、マージ可能と判断します。

## 修正内容

### post_pr_codex_review.py
- gh pr create の判定をプレフィックス判定に変更
- --help コマンドを除外
- PR URL判定を正規表現で厳密化

### pre_exit_plan_codex_review.py
- Codex実行失敗時に成功メッセージを出さないように修正
- "plan is ready" の明示的な承認がある場合のみ成功表示
- それ以外は「明確な承認なし」と表示

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.claude/hooks/post_pr_codex_review.py:
- Around line 91-97: The current flow prints an error when result.returncode !=
0 but always prints the success banner ("✅ Codexレビュー完了"), which is confusing;
change the control flow so the success banner is only printed when
result.returncode == 0 — e.g., wrap the trailing prints (including the blank
line, separator lines and "✅ Codexレビュー完了") in an else branch or perform an early
return/exit after printing the error (the check involves result.returncode and
result.stderr) so that the success message is not emitted on failure.
🧹 Nitpick comments (1)
.claude/hooks/post_pr_codex_review.py (1)

32-34: The -h check may cause false positives.

The substring check "-h" in command matches -h anywhere in the command string, including in branch names, PR bodies, or other arguments.

Example false positives:

  • gh pr create --head feature-branch-h
  • gh pr create --body "Fix -h flag handling"
🔧 Suggested fix: Match `-h` as a standalone argument
-# ヘルプコマンドは除外
-if "--help" in command or "-h" in command:
-    sys.exit(0)
+# ヘルプコマンドは除外(独立した引数としてマッチ)
+import shlex
+try:
+    args = shlex.split(command)
+    if "--help" in args or "-h" in args:
+        sys.exit(0)
+except ValueError:
+    pass  # shlex parse error - continue with review
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e8bce8 and 39e9d2a.

📒 Files selected for processing (2)
  • .claude/hooks/post_pr_codex_review.py
  • .claude/hooks/pre_exit_plan_codex_review.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T10:08:03.062Z
Learning: Follow the GitHub Issues workflow: create issues with clear requirements and acceptance criteria, mention claude for AI assistance, ensure quality checks pass, and conduct human code review in PRs
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T10:08:03.062Z
Learning: Use GitHub Actions and Claude Code integration for automated issue resolution, PR review support, quality checks, and documentation synchronization
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to {.codex/**,.devcontainer/codex*,package*.json,npm/global.json} : Use Conventional Commits format with release-triggering types (feat/fix/perf/revert/docs) for commits touching .codex/**, .devcontainer/codex*, package*.json, or npm/global.json
📚 Learning: 2026-01-12T10:08:03.062Z
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-12T10:08:03.062Z
Learning: Use GitHub Actions and Claude Code integration for automated issue resolution, PR review support, quality checks, and documentation synchronization

Applied to files:

  • .claude/hooks/post_pr_codex_review.py
🪛 Ruff (0.14.11)
.claude/hooks/post_pr_codex_review.py

28-28: Comment contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF003)


28-28: Comment contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF003)


40-40: Comment contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF003)


40-40: Comment contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF003)


77-77: subprocess call: check for execution of untrusted input

(S603)


100-100: String contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF001)


100-100: String contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF001)


102-102: Do not catch blind exception: Exception

(BLE001)


105-105: Comment contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF003)


105-105: Comment contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF003)

.claude/hooks/pre_exit_plan_codex_review.py

52-52: Do not catch blind exception: Exception

(BLE001)


92-92: subprocess call: check for execution of untrusted input

(S603)


126-126: String contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF001)


126-126: String contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF001)


127-127: Comment contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF003)


127-127: Comment contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF003)


129-129: Do not catch blind exception: Exception

(BLE001)


139-139: String contains ambiguous (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?

(RUF001)


139-139: String contains ambiguous (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?

(RUF001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: check-ci-status
🔇 Additional comments (10)
.claude/hooks/post_pr_codex_review.py (4)

14-19: LGTM!

Input parsing is robust with appropriate fallbacks for missing keys.


40-47: LGTM!

The PR URL detection regex is appropriately strict and handles both stdout/stderr outputs.


61-74: LGTM!

The Codex prompt is comprehensive and the --sandbox read-only flag ensures safe execution.


105-106: LGTM!

Exiting with 0 regardless of Codex results ensures the hook doesn't block the workflow, which is the correct behavior for a post-tool hook.

.claude/hooks/pre_exit_plan_codex_review.py (6)

1-22: LGTM!

Imports and tool name validation are appropriate.


29-46: LGTM!

Using modification time to find the latest plan is a reasonable heuristic for typical workflows.


48-61: LGTM!

File reading with UTF-8 and graceful error handling is appropriate.


63-87: LGTM!

The prompt is comprehensive and covers key aspects of plan review. The --sandbox read-only flag ensures safe execution.


107-117: Verdict detection logic is correctly ordered.

Checking "plan needs revision" before "plan is ready" is the safer approach - if both phrases somehow appear in output, the stricter condition takes precedence.


133-142: LGTM!

The result display distinguishes between explicit approval and ambiguous results, which provides useful feedback to the user.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread .claude/hooks/post_pr_codex_review.py Outdated
Comment on lines +91 to +97
if result.returncode != 0 and result.stderr:
print(f"⚠️ Codexエラー: {result.stderr}", file=sys.stderr)

print("", file=sys.stderr)
print("=" * 60, file=sys.stderr)
print("✅ Codexレビュー完了", file=sys.stderr)
print("=" * 60, file=sys.stderr)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Success message shown even on Codex execution failure.

When result.returncode != 0, both the error warning (line 92) and the success message "✅ Codexレビュー完了" (line 96) are printed, which is confusing.

🐛 Proposed fix
     if result.returncode != 0 and result.stderr:
         print(f"⚠️  Codexエラー: {result.stderr}", file=sys.stderr)
+        print("", file=sys.stderr)
+        print("=" * 60, file=sys.stderr)
+        print("⚠️  Codexレビュー完了(エラーあり)", file=sys.stderr)
+        print("=" * 60, file=sys.stderr)
+    else:
+        print("", file=sys.stderr)
+        print("=" * 60, file=sys.stderr)
+        print("✅ Codexレビュー完了", file=sys.stderr)
+        print("=" * 60, file=sys.stderr)

-    print("", file=sys.stderr)
-    print("=" * 60, file=sys.stderr)
-    print("✅ Codexレビュー完了", file=sys.stderr)
-    print("=" * 60, file=sys.stderr)
🤖 Prompt for AI Agents
In @.claude/hooks/post_pr_codex_review.py around lines 91 - 97, The current flow
prints an error when result.returncode != 0 but always prints the success banner
("✅ Codexレビュー完了"), which is confusing; change the control flow so the success
banner is only printed when result.returncode == 0 — e.g., wrap the trailing
prints (including the blank line, separator lines and "✅ Codexレビュー完了") in an
else branch or perform an early return/exit after printing the error (the check
involves result.returncode and result.stderr) so that the success message is not
emitted on failure.

@claude

claude Bot commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

PR Review - feat/add ci failure handling instructions

このPRは、CI失敗対応ルールの追加とCodexによる自動レビュー機能の実装を含む包括的な開発ワークフロー改善です。全体として非常によく設計されていますが、いくつかの改善提案があります。

全体評価

良い点

  • CI失敗時の対応フローが明確に文書化されている
  • Codexレビューの自動化により品質向上が期待できる
  • 段階的なコミット履歴で変更内容が追跡しやすい
  • エラーハンドリングが適切に実装されている
  • 前提条件チェック(Codex CLI有無)が実装されている

⚠️ 改善提案

1. コード品質

post_pr_codex_review.py

重大度: 中

問題点: タイムアウト設定が600秒(10分)は長すぎる可能性があり、フィードバックループが遅延する

推奨: タイムアウトを300秒(5分)に短縮

pre_exit_plan_codex_review.py

重大度: 低

問題点: Line 105のoutput.lower()は英語の文字列マッチングを前提としているが、Codexの出力形式が変更された場合に脆弱

推奨: より堅牢なパターンマッチング(正規表現の使用)

2. セキュリティ

重大度: 中

問題点: stderrの出力を500文字でトリミングしているが、機密情報が含まれる可能性

推奨: エラーメッセージのサニタイズ実装(トークン、APIキー、パスワードのマスキング)

3. テストカバレッジ

重大度: 高

問題点: 新しいPythonスクリプトにユニットテストが存在しない

推奨: テストファイルを追加

  • tests/hooks/test_post_pr_codex_review.py
  • tests/hooks/test_pre_exit_plan_codex_review.py

根拠: CLAUDE.mdのTDD原則(70%+カバレッジ)に準拠する必要がある

まとめ

必須対応(マージ前)

  1. ユニットテストの追加(カバレッジ70%+を満たすため)
  2. タイムアウト設定の見直し(フィードバックループの最適化)

推奨対応(マージ後可)

  1. エラーメッセージのサニタイズ実装
  2. 正規表現の事前コンパイル
  3. より堅牢なverdict検出ロジック
  4. CIパイプラインへのhooksテスト追加
  5. ドキュメントへのトラブルシューティング追加

総合評価

判定: 条件付き承認

理由:

  • 機能実装は堅牢でよく設計されている
  • しかし、CLAUDE.mdで定義されたTDD原則(70%+カバレッジ)に準拠していない
  • テストカバレッジが追加されれば、マージ可能

素晴らしいワークフロー改善です。テストが追加されれば、組織全体の開発品質向上に大きく貢献するでしょう!

Codex専用のhooksをCodex+Gemini両対応に拡張しました。
インストールされているAIツールで自動的にレビューを実行します。

## 変更内容

### 新規ファイル
- post_pr_ai_review.py: PR作成後のAIレビュー(Codex+Gemini)
- pre_exit_plan_ai_review.py: プラン作成後のAIレビュー(Codex+Gemini)

### 削除ファイル
- post_pr_codex_review.py: Codex専用版を削除
- pre_exit_plan_codex_review.py: Codex専用版を削除

### 更新ファイル
- README.md: 新しいhooksのドキュメント
- settings.local.json.template: hooks参照とgemini権限を更新

## 動作
- Codex/Geminiのいずれか、または両方がインストールされていれば実行
- どちらも未インストールの場合はスキップ

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude

claude Bot commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

PR Review - feat/add ci failure handling instructions

総合評価

このPRは、PR作成後のCI失敗対応ルールとAI自動レビュー機能を追加する重要な機能追加です。全体的によく設計されていますが、いくつか改善が必要な点があります。


🟢 良い点

1. 明確なCI失敗対応ルールの追加

.claude/CLAUDE.md:63-85 にCI失敗時の対応フローが明確に定義されており、開発プロセスの品質向上に貢献します。

2. AIレビュー機能の柔軟な設計

  • Codex/Geminiの両方に対応し、インストールされているツールのみを使用する柔軟な設計
  • post_pr_ai_review.py:49-55 でツールの存在チェックを適切に実装

3. 適切なエラーハンドリング

  • タイムアウト処理(600秒)の実装
  • エラー出力の制限(300文字)により、過度なログ出力を防止

4. Skills分離による再利用性

CI CheckとCodex ReviewをSkillsとして分離し、再利用可能な設計になっている点は優れています。


🟡 改善が必要な点

1. セキュリティ: コマンドインジェクションのリスク

場所: post_pr_ai_review.py:79-83, pre_exit_plan_ai_review.py:97-101

問題: review_prompt変数が直接コマンド引数に渡されています。pre_exit_plan_ai_review.py:64-82では、plan_contentがf-stringでプロンプトに埋め込まれており、プランファイルに悪意のあるコードが含まれていた場合、シェルインジェクションのリスクがあります。

推奨対応:

# pre_exit_plan_ai_review.py の改善例
# プランファイルの内容をサニタイズ
import shlex

# または、プロンプトをファイル経由で渡す方法を検討
with tempfile.NamedTemporaryFile(mode='w', suffix='.txt', delete=False) as f:
    f.write(review_prompt)
    prompt_file = f.name

codex_command = [
    "codex", "exec",
    "--sandbox", "read-only",
    "--prompt-file", prompt_file
]

2. エラーハンドリング: ステータスコードの不一致

場所: pre_exit_plan_ai_review.py:195-198

問題: "plan needs revision"の場合はsys.exit(2)でブロックしますが、レビュー実行失敗時はsys.exit(0)で成功扱いになっています。これは意図した動作でしょうか?

推奨対応:

# レビュー実行失敗時の扱いを明確化
if not any_success:
    print("⚠️  AIレビューが実行できませんでした。続行しますか?", file=sys.stderr)
    # オプション: sys.exit(1) でブロックするか、sys.exit(0) で許可するか明確に

3. 保守性: マジックナンバーとハードコーディング

場所: post_pr_ai_review.py:91, pre_exit_plan_ai_review.py:109

問題: タイムアウト値(600秒)、エラー出力制限(300文字)がハードコードされています。

推奨対応:

# ファイル先頭で定数として定義
REVIEW_TIMEOUT_SECONDS = 600
ERROR_OUTPUT_MAX_LENGTH = 300

# 使用時
timeout=REVIEW_TIMEOUT_SECONDS
result.stderr[:ERROR_OUTPUT_MAX_LENGTH]

4. パフォーマンス: 並列実行の検討

場所: post_pr_ai_review.py:139-144, pre_exit_plan_ai_review.py:170-175

問題: CodexとGeminiのレビューを順次実行しています。両方がインストールされている場合、レビュー時間が最大20分(10分×2)かかる可能性があります。

推奨対応:

import concurrent.futures

# 並列実行
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
    futures = []
    if has_codex:
        futures.append(executor.submit(run_codex_review))
    if has_gemini:
        futures.append(executor.submit(run_gemini_review))
    
    concurrent.futures.wait(futures)

5. ドキュメント: 設定例の不完全性

場所: .claude/settings.local.json.template:71-74

問題: Geminiの実行権限が追加されていますが、Gemini CLIのインストール方法や設定方法がREADME.mdに記載されていません。

推奨対応:

  • .claude/hooks/README.md にCodex/Gemini CLIのインストール手順を追加
  • 各ツールの認証設定方法を記載

6. テストカバレッジ: 単体テストの欠如

問題: Pythonスクリプトに対する単体テストが含まれていません。

推奨対応:

# tests/hooks/test_post_pr_ai_review.py の例
import unittest
from unittest.mock import patch, MagicMock
import json

class TestPostPRAIReview(unittest.TestCase):
    @patch('subprocess.run')
    @patch('shutil.which')
    def test_codex_review_success(self, mock_which, mock_run):
        mock_which.return_value = '/usr/bin/codex'
        mock_run.return_value = MagicMock(
            returncode=0,
            stdout="patch is correct\nConfidence: 0.95"
        )
        # テストロジック

7. Skills: 重複したドキュメント

場所: .claude/skills/codex-review.md

問題: このSkillはpost_pr_ai_review.pyフックと機能が重複しています。フックが自動実行される場合、Skillは不要かもしれません。

推奨対応:

  • フックとSkillの役割を明確に分離
  • Skillは手動レビュー用、フックは自動レビュー用など使い分けを文書化

🔴 修正必須の問題

1. CLAUDE.mdとの整合性

場所: .claude/CLAUDE.md:63

問題: CLAUDE.mdには「Release Types Required for Tooling Changes」ルールがあり、.codex/**への変更はfeat/fixなどのリリース型コミットが必要と記載されていますが、このPRでは.claude/**への変更が含まれています。コミットメッセージは適切にfeat:を使用していますが、ルール自体に.claude/**が含まれていません。

推奨対応:

# CLAUDE.md の更新
- Release Types Required for Tooling Changes: Commits that touch `.codex/**`, `.claude/**`, `.devcontainer/codex*`, `package*.json`, or `npm/global.json` must use release-triggering types

2. PR本文の未記入

問題: PR本文のチェックリストやセクションが未記入です。CLAUDE.mdのDefinition of Doneに「ドキュメント更新」が含まれています。

推奨対応:

  • PR本文のチェックリストを完成させる
  • Summary、Changes Made、Testingセクションを記入

📊 品質メトリクス

カテゴリ 評価 コメント
コード品質 🟡 B 全体的に良好だが、セキュリティとエラーハンドリングに改善の余地
セキュリティ 🟡 B コマンドインジェクションリスクへの対応が必要
パフォーマンス 🟡 B 並列実行により改善可能
保守性 🟡 B マジックナンバーの定数化が必要
テストカバレッジ 🔴 C 単体テストが不足
ドキュメント 🟡 B インストール手順の追加が必要

✅ チェックリスト

  • Conventional Commits準拠
  • 機能の明確な説明
  • セキュリティリスクへの対応(コマンドインジェクション)
  • 単体テストの追加
  • PR本文の完成
  • ドキュメント更新(README.md)
  • CLAUDE.mdルールの更新(.claude/**の追加)
  • インストール手順の追加

🎯 推奨アクション

優先度: 高

  1. セキュリティリスク(コマンドインジェクション)への対応
  2. PR本文の完成
  3. CLAUDE.mdルールの更新

優先度: 中

  1. エラーハンドリングの明確化
  2. マジックナンバーの定数化
  3. インストール手順のドキュメント化

優先度: 低

  1. 並列実行の実装
  2. 単体テストの追加
  3. Skills/Hooksの役割明確化

総評

このPRは開発プロセスの自動化と品質向上に大きく貢献する重要な機能追加です。基本設計は優れていますが、セキュリティとエラーハンドリング、ドキュメントの面で改善が必要です。

優先度:高の項目を対応後、マージを推奨します。

レビュー実施: Claude Sonnet 4.5

@keito4

keito4 commented Jan 16, 2026

Copy link
Copy Markdown
Owner Author

(aside)
@claude PRがbaseにマージする際にCIが落ちています。
修正してください。

@claude

claude Bot commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

Claude finished @keito4's task in 2m 1s —— View job


CI失敗の修正

状況確認

現在のCI状態を確認しました:

✅ すべてのステータスチェックが成功しています:

  • Claude Code Review: SUCCESS
  • GitGuardian Security Checks: SUCCESS
  • CodeRabbit: SUCCESS

✅ マージ状態:

  • Mergeable: MERGEABLE
  • Merge State: CLEAN

調査結果

  1. すべてのステータスチェックが緑(SUCCESS)になっています
  2. マージコンフリクトはありません(CLEAN状態)
  3. PRは現在マージ可能な状態です

確認事項

@keito4 さん、具体的にどのCIが失敗していますでしょうか?以下のいずれかに該当しますか:

  1. 過去のCI失敗を修正済み: すでに修正されて現在は成功している
  2. 特定のワークフローの失敗: 上記以外のワークフローで失敗がある場合、ワークフロー名を教えてください
  3. ローカルでの品質チェック失敗: npm run lintnpm run format:checknpm testなどのいずれかが失敗している

View job

Geminiはファイルアクセスができないため、git diffの内容を
プロンプトに直接含めるように修正。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude

claude Bot commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

PR Review - PR #346

このPRは、AI(Codex + Gemini)による自動レビュー機能をClaude Code hooksとskillsに統合する大規模な改善です。全体的に良く設計されており、コードの品質も高いですが、いくつかの改善点と懸念事項があります。

✅ 良い点

  1. 包括的なドキュメント: README.mdに詳細な使用方法とトラブルシューティングが記載されています
  2. 柔軟な設計: Codex/Geminiのどちらか、または両方がインストールされている場合に動作する適応型設計
  3. 適切なエラーハンドリング: タイムアウト、実行エラー、ツール未インストールなどのケースを適切に処理
  4. 段階的な機能拡張: commitの履歴から、iterativeに改善されていることが分かります

⚠️ 懸念事項・改善提案

1. セキュリティ: diffの内容制限が不十分

post_pr_ai_review.py:150

{diff_content[:50000]}

問題: 50,000文字制限はありますが、機密情報のマスキング処理がありません。

推奨:

  • 環境変数、APIキー、パスワードなどの機密情報を検出してマスクする処理を追加
  • または既存の security-credential-scan を活用してdiffをスキャン

2. パフォーマンス: 並列実行の欠如

post_pr_ai_review.py:175-179

if has_codex:
    run_codex_review()

if has_gemini:
    run_gemini_review()

問題: CodexとGeminiのレビューが直列実行されるため、両方インストールされている場合は最大20分(10分×2)かかる可能性があります。

推奨: subprocess.Popen または concurrent.futures.ThreadPoolExecutor を使用して並列実行

3. コード重複: レビュープロンプトの重複

両方のファイルで類似のレビュープロンプトが定義されています。

推奨: 共通のプロンプトテンプレートファイルを作成するか、環境変数で管理

4. エラーハンドリング: subprocess失敗時の情報不足

post_pr_ai_review.py:122-123

if result.returncode \!= 0:
    print(f"⚠️  Codex実行エラー (exit code: {result.returncode})", file=sys.stderr)

問題: exit codeのみでstderrが表示されない場合、デバッグが困難です。

推奨:

if result.returncode \!= 0:
    print(f"⚠️  Codex実行エラー (exit code: {result.returncode})", file=sys.stderr)
    if result.stderr:
        print(f"エラー詳細: {result.stderr[:500]}", file=sys.stderr)

5. テストカバレッジ: 単体テストの欠如

新規追加されたPythonスクリプトに対する単体テストがありません。

推奨:

  • tests/hooks/test_post_pr_ai_review.py を作成
  • モックを使用してsubprocess呼び出しをテスト
  • 各エッジケース(ツール未インストール、タイムアウト、diffなし等)をカバー

6. 保守性: マジックナンバー

post_pr_ai_review.py:91, 119, 132, 159 などでタイムアウト値がハードコードされています。

推奨:

CODEX_TIMEOUT = int(os.getenv('CODEX_REVIEW_TIMEOUT', '600'))
GEMINI_TIMEOUT = int(os.getenv('GEMINI_REVIEW_TIMEOUT', '600'))
GIT_COMMAND_TIMEOUT = int(os.getenv('GIT_COMMAND_TIMEOUT', '60'))

7. 機能性: レビュー結果の永続化

レビュー結果が標準エラー出力のみで、後から確認できません。

推奨:

  • レビュー結果を .claude/review-results/ に保存
  • PRコメントとして自動投稿する機能を追加(オプション)

8. Skillsファイルの一貫性

.claude/skills/codex-review.md は「Codex専用」ですが、実際のhookはCodex+Gemini両対応です。

推奨:

  • Skillファイル名を ai-review.md に変更
  • 内容をCodex+Gemini両対応に更新

📋 品質基準との整合性

基準 状態 コメント
TDD (70%+カバレッジ) Pythonスクリプトのテストが欠如
Lint/Format CIチェック待ち
セキュリティ ⚠️ 機密情報マスキングの検討が必要
ドキュメント 包括的なREADME
Conventional Commits 適切なコミットメッセージ

🎯 アクションアイテム

必須 (マージ前):

  1. セキュリティ: diffに機密情報が含まれる場合のマスキング処理を追加
  2. テスト: 基本的な単体テストを追加(少なくとも正常系とエラー系)
  3. Skillsファイル名と内容の整合性を修正

推奨 (次回PR):

  1. Codex/Geminiレビューの並列実行
  2. レビュー結果の永続化
  3. タイムアウト値の環境変数化
  4. エラーメッセージの改善

💭 総評

このPRは開発ワークフローに大きな価値を提供する優れた機能追加です。AIレビューの自動統合は品質向上に寄与しますが、セキュリティとテストカバレッジの観点でいくつかの改善が必要です。

推奨アクション: 上記の「必須」項目を対応後にマージ承認


🤖 Generated with Claude Code (Sonnet 4.5)

@keito4
keito4 merged commit ac5f3d3 into main Jan 16, 2026
4 checks passed
@keito4
keito4 deleted the feat/add-ci-failure-handling-instructions branch January 29, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant