← 返回
数据分析 中文

Describe Design

Research a codebase and create architectural documentation describing how features or systems work. Use when the user asks to: (1) Document how a feature works, (2) Create an architecture overview, (3) Explain code structure for onboarding or knowledge transfer, (4) Research and describe a system's design. Produces markdown documents with Mermaid diagrams and stable code references suitable for humans and AI agents.
研究代码库并创建架构文档,说明功能或系统的运作方式。适用于用户要求:(1)记录功能运作方式,(2)创建架构概览,(3)解释代码结构以便入职或知识转移,(4)研究并描述系统设计。生成包含 Mermaid 图表和稳定代码引用的 Markdown 文档,适合人类和 AI 智能体阅读。
ziad-hsn
数据分析 clawhub v0.1.0 1 版本 99806.5 Key: 无需
★ 1
Stars
📥 2,043
下载
💾 45
安装
1
版本
#latest

概述

Describe Design

Research a codebase and produce an architectural document describing how features or

systems work. The output is a markdown file organized for both human readers and

future AI agents.

Workflow

Stage 1: Scope Definition

Understand what to document before exploring:

  1. Ask what feature, system, or component to document.
  2. Clarify the target audience (developers, AI agents, or both).
  3. Confirm the codebase location if not obvious from context.

Stage 2: Initial Exploration

Explore the codebase broadly to build a mental model. Use lightweight, fast exploration

methods when available (in Claude Code, for example, use a Haiku Explore subagent):

  1. Scan directory structure and identify key entry points.
  2. Read README, config files, and existing documentation.
  3. Identify the main files and modules related to the feature.
  4. Build a mental model of codebase organization.

Present a high-level outline to the user:

## Proposed Outline

1. [Component A] - Brief description
2. [Component B] - Brief description
3. [Component C] - Brief description

* Have I correctly captured the scope of the research? Reply "yes" to continue.
* Otherwise, please let me know what I've misunderstood.

When the user confirms the scope, move on to deep research.

Stage 3: Deep Research

For each component in the approved outline:

  1. Trace code paths from entry points.
  2. Identify dependencies and interactions between components.
  3. Note configuration options and where they're defined.
  4. Find where data is stored or persisted.
  5. Build a code reference index (file paths + key function/class names).

Try to rely on the initial code exploration for much of this information. Read

additional files as needed. If the scope changed considerably in Stage 2, you

can engage a second code exploration subagent.

When to Stop Exploring

You're ready to draft when you can:

  • Trace the happy path — Follow a typical request/action from entry point to

completion without gaps.

  • Name the boundaries — Clearly state what's in scope and what's external.
  • Draw the diagram — Sketch the architecture without placeholder boxes.
  • Answer "what talks to what?" — For each component, you know its inputs and outputs.

Signs you're not done:

  • Uncertainty: "I think this connects to..." or "probably calls..."
  • Unresolved references: Found imports/calls to modules you haven't examined.
  • Missing edges: Can't explain how data gets from component A to B.

Signs you've gone too far:

  • Reading every file in a directory instead of representative samples.
  • Tracing into external libraries or framework internals.
  • Exploring implementation details that don't affect architecture.

Stage 4: Document Draft

Generate the document following the template below. Present the draft to the user

for review and iterate based on feedback. If available, use the AskUserQuestion

tool to request user input on key decisions.

Stage 5: Finalize

  1. Confirm the file location before writing. You may propose a path based on repository

conventions (e.g., docs/architecture/, ARCHITECTURE.md), but NEVER write the file

without explicit user confirmation of the location. If the user provided a path upfront,

that counts as confirmation.

  1. Write the final document to the confirmed location.

Document Template

The following template provides a starting point. Adapt it to fit the feature being

documented — omit sections that don't apply, add sections for unique aspects, and

adjust the structure to best serve the target audience.

# [Feature/System Name] Architecture

## Overview

[1-2 paragraph summary of what this feature/system does and why it exists]

## Architecture Diagram

flowchart TD

A[Entry Point] --> B[Component]

B --> C[Data Store]


## Components

### [Component Name]

**Purpose**: [What it does]

**Location**: `path/to/file.ext`

**Key Functions**:
- `functionName()` - Brief description
- `anotherFunction()` - Brief description

**Interactions**:
- Receives input from: [Component]
- Sends output to: [Component]

## Data Flow

[Description of how data moves through the system, from input to output]

## Configuration

[How features are enabled, disabled, or configured. Include file paths and
environment variables.]

## Code References

| Component | File | Key Symbols |
|-----------|------|-------------|
| Auth | `src/auth/index.ts` | `authenticate()`, `AuthConfig` |
| Cache | `src/cache/redis.ts` | `CacheManager`, `invalidate()` |

## Glossary

| Term | Definition |
|------|------------|
| [Term] | [Project-specific definition] |

Code Reference Conventions

Use stable references that survive refactoring:

  • Paths: Use relative paths from repository root (src/auth/login.ts)
  • Symbols: Reference function and class names, not line numbers
  • Format: path/to/file.ext with key symbols listed separately
  • Anchors: Use search patterns when helpful (handleAuth function in auth/)

Avoid:

  • Copying code: Never paste code into the document. Code goes stale immediately;

the document should be a guide that points readers to the source. Describe what

code does, then reference where to find it.

  • Line numbers: They change with every edit.
  • Absolute paths: Use repository-relative paths only.

Mermaid Diagrams

Use Mermaid for architecture visualizations:

Flowcharts for component relationships:

flowchart TD
    A[Client] --> B[API Gateway]
    B --> C[Service]
    C --> D[(Database)]

Sequence diagrams for request flows:

sequenceDiagram
    Client->>API: Request
    API->>Service: Process
    Service-->>API: Response
    API-->>Client: Result

Keep diagrams focused on the specific feature being documented. Avoid overcrowding

with unrelated components.

Writing Guidelines

  • Describe, never copy: Explain what code does and where to find it. Readers who

need implementation details will read the actual source — which is always current.

  • Structure for scanning: Use headers, tables, and lists for quick navigation.
  • Be specific: Include actual file paths, function names, and config keys.
  • Serve two audiences: Write clearly for humans; use consistent structure for AI.
  • Stay current: Note any assumptions about code state or version.

版本历史

共 1 个版本

  • v0.1.0 当前
    2026-03-28 21:16 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

Critical Code Reviewer

ziad-hsn
进行严格对抗性的代码审查,绝不容忍平庸。用于用户要求严格审查代码或PR、批评代码、找出代码问题或代码有何不足时。识别Python、R、JavaScript/TypeScript、SQL及前端代码中的安全漏洞、懒散模式、边界情况失败和不良实践
★ 5 📥 6,115
data-analysis

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 162 📥 59,674
data-analysis

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 366 📥 139,963