一键导入
draft-design
Draft structured design documents with numbered sections from requirements
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Draft structured design documents with numbered sections from requirements
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | draft-design |
| description | Draft structured design documents with numbered sections from requirements |
| version | 2.0.0 |
| author | potato |
| triggers | {"patterns":["write design","写设计","design doc","设计文档","DESIGN.md"],"regex":["(?i)design\\.md"]} |
| tags | ["development","planning"] |
| priority | 60 |
| always_load | false |
| max_body_size | 4096 |
| subagent_preamble | You are a sub-agent writing a design document. Key rules: - All input files (requirements, existing designs) are ALREADY pre-loaded in your context. Do NOT call read_file for them. - START WRITING the output file within your first 3 tool calls. - Write incrementally: skeleton first (all headings + structure), then fill each section with edit_file. - Each edit_file call should add 50-150 lines. Never try to write the entire document in one call. - Budget: spend at most 20% of your iterations reading anything. 80% must be writing. - If the skill instructions say "Read ALL requirements first" — they are already in your context. Skip that step. |
Transform requirements into technical design documents with numbered sections for deterministic GID extraction.
This is Phase 3 of the GID pipeline: Idea → Requirements → Design → Graph → Execute.
Design documents define HOW the system is built. Every section is numbered so GID task nodes can reference specific sections via design_ref: "3.2" for precise context assembly.
gid_design to generate the graph (Phase 4).gid/docs/requirements.md (GUARDs + feature index).gid/features/{feature}/requirements.md (per-feature GOALs).gid/features/{feature}/requirements.md only.gid/docs/) and feature-level docs (.gid/features/) if they existA single design document MUST NOT exceed ~8 components (sections 3.1-3.N). If it does, split into feature-level documents.
Why: Design docs with 10+ components exceed context limits during implementation. Sub-agents implementing a task need to read the relevant design section — a 15-component monolith forces them to read everything. Smaller, focused docs = better implementation quality.
Structure for large projects:
.gid/
├── docs/
│ └── architecture.md ← Master: architecture overview, cross-cutting concerns, component index
└── features/
├── auth/design.md ← 4-6 components for auth
├── pipeline/design.md ← 4-6 components for pipeline
└── cli/design.md ← 4-6 components for CLI
Master architecture.md (in .gid/docs/) contains:
Each feature design.md contains:
When to split:
Depends on project structure:
.gid/features/{feature-name}/design.md.gid/docs/architecture.md + features at .gid/features/{feature-name}/design.md.gid/issues/{ISS-NNN}/design.mdThe .gid/features/ location is canonical — assemble_task_context() resolves design docs from there via the feature node's design_doc metadata.
Requirements define WHAT. Design defines HOW. This skill produces HOW.
"Uses Kahn's algorithm with visited set for cycle detection"
"Stores state in SQLite with WAL mode for concurrent reads"
"Merges via git rebase then --no-ff merge to preserve history"
"Context assembled by traversing depends_on edges and extracting heading-matched sections"
"System detects cycles and rejects cyclic graphs" → requirement (WHAT)
"CLI responds within 500ms" → requirement (WHAT)
"Auth tokens never appear in logs" → guard (WHAT)
"We should build a CLI tool for auth management" → idea/overview (WHY)
Rule of thumb: If it describes observable behavior without specifying mechanism, it's a requirement. If it specifies the mechanism, it's design.
# Design: {Project Name}
## 1. Overview
{High-level architecture summary. What approach and why.
Key trade-offs made. 2-3 paragraphs max.
Reference GOAL numbers when a design choice directly addresses one.}
## 2. Architecture
{System-level component diagram.}
```mermaid
graph TD
A[Component A] --> B[Component B]
A --> C[Component C]
B --> D[Shared Module]
C --> D
{Brief explanation. Why this structure.}
{One subsection per component. This is the core of the design.
Section numbers here (3.1, 3.2, ...) become design_ref values in GID tasks.}
Responsibility: {One sentence}
Interface:
pub struct ComponentName { ... }
impl ComponentName {
pub fn method_a(&self, param: Type) -> Result<Output> { ... }
pub fn method_b(&mut self, param: Type) -> Result<()> { ... }
}
Key Details:
Satisfies: GOAL-1.1, GOAL-1.2
...
{Core data structures with all fields, types, and validation rules.}
pub struct ModelName {
pub field_a: String,
pub field_b: Option<DateTime>,
pub field_c: Vec<SubModel>,
}
{How data moves through the system. Sequence diagrams for key operations.}
sequenceDiagram
participant User
participant CLI
participant Core
User->>CLI: command
CLI->>Core: parsed args
Core-->>CLI: result
CLI-->>User: display
{Error types, propagation strategy, user-facing messages, recovery.}
{How to verify the implementation. These verify commands become task metadata.verify in GID.}
Per-component verification:
| Component | Verify Command | What It Checks |
|---|---|---|
| 3.1 Config | cargo test --test config_test | Config load/save, defaults, validation |
| 3.2 Auth | cargo test --test auth_test | Profile CRUD, token masking |
Layer checkpoint: cargo check && cargo test
Guard checks:
| Guard | Check Command |
|---|---|
| GUARD-1: Atomic writes | grep -rn 'fs::write' src/ | grep -v atomic | wc -l → expect 0 |
{Expected file layout after implementation.}
src/
├── main.rs # Entry point (3.1)
├── config.rs # Configuration (3.2)
├── auth.rs # Auth management (3.3)
└── error.rs # Error types (6)
tests/
├── config_test.rs
└── auth_test.rs
## Section Numbering Rules
**Every section and subsection must have a number.** GID tasks reference sections by number:
```yaml
- id: auth-read-profiles
metadata:
design_ref: "3.2" # → extracts section 3.2 from DESIGN.md
Rules:
## 1., ## 2., ... ## 8. (always these 8)### 3.1, ### 3.2, ... (match component count)#### 3.2.1, #### 3.2.2 (when needed)Sub-agents implement from these signatures. They must be complete and real — not pseudocode.
pub fn read_profiles(path: &Path) -> Result<Vec<AuthProfile>>
pub struct AuthProfile { pub name: String, pub token_prefix: String, pub status: ProfileStatus }
pub enum ProfileStatus { Active, Cooldown { expires_at: DateTime<Utc> } }
def read_profiles(path: Path) -> list[AuthProfile]:
@dataclass
class AuthProfile:
name: str
token_prefix: str
status: ProfileStatus
function readProfiles(path: string): Promise<AuthProfile[]>
interface AuthProfile { name: string; tokenPrefix: string; status: ProfileStatus }
type ProfileStatus = { kind: 'active' } | { kind: 'cooldown'; expiresAt: Date }
Rules:
..., TODO, // fill in later### 3.x section should map to 1-3 GID tasks laterThings like logging, config loading, and error types appear everywhere. Handle them:
ProjectError from §6"Each ### 3.x section must be understandable in isolation — a sub-agent reading only section 3.2 (via design_ref) should be able to implement it.
### 3.2 Auth Module
**Responsibility:** Manage auth profiles (CRUD, validation, switching).
**Interface:**
pub fn list_profiles(config: &Config) -> Vec<ProfileSummary>
pub fn switch_profile(config: &mut Config, name: &str) -> Result<()>
Config is defined in §3.1: { profiles: Vec<AuthProfile>, active: String }
AuthProfile: { name: String, token: String, provider: String }
**Key Details:**
- Reads from ~/.agentctl/config.toml (see §3.1 for format)
- Token prefix = first 8 chars of token field
- switch_profile writes config back via Config::save()
### 3.2 Auth Module
Handles the auth stuff. Uses the config from above.
See 3.1 for the struct definitions.
Rules:
| Mistake | Why it's bad | Fix |
|---|---|---|
| Unnumbered subsections | GID can't reference them via design_ref | Number everything |
| Pseudocode signatures | Sub-agents implement wrong types | Write real language syntax |
| "See section X" without summary | Sub-agent only gets one section | Inline key info + reference |
| Missing edge cases | Sub-agent doesn't handle them | List edge cases in Key Details |
No Satisfies: line | Traceability breaks | Every component traces to GOALs |
| Business requirements in design | Mixing WHAT and HOW | Move to requirements.md |
| Diagram without explanation | Ambiguous relationships | Always explain diagrams in text |
| Component too large | Maps to 5+ tasks, too complex | Split into 3.x.1, 3.x.2 subsections |
| Diagram | Use for | Example |
|---|---|---|
graph TD | Architecture, component relationships, data dependencies | §2 Architecture |
sequenceDiagram | Request flows, multi-step operations, async interactions | §5 Data Flow |
classDiagram | Data model relationships (rarely needed if structs are clear) | §4 Data Models |
stateDiagram-v2 | State machines, lifecycle transitions | Task states, connection states |
ls .gid/features/ — if feature dirs exist, read ALL feature requirements.gid/requirements.md or REQUIREMENTS.md.gid/requirements.md (GUARDs + feature index) + each .gid/features/{feature}/requirements.md (GOALs)engram recall "{project} architecture decisions" for past contextThis step prevents the #1 source of multi-round review cycles: unverified assumptions about existing code.
Before finalizing, for EVERY reference to existing code in the design:
For every function, struct, trait, or method the design references from the existing codebase:
search_files or read_file to find it(verified: src/foo.rs:123) after the reference in the design doc### ❌ BAD — unverified assumption
"calls `merge_project_layer()` which handles deduplication"
### ✅ GOOD — verified against source
"calls `merge_project_layer(graph: &mut Graph, incoming: Vec<Node>, edges: Vec<Edge>)`
which replaces all project-layer nodes and edges (verified: src/unified.rs:89).
Note: does NOT deduplicate edges — caller must handle dedup."
If the design says "function X does Y" or "feature X supports Y":
For every external crate, library, or tool the design assumes:
Cargo.toml / package.json — is it already a dependency?notify crate to Cargo.toml"If the design says "~20 lines" or "small change":
Every verified claim gets a citation:
(verified: src/graph.rs:245) — line number(verified: Cargo.toml, notify not present) — absence(verified: search for "merge_feature" returned 0 results) — function doesn't exist yetIf you cannot verify a claim (no access to source, function doesn't exist yet, etc.), explicitly mark it as unverified:
⚠️ UNVERIFIED: Assumes `extract_incremental()` preserves the code layer.
Need to verify: does it merge or overwrite?
Before presenting, verify:
Satisfies: line)..., no TODO, no pseudocodemetadata.verify)DESIGN.md (or docs/DESIGN.md for internal)engram add --type factual --importance 0.7 "Design written for {project}: {N} components, sections 3.1-3.{N}"The chain flows through this document:
requirements.md → GOAL-1.1, GOAL-1.2
↓
DESIGN.md §3.2 → "Auth Module" satisfies GOAL-1.1, GOAL-1.2
↓
.gid/graph.yml task → design_ref: "3.2", satisfies: ["GOAL-1.1"]
↓
Sub-agent implementation → reads §3.2 content, implements interface
↓
Verification → runs verify command from §7 table
Every GOAL must be traceable through this chain. If a GOAL has no corresponding design section, either the design is incomplete or the GOAL is out of scope.
Apply approved review findings to a document — reads the review file and makes targeted edits
Systematically review design documents for bugs, inconsistencies, and missing cases
Systematically review requirements documents for completeness, testability, and consistency
Systematically review task breakdowns for completeness, dependency correctness, and implementability
Incremental write pattern for long documents (design, requirements, specs, postmortems, RFCs, ADRs, any structured markdown)
Track, manage, and fix issues across all projects (full lifecycle, strict format)