Reverse Engineering Assistant | 反向工程助手
System archeology framework: reverse engineer existing systems across three dimensions — Logic, Data, and Runtime.
系統考古框架:從三個維度反向工程既有系統——邏輯、資料、執行環境。
Three Dimensions | 三大維度
┌─────────────────────────────────────────────────────────┐
│ System Archeology Framework │
├──────────┬──────────────┬────────────────────────────────┤
│ Logic │ Data │ Runtime │
│ (spec) │ (data) │ (runtime) │
├──────────┼──────────────┼────────────────────────────────┤
│ APIs │ DB Schemas │ Logs & Error Patterns │
│ Modules │ ORMs/Models │ Config & Environment │
│ Flows │ Migrations │ Metrics & Performance │
│ Tests │ Seed Data │ Infra & Deployment │
└──────────┴──────────────┴────────────────────────────────┘
Subcommands | 子命令
| Subcommand |
Dimension |
Input |
Output |
說明 |
| (none) |
All |
Project root |
Full Archeology Report |
三維度全面分析 |
spec |
Logic |
Code files/dirs |
SPEC-XXX.md |
從程式碼提取規格 |
data |
Data |
DB schemas, ORMs, migrations |
Data Model Spec |
分析資料模型與結構 |
runtime |
Runtime |
Logs, configs, metrics |
Runtime Baseline |
分析執行環境基準 |
bdd |
— |
SPEC-XXX.md |
.feature |
將 AC 轉為 Gherkin |
tdd |
— |
.feature |
Coverage Report |
分析測試覆蓋率 |
Full Analysis Mode | 全面分析模式
When /reverse is invoked without a subcommand, execute all three dimensions sequentially:
- Data → Scan schemas, ORMs, migrations
- Runtime → Analyze logs, configs, deployment
- Logic (spec) → Extract APIs, flows, tests → Generate SPEC
Output: Integrated System Archeology Report combining all three dimensions.
Dimension Details | 維度詳情
spec: Logic Dimension (既有)
- Scan - Read source files and identify public APIs, data flows, and business logic
- Classify - Tag each finding as
[Confirmed], [Inferred], or [Unknown]
- Structure - Organize into SDD spec format with Acceptance Criteria
- Attribute - Cite every reversed item with
file:line source reference
data: Data Dimension (新增)
- Discover - Find database schemas, ORM models, migration files, seed data
- Map - Build entity-relationship model from code evidence
- Classify - Tag relationships as
[Confirmed] (FK constraints) or [Inferred] (code patterns)
- Report - Output data model spec with:
- Entity list with fields and types
- Relationship map (1:1, 1:N, M:N)
- Index and constraint inventory
- Migration history summary
- Data flow paths (write → read)
Evidence sources: schema.prisma, *.migration.*, models/, entities/, knexfile.*, sequelize, typeorm, SQL files, docker-compose.yml (DB services)
runtime: Runtime Dimension (新增)
- Scan configs - Environment variables, config files, feature flags
- Analyze logs - Log patterns, error frequency, log levels
- Check infra - Docker configs, CI/CD pipelines, deployment manifests
- Baseline - Output runtime baseline with:
- Environment variable inventory (names only, never values/secrets)
- Config file map and hierarchy
- External service dependencies (APIs, queues, caches)
- Deployment topology (containers, services)
- Health check and monitoring endpoints
Evidence sources: .env.example, docker-compose.yml, Dockerfile, *.config.*, CI/CD files, k8s/, log files (patterns only)
Security: NEVER output actual secret values. Only list variable names and describe their purpose.
Anti-Hallucination Rules | 防幻覺規則
| Rule |
Requirement |
要求 |
| Certainty Tags |
Use [Confirmed], [Inferred], [Unknown] for all findings |
所有發現須標注確定性 |
| Source Attribution |
Cite file:line for every reversed item |
每項反向結果須引用來源 |
| No Fabrication |
Never invent APIs or behaviors not found in code |
不得捏造程式碼中不存在的 API 或行為 |
| No Secrets |
Never output secret values from configs or env files |
不得輸出設定檔或環境變數的密鑰值 |
Usage | 使用方式
/reverse - Full 3-dimension analysis | 三維度全面分析
/reverse spec src/auth/ - Logic: extract spec | 邏輯:提取規格
/reverse data - Data: analyze schemas & models | 資料:分析結構
/reverse runtime - Runtime: analyze configs & infra | 執行環境:分析配置
/reverse bdd specs/SPEC-AUTH.md - Convert spec ACs to Gherkin
/reverse tdd features/auth.feature - Analyze test coverage
Next Steps Guidance | 下一步引導
After /reverse (full or spec) completes, the AI assistant should suggest:
系統考古完成。建議下一步 / System archeology complete. Suggested next steps:
- 執行
/sdd 審查並核准此規格 ⭐ Recommended / 推薦 — Review and approve the generated spec
- 執行
/derive 從規格推導測試 — Derive tests from spec (requires approval first)
- 審查規格中的
[Inferred] 和 [Unknown] 標記 — Review uncertainty tags manually
Reference | 參考
AI Agent Behavior | AI 代理行為
完整的 AI 行為定義請參閱對應的命令文件:/reverse
For complete AI agent behavior definition, see the corresponding command file: /reverse
1---2name: reverse3scope: partial4description: |5 [UDS] System archeology — reverse engineer an existing system across the Logic, Data, and Runtime dimensions.6 Use when: documenting an undocumented system, recovering specifications from existing code, mapping an unknown data model or runtime topology.7 Not for: assessing health and risk before a feature — use /discover; deriving tests forward from an approved spec — use /spec-derive.8 Keywords: reverse engineering, system archeology, legacy code, spec extraction, data model, runtime, 反向工程, 系統考古, 規格提取.9allowed-tools: Read, Grep, Glob, Bash(pg_dump:*), Bash(mysql:*), Bash(sqlite3:*), Bash(npm run:*), Bash(cat:*), Bash(docker:*)10argument-hint: "[spec|data|runtime|bdd|tdd] <input>"11status: stable12# 2026-08-18: `disable-model-invocation: true` removed, and a status recorded.13#14# The flag was applied by d415937e alongside the description rewrite and, like15# the two lifted on 2026-08-17, followed no stateable rule. These eight were16# left alone that day for a reason that was correct at the time: the rule17# settled on was "a reference is model-invocable", and none of them carried a18# `status` at all, so lifting them would have replaced one unruled state with19# one unruled action.20#21# Measured 2026-08-18, which is what closed it: all eight carry a full22# `Use when:` trigger and a `Not for:` exclusion, all eight describe an action23# rather than reference material, and all eight already have a slash command —24# which is exactly the shape of `code-review-assistant`, whose paired `/code-review`25# was ruled not to justify the flag. `journey-test-assistant` is the standing26# precedent: same "Generate X" shape, `status: stable`, never disabled.27#28# `stable` rather than a new value: `skills/` uses reference, stable and29# experimental, and inventing a fourth would be the same unruled-action mistake30# in different clothing.31#32# The cost of being wrong is asymmetric and observable in only one direction.33# Over-triggering shows up and is undone by deleting a line; a skill that is34# structurally unable to fire produces no signal at all. (XSPEC-378 R5)35---3637# Reverse Engineering Assistant | 反向工程助手3839System archeology framework: reverse engineer existing systems across three dimensions — **Logic**, **Data**, and **Runtime**.4041系統考古框架:從三個維度反向工程既有系統——**邏輯**、**資料**、**執行環境**。4243## Three Dimensions | 三大維度4445```46┌─────────────────────────────────────────────────────────┐47│ System Archeology Framework │48├──────────┬──────────────┬────────────────────────────────┤49│ Logic │ Data │ Runtime │50│ (spec) │ (data) │ (runtime) │51├──────────┼──────────────┼────────────────────────────────┤52│ APIs │ DB Schemas │ Logs & Error Patterns │53│ Modules │ ORMs/Models │ Config & Environment │54│ Flows │ Migrations │ Metrics & Performance │55│ Tests │ Seed Data │ Infra & Deployment │56└──────────┴──────────────┴────────────────────────────────┘57```5859## Subcommands | 子命令6061| Subcommand | Dimension | Input | Output | 說明 |62|------------|-----------|-------|--------|------|63| *(none)* | All | Project root | Full Archeology Report | 三維度全面分析 |64| `spec` | Logic | Code files/dirs | `SPEC-XXX.md` | 從程式碼提取規格 |65| `data` | Data | DB schemas, ORMs, migrations | Data Model Spec | 分析資料模型與結構 |66| `runtime` | Runtime | Logs, configs, metrics | Runtime Baseline | 分析執行環境基準 |67| `bdd` | — | `SPEC-XXX.md` | `.feature` | 將 AC 轉為 Gherkin |68| `tdd` | — | `.feature` | Coverage Report | 分析測試覆蓋率 |6970## Full Analysis Mode | 全面分析模式7172When `/reverse` is invoked without a subcommand, execute all three dimensions sequentially:73741. **Data** → Scan schemas, ORMs, migrations752. **Runtime** → Analyze logs, configs, deployment763. **Logic (spec)** → Extract APIs, flows, tests → Generate SPEC7778Output: Integrated **System Archeology Report** combining all three dimensions.7980## Dimension Details | 維度詳情8182### spec: Logic Dimension (既有)83841. **Scan** - Read source files and identify public APIs, data flows, and business logic852. **Classify** - Tag each finding as `[Confirmed]`, `[Inferred]`, or `[Unknown]`863. **Structure** - Organize into SDD spec format with Acceptance Criteria874. **Attribute** - Cite every reversed item with `file:line` source reference8889### data: Data Dimension (新增)90911. **Discover** - Find database schemas, ORM models, migration files, seed data922. **Map** - Build entity-relationship model from code evidence933. **Classify** - Tag relationships as `[Confirmed]` (FK constraints) or `[Inferred]` (code patterns)944. **Report** - Output data model spec with:95 - Entity list with fields and types96 - Relationship map (1:1, 1:N, M:N)97 - Index and constraint inventory98 - Migration history summary99 - Data flow paths (write → read)100101**Evidence sources**: `schema.prisma`, `*.migration.*`, `models/`, `entities/`, `knexfile.*`, `sequelize`, `typeorm`, SQL files, `docker-compose.yml` (DB services)102103### runtime: Runtime Dimension (新增)1041051. **Scan configs** - Environment variables, config files, feature flags1062. **Analyze logs** - Log patterns, error frequency, log levels1073. **Check infra** - Docker configs, CI/CD pipelines, deployment manifests1084. **Baseline** - Output runtime baseline with:109 - Environment variable inventory (names only, **never values/secrets**)110 - Config file map and hierarchy111 - External service dependencies (APIs, queues, caches)112 - Deployment topology (containers, services)113 - Health check and monitoring endpoints114115**Evidence sources**: `.env.example`, `docker-compose.yml`, `Dockerfile`, `*.config.*`, CI/CD files, `k8s/`, log files (patterns only)116117**Security**: NEVER output actual secret values. Only list variable names and describe their purpose.118119## Anti-Hallucination Rules | 防幻覺規則120121| Rule | Requirement | 要求 |122|------|-------------|------|123| **Certainty Tags** | Use `[Confirmed]`, `[Inferred]`, `[Unknown]` for all findings | 所有發現須標注確定性 |124| **Source Attribution** | Cite `file:line` for every reversed item | 每項反向結果須引用來源 |125| **No Fabrication** | Never invent APIs or behaviors not found in code | 不得捏造程式碼中不存在的 API 或行為 |126| **No Secrets** | Never output secret values from configs or env files | 不得輸出設定檔或環境變數的密鑰值 |127128## Usage | 使用方式129130```131/reverse - Full 3-dimension analysis | 三維度全面分析132/reverse spec src/auth/ - Logic: extract spec | 邏輯:提取規格133/reverse data - Data: analyze schemas & models | 資料:分析結構134/reverse runtime - Runtime: analyze configs & infra | 執行環境:分析配置135/reverse bdd specs/SPEC-AUTH.md - Convert spec ACs to Gherkin136/reverse tdd features/auth.feature - Analyze test coverage137```138139## Next Steps Guidance | 下一步引導140141After `/reverse` (full or `spec`) completes, the AI assistant should suggest:142143> **系統考古完成。建議下一步 / System archeology complete. Suggested next steps:**144> - 執行 `/sdd` 審查並核准此規格 ⭐ **Recommended / 推薦** — Review and approve the generated spec145> - 執行 `/derive` 從規格推導測試 — Derive tests from spec (requires approval first)146> - 審查規格中的 `[Inferred]` 和 `[Unknown]` 標記 — Review uncertainty tags manually147148## Reference | 參考149150- [BDD Extraction Workflow Guide](./bdd-extraction.md) — Read it when extracting BDD scenarios out of an existing spec.151- [TDD Analysis Workflow Guide](./tdd-analysis.md) — Read it when analysing test coverage against scenarios and finding the gaps.152- Step-by-step workflow: [workflow.md](./workflow.md) — the reverse-engineering phases in order (code scanning, data models, configuration, test analysis, coverage). Read it when actually running the process rather than deciding whether to.153- Detailed guide: [guide.md](./guide.md)154- Core standard: [reverse-engineering-standards.md](../../core/reverse-engineering-standards.md)155156157## AI Agent Behavior | AI 代理行為158159> 完整的 AI 行為定義請參閱對應的命令文件:[`/reverse`](../commands/reverse.md#ai-agent-behavior--ai-代理行為)160>161> For complete AI agent behavior definition, see the corresponding command file: [`/reverse`](../commands/reverse.md#ai-agent-behavior--ai-代理行為)