PRD UI Annotator
Map PRD requirements onto UI pages as module-level numbered badges and detailed Markdown tooltips. The result must let developers understand the relevant PRD requirements from the page without rereading the original PRD.
Required Inputs
- A PRD Markdown file, normally named
prd.md, PRD.md, or similar.
- A page implementation to annotate, such as React, Vue, or static HTML.
- A clear user intent:
- Workflow A: 初始化标注 for new pages/documents.
- Workflow B: 标注内容更新 for existing annotations.
If the user intent is unclear, ask exactly: 请问您是需要执行【Workflow A: 初始化标注】(针对新页面/新文档),还是执行【Workflow B: 标注内容更新】(针对已有标注的增量修改)?
Codex Implementation Contract
- Before editing, inspect the project stack, existing annotation code, PRD path, and page files.
- Maintain a machine-readable mapping file named
prd-annotations.json near the annotated page or in a clear project docs/config folder.
- Use
prd-annotations.json as the stable source of truth for requirement id, module name, target selector/component, source PRD section, full Markdown content, and status.
- Write the requirement number back into the PRD at the start of the corresponding source requirement using
[N].
- Do not place multiple badges on the same component or tightly coupled module.
- Preserve all original PRD details inside the tooltip content. Do not summarize away business rules, preconditions, exceptions, permissions, or edge cases.
- Do not invent requirements. If PRD text or page mapping is ambiguous, ask before annotating.
Workflow A: 初始化标注
Discover
- Locate the PRD file and target page.
- Identify framework and styling conventions.
- Check for existing annotation components, tooltip libraries, portals, z-index tokens, or
prd-annotations.json.
Aggregate Requirements
- Parse PRD requirements into UI modules.
- Merge related requirements into one marker per module.
- Examples:
- Row actions: edit/delete/view/permission rules belong in one "操作" marker.
- Filter area: inputs, selects, query/reset logic belong in one filter marker.
- Tabs/container: all switching and visibility logic belong in one tabs marker.
- Assign continuous numeric ids from
1 to 999.
Create Mapping
- Generate or update
prd-annotations.json.
- Each item must include:
id
moduleName
target
sourcePrdHeading
sourcePrdExcerpt
tooltipMarkdown
status
- Keep full Markdown structure in
tooltipMarkdown, including bold, italic, nested lists, ordered lists, and blockquotes.
Implement UI Annotation Layer
- Prefer a reusable annotation component rather than hardcoding each tooltip.
- Use absolute positioning or a portal/body mount when the target container uses
overflow: hidden.
- Ensure annotations do not change the original layout, dimensions, spacing, or business behavior.
- Render Markdown deeply inside tooltips.
Write Back to PRD
- Insert
[N] at the start of each mapped requirement's source description.
- The page badge number and PRD number must match exactly.
- Do not duplicate numbers if they already exist.
Workflow B: 标注内容更新
- Read existing
prd-annotations.json, current PRD, and annotated page code.
- Identify added, modified, removed, and unchanged requirement mappings.
- Apply only affected changes:
- Added: create a new continuous id, mapping entry, badge target, and PRD number.
- Modified: update only
tooltipMarkdown and source excerpt unless the component moved.
- Removed: remove mapping entry, badge rendering, and stale PRD numbering if safe.
- Style Lock: do not change badge colors, sizes, tooltip background, offsets, z-index, drag behavior, or close behavior unless the user explicitly asks.
Required Visual & Interaction Specs
Badge:
display: inline-block;
vertical-align: top;
background: rgb(250, 173, 20);
color: #fff;
font-size: 10px;
font-weight: 700;
line-height: 14px;
padding: 0 4px;
border-radius: 2px;
border: 0;
cursor: pointer;
position: absolute;
top: -8px;
right: -4px;
z-index: 9998;
Tooltip:
background: #f0efef;
border-radius: 4px;
width: 450px;
z-index: 9999;
line-height: 1.6;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
Interaction:
- Hovering a badge opens its tooltip immediately.
- A tooltip can only be closed by its top-right
X button.
- The same requirement id can have only one open tooltip.
- Multiple different ids may be open at once.
- Tooltip content and dragging must stop event propagation.
- Tooltip supports free mouse dragging.
- Tooltip defaults to the badge's lower-left with 8px spacing, then flips/repositions to stay inside the viewport.
Tooltip content structure:
- Header: badge-styled requirement id +
需求描述:[模块名称]
- Divider: thin light-gray line under the header.
- Body: rendered Markdown preserving paragraphs, bold, italic, nested lists, ordered lists, and blockquotes.
- Status colors: when status colors are mentioned, prefix text with a matching colored dot.
Self-Check Before Final Response
- Confirm whether Workflow A or Workflow B was executed.
- Confirm each module/component has at most one badge.
- Confirm tooltip content can replace reading the original PRD for the mapped module.
- Confirm hover, drag, close-by-X, event isolation, and viewport avoidance are implemented.
- Confirm visual parameters match the required specs and style lock was preserved during updates.
- Confirm
prd-annotations.json exists and PRD numbering matches page badges.
- Run available checks or a targeted build/test when feasible.
Final Response
Report:
- Workflow executed.
- PRD file updated.
- Mapping file path.
- Page/component files changed.
- Validation performed.
- Any ambiguous requirements left unmapped.
1---2name: prd-ui-annotator3description: PRD 标注技能,用于把需求文档转成页面上的编号标注和可拖拽富提示,并支持增量更新现有 UI 注释。4---56# PRD UI Annotator78Map PRD requirements onto UI pages as module-level numbered badges and detailed Markdown tooltips. The result must let developers understand the relevant PRD requirements from the page without rereading the original PRD.910## Required Inputs1112- A PRD Markdown file, normally named `prd.md`, `PRD.md`, or similar.13- A page implementation to annotate, such as React, Vue, or static HTML.14- A clear user intent:15 - **Workflow A: 初始化标注** for new pages/documents.16 - **Workflow B: 标注内容更新** for existing annotations.1718If the user intent is unclear, ask exactly: `请问您是需要执行【Workflow A: 初始化标注】(针对新页面/新文档),还是执行【Workflow B: 标注内容更新】(针对已有标注的增量修改)?`1920## Codex Implementation Contract2122- Before editing, inspect the project stack, existing annotation code, PRD path, and page files.23- Maintain a machine-readable mapping file named `prd-annotations.json` near the annotated page or in a clear project docs/config folder.24- Use `prd-annotations.json` as the stable source of truth for requirement id, module name, target selector/component, source PRD section, full Markdown content, and status.25- Write the requirement number back into the PRD at the start of the corresponding source requirement using `[N]`.26- Do not place multiple badges on the same component or tightly coupled module.27- Preserve all original PRD details inside the tooltip content. Do not summarize away business rules, preconditions, exceptions, permissions, or edge cases.28- Do not invent requirements. If PRD text or page mapping is ambiguous, ask before annotating.2930## Workflow A: 初始化标注31321. **Discover**33 - Locate the PRD file and target page.34 - Identify framework and styling conventions.35 - Check for existing annotation components, tooltip libraries, portals, z-index tokens, or `prd-annotations.json`.36372. **Aggregate Requirements**38 - Parse PRD requirements into UI modules.39 - Merge related requirements into one marker per module.40 - Examples:41 - Row actions: edit/delete/view/permission rules belong in one "操作" marker.42 - Filter area: inputs, selects, query/reset logic belong in one filter marker.43 - Tabs/container: all switching and visibility logic belong in one tabs marker.44 - Assign continuous numeric ids from `1` to `999`.45463. **Create Mapping**47 - Generate or update `prd-annotations.json`.48 - Each item must include:49 - `id`50 - `moduleName`51 - `target`52 - `sourcePrdHeading`53 - `sourcePrdExcerpt`54 - `tooltipMarkdown`55 - `status`56 - Keep full Markdown structure in `tooltipMarkdown`, including bold, italic, nested lists, ordered lists, and blockquotes.57584. **Implement UI Annotation Layer**59 - Prefer a reusable annotation component rather than hardcoding each tooltip.60 - Use absolute positioning or a portal/body mount when the target container uses `overflow: hidden`.61 - Ensure annotations do not change the original layout, dimensions, spacing, or business behavior.62 - Render Markdown deeply inside tooltips.63645. **Write Back to PRD**65 - Insert `[N]` at the start of each mapped requirement's source description.66 - The page badge number and PRD number must match exactly.67 - Do not duplicate numbers if they already exist.6869## Workflow B: 标注内容更新70711. Read existing `prd-annotations.json`, current PRD, and annotated page code.722. Identify added, modified, removed, and unchanged requirement mappings.733. Apply only affected changes:74 - Added: create a new continuous id, mapping entry, badge target, and PRD number.75 - Modified: update only `tooltipMarkdown` and source excerpt unless the component moved.76 - Removed: remove mapping entry, badge rendering, and stale PRD numbering if safe.774. **Style Lock**: do not change badge colors, sizes, tooltip background, offsets, z-index, drag behavior, or close behavior unless the user explicitly asks.7879## Required Visual & Interaction Specs8081Badge:8283```css84display: inline-block;85vertical-align: top;86background: rgb(250, 173, 20);87color: #fff;88font-size: 10px;89font-weight: 700;90line-height: 14px;91padding: 0 4px;92border-radius: 2px;93border: 0;94cursor: pointer;95position: absolute;96top: -8px;97right: -4px;98z-index: 9998;99```100101Tooltip:102103```css104background: #f0efef;105border-radius: 4px;106width: 450px;107z-index: 9999;108line-height: 1.6;109box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);110```111112Interaction:113114- Hovering a badge opens its tooltip immediately.115- A tooltip can only be closed by its top-right `X` button.116- The same requirement id can have only one open tooltip.117- Multiple different ids may be open at once.118- Tooltip content and dragging must stop event propagation.119- Tooltip supports free mouse dragging.120- Tooltip defaults to the badge's lower-left with 8px spacing, then flips/repositions to stay inside the viewport.121122Tooltip content structure:123124- Header: badge-styled requirement id + `需求描述:[模块名称]`125- Divider: thin light-gray line under the header.126- Body: rendered Markdown preserving paragraphs, bold, italic, nested lists, ordered lists, and blockquotes.127- Status colors: when status colors are mentioned, prefix text with a matching colored dot.128129## Self-Check Before Final Response130131- Confirm whether Workflow A or Workflow B was executed.132- Confirm each module/component has at most one badge.133- Confirm tooltip content can replace reading the original PRD for the mapped module.134- Confirm hover, drag, close-by-X, event isolation, and viewport avoidance are implemented.135- Confirm visual parameters match the required specs and style lock was preserved during updates.136- Confirm `prd-annotations.json` exists and PRD numbering matches page badges.137- Run available checks or a targeted build/test when feasible.138139## Final Response140141Report:142143- Workflow executed.144- PRD file updated.145- Mapping file path.146- Page/component files changed.147- Validation performed.148- Any ambiguous requirements left unmapped.