npx skills add https://github.com/jschulte/claude-plugins --skill reverse-engineer第 2 步,共 6 步,属于从逆向工程到规范驱动开发流程的一部分。该流程共 6 步:1. 分析,2. 逆向工程(本技能),3. 创建规范,4. 差距分析,5. 实施规划,6. 实施。
预计时间: 30-45 分钟 前提条件: 已完成第 1 步(analysis-report.md 和在 .stackshift-state.json 中选择路由) 输出: docs/reverse-engineering/ 目录下的 11 个文档文件
路由依赖行为:
无论选择哪种实施框架(Spec Kit、BMAD 或 BMAD Auto-Pilot),输出都是相同的。框架选择仅影响第 2 步之后的操作。
防护:在继续之前验证状态文件是否存在。
if [ ! -f .stackshift-state.json ]; then
echo "ERROR: .stackshift-state.json not found."
echo "Step 1 (Initial Analysis) must be completed first. Run /stackshift.analyze to begin."
exit 1
fi
DETECTION_TYPE=$(cat .stackshift-state.json | jq -r '.detection_type')
ROUTE=$(cat .stackshift-state.json | jq -r '.route')
if [ "$DETECTION_TYPE" = "null" ] || [ -z "$DETECTION_TYPE" ]; then
echo "ERROR: detection_type missing from state file. Re-run /stackshift.analyze."
exit 1
fi
if [ "$ROUTE" = "null" ] || [ -z "$ROUTE" ]; then
echo "ERROR: route missing from state file. Re-run /stackshift.analyze."
exit 1
fi
echo "Detection: $DETECTION_TYPE"
echo "Route: $ROUTE"
SPEC_OUTPUT=$(cat .stackshift-state.json | jq -r '.config.spec_output_location // "."')
echo "Writing specs to: $SPEC_OUTPUT"
if [ "$SPEC_OUTPUT" != "." ]; then
mkdir -p "$SPEC_OUTPUT/docs/reverse-engineering"
mkdir -p "$SPEC_OUTPUT/.specify/memory/specifications"
fi
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
状态文件结构:
{
"detection_type": "monorepo-service",
"route": "greenfield",
"implementation_framework": "speckit",
"config": {
"spec_output_location": "~/git/my-new-app",
"build_location": "~/git/my-new-app",
"target_stack": "Next.js 15..."
}
}
捕获提交哈希以进行增量更新:
COMMIT_HASH=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
COMMIT_DATE=$(git log -1 --format=%ci 2>/dev/null || date -u +"%Y-%m-%d %H:%M:%S")
echo "Pinning docs to commit: $COMMIT_HASH"
基于检测类型 + 路由的提取方法:
| 检测类型 | + 绿地项目 | + 棕地项目 |
|---|---|---|
| Monorepo 服务 | 仅业务逻辑(与技术无关) | 完整实现 + 共享包(技术规定性) |
| Nx 应用 | 仅业务逻辑(与框架无关) | 完整的 Nx/Angular 实现细节 |
| 通用应用 | 仅业务逻辑 | 完整实现 |
detection_type 决定查找什么模式(共享包、Nx 项目配置、monorepo 结构等)route 决定如何记录它们(与技术无关 vs 技术规定性)使用 Task 工具并设置 subagent_type=stackshift:stackshift-code-analyzer:AGENT 执行分析。如果该代理不可用,则回退到 Explore 代理。
错误恢复: 如果子代理在某个子阶段失败或返回空结果,则使用 Explore 代理重试一次。如果重试也失败,则用 [ANALYSIS INCOMPLETE] 标记记录差距,并继续处理剩余的子阶段。
缺失组件: 如果某个子阶段未找到相关代码(例如,仅后端服务中没有前端),则在相应的输出文件中记录缺失情况,而不是跳过该子阶段。
使用单独的子代理调用并行启动子阶段 1.1 到 1.6。在进入阶段 2 之前收集所有结果。
进度信号: 所有子阶段完成后,记录:"Phase 1 complete: Analysis gathered for [列出哪些子阶段产生了结果]。"
创建 docs/reverse-engineering/ 目录并生成所有 11 个文档文件。对于每个文件,根据 operations/output-file-specs.md 中的描述应用绿地或棕地变体。现在请阅读该文件以获取详细的每个文件规范。
如果 .stackshift-docs-meta.json 已存在,则用新的元数据完全覆盖它。
COMMIT_HASH=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
COMMIT_DATE=$(git log -1 --format=%ci 2>/dev/null || date -u +"%Y-%m-%d %H:%M:%S")
GENERATED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
写入 docs/reverse-engineering/.stackshift-docs-meta.json:
{
"commit_hash": "<COMMIT_HASH>",
"commit_date": "<COMMIT_DATE>",
"generated_at": "<GENERATED_AT>",
"doc_count": 11,
"route": "<greenfield|brownfield>",
"docs": {
"functional-specification.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"integration-points.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"configuration-reference.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"data-architecture.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"operations-guide.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"technical-debt-analysis.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"observability-requirements.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"visual-design-system.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"test-documentation.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"business-context.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"decision-rationale.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" }
}
}
每个生成的文档在标题后以此头部开始:
# [文档标题]
> **由 StackShift 生成** | 提交:`<short-hash>` | 日期:`<GENERATED_AT>`
> 运行 `/stackshift.refresh-docs` 以更新为最新更改。
按此顺序生成文件,并在每个文件后记录进度:
批次 1(核心架构):
写入文件 1-4 后,记录:"Generated 4/11 files (core architecture complete)." 在继续之前验证输出目录包含 4 个文件。
批次 2(运维和质量): 5. operations-guide.md 6. technical-debt-analysis.md 7. observability-requirements.md 8. visual-design-system.md 9. test-documentation.md
写入文件 5-9 后,记录:"Generated 9/11 files (operations and quality complete)." 在继续之前验证输出目录包含 9 个文件。
批次 3(上下文和决策): 10. business-context.md 11. decision-rationale.md
写入文件 10-11 后,记录:"Generated 11/11 files. Phase 2 complete."
输出结构:
docs/reverse-engineering/
├── .stackshift-docs-meta.json
├── functional-specification.md
├── integration-points.md
├── configuration-reference.md
├── data-architecture.md
├── operations-guide.md
├── technical-debt-analysis.md
├── observability-requirements.md
├── visual-design-system.md
├── test-documentation.md
├── business-context.md
└── decision-rationale.md
docs/reverse-engineering/ 中生成了所有 11 个文档文件[INFERRED] / [NEEDS USER INPUT] 标记.stackshift-docs-meta.json,包含用于增量更新的提交哈希所有文档生成后:
对于 GitHub Spec Kit (implementation_framework: speckit):进行第 3 步 —— 使用 /stackshift.create-specs 将文档转换为 .specify/ 规范。
对于 BMAD 方法 (implementation_framework: bmad):进行第 6 步 —— 移交给 BMAD 的 *workflow-init。BMAD 的 PM 和 Architect 代理使用逆向工程文档作为上下文。
对于 BMAD Auto-Pilot (implementation_framework: bmad-autopilot):进行 /stackshift.bmad-synthesize 以自动生成 BMAD 工件。这 11 个逆向工程文档提供了 BMAD 所需约 90% 的内容。
应做:
[INFERRED] = 合理推断,[NEEDS USER INPUT] = 确实未知不应做:
验证分析是否捕获了:
每个文档必须全面、准确、有条理、可操作,并诚实地说明推断信息与已验证信息。
每周安装次数
91
仓库
GitHub 星标数
1
首次出现
2026年1月23日
安全审计
安装于
github-copilot69
gemini-cli67
opencode67
codex57
claude-code54
cursor53
Step 2 of 6 in the Reverse Engineering to Spec-Driven Development process. The 6-step process: 1. Analyze, 2. Reverse Engineer (this skill), 3. Create Specs, 4. Gap Analysis, 5. Implementation Planning, 6. Implementation.
Estimated Time: 30-45 minutes Prerequisites: Step 1 completed (analysis-report.md and route selection in .stackshift-state.json) Output: 11 documentation files in docs/reverse-engineering/
Route-Dependent Behavior:
Output is the same regardless of implementation framework (Spec Kit, BMAD, or BMAD Auto-Pilot). The framework choice only affects what happens after Step 2.
Guard: Verify state file exists before proceeding.
if [ ! -f .stackshift-state.json ]; then
echo "ERROR: .stackshift-state.json not found."
echo "Step 1 (Initial Analysis) must be completed first. Run /stackshift.analyze to begin."
exit 1
fi
DETECTION_TYPE=$(cat .stackshift-state.json | jq -r '.detection_type')
ROUTE=$(cat .stackshift-state.json | jq -r '.route')
if [ "$DETECTION_TYPE" = "null" ] || [ -z "$DETECTION_TYPE" ]; then
echo "ERROR: detection_type missing from state file. Re-run /stackshift.analyze."
exit 1
fi
if [ "$ROUTE" = "null" ] || [ -z "$ROUTE" ]; then
echo "ERROR: route missing from state file. Re-run /stackshift.analyze."
exit 1
fi
echo "Detection: $DETECTION_TYPE"
echo "Route: $ROUTE"
SPEC_OUTPUT=$(cat .stackshift-state.json | jq -r '.config.spec_output_location // "."')
echo "Writing specs to: $SPEC_OUTPUT"
if [ "$SPEC_OUTPUT" != "." ]; then
mkdir -p "$SPEC_OUTPUT/docs/reverse-engineering"
mkdir -p "$SPEC_OUTPUT/.specify/memory/specifications"
fi
State file structure:
{
"detection_type": "monorepo-service",
"route": "greenfield",
"implementation_framework": "speckit",
"config": {
"spec_output_location": "~/git/my-new-app",
"build_location": "~/git/my-new-app",
"target_stack": "Next.js 15..."
}
}
Capture commit hash for incremental updates:
COMMIT_HASH=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
COMMIT_DATE=$(git log -1 --format=%ci 2>/dev/null || date -u +"%Y-%m-%d %H:%M:%S")
echo "Pinning docs to commit: $COMMIT_HASH"
Extraction approach based on detection + route:
| Detection Type | + Greenfield | + Brownfield |
|---|---|---|
| Monorepo Service | Business logic only (tech-agnostic) | Full implementation + shared packages (tech-prescriptive) |
| Nx App | Business logic only (framework-agnostic) | Full Nx/Angular implementation details |
| Generic App | Business logic only | Full implementation |
detection_type determines WHAT patterns to look for (shared packages, Nx project config, monorepo structure, etc.)route determines HOW to document them (tech-agnostic vs tech-prescriptive)Use the Task tool with subagent_type=stackshift:stackshift-code-analyzer:AGENT to perform analysis. If the agent is unavailable, fall back to the Explore agent.
Error recovery: If a subagent fails or returns empty results for a sub-phase, retry once with the Explore agent. If the retry also fails, record the gap with an [ANALYSIS INCOMPLETE] marker and continue with remaining sub-phases.
Missing components: If a sub-phase finds no relevant code (e.g., no frontend in a backend-only service), document the absence in the corresponding output file rather than skipping the sub-phase.
Launch sub-phases 1.1 through 1.6 in parallel using separate subagent invocations. Collect all results before proceeding to Phase 2.
Progress signal: After all sub-phases complete, log: "Phase 1 complete: Analysis gathered for [list which sub-phases produced results]."
Create docs/reverse-engineering/ directory and generate all 11 documentation files. For each file, apply the greenfield or brownfield variant as described in operations/output-file-specs.md. Read that file now for the detailed per-file specifications.
If .stackshift-docs-meta.json already exists, overwrite it completely with fresh metadata.
COMMIT_HASH=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
COMMIT_DATE=$(git log -1 --format=%ci 2>/dev/null || date -u +"%Y-%m-%d %H:%M:%S")
GENERATED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
Write docs/reverse-engineering/.stackshift-docs-meta.json:
{
"commit_hash": "<COMMIT_HASH>",
"commit_date": "<COMMIT_DATE>",
"generated_at": "<GENERATED_AT>",
"doc_count": 11,
"route": "<greenfield|brownfield>",
"docs": {
"functional-specification.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"integration-points.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"configuration-reference.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"data-architecture.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"operations-guide.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"technical-debt-analysis.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"observability-requirements.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"visual-design-system.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"test-documentation.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"business-context.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" },
"decision-rationale.md": { "generated_at": "<GENERATED_AT>", "commit_hash": "<COMMIT_HASH>" }
}
}
Every generated doc starts with this header after the title:
# [Document Title]
> **Generated by StackShift** | Commit: `<short-hash>` | Date: `<GENERATED_AT>`
> Run `/stackshift.refresh-docs` to update with latest changes.
Generate files in this order, logging progress after each:
Batch 1 (core architecture):
After writing files 1-4, log: "Generated 4/11 files (core architecture complete)." Verify the output directory contains 4 files before continuing.
Batch 2 (operations and quality): 5. operations-guide.md 6. technical-debt-analysis.md 7. observability-requirements.md 8. visual-design-system.md 9. test-documentation.md
After writing files 5-9, log: "Generated 9/11 files (operations and quality complete)." Verify the output directory contains 9 files before continuing.
Batch 3 (context and decisions): 10. business-context.md 11. decision-rationale.md
After writing files 10-11, log: "Generated 11/11 files. Phase 2 complete."
Output structure:
docs/reverse-engineering/
├── .stackshift-docs-meta.json
├── functional-specification.md
├── integration-points.md
├── configuration-reference.md
├── data-architecture.md
├── operations-guide.md
├── technical-debt-analysis.md
├── observability-requirements.md
├── visual-design-system.md
├── test-documentation.md
├── business-context.md
└── decision-rationale.md
docs/reverse-engineering/[INFERRED] / [NEEDS USER INPUT] markers.stackshift-docs-meta.json created with commit hash for incremental updatesOnce all documentation is generated:
For GitHub Spec Kit (implementation_framework: speckit): Proceed to Step 3 -- use /stackshift.create-specs to transform docs into .specify/ specs.
For BMAD Method (implementation_framework: bmad): Proceed to Step 6 -- hand off to BMAD's *workflow-init. BMAD's PM and Architect agents use the reverse-engineering docs as context.
For BMAD Auto-Pilot (implementation_framework: bmad-autopilot): Proceed to /stackshift.bmad-synthesize to auto-generate BMAD artifacts. The 11 reverse-engineering docs provide ~90% of what BMAD needs.
DO:
[INFERRED] = reasonable inference, [NEEDS USER INPUT] = genuinely unknownDON'T:
Verify analysis captured:
Each document must be comprehensive, accurate, organized, actionable, and honest about inferred vs verified information.
Weekly Installs
91
Repository
GitHub Stars
1
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
github-copilot69
gemini-cli67
opencode67
codex57
claude-code54
cursor53
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
46,600 周安装