Skip to content

Commit 2ccff1f

Browse files
committed
feat(claude): add pm-codex skill
Introduce SKILL.md detailing the pm-codex skill, which delegates implementation tasks to Codex while acting as a product manager. The document outlines arguments, prerequisites, principles, and execution settings. Add workflow.md to describe the detailed workflow for using the pm-codex skill, including phases from preflight checks to completion verification.
1 parent 56eecd0 commit 2ccff1f

2 files changed

Lines changed: 308 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
name: pm-codex
3+
description: |
4+
プロダクトマネージャーとして振る舞い、Codex に実装を委譲するスキル。
5+
タスク記述または GitHub Issue 番号を受け取り、プラン作成 → Issue 分割 →
6+
Codex 並列実行 → コミット管理を行う。自分では一切コードを書かない。
7+
使用例: /pm-codex "認証機能のリファクタリング", /pm-codex 42
8+
---
9+
10+
# pm-codex
11+
12+
プロダクトマネージャーとして振る舞い、すべての実装を Codex に委譲するオーケストレーションスキル。
13+
14+
## 引数
15+
16+
```
17+
/pm-codex <タスク記述 | Issue番号>
18+
```
19+
20+
- 数値 → GitHub Issue 番号として解釈
21+
- それ以外 → フリーテキストのタスク記述として解釈
22+
23+
## 前提条件
24+
25+
| ツール | 確認コマンド |
26+
|--------|-------------|
27+
| `gh` CLI(認証済み) | `gh auth status` |
28+
| `codex` CLI | `codex --version` |
29+
| `gh sub-issue` extension | `gh sub-issue --help` |
30+
31+
## 原則
32+
33+
- **PM 専任**: Claude はコードを一切書かない。すべて Codex に委譲する
34+
- **Human-in-the-loop**: プラン承認後に実行。承認なしに Phase 5 に進まない
35+
- **Git 責務分離**: Codex は commit/push/branch 操作を行わない。Git 操作は Claude が担当
36+
- **進捗報告**: 変更や進捗がある都度、該当 Issue に `gh issue comment` でアップデート
37+
- **実行単位**: sub-issue = branch = worktree = 1 Codex session
38+
- **タスク管理**: TASKS.md は作成不要。GitHub Issues がタスクマネージャー
39+
40+
## Codex 実行設定
41+
42+
共通フラグ:
43+
44+
```bash
45+
-m gpt-5.4 --config model_reasoning_effort="high" --skip-git-repo-check --full-auto
46+
```
47+
48+
| 用途 | sandbox | 追加フラグ |
49+
|------|---------|-----------|
50+
| レビュー | `--sandbox read-only` ||
51+
| 実装 | `--sandbox workspace-write` | `-C <worktree-path>` |
52+
53+
ログ: `2>> .claude/logs/codex-<issue番号>.log`
54+
55+
## ワークフロー概要
56+
57+
| Phase | 概要 |
58+
|-------|------|
59+
| 0: Preflight | 前提条件・clean worktree・GitHub repo 確認 |
60+
| 1: タスク理解 | Issue 取得 or フリーテキスト分析。成功基準の明確化 |
61+
| 2: プラン作成 | コードベース調査 → タスク分割 → Codex レビュー → ユーザー承認 |
62+
| 3: プランコミット | `.claude/plans/` にコミット。commit SHA を記録 |
63+
| 4: Issue 分割 | 親 Issue + sub-issue 作成。固定テンプレート使用 |
64+
| 5: Codex 実行 | worktree 隔離で並列実行。完了後コミット (`fix #<issue>`) |
65+
| 6: 完了確認 | 検証 → sub-issue クローズ → `/create-pr` 提案 |
66+
67+
詳細は [references/workflow.md](references/workflow.md) を参照。
68+
69+
## 注意事項
70+
71+
- `codex exec` を使用すること。MCP 経由の Codex はハングすることがあるため使用しない
72+
- 中断復帰時は既存の親 Issue / sub-issue を確認し、重複作成しない
73+
- sub-issue を close するのは検証完了後。全体テスト前に close しない
74+
- PR body にも closing keyword (`fix #<issue>`) を含め、squash merge 時の取りこぼしを防ぐ
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
# pm-codex ワークフロー詳細
2+
3+
## Phase 0: Preflight
4+
5+
以下を並列で確認し、失敗があれば中止して案内する:
6+
7+
```bash
8+
gh auth status
9+
codex --version
10+
gh sub-issue --help
11+
git status --porcelain
12+
gh repo view --json nameWithOwner --jq '.nameWithOwner'
13+
```
14+
15+
確認事項:
16+
- worktree が clean であること(未コミット変更がある場合は警告しユーザーに確認)
17+
- `.claude/plans/` ディレクトリが存在すること(なければ作成)
18+
- `.claude/logs/` ディレクトリが存在すること(なければ作成)
19+
20+
## Phase 1: タスク理解
21+
22+
### Issue 番号の場合
23+
24+
```bash
25+
gh issue view <番号> --json title,body,labels,comments,assignees,state
26+
```
27+
28+
- Issue が closed の場合は警告
29+
- Issue の内容から成功基準を抽出
30+
31+
### フリーテキストの場合
32+
33+
- タスク記述を分析
34+
- 成功基準を明確化
35+
- 親 Issue を作成:
36+
37+
```bash
38+
gh issue create --title "<タスクタイトル>" --body "<タスク詳細と成功基準>"
39+
```
40+
41+
### 中断復帰チェック
42+
43+
既存の親 Issue に紐づく sub-issue がないか確認:
44+
45+
```bash
46+
gh sub-issue list <親Issue番号>
47+
```
48+
49+
既存の sub-issue がある場合は状態を確認し、未完了分から再開する。
50+
51+
## Phase 2: プラン作成
52+
53+
### 2-1: コードベース調査
54+
55+
Explore エージェントを使用して関連ファイル・パターンを特定する。
56+
57+
### 2-2: プラン策定
58+
59+
1. 解決アプローチの候補を列挙
60+
2. 各アプローチの tradeoff を分析
61+
3. 推奨アプローチを選択
62+
4. タスクを Codex が 1 セッションで完結するサイズに分割
63+
5. 依存関係と並列実行性を整理
64+
6. テスト計画を明記
65+
66+
### 2-3: Codex レビュー
67+
68+
プランを Codex に送り、致命的な欠陥がないかレビューさせる:
69+
70+
```bash
71+
echo "<プラン全文>" | codex exec \
72+
--skip-git-repo-check \
73+
-m gpt-5.4 \
74+
--config model_reasoning_effort="high" \
75+
--sandbox read-only \
76+
--full-auto \
77+
2>> .claude/logs/codex-review.log
78+
```
79+
80+
レビュー結果を反映し、必要に応じて修正。
81+
82+
### 2-4: ユーザー承認
83+
84+
プランを提示し、承認を待つ。**承認されるまで Phase 3 に進まない。**
85+
86+
## Phase 3: プランコミット
87+
88+
```bash
89+
git add .claude/plans/<slug>.md
90+
git commit -m "docs(plan): <タスクサマリ>"
91+
```
92+
93+
commit SHA を記録し、以降の Issue に含める。
94+
95+
## Phase 4: Issue 分割
96+
97+
### 親 Issue の準備
98+
99+
Phase 1 で作成済み、または既存の Issue を使用。
100+
101+
### sub-issue 作成
102+
103+
各タスクを以下のテンプレートで sub-issue として登録:
104+
105+
```bash
106+
gh sub-issue create --parent <親Issue番号> --title "タスクN: <タイトル>" --body "$(cat <<'EOF'
107+
## 概要
108+
<タスクの説明>
109+
110+
## 背景
111+
<なぜ必要か>
112+
113+
## 対象範囲
114+
- <変更するファイル/モジュール>
115+
116+
## 非対象
117+
- <触らないもの>
118+
119+
## 完了条件
120+
- [ ] <具体的な条件>
121+
122+
## 検証コマンド
123+
```bash
124+
<検証コマンド>
125+
```
126+
127+
## 期待出力
128+
<期待される結果>
129+
130+
## ブロック時
131+
<依存タスクが未完了の場合の対応>
132+
133+
## プラン
134+
<plan の commit SHA / permalink>
135+
EOF
136+
)"
137+
```
138+
139+
依存関係がある場合は Issue body の「ブロック時」セクションに明記する。
140+
141+
## Phase 5: Codex 実行
142+
143+
### 5-1: worktree 作成
144+
145+
sub-issue ごとに専用 worktree を作成:
146+
147+
```bash
148+
git worktree add .worktrees/issue-<番号> -b issue-<番号>/task
149+
```
150+
151+
### 5-2: Codex 実行
152+
153+
Issue body を元に Codex プロンプトを構成し実行:
154+
155+
```bash
156+
echo "<wrapper prompt + issue body>" | codex exec \
157+
--skip-git-repo-check \
158+
-m gpt-5.4 \
159+
--config model_reasoning_effort="high" \
160+
--sandbox workspace-write \
161+
--full-auto \
162+
-C .worktrees/issue-<番号> \
163+
2>> .claude/logs/codex-<番号>.log
164+
```
165+
166+
**並列実行**: 依存関係のない sub-issue は複数の Bash tool call で同時に実行する。
167+
**順次実行**: 依存関係がある sub-issue は前のタスク完了後に実行する。
168+
169+
### 5-3: 変更のマージとコミット
170+
171+
Codex 完了後:
172+
173+
1. worktree の変更を確認
174+
2. 変更をメインブランチにマージ:
175+
176+
```bash
177+
cd .worktrees/issue-<番号>
178+
git add -A
179+
git stash
180+
cd -
181+
git stash pop
182+
git add <変更ファイル>
183+
git commit -m "<type>(<scope>): <description> (fix #<issue番号>)"
184+
```
185+
186+
3. worktree を削除:
187+
188+
```bash
189+
git worktree remove .worktrees/issue-<番号>
190+
```
191+
192+
### 5-4: 進捗報告
193+
194+
各タスク完了後、Issue にコメントを追加:
195+
196+
```bash
197+
gh issue comment <番号> --body "実装完了。コミット: <SHA>"
198+
```
199+
200+
問題が発生した場合も Issue にコメントして報告する。
201+
202+
## Phase 6: 完了確認
203+
204+
### 6-1: 全 sub-issue の検証
205+
206+
各 sub-issue の検証コマンドを実行し、期待出力と一致するか確認する。
207+
検証完了した sub-issue をクローズ:
208+
209+
```bash
210+
gh issue close <番号> --comment "検証完了"
211+
```
212+
213+
### 6-2: 全体テスト
214+
215+
プロジェクトのテストスイートを実行(存在する場合)。
216+
217+
### 6-3: サマリ報告
218+
219+
完了した全タスクのサマリをユーザーに報告する。
220+
221+
### 6-4: PR 提案
222+
223+
feature ブランチ上にいる場合、`/create-pr` を提案する。
224+
PR body には全 sub-issue の closing keyword を含める:
225+
226+
```markdown
227+
## Summary
228+
- ...
229+
230+
Fixes #<親Issue番号>
231+
- fix #<sub-issue-1>
232+
- fix #<sub-issue-2>
233+
- ...
234+
```

0 commit comments

Comments
 (0)