sdd-design-engine
npx machina-cli add skill leoheart0125/sdd-skills/sdd-design-engine --openclawSDD Design Engine
This skill consolidates the entire design phase into a unified, friction-free flow. It transforms a structured request.md (produced by sdd-request-engine) into precise technical specifications through an automated pipeline with built-in Ambiguity Resolution.
Core Responsibilities
- Unified Design Flow: Seamlessly transitions from Requirements Analysis → System Architecture → Object Design → Interface & Contract Design.
- Ambiguity Resolution: Surface concerns, ask clarifying questions, and converge on precise specs before proceeding.
- Continuous Guardrails: Automatically invokes
sdd-guardrailsat every sub-stage to ensure consistency. - Auto-Persistence: Automatically saves state to
sdd-knowledge-base—no manual commit steps required. - Drift Management: Handles feedback from implementation via
/sdd-spec-update.
Commands
/sdd-design: Main entry point. Intelligently determines the next design step based oncontext.json.current_stage.- If no active feature: Suggest running
/sdd-requestfirst to create a feature and producerequest.md. - If stage is
designandrequest.mdexists: Starts Requirements Analysis. - If requirements exist: Proceed to Architecture.
- If architecture exists: Proceed to Object Design.
- If object design exists: Proceed to Interface & Contract Design.
- If no active feature: Suggest running
/sdd-design-requirements: Force entry into Requirements Analysis./sdd-design-architecture: Force entry into Architecture Design./sdd-design-objects: Force entry into Object Design./sdd-design-interfaces: Force entry into Interface & Contract Design./sdd-spec-update: Adjust spec based on "drift" detected during implementation.
JSON Writing Rule
When generating any JSON artifact (requirements.json, architecture.json, data_api.json, concerns.json), all string values MUST have special characters properly escaped (\", \\, \n, \t, control chars). Validate JSON is well-formed before writing to disk. If validation fails, fix escaping issues before saving.
Feature-Scoped Output
All spec artifacts are written to .sdd/spec/<feature-id>/:
requirements.jsonarchitecture.jsonobject_design.jsonopenapi.yaml— if feature involves HTTP APIsdata_api.json— if feature involves persistent datainterface_contract.json— if feature has other interface boundaries (CLI, SDK, events, IPC, etc.)diagrams/*.mmd(component, sequence, class diagrams)concerns.json(clarification history)
The <feature-id> is read from context.json.current_feature. If null, prompt the user for a feature name before proceeding.
Ambiguity Resolution Protocol
Between every sub-stage, the agent runs a clarification loop before writing final output:
Step 1: Analyze and Score
After analyzing user intent or input artifacts, the agent assigns a confidence assessment to each generated item and produces a concerns.json:
{
"feature": "user-auth",
"stage": "requirements",
"concerns": [
{
"id": "C-001",
"category": "BLOCKING",
"question": "Authentication via JWT or Session-based?",
"context": "Both are viable but affect architecture significantly.",
"answer": null,
"resolved": false
},
{
"id": "C-002",
"category": "WARNING",
"question": "Assuming minimum password length is 8 characters. OK?",
"context": "No explicit requirement stated.",
"answer": null,
"resolved": false
},
{
"id": "C-003",
"category": "INFO",
"question": "Per project_rules.md, using Clean Architecture.",
"context": "Matches architecture_style in context.json.",
"answer": null,
"resolved": false
}
]
}
Step 2: Categorize Concerns
| Category | Meaning | Behavior |
|---|---|---|
| BLOCKING | Must clarify before proceeding | Agent stops and asks the user |
| WARNING | Can assume but needs user confirmation | Agent states assumption and asks for confirmation |
| INFO | Informational, no action needed | Agent informs and proceeds |
Step 3: Resolve and Iterate
- STOP and Ask User: If ANY BLOCKING concerns exist, you MUST present them to the user and WAIT for their response. DO NOT proceed. DO NOT makeup answers.
- Collect Answers: Record user answers in
concerns.json. - Re-incorporate: Re-incorporate answers into the spec.
- Re-run Analysis: If new concerns arise, repeat.
- Proceed: Only proceed to the next sub-stage when ALL BLOCKING items are resolved.
Post-step: Feedback Capture (MANDATORY)
After presenting any design artifact to the user, if the user requests changes or corrections:
- Apply the requested changes to the design artifact.
- Immediately write a lesson to
.sdd/knowledge/lessons/capturing:- What was originally generated vs what the user corrected.
- Why the correction was needed (infer from context or ask the user).
- Tags for future retrieval (feature name, design stage, domain keywords).
- If the correction reveals a reusable pattern (e.g., a preferred architectural style, a standard API convention), also save to
.sdd/knowledge/patterns/.
This is NOT optional. Every user correction during design is a gap between expectation and reality — it MUST be recorded as a lesson.
Design Pipeline
Pre-step: Knowledge Lookup (MANDATORY — Index-Based)
Before generating any design artifact (requirements, architecture, or API), the engine MUST:
- Read
.sdd/knowledge/index.json(the lightweight index). - Filter
patternsentries whosetagsoverlap with the current feature's domain keywords. - Filter
lessonsentries whosetagsoverlap OR whosetriggermatches"designing-*". - Load ONLY the matched files (via the
filepath in each index entry). Do NOT scan the fullpatterns/orlessons/directories. - Summarize relevant findings and incorporate them into the design output.
- If no matches found in the index, proceed normally without loading any knowledge files.
- Output the knowledge match results before proceeding to the design pipeline:
📚 **Knowledge Loaded** (stage: design)
| Type | ID | Matched Tags | Summary |
|------|----|-------------|---------|
| <type> | <id> | `<tag1>`, `<tag2>` | <summary> |
> No knowledge matched. (if empty)
1. Requirements (formerly sdd-requirements-engine)
- Input:
.sdd/spec/<feature-id>/request.md(produced bysdd-request-engine). - Action: Transform structured user stories and acceptance criteria into technical requirements. Assign
confidence_scoreto each requirement. - Clarify: Run Ambiguity Resolution Protocol. Resolve all BLOCKING concerns.
- Output:
.sdd/spec/<feature-id>/requirements.json. - Guardrail: Check for ambiguity and potential conflicts with
project_rules.md.
2. Architecture (formerly sdd-architecture-system)
- Input:
requirements.json. - Action: Generate Mermaid diagrams (Component, Sequence) and architectural decisions.
- Clarify: Run Ambiguity Resolution Protocol (e.g., "Should User and Session be separate bounded contexts?").
- Output:
.sdd/spec/<feature-id>/architecture.json+.sdd/spec/<feature-id>/diagrams/*.mmd. - Guardrail: Ensure all user stories are covered by components. Validate architecture style compliance (see
sdd-guardrails).
3. Object Design
- Input:
architecture.json. - Action:
- Define core design units appropriate to the project — classes/interfaces (OOP), modules/functions (FP), components/hooks (UI), commands/handlers (CLI), resources/modules (IaC), etc.
- Define abstractions — dependency inversion boundaries between layers.
- Define relationships — inheritance, composition, dependency, association.
- Generate Class / Module Diagram (Mermaid).
- Clarify: Run Ambiguity Resolution Protocol on structural decisions.
- Output:
.sdd/spec/<feature-id>/object_design.json(seetemplates/object_design.json) +.sdd/spec/<feature-id>/diagrams/class.mmd. - Guardrail: Validate layer boundaries per
project_rules.md. Ensure all components fromarchitecture.jsonhave corresponding design units.
4. Interface & Contract Design
-
Input:
object_design.json+architecture.json. -
Action: Define the external-facing contracts and data schemas appropriate to the feature. Produce only the artifacts relevant to the feature's interface boundaries:
Artifact When to produce openapi.yamlFeature exposes or consumes HTTP/REST APIs data_api.jsonFeature involves persistent data (DB entities, schemas) interface_contract.jsonFeature has non-HTTP interfaces (CLI args, SDK public API, event schemas, IPC, etc.) If the feature has no external interface boundaries (e.g., a pure refactoring or internal library), this stage may be skipped entirely.
-
Clarify: Run Ambiguity Resolution Protocol on interface decisions.
-
Output: Whichever artifacts from the table above are relevant, written to
.sdd/spec/<feature-id>/. -
Guardrail: Validate consistency between produced interface specs and
object_design.json; check for breaking changes.
Compounding Features
- Pattern Recognition: When generating architecture/interfaces, the engine queries
sdd-knowledge-basefor similar past patterns by tags to suggest proven designs. - Lessons Learned: Checks
sdd-knowledge-basefor "avoid" lists before making decisions.
Stage Transitions
After completing each sub-stage successfully:
- Auto-save artifacts to feature directory.
- Update
context.json.current_stageappropriately. - After all design sub-stages complete, set
current_stageto"design-complete".
graph TD
A[request.md] -->|/sdd-design| B(Analyze Requirements)
B --> B1{Concerns?}
B1 -->|BLOCKING/WARNING| B2[Ask User]
B2 --> B3[User Answers]
B3 --> B
B1 -->|All Resolved| C{Guardrails Pass?}
C -->|No| B
C -->|Yes| D[Auto-Save requirements.json]
D --> E(Generate Architecture)
E --> E1{Concerns?}
E1 -->|BLOCKING/WARNING| E2[Ask User]
E2 --> E3[User Answers]
E3 --> E
E1 -->|All Resolved| F{Guardrails Pass?}
F -->|No| E
F -->|Yes| G[Auto-Save architecture.json]
G --> OD(Object Design)
OD --> OD1{Concerns?}
OD1 -->|BLOCKING/WARNING| OD2[Ask User]
OD2 --> OD3[User Answers]
OD3 --> OD
OD1 -->|All Resolved| ODF{Guardrails Pass?}
ODF -->|No| OD
ODF -->|Yes| ODG[Auto-Save object_design.json]
ODG --> H(Interface & Contract Design)
H --> H1{Concerns?}
H1 -->|BLOCKING/WARNING| H2[Ask User]
H2 --> H3[User Answers]
H3 --> H
H1 -->|All Resolved| I{Guardrails Pass?}
I -->|No| H
I -->|Yes| J[Finalize: Ready for Planning]
Example Usage
User: /sdd-design
Agent: Active feature: "001-user-auth". Found request.md.
[Requirements] Analyzing request.md...
> Generated 5 Technical Requirements from User Stories.
> Confidence: REQ-001 (1.0), REQ-002 (0.8), REQ-003 (0.5)
⚠️ BLOCKING Concerns:
- C-001: JWT or session-based tokens for social auth?
ℹ️ INFO:
- C-002: Per project_rules, using Clean Architecture.
User: JWT with refresh tokens.
Agent: > Resolved. Updating requirements...
> All concerns resolved. Guardrails passed. Auto-saving...
[Architecture] Generating...
...
[Object Design] Analyzing architecture components...
> Defined 4 Domain Classes: User, UserProfile, AuthToken, UserRepository.
> Generated class diagram with relationships.
⚠️ BLOCKING Concerns:
- C-004: Should UserService implement IAuthService or be a separate class?
User: Separate class. UserService handles profile, AuthService handles auth.
Agent: > Resolved. Auto-saving object_design.json + class.mmd...
[Interface & Contract Design] Analyzing interface boundaries...
...
Source
git clone https://github.com/leoheart0125/sdd-skills/blob/main/skills/sdd-design-engine/SKILL.mdView on GitHub Overview
This skill consolidates the design phase by converting a structured request.md into precise technical specifications through an automated pipeline with Ambiguity Resolution. It auto-persists state to the knowledge base and enforces guardrails at every sub-stage.
How This Skill Works
The engine progresses through Requirements Analysis, Architecture, Object Design, and Interface & Contract Design. At each sub-stage, it runs an Ambiguity Resolution loop to surface concerns and converge on exact specs before proceeding, while automatically invoking guardrails and saving outputs to the knowledge base. Drift detected during implementation is managed via the spec-update mechanism.
When to Use It
- You have a structured request.md from sdd-request-engine and want to generate precise specs
- You need to transform Requirements into Architecture, Object Design, and Interface specifications
- Ambiguity exists and requires clarifying questions before proceeding
- You want automated guardrails and auto-persistence of design artifacts
- You are handling feature drift and need to update specs through /sdd-spec-update
Quick Start
- Step 1: Ensure a feature exists in context.json and run /sdd-request if needed to generate request.md
- Step 2: Run /sdd-design to begin Requirements Analysis and trigger the Ambiguity Resolution loop
- Step 3: Review generated artifacts and update via /sdd-spec-update as drift is detected
Best Practices
- Define a clear feature name in context.json.current_feature before design
- Run the ambiguity resolution loop to surface blocking concerns at each stage
- Verify that each stage outputs corresponding artifacts in .sdd/spec and that JSON is valid
- Regularly review and incorporate concerns.json after each sub-stage
- Use /sdd-spec-update to efficiently manage drift from implementation
Example Use Cases
- Designing a user authentication feature from requirements to interfaces and contracts
- Designing a REST data API with openapi and data_api.json persistence
- Defining CLI or SDK boundary contracts during object and interface design
- Clarifying password policy and nonfunctional requirements via concerns.json
- Managing post-implementation drift and updating specs with /sdd-spec-update