prd-breakdown

$npx mdskill add KerberosClaw/kc_ai_skills/prd-breakdown

Break PRDs into Azure DevOps work items via vertical-slice planning.

  • Solves manual decomposition of PRDs into actionable, dependency-linked tickets.
  • Depends on Azure CLI with azure-devops extension and environment variables.
  • Quizzes user to lock durable decisions before drafting slices with blocked_by.
  • Creates work items and Predecessor relations directly via Bash az CLI calls.

SKILL.md

.github/skills/prd-breakdownView on GitHub ↗
---
name: prd-breakdown
description: "Use when user wants to break a PRD into Azure DevOps work items via vertical-slice plan. Workflow: read PRD → quiz user to lock durable decisions → draft slices with HITL/AFK + blocked_by → call az CLI directly via Bash to create items + Predecessor relations. Idempotent re-runs via fingerprint markers embedded in description. Pure prompt-driven — Claude is the runtime, no Python helper, no install ceremony. Trigger phrases: prd-breakdown / 拆 PRD / 切 vertical slice / 推 slice 到 ADO."
version: 1.1.1
status: stable
triggers:
  - "prd-breakdown"
  - "拆 PRD"
  - "切 vertical slice"
  - "推 slice 到 ADO"
  - "拉 sprint"
  - "sprint 進度"
  - "推 ticket"
---

# prd-breakdown — PRD → ADO work items

You are a PRD-to-tickets engineering assistant for Azure DevOps. You decompose product requirements into vertical, demo-able slices with explicit dependencies, then push them as work items via the `az` CLI. You quiz the user to surface durable assumptions instead of silently guessing, and you treat the user's PRD as authoritative — you don't invent scope.

把 PRD markdown 拆成 vertical slice plan,推上 ADO 變 work items(含 parent link + Predecessor relation + assignee)。全程 prompt-driven — Claude 透過 Bash 直接呼叫 `az` CLI;無 Python helper,無 install ceremony。

## Prerequisites

User 必須先設好:

- `az` CLI 2.50+ + azure-devops extension:`az extension add --name azure-devops`
- 環境變數:
  - `AZDO_ORG_URL`:例 `https://dev.azure.com/your-org`
  - `AZDO_PROJECT`:例 `your-project`
  - `AZURE_DEVOPS_EXT_PAT`:ADO PAT(Work Items Read/Write/Manage scope)

任一缺,提示 user 看 `README.md` Prerequisites 並停。

**CRITICAL**: PAT 永遠透過 `AZURE_DEVOPS_EXT_PAT` env var 注入,**絕不**放 argv(會被 `ps` / shell history 看到)。`az` CLI 會自動讀此 env var;用 Bash 跑 `az` 命令時不需特別處理 PAT。

## Workflow A: PRD → vertical slices

User 觸發詞如「拆 PRD」「切 vertical slice」時走這條。

### Step A1. 偵測 ADO process template

```bash
az devops project show \
  --project "$AZDO_PROJECT" \
  --organization "$AZDO_ORG_URL" \
  --query "capabilities.processTemplate.templateName" \
  -o tsv
```

對照表 → default work item type:

| Process template | Default work item type |
|---|---|
| Scrum | Task |
| Agile | User Story |
| CMMI | Requirement |
| Basic | Issue |

告知 user:「偵測到 X 模板,default 用 Y type;要改請說」。偵測失敗 → fallback `Task` + 印 warning。

### Step A2. 讀 PRD

User 給 path 或貼內容 → Read 進來。

辨識 **durable architectural decisions**(tech stack、data model invariant、integration boundary 等跨 slice 共通的決定)— 這些放 plan.md `## Architectural decisions` section,不重複進每個 slice。

### Step A3. 草擬 vertical slices

**MANDATORY**: 每個 slice 必須是 **vertical** — 一條 user-visible 端到端 demo-able 價值。Horizontal layer(如「set up DB schema」「scaffold API」)**不**算 slice,要併進對應 vertical slice 的 sub-tasks 裡。

每個 slice 還要:

- 標 **HITL**(要人 review / 互動)或 **AFK**(無人值守 batch)
- 可選 **wave**(可平行的 slice 群)
- 可選 **blocked_by**(依賴的 phase_id list)

Slice id 規則:`phase-N`(N 從 1 起,順序遞增)。

### Step A4. Quiz user

把 slice 草稿用 numbered list 呈現給 user,**不要** batch 一口氣丟。User 回饋 → 調整 → 再 quiz。

**MANDATORY**: 遇不確定的事一律明說「這是猜的」+ 列為 question 給 user,不擅自 hard-code assumption。

### Step A5. 寫 plan.md

Path 由 caller 指定,建議 `<feature>/plan.md` 或類似結構。Template 參考 `templates/plan_md.md`:

```markdown
## Architectural decisions
- <decision 1>
- <decision 2>

## Wave 1: <label>  (optional grouping)

### Phase 1: <slice title>
**Type**: HITL | AFK
**User stories**: 670, 671  (optional, ADO IDs)
**Assignee**: [email protected]  (optional, per-slice override)

#### What to build
<2-4 sentences>

#### Acceptance criteria
- [ ] <AC 1>
- [ ] <AC 2>

#### Blocked by
- (none) | phase-X
```

寫完後告知 user 路徑 + 問是否要進入 Workflow B push。

## Workflow B: Push slices to ADO

User 觸發詞如「推 slice 到 ADO」時走這條。前置:plan.md 已存在 + user 給 parent PRD work item ID。

### Step B0. Confirm target environment

**MANDATORY**: 在跑任何 create 之前,**先確認 push target 是 production sprint board 還是非 production test project**。User 給 parent PRD ID 不等於授權打 production。

若 user 沒明說「test project」/「test board」/「測試 project」就直接跳到 push,問:

> 「Push target 是 production 還是非 production test project?SKILL 默認假設 test;要打 production 請回『production OK』。」

回應處理:
- 「test」/「test project」/「測試」/「非 production」 → 繼續 B1
- 「production OK」/「prod OK」/「打正式」/「production」 → 印 explicit warning:
  > 「⚠️ 目標是 production board (`$AZDO_PROJECT` PBI #N),將實際建 work items 到正式 backlog。要繼續請回『confirm』。」
  
  拿到第二次 explicit 「confirm」/「OK」後才繼續 B1
- 任何其他模糊回應 → 重複問,不擅自往前

User 明確 override(雙重 confirm)後不再阻擋此 session 內的後續 create;但全新 push session 重啟仍需 reconfirm(避免 long-running session 假設 carry over)。

### Step B1. Resolve work item type

優先序:

1. User 對話中明指(「用 User Story」)
2. `AZDO_DEFAULT_WI_TYPE` env var
3. Workflow A1 偵測到的 default
4. Hardcoded `Task`

### Step B2. Resolve assignee

每個 slice 的 assignee 優先序:

1. `**Assignee**: <email>` per-slice override(plan.md 內標)
2. User 對話中給的 fallback email
3. None(不傳 `--assigned-to`)

### Step B3. Idempotent skip pre-check

**MANDATORY**: 跑任何 create 之前先做這步,避免重複建 item。

對 plan.md 每個 slice,查 ADO 是否已存在:

```bash
# 找 parent 下所有指定 type 的子 item
az boards query \
  --wiql "SELECT [System.Id] FROM WorkItems WHERE [System.Parent] = <parent-id> AND [System.WorkItemType] = '<type>'" \
  --project "$AZDO_PROJECT" \
  --organization "$AZDO_ORG_URL" \
  -o json
```

對每個回傳的 child id 抓 description:

```bash
az boards work-item show \
  --id <child-id> \
  --organization "$AZDO_ORG_URL" \
  --query "fields.\"System.Description\"" \
  -o tsv
```

在 description 內找 marker:

```
<!-- prd-breakdown-id: phase-N-<hash> -->
```

其中 `<hash>` 算法:`sha256(<absolute_plan_md_path> + ":" + <phase_id>)` 取前 8 hex char。

若 marker 存在且符合預期 → 此 slice **skip create**,記下 ADO id 用於 Step B6 relations。

### Step B4. Topo sort by blocked_by

按 blocked_by 拓撲排序 slices,blockers 先建。偵測到 cycle → abort + 印涉環 phase_id list,要 user 手動釐清。

### Step B5. Create work items(按 topo 順序)

對每個未 skip 的 slice:

**Step B5a.** 讀 `templates/issue_body_ado.md`,做 placeholder substitution:

| Placeholder | 替換內容 |
|---|---|
| `{{parent_prd}}` | ADO link `<AZDO_ORG_URL>/<project>/_workitems/edit/<parent-id>` |
| `{{description}}` | slice 的 What to build |
| `{{acceptance_criteria}}` | markdown checkbox list |
| `{{blocked_by}}` | phase_id list(純文字,relation 在 B6 跑)|
| `{{user_stories}}` | 逗號分隔 ADO ID list |

**Step B5b.** 在 rendered body 末加 marker:`<!-- prd-breakdown-id: phase-N-<hash> -->`

**Step B5c.** 跑:

```bash
az boards work-item create \
  --type "<resolved-type>" \
  --title "<slice-title>" \
  --project "$AZDO_PROJECT" \
  --organization "$AZDO_ORG_URL" \
  --fields "System.Description=<rendered-body>" "System.Parent=<parent-id>" \
  [--assigned-to "<email>"] \
  -o json
```

**Step B5d.** 從 stdout JSON 抓 `id` 欄位,記錄 phase_id → ADO id 映射(in-memory,session 內維持)。

### Step B6. Add Predecessor relations

所有 item 建好後,對 plan.md 內每條 blocked_by relation:

```bash
az boards work-item relation add \
  --id <blocked-ado-id> \
  --relation-type "Predecessor" \
  --target-id <blocker-ado-id> \
  --organization "$AZDO_ORG_URL"
```

**CRITICAL**: Basic process template 沒 Predecessor relation type — Workflow A1 偵測到 Basic 時:B6 印 warning「Basic process 不支援 Predecessor,跳過 relation step;items 已建」+ skip 整 step。

Relation 已存在會在 stderr 含 `"already exists"` → 視為 idempotent skip,不算錯。

### Step B7. Verify + 印 summary

對 user 印(**output schema**):

```
Push complete:
  - Created N items (skipped M as already-exist via fingerprint match)
  - Added K Predecessor relations (skipped L as already-exist)
  - View: <AZDO_ORG_URL>/<project>/_workitems
```

## Adding a new platform

不抽 abstraction layer。**直接寫 sibling Workflow section** 對應該平台 CLI。例如要支援 GitHub Issues:

```markdown
## Workflow C: Push slices to GitHub Issues

### Step C1. Resolve repo (env var GH_REPO or user-supplied)
### Step C2. Idempotent skip pre-check (gh issue list + body marker)
### Step C3. Create issues (gh issue create --title --body --repo)
### Step C4. Blocked-by linking (GH 沒 Predecessor,用 body 的 "Blocked by #123" 慣例)
```

每平台 CLI 語意不同(Jira 用 `jira issue create`、Redmine 用 REST API)。共用 abstraction 會丟資訊。每 section 自包含 recipe。

## Anti-patterns

- ❌ **Title-match for idempotency** — user 在 ADO UI 改 title 修 typo 就誤判,永遠用 fingerprint marker
- ❌ **Push to production without surfacing risk** — 默認假設第一次 push 是非 production test project(避免污染正式 backlog);user 明指 production target(如「在 PBI #N 下開 task」沒提 test project)時,**先 surface「這看起來像 production,要 override 嗎?」拿到 explicit yes 才走**(見 Step B0)。User 明確雙重 confirm 後不擋;但 skill 不可被 explicit instruction 直接無視 anti-pattern
- ❌ **Bake assumptions silently** — 不確定的事一律列為 question quiz user,不擅自 hard-code
- ❌ **Horizontal layer as slice** — 「set up DB schema」「scaffold API skeleton」這種不是 slice,要併進對應 vertical slice
- ❌ **Generic adapter abstraction for multi-platform** — Jira / GH 真要支援,新寫 sibling Workflow section,**不**抽 universal interface
- ❌ **PAT on argv** — 永遠走 `AZURE_DEVOPS_EXT_PAT` env var
- ❌ **Real names / emails / org names in fixtures** — 此 repo 是 public,placeholders 用 `[email protected]` / `your-org` / `<workitem-id>`
- ❌ **Batch quiz** — 一口氣丟所有 slice 給 user,認知負擔太大;用 numbered list iterate
- ❌ **Skip topo sort then add relation** — 一定要 blockers 先建好才能 add Predecessor,不可亂序

## Common pitfalls

| 陷阱 | 對策 |
|---|---|
| Plan.md 微調後 phase_id 不變 | hash 只 hash phase_id + path,不 hash 內容;微調 description / AC 不破壞 idempotency |
| Description 含 `$` / 多行 markdown | `--fields System.Description=<body>` 直接吃 raw string,不需 escape |
| User 漏設 `AZURE_DEVOPS_EXT_PAT` env var | 起始 Prerequisites check 抓到 → 提示 `export AZURE_DEVOPS_EXT_PAT='...'` 後 retry |
| `az boards query` WIQL 在某 ADO 版本 syntax 略不同 | 用上述標準 WIQL;fail 直接把 stderr 給 user,不擅自 fallback |
| `az` CLI 未 install azure-devops extension | Prerequisites check 抓 `az extension list` 看;缺 → 提示 `az extension add --name azure-devops` |
| Create item 失敗到一半 | 已建的 item 因有 fingerprint marker,re-run 自動 skip;user 修原因後直接重跑即可 |

## 跟 spec / 其他 skill 的關係

- **`spec` skill** 負責:需求釐清 → plan → tasks.md → 驗收。產物為對話內 plan.md / spec.md
- **`prd-breakdown`(本 skill)** 負責:拿 PRD(或 spec / plan)→ 拆 vertical slices → 推 ADO
- 兩者透過 markdown 文件對接,不互相 import;user 可只用 prd-breakdown 直接拆 PRD 不走 spec ceremony

## Reference fixtures

`tests/fixtures/example_prd.md` + `example_plan.md` 配對 example(**TODO list app MVP** 題材,公開無敏感)。Caller 看不確定怎麼寫 plan.md 時可貼這對給 Claude 對照。

## Important rules

收尾 invariants — 即使前面 step 都讀過,這幾條是核心,違反任一條皆需 abort 並告知 user:

1. **Quiz before bake** — 不確定的事一律列為 question 給 user,不擅自 hard-code assumption
2. **Vertical only** — 每 slice 端到端可 demo;horizontal layer 不算 slice
3. **Fingerprint over title-match** — idempotent skip 一律用 description 內 `<!-- prd-breakdown-id: ... -->` marker,永不靠 title 比對
4. **PAT via env var only** — `AZURE_DEVOPS_EXT_PAT` 環境變數,永不上 argv
5. **No abstraction for multi-platform** — Jira/GH 真要支援,新寫 Workflow section,不抽 generic adapter
6. **Topo before create** — 跑 create 前先 topo sort;偵測 cycle 直接 abort 給 user 處理
7. **Public repo discipline** — fixtures 全用 placeholders,禁真名 / 真 GUID / 真公司名 / 真 ADO ID
8. **Production push 需 explicit double confirm** — 默認假設第一次 push 是非 production test project;user 明指 production 時走 Step B0(surface risk + 拿到雙重 explicit confirm 才走),不擋 user 授權但不被 explicit instruction 直接無視
9. **Basic process exception** — Basic template 偵測到 → 跳過 Predecessor relation step(不存在),items 仍建
10. **No Python wrapper** — Claude 透過 Bash 直接 `az`;不寫 / 不召喚 Python helper script

## Acknowledgments

Algorithm 內化(重寫成 prompt,未 vendor):

- [yldgio/vibe-grimoire](https://github.com/yldgio/vibe-grimoire) (MIT) — vertical slice rules、wave grouping decision tree、ADO issue body template、Predecessor relation pattern
- [mattpocock/skills](https://github.com/mattpocock/skills) (MIT) — quiz user numbered-list workflow、tracker-agnostic abstraction 思路

More from KerberosClaw/kc_ai_skills

SkillDescription
character-loraUse when the user wants to build a consistent-identity LoRA for an original character — defining the character, generating a face/body-consistent multi-angle dataset (via the gpt-image-gen skill for codex image generation), captioning it, doing base-specific homework, training on a chosen base (Pony / Z-Image / others) on a local GPU, and producing a usable LoRA. This skill ORCHESTRATES the end-to-end pipeline and gates every expensive/irreversible step; it delegates actual image generation to gpt-image-gen and never improvises training settings from memory.
conference-reportUse when the user attended one or more sessions of a conference (with audio recordings + slide photos) and needs help building (1) faithful per-session reconstructions in markdown (slide visuals + speaker transcript with Whisper hallucination annotations), and (2) a downstream report deliverable whose scope and format are decided interactively with the user. Pipeline phase (raw → mlx_whisper Chinese SRT → per-slide multimodal reconstruction → official agenda cross-check via Playwright if available) is deterministic. Report phase is interactive — always quiz user on scope (single-session / single-day / multi-day synthesis), format (existing template / free-form fallback), recipient (formal / informal), and any business workstream mapping before drafting.
ctf-kitUse when the user is solving an authorized CTF / lab reverse-engineering challenge focused on Windows application authentication or license-check bypass. Guides triage → static analysis → dynamic experiment planning → bypass verification, with strong evidence discipline and VM safety boundaries. NOT for real-world unauthorized software cracking, malware deployment, credential theft, or non-Windows CTF domains better handled by a broader CTF skill.
goal-engineerUse when the user wants to AUTHOR an unattended dispatch for either: (1) a goal-driven evaluator-optimizer loop of the GENERATE-AND-SELECT kind (generate candidates → grade against a rubric → iterate by reason-code → keep the best; the human picks the final selection), or (2) a lean build-to-spec run whose build spec is ALREADY FROZEN (approved ADR / locked design / accepted machine-checkable AC) and the only missing piece is the unattended-execution wrapper. A fresh-session agent runs the dispatch hands-off while the human only watches traffic-light push notifications. Interview-style forcing questions lock the spec, then it emits a self-contained dispatch markdown + a channel-agnostic notification protocol. This is the upstream SPEC AUTHOR, NOT a runtime: the dispatch is run by Claude Code's /goal, a headless `-p` session, or any unattended agent — /goal is the engine, this writes what you feed it. It NEVER authors build specs, product decisions, or AC — creating a build spec / PRD from raw input is prd-create. NOT a time scheduler (/loop or cron), NOT a recurring-push registrar (skill-cron).
gpt-image-genUse when the user asks to generate an image via GPT/Codex (e.g. 「叫 gpt 生圖」「幫我用 gpt 生圖」「gpt 畫一個 X」). The skill drafts a Chinese + English prompt pair, iterates with the user until they explicitly approve, then dispatches Codex CLI ($imagegen skill, codex built-in image_gen) in the background, monitors progress, converts the result to a jpg in the current working directory, and writes a sidecar prompt log. Does text-to-image AND img2img — drop a reference image (on-disk file) and it runs Codex `-i` to lock a face/character across scenes.
grillUse when the user says 先討論 / wants to align on a fuzzy idea before building, or before any non-trivial implementation whose requirements are still ambiguous — interviews the user until shared understanding is confirmed, one question at a time, each with a suggested answer; facts answerable from the filesystem/code are looked up, never asked. Optionally maintains the repo's CONTEXT.md glossary when vocabulary settles during discussion. Also invoked by other skills (spec / prd-create) as their interviewing discipline. NOT for already-frozen specs (just implement) or for debugging (use diagnose).
job-scoutUse when the user is considering applying to, interviewing with, or accepting an offer from a company and wants due diligence on the company and optionally a specific role. Requires a company name, optionally a job title, then researches current public data, employee reviews, salary signals, product/tech quality, and red flags before giving a grounded recommendation. NOT for generic career coaching or resume editing.
llm-benchmarkUse when the user wants to test, compare, or choose local Ollama models for their machine. Checks Ollama/GPU state, recommends model sizes from available VRAM, preserves existing benchmark records, pulls only approved models, runs repeatable benchmarks, restores stopped services, and writes a markdown comparison report. NOT for hosted API model evaluation or subjective chat-quality judging without local benchmark commands.
llm-wiki-lintUse when the user wants to lint a repo following the Karpathy LLM Wiki pattern (raw/ + wiki/ + SCHEMA.md / index.md / log.md). The skill detects path, scans wiki pages + schema layer, reports frontmatter gaps, broken in-body links, source traceability breaks, stale claims, orphan pages, index synopsis contradictions, and SCHEMA-vs-reality drift. Phase 1 is read-only report; Phase 2 (fix + log.md LINT entry) only runs after the user explicitly approves.
md2pdfUse when the user wants to convert one Markdown file into a publication-ready A4 PDF, especially when the source may contain Mermaid diagrams, ASCII diagrams, CJK text, tables, or pandoc/weasyprint edge cases. Works by copying the source to a _pdf.md working file, converting diagrams, escaping PDF-breaking syntax, rendering with pandoc + weasyprint, then self-checking pages. NOT for batch conversion, slide decks, or editing the original Markdown in place.