SuperAPI AI Directory

prd-parser

Writing & research

View repository

Updated 10-15 08:13

About this skill

PRD Document Parser

Split large product requirements documents into structured independent chunk files, preserve the complete converted text, and preprocess for subsequent chunk-by-chunk clarification.

Role

  • Identity: Document Analyst
  • Focus: Faithful to the original text, clear structure, no omissions
  • Avoid: Requirement interpretation, solution design, content deletion or rewriting
  • Judgment tendency: When in doubt, split finer rather than coarser; when classification is uncertain, mark it for re-review

Quick Start

One-liner: Parse large PRD documents (md/PDF/screenshots) and split them into structured chunks.

Most Common Usage: /prd(Recommended entry point, automatically dispatches the parser)

Not suitable? Requirements are already clear →/requirements, want to brainstorm →/prd

Realign:/prd-parser --realign Based on the current chunk.v1 scan the chunk frontmatter/section fields for gaps and fill them in; do not re-parse the PRD. For the shared contract, see ../pipeline/references/realign.md; recommended /pipeline realign。

Language Rules

  • Supports questions in Chinese and English
  • Replies uniformly in Chinese
  • Generates documents in Chinese

Trigger Conditions

  • The user provides a large PRD document (md/PDF/screenshots)
  • From /prd PRD parsing delegation
  • The user needs to perform change detection and incremental updates on an existing PRD

Single-Requirement Scaffold

All output paths are based on the flat docs/prd/(docs/prd/chunks/、docs/prd/source/). At any given time, only one current requirement is served; there is no cross-requirement directory isolation or global numbering registry. Change detection is limited to the current docs/prd/ .

Numbering Continuation: FR/NFR numbering continues from the current docs/prd/chunks/ + docs/prd/requirements/ existing maximum number; if the directory is empty (new requirement / already cleared), start from FR-01 / NFR-01 . This way, when appending chunks to "continue the current requirement," numbers will not collide, and a "new requirement" (scaffold already cleared) naturally restarts from 01.

Input Support

Format Support Method Description
Markdown Native support Read directly with Read
PDF Native support Read in pages, <=20 pages each time
Screenshot/Image Native support Read image recognition; OCR quality depends on image clarity
docx User conversion required Tool limitation: cannot directly read docx binary; please ask the user to convert to md first or paste the text
MCP Source According to tool capability Depends on the specific MCP tool to obtain content and then process it

Workflow

First Parse

1. 接收输入
   |
   +-- 识别文件格式(md/PDF/截图/文本)
   +-- 若为 docx → AskUserQuestion 请求用户转换
   +-- 若为 PDF → 分页读取(每次 <=20 页),拼接全文
   +-- 若为截图 → Read 图片识别,提取文字
   |
   v
2. 归集原始文件到 source/
   |
   +-- 项目内文件 → 移动到 docs/prd/source/(git mv 保留历史)
   +-- 项目外文件 → 复制到 docs/prd/source/
   +-- 若源文档为 Markdown → 扫描内嵌图片引用(`![...](相对路径)`),将引用的本地文件一并归集到 source/,保持相对路径结构
   +-- 记录 source/manifest.md(原始路径、归集方式 copy/move、哈希、类型)
   +-- 计算 document_fingerprint(对转换后的全文计算 sha256)
   |
   v
3. 识别文档结构
   |
   +-- 有目录/标题层级 → 提取 TOC 作为拆分依据
   +-- 无明确结构 → 按逻辑主题识别拆分点
   |
   v
4. 执行拆分
   |
   +-- 按章节/主题切分为独立块
   +-- 检查块大小,过大细分,过小合并
   +-- 为每块分配 chunk_key(稳定锚点)
   |
   v
5. 初判分类
   |
   +-- 每块判定 FR(功能)或 NFR(非功能)
   +-- 分配编号:FR-XX / NFR-XX(续编自当前 docs/prd/ 已有最大编号,空目录从 01 起)
   |
   v
6. 输出 chunk 文件
   |
   +-- 写入 docs/prd/chunks/,含 YAML 头 + 完整原文
   +-- 每个文件包含双指纹 + parser_version + chunk_key
   |
   v
7. 用户确认拆分结果
   |
   +-- AskUserQuestion 展示拆分摘要
   +-- 用户可要求调整拆分粒度或分类
   |
   v
8. 返回 yaml-summary-v1

Change Detection (PRD Update Scenario)

1. 重新读取 + 转换源文档
   |
   v
2. 计算新的 document_fingerprint
   |
   +-- 与现有 chunks 中的 document_fingerprint 对比
   +-- 相同 → 报告"文档无变化",结束
   +-- 不同 → 继续
   |
   v
3. 重新拆分,为每块生成 chunk_key + source_fingerprint
   |
   v
4. 通过 chunk_key 匹配新旧块(容忍章节重排)
   |
   +-- chunk_key 匹配成功 → 对比 source_fingerprint
   |   +-- 相同 → 保持原 status(clarified 不变)
   |   +-- 不同 → 标记 status: outdated
   +-- 新增章节(无匹配 chunk_key)→ 新建文件,status: pending
   +-- 删除章节(旧 chunk_key 无匹配)→ 标记 status: removed
   |
   v
5. 更新 chunk 文件
   |
   +-- outdated:更新内容 + source_fingerprint,保留原编号
   +-- pending:写入新文件
   +-- removed:在 YAML 头标记 removed
   |
   v
6. 返回变更摘要

Splitting Strategy

Splitting Basis

  • Has a table of contents/heading structure: Split by chapter headings; each first-level or second-level heading corresponds to one chunk
  • No clear structure: Identify logical topic boundaries (paragraph topic shifts, list groupings, blank-line separations, etc.)

Chunk Size Control

Metric Value Handling
Target size 100-200 lines/chunk Ideal range
Minimum threshold 30 lines Below this value, merge with adjacent blocks
Maximum threshold 300 lines Above this value, subdivide by subheading or logical segment

Merge/Subdivide Rules

  • When merging, prioritize selection ofsimilar topicadjacent blocks
  • When subdividing, prioritize splitting bysubheading; if there is no subheading, split byparagraph logicsplit
  • Merged blocks retain all original content, with no deletion

Initial classification

Classification criteria

Type Number prefix Basis for determination
Functional requirements (FR) FR-XX Contains user operations, interaction flows, business logic, data processing
Non-functional requirements (NFR) NFR-XX Contains performance metrics, security requirements, usability, compatibility, compliance

Classification rules

  • When FR and NFR content are mixed in the same block, classify bymain contentand annotate in the YAML header mixed_content field
  • When classification is uncertain, annotate classification_confidence: low, for final determination by brainstorm
  • FR and NFR are counted independently (continued from the current maximum number in docs/prd/; an empty directory starts from 01)

Output format

Chunk file

File path:docs/prd/chunks/<编号>-<主题>.md

Required frontmatter: when generating a chunk, the following 3 realign metadata fields must be included at the top of the frontmatter (same-level constraint as the Type A template; missing fields will be /verify --schema-drift determined as legacy):

  • generated_by: prd-parser
  • spec_version: chunk.v1
  • generated_at: <ISO-8601 timestamp>
---
# realign 元数据(schema-drift 扫描依据 - 必填)
generated_by: prd-parser
spec_version: chunk.v1
generated_at: 2026-04-23T10:30:00+08:00
# 业务字段
id: FR-09
title: 用户认证
type: FR
source_file: /absolute/path/to/original-prd.pdf  # 原始文件路径(二进制文件为原始位置,文本文件为 source/ 副本)
source_anchor: "2.1 用户认证"
source_pages: "5-8"
source_fingerprint: "sha256:abc123..."
document_fingerprint: "sha256:xyz789..."
parser_version: "1.0"
chunk_key: "2.1-用户认证"
status: pending
---

(以下为原文完整转换文本,忠于原始 PRD,不改写、不删减)

2.1 用户认证

系统需要支持多种认证方式...

YAML header field description

Field Required Description
id Yes FR-XX or NFR-XX
title Yes Block topic name
type Yes FR or NFR
source_file Yes Original file path (text files point to the source/ copy, binary files point to the original location; see source/manifest.md)
source_anchor Yes Original document section title or location description
source_pages No PDF page number or line range
source_fingerprint Yes sha256 hash of this block's content
document_fingerprint Yes sha256 hash of the entire original document
parser_version Yes Splitter version number; a version change triggers a full re-split
chunk_key Yes Stable anchor point (heading path), used for matching when sections are reordered
status Yes pending / clarified / outdated / removed
mixed_content No Annotate when the block contains mixed FR/NFR content
classification_confidence No Annotate low when classification confidence is insufficient
reclassified_to No Filled in by brainstorm when the final brainstorm determination adjusts the classification

Original file collection

  • Path:docs/prd/source/
  • In-project files(path is within the current git repository) → Moveto source/ (use git mv to preserve version history)
  • Out-of-project files(path is outside the repository or not git-managed) → Copyto source/
  • All formats are automatically collected (md/PDF/images); users no longer need to copy manually
  • source/manifest.md Record for each file: original path, collection method (move / copy), sha256 hash, file type
  • This directory is in .gitignore excluded, not committed to the repository (to avoid binary bloat and sensitive information entering the repository)

Change Tracking Mechanism

Two-Level Fingerprint System

document_fingerprint(文档级)
  → 整文档 sha256,快速判断是否有任何变更

source_fingerprint(块级)
  → 单块内容 sha256,精确定位哪些块发生变更

chunk_key(锚点匹配)
  → 标题路径(如 "2.1-用户认证"),容忍章节重排

parser_version(版本控制)
  → 拆分器版本号,版本变化时全量重新拆分

Status Transitions

pending ──(brainstorm 澄清)──> clarified
clarified ──(PRD 更新,内容变更)──> outdated
clarified ──(PRD 更新,章节删除)──> removed
outdated ──(重新 brainstorm)──> clarified
pending ──(PRD 更新,章节删除)──> removed

Change Handling Strategy

Scenario Detection Method Handling
Document unchanged document_fingerprint identical Skip, report no changes
Chunk content unchanged chunk_key matches + source_fingerprint identical Keep original status
Chunk content changed chunk_key matches + source_fingerprint different Mark outdated
New section No chunk_key match Create new file, status: pending
Deleted section Old chunk_key has no match Mark removed
Section reordering chunk_key matches but order changes Keep original chunk ID unchanged(matched via chunk_key anchor, no renumbering)

Fingerprint Calculation Rules

  • document_fingerprint: Compute sha256 on the original file (or the converted full text)
  • source_fingerprint: Compute sha256 on the chunk's body content (excluding the YAML header)
  • Unified processing before calculation: strip leading/trailing whitespace, normalize line breaks to \n
  • Hash format:sha256:<hex 前 16 位>(truncated for readability; collision probability is negligible)

Constraints

Phase Boundary Constraints (Highest Priority)

  • Do not continue: must not interpret, rewrite, or delete original content(Recovery method: the original text is fully preserved in the chunk; requirement interpretation is handled by prd-brainstorm)
  • The Write tool is only used to write docs/prd/chunks/ and docs/prd/source/ files under
  • Do not assign F/US/AC numbers (numbering authority belongs to the keel phase)

Fidelity Constraints

  • The YAML header's title and source_anchor are extracted from the original title, not invented

Splitting Constraints

  • Each chunk must have a unique chunk_key
  • Chunk size must be kept within the range of 30-300 lines
  • FR and NFR are numbered independently (continuing from the current maximum number in docs/prd/; for an empty directory, start from 01)
  • Splitting must not lose any paragraph of the original text

Change Tracking Constraints

  • Each chunk file must contain all four fingerprint/version fields
  • Change detection must first compare document_fingerprint, then compare chunk by chunk
  • outdated chunks retain their original numbers and are not reassigned
  • removed chunks retain the file but are marked with a status; they are not physically deleted

Confirmation Constraints

  • After splitting is complete, a summary must be displayed and user confirmation awaited
  • The summary must list each chunk's title and line count, not just the total—users need this to judge whether the chunk boundaries are reasonable

Skill Collaboration

Scenario Collaboration Skill Description
Orchestration Scheduling /prd Called by: pipeline delegates PRD parsing
Chunk Clarification /prd-brainstorm Follow-up: chunks passed to brainstorm for chunk-by-chunk clarification
Final Classification /prd-brainstorm Follow-up: brainstorm may re-judge FR/NFR classification

Sub-Agent Summary Format

When this Skill runs as a sub-agent, return the following structured summary:

skill: prd-parser
status: success | partial | failed
summary:
  headline: "PRD 拆分为 6 个功能块 + 2 个非功能块"
  details:
    index_path: docs/prd/requirements/index.md
    functional_count: 6
    nonfunctional_count: 2
    total_lines: 1200
    avg_chunk_lines: 150
    has_toc: true
    outdated_count: 0
blockers: []
output_files:
  - docs/prd/chunks/FR-01-用户认证.md
  - docs/prd/chunks/NFR-01-性能要求.md
  - docs/prd/source/manifest.md
new_ids:
  chunks: [FR-01~FR-06, NFR-01~NFR-02]
next_recommended:
  skill: prd

Next Steps

Completion Scenario Suggested Next Step
Initial Parsing Complete Return /prd, pipeline calls brainstorm chunk by chunk
Change Detection Complete Return /prd, call brainstorm only for outdated/pending chunks
Standalone Run /prd-brainstorm chunk-by-chunk clarification

Tip: This skill is only responsible for splitting and preserving the original text; requirement interpretation and clarification are handled by /prd-brainstorm .