Skip to content
17 changes: 17 additions & 0 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@
Lint → Test → Build → SCA → Deploy:Stg → E2E → Deploy:Prod
デプロイは Blue-Green もしくは Canary + Auto-Rollback を推奨。

### 2.5 PR作成後のCI失敗対応

PR作成後にCIが失敗した場合、**そのブランチで解決できる問題は必ず修正する**。

| 状況 | 対応 |
| -------------------------------- | -------------------------------------------- |
| 直接的な変更によるCI失敗 | 即座に修正してプッシュ |
| 間接的な影響によるCI失敗 | 原因を特定し、そのブランチで修正可能なら修正 |
| ベースブランチの問題によるCI失敗 | ベースブランチを更新後、再マージして修正 |
| 環境・インフラ起因のCI失敗 | 再実行を試みる、解決しない場合は報告 |

**原則**:

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

---

## 3. AI Prompt Design Baseline
Expand Down
19 changes: 19 additions & 0 deletions .claude/commands/create-pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,25 @@ PR URL: ${PR_URL}
4. マージ準備完了後、レビュアーに通知
```

## PR作成後のフォローアップ(Skills)

PR作成完了後、以下のskillsが自動的に適用されます。

### 1. Codex Review(`.claude/skills/codex-review.md`)

Codex CLIがインストール済みの場合、OpenAI Codexによるコードレビューを実行します。

- verdictが"patch is incorrect"の場合は指摘事項を修正
- 修正後、再度Codexレビューを実行

### 2. CI Check(`.claude/skills/ci-check.md`)

CIの結果を確認し、失敗している場合は修正します。

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

---

## Progress Reporting
Expand Down
60 changes: 60 additions & 0 deletions .claude/skills/ci-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
description: PR作成後にCIの結果を確認し、失敗している場合は修正する。PR作成完了後に自動的にこのスキルを適用してCIの状態を監視し、失敗時は修正を行うこと。
---

# CI Check Skill

PR作成後、CIの結果を確認し、失敗している場合は修正します。

## CI結果の確認

```bash
# PRのCI状態を確認
gh pr checks

# 失敗したチェックの詳細を確認
gh run list --limit 5
gh run view <run-id> --log-failed
```

## 失敗時の対応フロー

1. **失敗原因の特定**
- CIログを確認して失敗原因を特定
- 直接的な変更によるものか、間接的な影響かを判断

2. **修正の実施**
- そのブランチで修正可能な場合は即座に修正
- 修正をコミットしてプッシュ
- CIが再実行されることを確認

3. **再確認**
- CIが緑になるまで監視
- 必要に応じて追加修正を実施

## 対応パターン

| 失敗原因 | 対応 |
| ---------------------- | -------------------------------------------- |
| Lint/Format エラー | `npm run lint:fix` / `npm run format` で修正 |
| テスト失敗 | テストコードまたは実装を修正 |
| 型エラー | TypeScript の型定義を修正 |
| ベースブランチとの競合 | 最新のベースブランチをマージして解決 |
| 依存関係の問題 | package-lock.json を更新 |
| 環境・インフラ起因 | CI を再実行、解決しない場合は報告 |

## 修正完了後の報告

```
## CI Status

- 状態: 緑(すべてのチェック通過)
- 修正内容: [修正した内容の概要]
- 修正コミット: [コミットハッシュ]
```

## 原則

- CIが緑になるまでPRを放置しない
- 修正可能な問題は自分のブランチで解決する
- 解決不能な場合は原因と状況を明記してレビュアーに報告
47 changes: 47 additions & 0 deletions .claude/skills/codex-review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
description: PR作成後にOpenAI Codexによるコードレビューを実行する。Codex CLIがインストール済みの場合、PR作成完了後に自動的にこのスキルを適用してレビューを実行すること。
---

# Codex Review Skill

PR作成後、OpenAI Codexによるコードレビューを実行します。

## 前提条件

- Codex CLIがインストール済み(`codex` コマンドが利用可能)
- PRが作成済み

## レビュー実行

以下のコマンドでCodexレビューを実行:

```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."
```
Comment on lines +18 to +20

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.


## レビュー結果の対応

1. **verdict が "patch is correct"** の場合
- そのまま完了

2. **verdict が "patch is incorrect"** の場合
- 指摘された問題を確認
- 修正が必要な場合は修正してコミット・プッシュ
- 再度Codexレビューを実行

3. **重大な問題が指摘された場合**
- セキュリティ問題: 必ず修正
- パフォーマンス問題: 影響度を評価して対応
- 保守性の問題: 可能な範囲で対応

## レビュー結果の報告

レビュー完了後、以下の形式で報告する:

```
## Codex Review

- Verdict: [patch is correct / patch is incorrect]
- Confidence: [0〜1のスコア]
- 指摘事項: [件数]件(対応済み)
```