mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-19 04:59:28 +00:00
chore: add kiro spec-driven tooling and steering docs
Add the Kiro-style agentic SDLC tooling used to drive this project: the .opencode/skills/kiro-* skill set (discovery, spec init/requirements/design/ tasks, validation, implementation, review, steering), the .kiro/settings templates, and AGENTS.md describing the workflow. Update the spec docs (assessment/design/requirements/tasks) to current state. Scope tests/test_opencode_skills.py to the project's own openultrasast-* skills so the third-party kiro-* tooling (which uses a different frontmatter convention) no longer breaks the frontmatter check. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
8fe8911020
commit
6699f1f8f9
@@ -0,0 +1,207 @@
|
||||
---
|
||||
name: kiro-spec-design
|
||||
description: Create comprehensive technical design for a specification
|
||||
metadata:
|
||||
shared-rules: "design-principles.md, design-discovery-full.md, design-discovery-light.md, design-synthesis.md, design-review-gate.md"
|
||||
---
|
||||
|
||||
|
||||
# Technical Design Generator
|
||||
|
||||
<background_information>
|
||||
- **Success Criteria**:
|
||||
- All requirements mapped to technical components with clear interfaces
|
||||
- The design makes responsibility boundaries explicit enough to guide task generation and review
|
||||
- Appropriate architecture discovery and research completed
|
||||
- Design aligns with steering context and existing patterns
|
||||
- Visual diagrams included for complex architectures
|
||||
</background_information>
|
||||
|
||||
<instructions>
|
||||
## Execution Steps
|
||||
|
||||
### Step 1: Load Context
|
||||
|
||||
**Read all necessary context**:
|
||||
- `.kiro/specs/$1/spec.json`, `requirements.md`, `design.md` (if exists)
|
||||
- `.kiro/specs/$1/research.md` (if exists, contains gap analysis from `/kiro-validate-gap`)
|
||||
- Core steering context: `product.md`, `tech.md`, `structure.md`
|
||||
- Additional steering files only when directly relevant to requirement coverage, architecture boundaries, integrations, runtime prerequisites, security/performance constraints, or team conventions that affect implementation readiness
|
||||
- `.kiro/settings/templates/specs/design.md` for document structure
|
||||
- Read `rules/design-principles.md` from this skill's directory for design principles
|
||||
- `.kiro/settings/templates/specs/research.md` for discovery log structure
|
||||
|
||||
**Validate requirements approval**:
|
||||
- If `-y` flag provided ($2 == "-y"): Auto-approve requirements in spec.json
|
||||
- Otherwise: Verify approval status (stop if unapproved, see Safety & Fallback)
|
||||
|
||||
### Step 2: Discovery & Analysis
|
||||
|
||||
**Critical: This phase ensures design is based on complete, accurate information.**
|
||||
|
||||
1. **Classify Feature Type**:
|
||||
- **New Feature** (greenfield) → Full discovery required
|
||||
- **Extension** (existing system) → Integration-focused discovery
|
||||
- **Simple Addition** (CRUD/UI) → Minimal or no discovery
|
||||
- **Complex Integration** → Comprehensive analysis required
|
||||
|
||||
2. **Execute Appropriate Discovery Process**:
|
||||
|
||||
**For Complex/New Features**:
|
||||
- Read and execute `rules/design-discovery-full.md` from this skill's directory
|
||||
- Conduct thorough research using WebSearch/WebFetch:
|
||||
- Latest architectural patterns and best practices
|
||||
- External dependency verification (APIs, libraries, versions, compatibility)
|
||||
- Official documentation, migration guides, known issues
|
||||
- Performance benchmarks and security considerations
|
||||
|
||||
**For Extensions**:
|
||||
- Read and execute `rules/design-discovery-light.md` from this skill's directory
|
||||
- Focus on integration points, existing patterns, compatibility
|
||||
- Use Grep to analyze existing codebase patterns
|
||||
|
||||
**For Simple Additions**:
|
||||
- Skip formal discovery, quick pattern check only
|
||||
|
||||
#### Parallel Research (sub-agent dispatch)
|
||||
|
||||
The following research areas are independent and can be dispatched as **sub-agents**. The agent should decide the optimal decomposition based on feature complexity — split, merge, add, or skip sub-agents as needed. Each sub-agent returns a **findings summary** (not raw data) to keep the main context clean for synthesis.
|
||||
|
||||
**Typical research areas** (adjust as appropriate):
|
||||
- **Codebase analysis**: Existing architecture patterns, integration points, code conventions
|
||||
- **External research**: Dependencies, APIs, latest best practices
|
||||
- **Context loading** (usually main context): Steering files, design principles, discovery rules, templates
|
||||
|
||||
For simple additions, skip sub-agent dispatch entirely and do a quick pattern check in main context.
|
||||
|
||||
After all findings return, synthesize in main context before proceeding.
|
||||
|
||||
3. **Retain Discovery Findings for Step 3**:
|
||||
- External API contracts and constraints
|
||||
- Technology decisions with rationale
|
||||
- Existing patterns to follow or extend
|
||||
- Integration points and dependencies
|
||||
- Identified risks and mitigation strategies
|
||||
- Boundary candidates, out-of-boundary decisions, and likely revalidation triggers
|
||||
|
||||
4. **Persist Findings to Research Log**:
|
||||
- Create or update `.kiro/specs/$1/research.md` using the shared template
|
||||
- Summarize discovery scope and key findings (Summary section)
|
||||
- Record investigations in Research Log topics with sources and implications
|
||||
- Document architecture pattern evaluation, design decisions, and risks using the template sections
|
||||
- Use the language specified in spec.json when writing or updating `research.md`
|
||||
|
||||
### Step 3: Synthesis
|
||||
|
||||
**Apply design synthesis to discovery findings before writing.**
|
||||
|
||||
- Read and apply `rules/design-synthesis.md` from this skill's directory
|
||||
- This step requires the full picture from discovery — do not parallelize or delegate to sub-agents
|
||||
- Record synthesis outcomes (generalizations found, build-vs-adopt decisions, simplifications) in `research.md`
|
||||
|
||||
### Step 4: Generate Design Draft
|
||||
|
||||
1. **Load Design Template and Rules**:
|
||||
- Read `.kiro/settings/templates/specs/design.md` for structure
|
||||
- Read `rules/design-principles.md` from this skill's directory for principles
|
||||
|
||||
2. **Generate Design Draft**:
|
||||
- **Follow specs/design.md template structure and generation instructions strictly**
|
||||
- **Boundary-first requirement**: Before expanding supporting sections, make the boundary explicit. The draft must clearly define what this spec owns, what it does not own, which dependencies are allowed, and what changes would require downstream revalidation.
|
||||
- **Integrate all discovery findings and synthesis outcomes**: Use researched information (APIs, patterns, technologies) and synthesis decisions (generalizations, build-vs-adopt, simplifications) throughout component definitions, architecture decisions, and integration points
|
||||
- **File Structure Plan** (required): Populate the File Structure Plan section with concrete file paths and responsibilities. Analyze the codebase to determine which files need to be created vs. modified. Each file must have one clear responsibility. This section directly drives task `_Boundary:_` annotations and implementation Task Briefs — vague file structures produce vague implementations.
|
||||
- **Testing Strategy**: Derive test items from requirements' acceptance criteria, not generic patterns. Each test item should reference specific components and behaviors from this design. E2E paths must map to the critical user flows identified in requirements. Avoid vague entries like "test login works" -- instead specify what is being verified and why it matters.
|
||||
- If existing design.md found in Step 1, use it as reference context (merge mode)
|
||||
- Apply design rules: Type Safety, Visual Communication, Formal Tone
|
||||
- Use language specified in spec.json
|
||||
- Keep this as a draft until the review gate passes; do not write `design.md` yet
|
||||
|
||||
### Step 5: Review Design Draft
|
||||
|
||||
- Read and apply `rules/design-review-gate.md` from this skill's directory
|
||||
- Verify requirements coverage, architecture readiness, and implementation executability before finalizing the design
|
||||
- If issues are local to the draft, repair the design and review again
|
||||
- Keep the review bounded to at most 2 repair passes
|
||||
- If the draft exposes a real requirements/design gap, stop and return to requirements clarification instead of papering over it in `design.md`
|
||||
|
||||
### Step 6: Finalize Design Document
|
||||
|
||||
1. **Write Final Design and Research Log**:
|
||||
- Write `.kiro/specs/$1/design.md` only after the design review gate passes
|
||||
- Write research.md with discovery findings and synthesis outcomes (if not already written)
|
||||
- Persist any `research.md` updates that support the finalized design
|
||||
|
||||
2. **Update Metadata** in spec.json:
|
||||
- Set `phase: "design-generated"`
|
||||
- Set `approvals.design.generated: true, approved: false`
|
||||
- Set `approvals.requirements.approved: true`
|
||||
- Update `updated_at` timestamp
|
||||
|
||||
## Critical Constraints
|
||||
- **Type Safety**:
|
||||
- Enforce strong typing aligned with the project's technology stack.
|
||||
- For statically typed languages, define explicit types/interfaces and avoid unsafe casts.
|
||||
- For TypeScript, never use `any`; prefer precise types and generics.
|
||||
- For dynamically typed languages, provide type hints/annotations where available (e.g., Python type hints) and validate inputs at boundaries.
|
||||
- Document public interfaces and contracts clearly to ensure cross-component type safety.
|
||||
- **Requirements Traceability IDs**: Use numeric requirement IDs only (e.g. "1.1", "1.2", "3.1", "3.3") exactly as defined in requirements.md. Do not invent new IDs or use alphabetic labels.
|
||||
</instructions>
|
||||
|
||||
## Output Description
|
||||
|
||||
**Command execution output** (separate from design.md content):
|
||||
|
||||
Provide brief summary in the language specified in spec.json:
|
||||
|
||||
1. **Status**: Confirm design document generated at `.kiro/specs/$1/design.md`
|
||||
2. **Discovery Type**: Which discovery process was executed (full/light/minimal)
|
||||
3. **Key Findings**: 2-3 critical insights from `research.md` that shaped the design
|
||||
4. **Review Gate**: Confirm the design review gate passed
|
||||
5. **Next Action**: Approval workflow guidance (see Safety & Fallback)
|
||||
6. **Research Log**: Confirm `research.md` updated with latest decisions
|
||||
|
||||
**Format**: Concise Markdown (under 200 words) - this is the command output, NOT the design document itself
|
||||
|
||||
**Note**: The actual design document follows `.kiro/settings/templates/specs/design.md` structure.
|
||||
|
||||
## Safety & Fallback
|
||||
|
||||
### Error Scenarios
|
||||
|
||||
**Requirements Not Approved**:
|
||||
- **Stop Execution**: Cannot proceed without approved requirements
|
||||
- **User Message**: "Requirements not yet approved. Approval required before design generation."
|
||||
- **Suggested Action**: "Run `/kiro-spec-design $1 -y` to auto-approve requirements and proceed"
|
||||
|
||||
**Missing Requirements**:
|
||||
- **Stop Execution**: Requirements document must exist
|
||||
- **User Message**: "No requirements.md found at `.kiro/specs/$1/requirements.md`"
|
||||
- **Suggested Action**: "Run `/kiro-spec-requirements $1` to generate requirements first"
|
||||
|
||||
**Template Missing**:
|
||||
- **User Message**: "Template file missing at `.kiro/settings/templates/specs/design.md`"
|
||||
- **Suggested Action**: "Check repository setup or restore template file"
|
||||
- **Fallback**: Use inline basic structure with warning
|
||||
|
||||
**Steering Context Missing**:
|
||||
- **Warning**: "Steering directory empty or missing - design may not align with project standards"
|
||||
- **Proceed**: Continue with generation but note limitation in output
|
||||
|
||||
**Invalid Requirement IDs**:
|
||||
- **Stop Execution**: If requirements.md is missing numeric IDs or uses non-numeric headings (for example, "Requirement A"), stop and instruct the user to fix requirements.md before continuing.
|
||||
|
||||
**Spec Gap Found During Design Review**:
|
||||
- **Stop Execution**: Do not write a patched-over `design.md`
|
||||
- **User Message**: "Design review found a real spec gap or ambiguity that must be resolved before design can be finalized."
|
||||
- **Suggested Action**: Clarify or fix `requirements.md`, then re-run `/kiro-spec-design $1`
|
||||
|
||||
### Next Phase: Task Generation
|
||||
|
||||
**If Design Approved**:
|
||||
- Review generated design at `.kiro/specs/$1/design.md`
|
||||
- **Optional**: Run `/kiro-validate-design $1` for interactive quality review
|
||||
- Then `/kiro-spec-tasks $1 -y` to generate implementation tasks
|
||||
|
||||
**If Modifications Needed**:
|
||||
- Provide feedback and re-run `/kiro-spec-design $1`
|
||||
- Existing design used as reference (merge mode)
|
||||
@@ -0,0 +1,93 @@
|
||||
# Full Discovery Process for Technical Design
|
||||
|
||||
## Objective
|
||||
Conduct comprehensive research and analysis to ensure the technical design is based on complete, accurate, and up-to-date information.
|
||||
|
||||
## Discovery Steps
|
||||
|
||||
### 1. Requirements Analysis
|
||||
**Map Requirements to Technical Needs**
|
||||
- Extract all functional requirements from EARS format
|
||||
- Identify non-functional requirements (performance, security, scalability)
|
||||
- Determine technical constraints and dependencies
|
||||
- List core technical challenges
|
||||
|
||||
### 2. Existing Implementation Analysis
|
||||
**Understand Current System** (if modifying/extending):
|
||||
- Analyze codebase structure and architecture patterns
|
||||
- Map reusable components, services, utilities
|
||||
- Identify domain boundaries and data flows
|
||||
- Document integration points and dependencies
|
||||
- Determine approach: extend vs refactor vs wrap
|
||||
|
||||
### 3. Technology Research
|
||||
**Investigate Best Practices and Solutions**:
|
||||
- **Use WebSearch** to find:
|
||||
- Latest architectural patterns for similar problems
|
||||
- Industry best practices for the technology stack
|
||||
- Recent updates or changes in relevant technologies
|
||||
- Common pitfalls and solutions
|
||||
|
||||
- **Use WebFetch** to analyze:
|
||||
- Official documentation for frameworks/libraries
|
||||
- API references and usage examples
|
||||
- Migration guides and breaking changes
|
||||
- Performance benchmarks and comparisons
|
||||
|
||||
### 4. External Dependencies Investigation
|
||||
**For Each External Service/Library**:
|
||||
- Search for official documentation and GitHub repositories
|
||||
- Verify API signatures and authentication methods
|
||||
- Check version compatibility with existing stack
|
||||
- Investigate rate limits and usage constraints
|
||||
- Find community resources and known issues
|
||||
- Document security considerations
|
||||
- Note any gaps requiring implementation investigation
|
||||
|
||||
### 5. Architecture Pattern & Boundary Analysis
|
||||
**Evaluate Architectural Options**:
|
||||
- Compare relevant patterns (MVC, Clean, Hexagonal, Event-driven)
|
||||
- Assess fit with existing architecture and steering principles
|
||||
- Identify domain boundaries and ownership seams required to avoid team conflicts
|
||||
- Consider scalability implications and operational concerns
|
||||
- Evaluate maintainability and team expertise
|
||||
- Document preferred pattern and rejected alternatives in `research.md`
|
||||
|
||||
### 6. Risk Assessment
|
||||
**Identify Technical Risks**:
|
||||
- Performance bottlenecks and scaling limits
|
||||
- Security vulnerabilities and attack vectors
|
||||
- Integration complexity and coupling
|
||||
- Technical debt creation vs resolution
|
||||
- Knowledge gaps and training needs
|
||||
|
||||
## Research Guidelines
|
||||
|
||||
### When to Search
|
||||
**Always search for**:
|
||||
- External API documentation and updates
|
||||
- Security best practices for authentication/authorization
|
||||
- Performance optimization techniques for identified bottlenecks
|
||||
- Latest versions and migration paths for dependencies
|
||||
|
||||
**Search if uncertain about**:
|
||||
- Architectural patterns for specific use cases
|
||||
- Industry standards for data formats/protocols
|
||||
- Compliance requirements (GDPR, HIPAA, etc.)
|
||||
- Scalability approaches for expected load
|
||||
|
||||
### Search Strategy
|
||||
1. Start with official sources (documentation, GitHub)
|
||||
2. Check recent blog posts and articles (last 6 months)
|
||||
3. Review Stack Overflow for common issues
|
||||
4. Investigate similar open-source implementations
|
||||
|
||||
## Output Requirements
|
||||
Capture all findings that impact design decisions in `research.md` using the shared template:
|
||||
- Key insights affecting architecture, technology alignment, and contracts
|
||||
- Constraints discovered during research
|
||||
- Recommended approaches and selected architecture pattern with rationale
|
||||
- Rejected alternatives and trade-offs (documented in the Design Decisions section)
|
||||
- Updated domain boundaries that inform Components & Interface Contracts
|
||||
- Risks and mitigation strategies
|
||||
- Gaps requiring further investigation during implementation
|
||||
@@ -0,0 +1,49 @@
|
||||
# Light Discovery Process for Extensions
|
||||
|
||||
## Objective
|
||||
Quickly analyze existing system and integration requirements for feature extensions.
|
||||
|
||||
## Focused Discovery Steps
|
||||
|
||||
### 1. Extension Point Analysis
|
||||
**Identify Integration Approach**:
|
||||
- Locate existing extension points or interfaces
|
||||
- Determine modification scope (files, components)
|
||||
- Check for existing patterns to follow
|
||||
- Identify backward compatibility requirements
|
||||
|
||||
### 2. Dependency Check
|
||||
**Verify Compatibility**:
|
||||
- Check version compatibility of new dependencies
|
||||
- Validate API contracts haven't changed
|
||||
- Ensure no breaking changes in pipeline
|
||||
|
||||
### 3. Quick Technology Verification
|
||||
**For New Libraries Only**:
|
||||
- Use WebSearch for official documentation
|
||||
- Verify basic usage patterns
|
||||
- Check for known compatibility issues
|
||||
- Confirm licensing compatibility
|
||||
- Record key findings in `research.md` (technology alignment section)
|
||||
|
||||
### 4. Integration Risk Assessment
|
||||
**Quick Risk Check**:
|
||||
- Impact on existing functionality
|
||||
- Performance implications
|
||||
- Security considerations
|
||||
- Testing requirements
|
||||
|
||||
## When to Escalate to Full Discovery
|
||||
Switch to full discovery if you find:
|
||||
- Significant architectural changes needed
|
||||
- Complex external service integrations
|
||||
- Security-sensitive implementations
|
||||
- Performance-critical components
|
||||
- Unknown or poorly documented dependencies
|
||||
|
||||
## Output Requirements
|
||||
- Clear integration approach (note boundary impacts in `research.md`)
|
||||
- List of files/components to modify
|
||||
- New dependencies with versions
|
||||
- Integration risks and mitigations
|
||||
- Testing focus areas
|
||||
@@ -0,0 +1,198 @@
|
||||
# Technical Design Rules and Principles
|
||||
|
||||
## Core Design Principles
|
||||
|
||||
### 0. Boundary First
|
||||
- **Boundary is mandatory; owner is optional**
|
||||
- A design is not ready when it explains components but leaves responsibility seams ambiguous
|
||||
- Define what the spec owns before elaborating how it works
|
||||
- Explicitly record what is out of boundary
|
||||
- Do not leak downstream-specific behavior or assumptions into upstream boundaries
|
||||
|
||||
### 1. Type Safety is Mandatory
|
||||
- **NEVER** use `any` type in TypeScript interfaces
|
||||
- Define explicit types for all parameters and returns
|
||||
- Use discriminated unions for error handling
|
||||
- Specify generic constraints clearly
|
||||
|
||||
### 2. Design vs Implementation
|
||||
- **Focus on WHAT, not HOW**
|
||||
- Define interfaces and contracts, not code
|
||||
- Specify behavior through pre/post conditions
|
||||
- Document architectural decisions, not algorithms
|
||||
|
||||
### 3. Visual Communication
|
||||
- **Simple features**: Basic component diagram or none
|
||||
- **Medium complexity**: Architecture + data flow
|
||||
- **High complexity**: Multiple diagrams (architecture, sequence, state)
|
||||
- **Always pure Mermaid**: No styling, just structure
|
||||
|
||||
### 4. Component Design Rules
|
||||
- **Single Responsibility**: One clear purpose per component
|
||||
- **Clear Boundaries**: Explicit domain ownership
|
||||
- **Boundary Commitments First**: Before detailing components, state the responsibility boundary this design commits to
|
||||
- **Dependency Direction**: Follow architectural layers
|
||||
- **Interface Segregation**: Minimal, focused interfaces
|
||||
- **Team-safe Interfaces**: Design boundaries that allow parallel implementation without merge conflicts
|
||||
- **No Hidden Shared Ownership**: If two areas appear to co-own the same behavior or data, the design is incomplete
|
||||
- **Research Traceability**: Record boundary decisions and rationale in `research.md`
|
||||
|
||||
### 5. Data Modeling Standards
|
||||
- **Domain First**: Start with business concepts
|
||||
- **Consistency Boundaries**: Clear aggregate roots
|
||||
- **Normalization**: Balance between performance and integrity
|
||||
- **Evolution**: Plan for schema changes
|
||||
|
||||
### 6. Error Handling Philosophy
|
||||
- **Fail Fast**: Validate early and clearly
|
||||
- **Graceful Degradation**: Partial functionality over complete failure
|
||||
- **User Context**: Actionable error messages
|
||||
- **Observability**: Comprehensive logging and monitoring
|
||||
|
||||
### 7. Integration Patterns
|
||||
- **Loose Coupling**: Minimize dependencies
|
||||
- **Contract First**: Define interfaces before implementation
|
||||
- **Versioning**: Plan for API evolution
|
||||
- **Idempotency**: Design for retry safety
|
||||
- **Contract Visibility**: Surface API and event contracts in design.md while linking extended details from `research.md`
|
||||
|
||||
### 8. Dependency Direction
|
||||
- **Define and enforce the dependency direction** in the architecture section of design.md (e.g., Types → Config → Repository → Service → Runtime → UI)
|
||||
- Each layer imports only from layers to its left — never upward
|
||||
- This constraint is not a suggestion; implementation and review should treat violations as errors
|
||||
- When the File Structure Plan maps files to components, the dependency direction determines which imports are allowed
|
||||
|
||||
## Documentation Standards
|
||||
|
||||
### Language and Tone
|
||||
- **Declarative**: "The system authenticates users" not "The system should authenticate"
|
||||
- **Precise**: Specific technical terms over vague descriptions
|
||||
- **Concise**: Essential information only
|
||||
- **Formal**: Professional technical writing
|
||||
|
||||
### Structure Requirements
|
||||
- **Hierarchical**: Clear section organization
|
||||
- **Traceable**: Requirements to components mapping
|
||||
- **Complete**: All aspects covered for implementation
|
||||
- **Consistent**: Uniform terminology throughout
|
||||
- **Focused**: Keep design.md centered on architecture and contracts; move investigation logs and lengthy comparisons to `research.md`
|
||||
|
||||
## Section Authoring Guidance
|
||||
|
||||
### Global Ordering
|
||||
- Default flow: Overview → Goals/Non-Goals → Boundary Commitments → Architecture → File Structure Plan → Components & Interfaces → Optional sections.
|
||||
- Teams may swap Traceability earlier or place Data Models nearer Architecture when it improves clarity, but keep section headings intact.
|
||||
- Within each section, follow **Summary → Scope → Decisions → Impacts/Risks** so reviewers can scan consistently.
|
||||
|
||||
### Requirement IDs
|
||||
- Reference requirements as `2.1, 2.3` without prefixes (no “Requirement 2.1”).
|
||||
- All requirements MUST have numeric IDs. If a requirement lacks a numeric ID, stop and fix `requirements.md` before continuing.
|
||||
- Use `N.M`-style numeric IDs where `N` is the top-level requirement number from requirements.md (for example, Requirement 1 → 1.1, 1.2; Requirement 2 → 2.1, 2.2).
|
||||
- Every component, task, and traceability row must reference the same canonical numeric ID.
|
||||
|
||||
### Technology Stack
|
||||
- Include ONLY layers impacted by this feature (frontend, backend, data, messaging, infra).
|
||||
- For each layer specify tool/library + version + the role it plays; push extended rationale, comparisons, or benchmarks to `research.md`.
|
||||
- When extending an existing system, highlight deviations from the current stack and list new dependencies.
|
||||
|
||||
### System Flows
|
||||
- Add diagrams only when they clarify behavior:
|
||||
- **Sequence** for multi-step interactions
|
||||
- **Process/State** for branching rules or lifecycle
|
||||
- **Data/Event** for pipelines or async patterns
|
||||
- Always use pure Mermaid. If no complex flow exists, omit the entire section.
|
||||
|
||||
### Requirements Traceability
|
||||
- Use the standard table (`Requirement | Summary | Components | Interfaces | Flows`) to prove coverage.
|
||||
- Collapse to bullet form only when a single requirement maps 1:1 to a component.
|
||||
- Prefer the component summary table for simple mappings; reserve the full traceability table for complex or compliance-sensitive requirements.
|
||||
- Re-run this mapping whenever requirements or components change to avoid drift.
|
||||
|
||||
### Components & Interfaces Authoring
|
||||
- Boundary Commitments should already make the ownership seam explicit before this section begins.
|
||||
- Group components by domain/layer and provide one block per component.
|
||||
- Begin with a summary table listing Component, Domain, Intent, Requirement coverage, key dependencies, and selected contracts.
|
||||
- Table fields: Intent (one line), Requirements (`2.1, 2.3`), Owner/Reviewers (optional).
|
||||
- Dependencies table must mark each entry as Inbound/Outbound/External and assign Criticality (`P0` blocking, `P1` high-risk, `P2` informational).
|
||||
- Summaries of external dependency research stay here; detailed investigation (API signatures, rate limits, migration notes) belongs in `research.md`.
|
||||
- design.md must remain a self-contained reviewer artifact. Reference `research.md` only for background, and restate any conclusions or decisions here.
|
||||
- Contracts: tick only the relevant types (Service/API/Event/Batch/State). Unchecked types should not appear later in the component section.
|
||||
- Service interfaces must declare method signatures, inputs/outputs, and error envelopes. API/Event/Batch contracts require schema tables or bullet lists covering trigger, payload, delivery, idempotency.
|
||||
- Use **Integration & Migration Notes**, **Validation Hooks**, and **Open Questions / Risks** to document rollout strategy, observability, and unresolved decisions.
|
||||
- Detail density rules:
|
||||
- **Full block**: components introducing new boundaries (logic hooks, shared services, external integrations, data layers).
|
||||
- **Summary-only**: presentational/UI components with no new boundaries (plus a short Implementation Note if needed).
|
||||
- Implementation Notes must combine Integration / Validation / Risks into a single bulleted subsection to reduce repetition.
|
||||
- Prefer lists or inline descriptors for short data (dependencies, contract selections). Use tables only when comparing multiple items.
|
||||
|
||||
### Shared Interfaces & Props
|
||||
- Define a base interface (e.g., `BaseUIPanelProps`) for recurring UI components and extend it per component to capture only the deltas.
|
||||
- Hooks, utilities, and integration adapters that introduce new contracts should still include full TypeScript signatures.
|
||||
- When reusing a base contract, reference it explicitly (e.g., “Extends `BaseUIPanelProps` with `onSubmitAnswer` callback”) instead of duplicating the code block.
|
||||
|
||||
### Data Models
|
||||
- Domain Model covers aggregates, entities, value objects, domain events, and invariants. Add Mermaid diagrams only when relationships are non-trivial.
|
||||
- Logical Data Model should articulate structure, indexing, sharding, and storage-specific considerations (event store, KV/wide-column) relevant to the change.
|
||||
- Data Contracts & Integration section documents API payloads, event schemas, and cross-service synchronization patterns when the feature crosses boundaries.
|
||||
- Lengthy type definitions or vendor-specific option objects should be placed in the Supporting References section within design.md, linked from the relevant section. Investigation notes stay in `research.md`.
|
||||
- Supporting References usage is optional; only create it when keeping the content in the main body would reduce readability. All decisions must still appear in the main sections so design.md stands alone.
|
||||
|
||||
### Error/Testing/Security/Performance Sections
|
||||
- Record only feature-specific decisions or deviations. Link or reference organization-wide standards (steering) for baseline practices instead of restating them.
|
||||
|
||||
### Diagram & Text Deduplication
|
||||
- Do not restate diagram content verbatim in prose. Use the text to highlight key decisions, trade-offs, or impacts that are not obvious from the visual.
|
||||
- When a decision is fully captured in the diagram annotations, a short “Key Decisions” bullet is sufficient.
|
||||
|
||||
### General Deduplication
|
||||
- Avoid repeating the same information across Overview, Architecture, and Components. Reference earlier sections when context is identical.
|
||||
- If a requirement/component relationship is captured in the summary table, do not rewrite it elsewhere unless extra nuance is added.
|
||||
|
||||
## Diagram Guidelines
|
||||
|
||||
### When to include a diagram
|
||||
- **Architecture**: Use a structural diagram when 3+ components or external systems interact.
|
||||
- **Sequence**: Draw a sequence diagram when calls/handshakes span multiple steps.
|
||||
- **State / Flow**: Capture complex state machines or business flows in a dedicated diagram.
|
||||
- **ER**: Provide an entity-relationship diagram for non-trivial data models.
|
||||
- **Skip**: Minor one-component changes generally do not need diagrams.
|
||||
|
||||
### Mermaid requirements
|
||||
```mermaid
|
||||
graph TB
|
||||
Client --> ApiGateway
|
||||
ApiGateway --> ServiceA
|
||||
ApiGateway --> ServiceB
|
||||
ServiceA --> Database
|
||||
```
|
||||
|
||||
- **Plain Mermaid only** – avoid custom styling or unsupported syntax.
|
||||
- **Node IDs** – alphanumeric plus underscores only (e.g., `Client`, `ServiceA`). Do not use `@`, `/`, or leading `-`.
|
||||
- **Labels** – simple words. Do not embed parentheses `()`, square brackets `[]`, quotes `"`, or slashes `/`.
|
||||
- ❌ `DnD[@dnd-kit/core]` → invalid ID (`@`).
|
||||
- ❌ `UI[KanbanBoard(React)]` → invalid label (`()`).
|
||||
- ✅ `DndKit[dnd-kit core]` → use plain text in labels, keep technology details in the accompanying description.
|
||||
- ℹ️ Mermaid strict-mode will otherwise fail with errors like `Expecting 'SQE' ... got 'PS'`; remove punctuation from labels before rendering.
|
||||
- **Edges** – show data or control flow direction.
|
||||
- **Groups** – using Mermaid subgraphs to cluster related components is allowed; use it sparingly for clarity.
|
||||
|
||||
## Quality Metrics
|
||||
### Design Completeness Checklist
|
||||
- All requirements addressed
|
||||
- No implementation details leaked
|
||||
- Clear component boundaries
|
||||
- Explicit error handling
|
||||
- Comprehensive test strategy
|
||||
- Security considered
|
||||
- Performance targets defined
|
||||
- Migration path clear (if applicable)
|
||||
|
||||
### Common Anti-patterns to Avoid
|
||||
❌ Mixing design with implementation
|
||||
❌ Vague interface definitions
|
||||
❌ Missing error scenarios
|
||||
❌ Ignored non-functional requirements
|
||||
❌ Overcomplicated architectures
|
||||
❌ Tight coupling between components
|
||||
❌ Missing data consistency strategy
|
||||
❌ Incomplete dependency analysis
|
||||
@@ -0,0 +1,50 @@
|
||||
# Design Review Gate
|
||||
|
||||
Before writing `design.md`, review the draft design and repair local issues until the design passes or a true spec gap is discovered.
|
||||
|
||||
## Requirements Coverage Review
|
||||
|
||||
- Every numeric requirement ID from `requirements.md` must appear in the design traceability mapping and be backed by one or more concrete components, contracts, flows, data models, or operational decisions.
|
||||
- Every requirement that introduces an external dependency, integration point, runtime prerequisite, migration concern, observability need, security constraint, or performance target must be reflected explicitly in `design.md`.
|
||||
- If coverage is missing because the design draft is incomplete, repair the draft and review again.
|
||||
- If coverage cannot be completed cleanly because requirements are ambiguous, contradictory, or underspecified, stop and return to the requirements phase instead of inventing design detail.
|
||||
|
||||
## Architecture Readiness Review
|
||||
|
||||
- Component boundaries must be explicit enough that implementation tasks can be assigned without guessing ownership.
|
||||
- Interfaces, contracts, state transitions, and integration boundaries must be concrete enough for implementation and validation.
|
||||
- Build-vs-adopt decisions that materially affect architecture must be captured in `design.md`, with deeper investigation left in `research.md` when present.
|
||||
- Runtime prerequisites, migrations, rollout constraints, validation hooks, and failure modes must be surfaced when they materially affect implementation order or risk.
|
||||
|
||||
## Boundary Readiness Review
|
||||
|
||||
- The design must explicitly state what this spec owns.
|
||||
- The design must explicitly state what is out of boundary.
|
||||
- Allowed dependencies must be concrete enough that reviewers can detect boundary violations later.
|
||||
- If data, behavior, or integration responsibility appears shared across multiple areas without a clear seam, stop and repair the design.
|
||||
- If downstream assumptions are embedded in upstream components "for convenience," stop and repair the design.
|
||||
- If the boundary cannot be explained in a few direct bullets, it is probably still too vague for task generation.
|
||||
- If the design reveals multiple independent responsibility seams that could move separately, stop and split the spec or return to roadmap discovery instead of forcing them into one spec.
|
||||
|
||||
## Executability Review
|
||||
|
||||
- The design must be implementable as a sequence of bounded tasks without hidden prerequisites.
|
||||
- Parallel-safe boundaries should be visible where the architecture intends concurrent implementation.
|
||||
- Avoid speculative abstraction: remove components, adapters, or interfaces that exist only for hypothetical future scope.
|
||||
- If a section is too vague for tasks to reference directly, rewrite it before finalizing the design.
|
||||
|
||||
## Mechanical Checks
|
||||
|
||||
Before applying judgment, verify these mechanically:
|
||||
- **Requirements traceability**: Extract all numeric requirement IDs from `requirements.md`. Scan the design draft for each ID. Report any IDs not found in the design.
|
||||
- **Boundary section populated**: `Boundary Commitments`, `Out of Boundary`, `Allowed Dependencies`, and `Revalidation Triggers` must not be empty or placeholder-only.
|
||||
- **File Structure Plan populated**: The File Structure Plan section must contain concrete file paths (not just "TBD" or empty). Scan for placeholder text in that section.
|
||||
- **Boundary ↔ file structure alignment**: The File Structure Plan must reflect the stated responsibility boundary. If files imply broader ownership than the boundary section claims, report a mismatch.
|
||||
- **No orphan components**: Every component mentioned in the design must appear in the File Structure Plan with a file path. Scan for component names that have no corresponding file entry.
|
||||
|
||||
## Review Loop
|
||||
|
||||
- Run mechanical checks first, then judgment-based review.
|
||||
- If issues are local to the draft, repair the draft and re-run the review gate.
|
||||
- Keep the loop bounded: no more than 2 review-and-repair passes before escalating a real spec gap.
|
||||
- Write `design.md` only after the review gate passes.
|
||||
@@ -0,0 +1,29 @@
|
||||
# Design Synthesis
|
||||
|
||||
After discovery and before writing the design document, apply these three lenses to the collected findings. This step requires the full picture — do not parallelize.
|
||||
|
||||
## 1. Generalization
|
||||
|
||||
Look across all requirements as a group. Identify cases where multiple requirements are variations of the same underlying problem.
|
||||
|
||||
- If feature A is a special case of a more general capability X, design X with an interface that naturally supports A (and potentially B, C later)
|
||||
- Keep the implementation scope to what the current requirements demand — generalize the interface, not the implementation
|
||||
- Record identified generalizations in `research.md` under Design Decisions
|
||||
|
||||
## 2. Build vs. Adopt
|
||||
|
||||
For each major component in the emerging design, ask: is this problem already solved?
|
||||
|
||||
- Search for established standards (RFCs, protocols), battle-tested libraries, or platform-native capabilities that address the requirement
|
||||
- Prefer adopting existing solutions over building custom ones when they fit the requirements without significant adaptation
|
||||
- If adopting: verify the solution is actively maintained, compatible with the project's stack (check steering), and meets non-functional requirements
|
||||
- If building: document why existing solutions were rejected (capture in `research.md`)
|
||||
|
||||
## 3. Simplification
|
||||
|
||||
For each component and abstraction layer in the emerging design, ask: is this necessary?
|
||||
|
||||
- Remove components that exist "just in case" or for hypothetical future requirements not in the current spec
|
||||
- Flatten unnecessary abstraction layers — if an interface has only one implementation with no foreseeable second, it may not need the indirection
|
||||
- Prefer fewer, cohesive components over many fine-grained ones
|
||||
- The right design is the smallest one that satisfies all requirements and remains extensible at the interface level
|
||||
Reference in New Issue
Block a user