AgentSkillsCN

reverse-spec-batch

当用户提出以下需求时使用此技能: - 为整个项目或代码库生成规格说明书 - 系统性地记录所有模块 - 为项目创建完整的规格索引 - 批量处理多个模块以生成规格说明 此技能先生成架构概览索引,随后逐个模块迭代,产出单独的.spec.md文件。

SKILL.md
--- frontmatter
name: reverse-spec-batch
description: |
  Use this skill when the user asks to:
  - Generate specs for an entire project or codebase
  - Document all modules systematically
  - Create a complete specification index for the project
  - Batch process multiple modules for spec generation
  This skill generates an architecture overview index, then iterates through modules producing individual .spec.md files.

User Input

text
$ARGUMENTS

You MUST consider the user input before proceeding (if not empty).

Purpose

Systematically reverse-engineer specs for an entire codebase. Generates an index spec with architecture overview, then iterates through modules producing individual .spec.md files.

Execution Flow

1. Project Survey

Scan the project root to understand structure:

  1. Detect project type: monorepo, single app, library, CLI, etc.
  2. Identify top-level modules: src/ subdirectories, packages in monorepo, major feature folders
  3. Estimate total scope: file count, LOC per module
  4. Detect existing specs: Check specs/ directory for already-generated specs

2. Generate Batch Plan

Present the analysis plan to the user:

markdown
## Reverse-Spec Batch Plan

**Project**: <name>
**Type**: <project type>
**Total scope**: N files, ~N LOC

### Modules to analyze (in dependency order):

| # | Module | Files | LOC | Existing Spec? | Priority |
|---|--------|-------|-----|----------------|----------|
| 1 | core/utils | 5 | 320 | No | Foundation |
| 2 | models/ | 8 | 890 | No | Data layer |
| 3 | auth/ | 12 | 1450 | Yes (outdated) | Critical |
| ... | | | | | |

**Estimated effort**: ~N minutes with AI analysis

Proceed with all? Or select specific modules (e.g., "1,3,5" or "auth/ models/")

Wait for user confirmation before proceeding.

3. Run Batch Pipeline

Execute the batch pipeline using the globally installed reverse-spec CLI:

bash
reverse-spec batch

如果需要强制重新生成所有 spec:

bash
reverse-spec batch --force

如果需要自定义输出目录:

bash
reverse-spec batch --output-dir specs

4. Final Summary

After batch completes:

markdown
## Batch Reverse-Spec Complete

**Generated**: N/M specs
**Index**: specs/_index.spec.md
**Total time**: ~N minutes

### Generated Specs:
- specs/auth.spec.md (high confidence)
- specs/models.spec.md (medium confidence)
- specs/api.spec.md (skipped by user)

### Project-Wide Observations:
- <Cross-module patterns noticed>
- <Shared technical debt themes>
- <Architecture recommendations>

语言规范

所有 spec 文档的正文内容必须使用中文撰写。 具体规则:

  • 用中文:所有描述、说明、分析、总结、表格内容、注释
  • 保留英文:代码标识符(函数名、类名、变量名)、文件路径、类型签名、代码块内容
  • 章节标题:使用中文,例如 ## 1. 意图## 2. 接口定义
  • 表格表头:使用中文,例如 | 模块 | 规格 | 用途 | 依赖 |
  • Frontmatter:保留英文(YAML 键名)

Guidelines

  • 依赖顺序处理模块(基础模块优先)
  • 可恢复:如果中断,检查已有 specs 并跳过已完成的模块
  • 不重复生成已存在的 spec,除非用户指定 --force
  • 每个模块的 spec 保持自包含,但通过索引交叉引用