From omni-dsdd
Analyzes code architecture based on requirement intent, supporting simple and complex demand scenarios. Activated via reverse --target on-demand.
How this skill is triggered — by the user, by Claude, or both
Slash command
/omni-dsdd:reverse-on-demand --requirement=<文本>|--intent=<文本> [--demand-complexity=<simple|complex>] [--path=<dir1,dir2,...>] [--exclude=<glob1,glob2,...>] [--mode=<silent|interactive>]When to use
当用户执行 reverse --target on-demand 或需要基于需求意图进行代码架构分析时触发
--requirement=<文本>|--intent=<文本> [--demand-complexity=<simple|complex>] [--path=<dir1,dir2,...>] [--exclude=<glob1,glob2,...>] [--mode=<silent|interactive>]This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
以下规则在整个会话期间有效,不因对话长度而放松:
references/harness-contract.jsonreferences/implementation/deep-architecture-identification.mdreferences/stages/01-check-existing-products.mdreferences/stages/02-deep-architecture-identification.mdreferences/stages/03a-simple-on-demand-reverse.mdreferences/stages/03b-complex-on-demand-reverse.mdscripts/bash/reverse-on-demand-gate.shscripts/bash/reverse-on-demand-init-harness.shscripts/bash/verify-reverse-on-demand-stage2.shscripts/powershell/Reverse-On-Demand-Gate.ps1scripts/powershell/Reverse-On-Demand-InitHarness.ps1scripts/powershell/Verify-Reverse-On-Demand-Stage2.ps1scripts/python/reverse_on_demand_harness.pyscripts/python/test_reverse_on_demand_harness.py以下规则在整个会话期间有效,不因对话长度而放松:
--mode=interactive 时:步骤3b 步骤5.7 的用户确认点必须等待响应后方可继续。静默模式(默认)下无需等待,所有确认点自动通过(保留全部功能),直接继续后续步骤。每次输出前自检此条。❗ 标记规则 ≤3 条已达标。
| 变量 | 谁设置 | 含义 | 用途 |
|---|---|---|---|
CLAUDE_PLUGIN_ROOT | 运行时注入,或 Step 0.2 补全 | Omni 插件安装根(含 skills/、scripts/) | 拼插件脚本路径;调用封装脚本时传 --plugin-root |
CLAUDE_WORKING_DIR | 运行时注入,或 Step 0.2 补全 | 当前工作区目录(可为仓库子目录) | changes/、Harness 落盘、Git/目录操作工作区根 |
CREATE_BRANCH_HAS_GIT | Step 0.3 探测 | true / false | 传给 create-new-feature 的 --has-git |
已废弃:脚本内自推
REPO_ROOT、__file__/parents[n]推根、业务脚本内pwd/git rev-parse推根目录。
CLAUDE_PLUGIN_ROOT 补全顺序:
CLAUDE_WORKING_DIR 上级查找 .claude-plugin/plugin.json(内嵌开发态);CLAUDE_WORKING_DIR 补全:
export CLAUDE_WORKING_DIR="$(pwd)"(禁止使用 git rev-parse --show-toplevel)。# 校验目录变量存在且可用
test -d "${CLAUDE_PLUGIN_ROOT}"
test -d "${CLAUDE_WORKING_DIR}"
# 创建工作区下 changes
mkdir -p "${CLAUDE_WORKING_DIR}/changes"
# 仅探测一次是否存在 Git 工作区
if git -C "${CLAUDE_WORKING_DIR}" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
export CREATE_BRANCH_HAS_GIT=true
else
export CREATE_BRANCH_HAS_GIT=false
fi
执行初始化(显式传入工作区,不要依赖脚本内 pwd,不要仅 export 后无参调用):
bash "${CLAUDE_PLUGIN_ROOT}/scripts/bash/init_omni_infra.sh" \
--plugin-root "${CLAUDE_PLUGIN_ROOT}" \
--working-dir "${CLAUDE_WORKING_DIR}"
说明:init_omni_infra.sh 将 ${CLAUDE_PLUGIN_ROOT}/omni-infra 复制为 ${CLAUDE_WORKING_DIR}/.omni-infra;返回码 1 表示首次创建成功,按需 Task(omni-dsdd:constitution) 后继续;0 表示已存在;2 为失败。
${CLAUDE_PLUGIN_ROOT}/...${CLAUDE_WORKING_DIR}/...--working-dir(必填)python3 ... --working-dir "${CLAUDE_WORKING_DIR}" ...bash ... --plugin-root "${CLAUDE_PLUGIN_ROOT}" --working-dir "${CLAUDE_WORKING_DIR}" ...--mode=silent(默认)或 --mode=interactiveimpact_status=hit),直接进入步骤6后续处理。--mode 时默认为 silent。reverse --target on-demand ... 触发spec.md 存在,也不会创建/修改 changes/<feature>/spec.md{FEATURE_DIR}/on-demand/:按需反构中间产物/缓存{REPO_ROOT}/omni-doc/on-demand/on-demand-existing-function-analysis-{BRANCH_NAME}.md:主汇总文档{REPO_ROOT}/omni-doc/on-demand/functions/{function_key}.md:逐功能分析文档(简单/复杂流程共用目录){REPO_ROOT}/omni-doc/on-demand/interfaces/{interface_key}.md:逐接口分析文档(接口独立产物,功能文档通过引用关联)本 Skill 对应原
reverse-on-demand.md中的阶段化流程和子 Agent 调用约定,仅把入口改为 Skill。
阶段 3a 步骤 2.6 / 阶段 3b 步骤 5.6 落盘后、进入用户确认或步骤 6 之前,必须执行 Harness 门禁;gate_exit≠0 时不得继续。
| 约束 | 解决的问题 | 必落盘产物 | 门禁校验要点 |
|---|---|---|---|
| 检索范围约束 | 检索范围过大导致耗时和 token 过高,或范围失控导致漏检 | stage2-search-coverage.json | 未指定 --path 时:scan_mode=full_repo;指定 --path 时:scan_mode=scoped 且 scope.include_paths 与输入一致;--exclude 必须透传到 scope.exclude_globs |
| 调用链深度 | 追踪过深时自动浅层停止 | stage2-call-trace.json | 每入口根符号一条 trace;禁止 depth_limit/token_budget 等在未达 min_required_depth(默认 8)且无 leaf_evidence 时停止 |
| 配置解析 | 配置文件只列路径未解析 | stage2-static-asset-scan.json | 每个配置文件 parse_status=parsed;含 extracted_keys 或足够 structure_summary;含 consumer_refs |
| 多语言覆盖 | 主用语言外的附属语言(Lua/Shell/SQL/proto 等)被忽略 | stage2-search-coverage.json(languages 子结构) | languages 必须枚举仓库全部语言(Harness 自动扫盘校验,漏报即失败);每项含 role(primary/auxiliary)/coverage_status(covered/degraded)/analysis_method(lsp/grep/read/manual);禁止裸 uncovered,degraded 须含 degraded_rationale;至少一个 primary;波及校验:auxiliary 须含 impact_status(hit/no_hit),hit 时波及清单须出现该语言命中,no_hit 须含 no_impact_rationale 且清单不得命中该语言 |
契约文件:references/harness-contract.json
# 阶段1完成后、阶段3波及检索开始前(生成骨架,可选但推荐)
bash "${CLAUDE_PLUGIN_ROOT}/skills/reverse-on-demand/scripts/bash/reverse-on-demand-init-harness.sh" \
--working-dir "$CLAUDE_WORKING_DIR" \
--feature-dir "$FEATURE_DIR" \
--repo-root "$REPO_ROOT" \
--scope-paths "$SCOPE_PATHS_CSV" \
--exclude-globs "$EXCLUDE_GLOBS_CSV"
# 步骤 2.6 / 5.6 落盘全部 stage2 产物后(强制)
bash "${CLAUDE_PLUGIN_ROOT}/skills/reverse-on-demand/scripts/bash/reverse-on-demand-gate.sh" \
--working-dir "$CLAUDE_WORKING_DIR" \
--feature-dir "$FEATURE_DIR" \
--repo-root "$REPO_ROOT" \
--scope-paths "$SCOPE_PATHS_CSV" \
--exclude-globs "$EXCLUDE_GLOBS_CSV" \
--step stage2 \
--record
# 阶段1完成后、阶段3波及检索开始前(生成骨架,可选但推荐)
powershell -File "${CLAUDE_PLUGIN_ROOT}/skills/reverse-on-demand/scripts/powershell/Reverse-On-Demand-InitHarness.ps1" `
--working-dir "$CLAUDE_WORKING_DIR" `
--feature-dir "$FEATURE_DIR" `
--repo-root "$REPO_ROOT" `
--scope-paths "$SCOPE_PATHS_CSV" `
--exclude-globs "$EXCLUDE_GLOBS_CSV"
# 步骤 2.6 / 5.6 落盘全部 stage2 产物后(强制)
powershell -File "${CLAUDE_PLUGIN_ROOT}/skills/reverse-on-demand/scripts/powershell/Reverse-On-Demand-Gate.ps1" `
--working-dir "$CLAUDE_WORKING_DIR" `
--feature-dir "$FEATURE_DIR" `
--repo-root "$REPO_ROOT" `
--scope-paths "$SCOPE_PATHS_CSV" `
--exclude-globs "$EXCLUDE_GLOBS_CSV" `
--step stage2 `
--record
gate_exit=0:允许进入 3b 步骤 5.7(静默模式直接自动通过,交互模式等待用户确认)或 3a 步骤 3 子 Agentgate_exit=1:不得勾选 Todo / 不得进入后续步骤;按 JSON errors 补齐产物(检索范围/调用链/配置解析/多语言覆盖)后重跑 gate(每步最多 2 次)✅ Checkpoint 阶段2-Harness: gate_exit=0, artifacts=search-coverage+call-trace+static-asset-scan+languages
reverse 命令的关系reverse 负责:
$ARGUMENTS,包括 --requirement、--intent、--demand-complexity、--path、--exclude、--mode 等;--path 归一化为 SCOPE_PATHS_CSV,将 --exclude 归一化为 EXCLUDE_GLOBS_CSV,并在阶段2/阶段3全程透传;--mode(silent/interactive)透传给本 Skill;未指定时默认 silent;本 Skill 按以下阶段执行,阶段详细说明见本目录下 references/stages/:
omni-dsdd:create-branch(skills/create-branch/SKILL.md)FEATURE_DIR;REPO_ROOT:仓库根目录(绝对路径)BRANCH_NAME:特性分支名FEATURE_DIR:特性目录(绝对路径)SPEC_FILE:由 create-branch 返回(仅记录路径,不作为 on-demand 依赖)--working-dir "${CLAUDE_WORKING_DIR}";--plugin-root "${CLAUDE_PLUGIN_ROOT}";--has-git 必须使用 Step 0.3 得到的 CREATE_BRANCH_HAS_GIT,禁止在业务脚本层重复探测。FEATURE_DIR 必须位于 {REPO_ROOT}/changes/ 目录下(形如 {REPO_ROOT}/changes/<short-name>)。FEATURE_DIR 不在 changes/ 下(例如落到 specs/、features/),必须立即报错终止,不得继续阶段2/阶段3。REPO_ROOT、BRANCH_NAME、FEATURE_DIR),不得重新推导目录或分支名。deep_architecture_result:通常为 {REPO_ROOT}/omni-doc/on-demand/logic_architecture.md$ARGUMENTS 中解析 --demand-complexity=<simple|complex>;simple。$ARGUMENTS 中解析 --path(逗号分隔目录)与 --exclude(逗号分隔 glob);--path/--exclude 时,执行路径与现有流程完全一致(阶段2为 full_repo);--path 和/或 --exclude 时,阶段2检索、阶段3分析、文档产出、门禁校验都必须遵从同一范围;--path 限定候选,再应用 --exclude 排除;evidence不足,不得虚构结果。references/stages/03a-simple-on-demand-reverse.md(安装后路径可能为 {REPO_ROOT}/.claude/skills/reverse-on-demand/references/stages/03a-simple-on-demand-reverse.md,安装脚本会将 .claude/ 替换为实际的 agent 目录,例如 .claude/ 或 .cursor/);simple-on-demand-reverse-agent;FEATURE_DIR、REPO_ROOT、arguments、constitution_path(可选)、deep_architecture_result。{FEATURE_DIR}/on-demand/ 中的中间产物;references/stages/03b-complex-on-demand-reverse.md;complex-on-demand-function-analyzer,遍历波及功能清单;function-interface-map.json 逐接口生成并校验接口文档;gate_passed=false 时禁止进入步骤7);{REPO_ROOT}/scripts/bash/reverse/on-demand/build-stage3-todos.sh;{REPO_ROOT}/scripts/bash/reverse/on-demand/validate-stage3-gate.sh;{FEATURE_DIR}/on-demand/:阶段性产出与缓存(中间过程路径不可擅自更改);{REPO_ROOT}/omni-doc/on-demand/functions/:各波及功能独立文档;{REPO_ROOT}/omni-doc/on-demand/interfaces/:各波及接口独立文档;{REPO_ROOT}/omni-doc/on-demand/on-demand-existing-function-analysis-{BRANCH_NAME}.md:最终汇总文档(simple/complex 统一命名)。{FEATURE_DIR}/on-demand/stage3/function-interface-map.json 固化功能-接口关系。@startuml 和 @enduml执行复杂流程步骤5或简单流程步骤2.6中的波及检索时,除各 stage 文档既有要求外,必须同时遵守 references/stages/03b-complex-on-demand-reverse.md 中「波及功能分析强制补充步骤」,且 Harness 四项约束全部通过(见上文「Harness 执行契约」):
REPO_ROOT 执行全量文本检索并落盘 stage2-search-coverage.json;禁止仅以 src/、pkg/ 等少数目录代替全仓扫描。ls(或递归列出)得到完整文件清单,不遗漏同目录成员。stage2-call-trace.json;默认 min_required_depth=8;禁止浅层 depth_limit/token_budget 自动停止。stage2-static-asset-scan.json;每个命中配置须 parse_status=parsed 并提取 key/结构,记录消费方。simple-on-demand-reverse-agentcomplex-on-demand-function-analyzer委派约束:
| 子Agent名称 | 用途 | 调用阶段 | 必需参数 |
|---|---|---|---|
| simple-on-demand-reverse-agent | 简单需求反构 | 阶段3a | FEATURE_DIR、REPO_ROOT、arguments、deep_architecture_result |
| complex-on-demand-function-analyzer | 复杂需求功能分析 | 阶段3b | FEATURE_DIR、REPO_ROOT、arguments、function_key、function_item |
| requirement-similarity-analyzer | 相似需求检索 | 阶段3b(可选) | FEATURE_DIR、REPO_ROOT |
合并检查(强制):
arguments 向阶段3子流程透传;仅在显式传参时启用过滤本 Skill 的详细规范位于本目录下 references/,分支管理由 Skill omni-dsdd:create-branch 提供:
omni-dsdd:create-branch执行本 Skill 时,AI Agent 必须读取上述文档并严格按照其中的说明与约束执行。
omni-doc/on-demand/logic_architecture.md<FEATURE_DIR>/on-demand/stage*/来源引用要求: 所有阶段结论必须引用具体来源(文件路径+行号或工具返回),无来源 = 不输出。
零结果处理:
| 场景 | 正确输出 | 禁止输出 |
|---|---|---|
| 检索无结果 | "未发现相关功能/接口,标记为 evidence不足" | 推断/补充不存在的内容 |
| 文件不存在 | "目标文件不存在,路径: X" | 假设文件存在继续执行 |
| 缓存缺失 | "缓存不存在,将重新生成" | 使用旧缓存或不报错继续 |
结果分级标注:
问题1:阶段执行失败
问题2:子Agent调用失败
问题3:缓存文件冲突
/reverse-on-demand --requirement="分析用户认证模块" --demand-complexity=simple
/reverse-on-demand --requirement="分析用户认证模块" --demand-complexity=simple --path="src/auth,src/common"
/reverse-on-demand --requirement="分析用户认证模块" --demand-complexity=simple --exclude="**/test/**,**/build/**"
/reverse-on-demand --requirement="重构订单处理流程" --demand-complexity=complex
/reverse-on-demand @requirements/auth.md --demand-complexity=complex
npx claudepluginhub zte-aicloud/co-omnispec --plugin omni-dsddExecutes reverse engineering from codebases to extract interfaces, architecture, entities, scenarios, and requirements, generating standardized documentation.
Analyzes requirements to identify impacted specs and code, determining reuse scope and ripple effects. Outputs structured context for populating context.md, enabling upstream commands to generate coherent specifications.
Reverse-engineers existing codebases into V-Model artifacts (plan-context, ADRs, arc42, FEATURE inventory, backlog). Produces evidence-based documentation sourced from code and docs.