opencode-workflow/skills/design-architecture/SKILL.md

304 lines
12 KiB
Markdown
Raw Normal View History

2026-04-10 09:24:59 +00:00
---
name: design-architecture
2026-04-10 14:39:08 +00:00
description: "Design system architecture based on PRD requirements. The Architect pipeline's core step, producing the single strict output file. References deliverable skills for format details and knowledge contracts for design principles."
2026-04-10 09:24:59 +00:00
---
2026-04-10 11:28:45 +00:00
This skill produces the complete architecture document for a feature, including all required deliverables.
2026-04-10 09:24:59 +00:00
**Announce at start:** "I'm using the design-architecture skill to design the system architecture."
2026-04-10 09:34:54 +00:00
## Primary Input
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
- `docs/prd/{feature}.md` (required)
2026-04-10 09:24:59 +00:00
2026-04-10 09:34:54 +00:00
## Primary Output (STRICT PATH)
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
- `docs/architecture/{feature}.md`
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
This is the **only** file artifact produced by the Architect pipeline. No intermediate files are written to disk. All deliverables — diagrams, schemas, specs, ADRs — must be embedded within this single document.
2026-04-10 09:24:59 +00:00
## Hard Gate
Do NOT start this skill if the PRD has unresolved ambiguities that block architectural decisions. Resolve them with the PM first.
## Process
You MUST complete these steps in order:
2026-04-10 11:28:45 +00:00
1. **Read the PRD** at `docs/prd/{feature}.md` end-to-end to understand all requirements
2026-04-10 09:34:54 +00:00
2. **Apply internal analysis** from the `analyze-prd` step (if performed) to understand which knowledge domains are relevant
3. **Design each architecture section** based on PRD requirements and relevant knowledge domains
2026-04-10 11:28:45 +00:00
4. **Apply knowledge contracts** as needed:
2026-04-10 09:24:59 +00:00
- `system-decomposition` when designing service boundaries
- `api-contract-design` when defining API contracts
- `data-modeling` when designing database schema
- `distributed-system-basics` when dealing with distributed concerns
- `architecture-patterns` when selecting architectural patterns
- `storage-knowledge` when making storage technology decisions
- `async-queue-design` when designing asynchronous workflows
- `error-model-design` when defining error handling
2026-04-10 11:28:45 +00:00
- `security-boundary-design` when defining auth, authorization, tenant isolation
- `consistency-transaction-design` when defining consistency model, idempotency, saga
- `integration-boundary-design` when defining external API integration patterns
- `observability-design` when defining logs, metrics, traces, alerts, SLOs
- `migration-rollout-design` when defining rollout strategy, feature flags, rollback
2026-04-10 14:39:08 +00:00
5. **Apply deliverable skills** for format requirements when producing sections:
- `generate_mermaid_diagram` when producing the Mermaid Diagrams section
- `design_database_schema` when producing the Database Schema section
- `generate_openapi_spec` when producing the API Contract section
- `write_adr` when producing the ADR section
- `evaluate_tech_stack` when producing the Technology Stack subsection
2026-04-10 11:28:45 +00:00
6. **Ensure traceability** — every architectural decision must trace back to at least one PRD requirement
2026-04-10 14:39:08 +00:00
7. **Verify completeness** — all 18 required sections are present and substantive
2026-04-10 11:28:45 +00:00
8. **Write the architecture document** to `docs/architecture/{feature}.md`
## Architect Behavior Principles
Apply these principles in priority order when making design decisions:
1. **High Availability** — Design for fault tolerance and resilience over perfect consistency
2. **Scalability** — Design for horizontal scaling over vertical scaling
3. **Stateless First** — Prefer stateless services; externalize state to databases or caches
4. **API First** — Define contracts before implementation; APIs are the primary interface
5. **Event Driven First** — Prefer event-driven communication for cross-service coordination
6. **Async First** — Prefer asynchronous processing for non-realtime operations
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
## Anti-Placeholder Rule
Examples in deliverable skills and this template are illustrative only. Do not reuse placeholder components, fields, endpoints, or schemas unless explicitly required by the PRD. Every element in the architecture document must be grounded in actual requirements, not copied from examples.
2026-04-10 09:24:59 +00:00
## Architecture Document Template
2026-04-10 14:39:08 +00:00
The following 18 sections are required. If a section is not applicable, write `N/A` with a brief reason. Each section states what it must contain and which deliverable skill to reference for format details.
2026-04-10 09:24:59 +00:00
```markdown
# Architecture: {Feature Name}
2026-04-10 11:28:45 +00:00
## Overview
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
High-level description of the system architecture. Map every major PRD requirement to an architectural component. Summarize the system's purpose, key design decisions, and architectural style.
2026-04-10 09:24:59 +00:00
### Requirement Traceability
| PRD Requirement | Architectural Component |
|----------------|------------------------|
| ... | ... |
2026-04-10 11:28:45 +00:00
## System Architecture
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
Describe the complete system architecture including all services, databases, message queues, caches, and external integrations. Show how components are organized and how they communicate.
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
### Technology Stack
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
Reference `evaluate_tech_stack` deliverable skill for evaluation format.
2026-04-10 11:28:45 +00:00
| Layer | Technology | Justification |
|-------|-----------|---------------|
2026-04-10 14:39:08 +00:00
| ... | ... | ... |
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
If the feature has no backend component, write `N/A` with a brief reason.
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
### Component Architecture
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
Describe each major component, its responsibility, and how it fits into the overall system.
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
## Service Boundaries
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
Define service boundaries with clear responsibilities.
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
For each service or module:
- Name and single responsibility
- Owned data
- Communication patterns with other services (sync, async, event-driven)
- Potential coupling points and mitigation
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
### Communication Matrix
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
| From | To | Pattern | Protocol | Purpose |
|------|----|---------|----------|---------|
| ... | ... | ... | ... | ... |
## Data Flow
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
Describe how data moves through the system end-to-end. Include request lifecycle, background job processing, event propagation, and data transformation steps.
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
## Database Schema
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
Reference `design_database_schema` deliverable skill for table definition format, index format, partition key format, and relationship format.
2026-04-10 11:28:45 +00:00
2026-04-10 14:39:08 +00:00
Define all tables with field names, types, constraints, indexes, partition keys, and relationships. Include denormalization strategy and migration strategy where applicable.
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
If the feature requires no database changes, write `N/A` with a brief reason.
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
## API Contract
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
Reference `generate_openapi_spec` deliverable skill for endpoint definition format, error code format, idempotency format, and pagination format.
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
Define all API endpoints with method, path, request/response schemas, error codes, idempotency, and pagination. Include an endpoint catalog and endpoint details.
2026-04-10 11:28:45 +00:00
## Async / Queue Design
2026-04-10 09:24:59 +00:00
Define asynchronous operations and their behavior. If the feature has no asynchronous requirements, write `N/A` with a brief reason.
For each async operation:
- Operation name and trigger
- Queue or event topic
- Producer and consumer
- Retry policy (max retries, backoff, DLQ)
- Ordering guarantees
- Timeout and cancellation behavior
2026-04-10 11:28:45 +00:00
## Consistency Model
2026-04-10 14:39:08 +00:00
Define the consistency guarantees of the system. Reference `consistency-transaction-design` knowledge contract for design principles.
2026-04-10 11:28:45 +00:00
- Strong vs eventual consistency per data domain
2026-04-10 14:39:08 +00:00
- Idempotency design per idempotent operation
- Deduplication and retry strategy
2026-04-10 11:28:45 +00:00
- Outbox pattern usage (when applicable)
- Saga / compensation patterns (when applicable)
If the feature has no consistency or idempotency requirements, write `N/A` with a brief reason.
2026-04-10 09:24:59 +00:00
## Error Model
Define error handling strategy across the system.
2026-04-10 14:39:08 +00:00
- Error categories (client errors, server errors, business rule violations, timeout, cascading failure)
- Error propagation strategy (fail-fast, graceful degradation, circuit breaker)
- Error response format
- PRD edge case mapping
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
## Security Boundaries
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
Define security architecture. Reference `security-boundary-design` knowledge contract for design principles.
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
- Authentication mechanism
2026-04-10 14:39:08 +00:00
- Authorization model
2026-04-10 11:28:45 +00:00
- Service identity and service-to-service auth
- Token propagation strategy
2026-04-10 14:39:08 +00:00
- Tenant isolation
- Secret management
- Audit logging
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
If the feature has no security implications, write `N/A` with a brief reason.
2026-04-10 09:24:59 +00:00
2026-04-10 11:28:45 +00:00
## Integration Boundaries
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
Define all integrations with external systems. Reference `integration-boundary-design` knowledge contract for design principles.
2026-04-10 11:28:45 +00:00
2026-04-10 14:39:08 +00:00
For each external system:
- Integration pattern (API, webhook, polling, event)
2026-04-10 11:28:45 +00:00
- Rate limits and quotas
2026-04-10 14:39:08 +00:00
- Failure modes and fallback
2026-04-10 11:28:45 +00:00
- Retry strategy
2026-04-10 14:39:08 +00:00
- Data contract
- Authentication
2026-04-10 11:28:45 +00:00
If the feature has no external integrations, write `N/A` with a brief reason.
## Observability
2026-04-10 14:39:08 +00:00
Define observability strategy. Reference `observability-design` knowledge contract for design principles.
2026-04-10 11:28:45 +00:00
2026-04-10 14:39:08 +00:00
- Logs: levels, format, aggregation
- Metrics: business metrics, system metrics, naming conventions
- Traces: distributed tracing, correlation ID, span boundaries
- Alerts: conditions, thresholds, routing
- SLOs: availability, latency, error budget
2026-04-10 11:28:45 +00:00
## Scaling Strategy
Define how the system scales based on NFRs.
2026-04-10 14:39:08 +00:00
- Horizontal scaling approach
- Database scaling (read replicas, sharding, partitioning)
- Cache scaling
- Queue scaling
- Auto-scaling policies
2026-04-10 11:28:45 +00:00
- Bottleneck analysis
## Non-Functional Requirements
Document all NFRs from the PRD and how the architecture addresses each one.
| NFR | Requirement | Architectural Decision | Verification Method |
|-----|-------------|----------------------|---------------------|
2026-04-10 14:39:08 +00:00
| ... | ... | ... | ... |
2026-04-10 11:28:45 +00:00
## Mermaid Diagrams
2026-04-10 14:39:08 +00:00
Reference `generate_mermaid_diagram` deliverable skill for diagram format and guidelines.
2026-04-10 11:28:45 +00:00
2026-04-10 14:39:08 +00:00
Produce at minimum:
- 1 System Architecture Diagram
- 1 Sequence Diagram
- 1 Data Flow Diagram
2026-04-10 11:28:45 +00:00
Additional diagrams as needed (event flow, state machine, etc.).
## ADR
2026-04-10 14:39:08 +00:00
Reference `write_adr` deliverable skill for ADR format.
2026-04-10 09:24:59 +00:00
2026-04-10 14:39:08 +00:00
Document significant architectural decisions. Each ADR must include Context, Decision, Consequences, and Alternatives. Minimum 1 ADR.
2026-04-10 11:28:45 +00:00
## Risks
| Risk | Impact | Likelihood | Mitigation |
|------|--------|-----------|------------|
| ... | High/Medium/Low | High/Medium/Low | ... |
## Open Questions
2026-04-10 14:39:08 +00:00
List any unresolved questions that need PM or Engineering input.
2026-04-10 11:28:45 +00:00
1. ...
2. ...
2026-04-10 09:24:59 +00:00
```
## Completeness Check
Before finalizing the architecture document, verify:
2026-04-10 11:28:45 +00:00
1. All 18 required sections are present (or explicitly marked N/A with reason)
2. Every PRD functional requirement is traced to at least one architectural component
3. Every PRD NFR is traced to at least one architectural decision
2026-04-10 14:39:08 +00:00
4. Every architecture section that is not N/A has substantive content grounded in PRD requirements
2026-04-10 09:24:59 +00:00
5. All API endpoints map to PRD functional requirements
6. All DB tables map to data requirements from functional requirements or NFRs
7. All async flows map to PRD requirements
8. All error handling strategies map to PRD edge cases
2026-04-10 11:28:45 +00:00
9. ADRs exist for all significant decisions (minimum 1)
10. At least 3 Mermaid diagrams are present (system, sequence, data flow)
2026-04-10 14:39:08 +00:00
11. No placeholder content reused from examples — all content must be grounded in actual requirements
2026-04-10 09:24:59 +00:00
## Guardrails
This is a pure Architecture skill.
Do:
- Design system structure and boundaries
- Define API contracts and data models
2026-04-10 11:28:45 +00:00
- Define error handling, retry, and consistency strategies
- Define security boundaries and integration patterns
2026-04-10 14:39:08 +00:00
- Reference deliverable skills for format requirements of specific sections
- Reference knowledge contracts for design principles
2026-04-10 09:24:59 +00:00
- Ensure traceability to PRD requirements
2026-04-10 14:39:08 +00:00
- Ensure all content is grounded in actual PRD requirements, not placeholder examples
2026-04-10 09:24:59 +00:00
Do not:
- Change PRD requirements or scope
- Create task breakdowns, milestones, or deliverables
- Write test cases or test plans
- Write implementation code or pseudocode
- Choose specific libraries or frameworks at the implementation level
- Prescribe code patterns, class structures, or function-level logic
2026-04-10 11:28:45 +00:00
- Produce any file artifact other than `docs/architecture/{feature}.md`
2026-04-10 14:39:08 +00:00
- Reuse placeholder components, fields, endpoints, or schemas from examples unless explicitly required by the PRD
2026-04-10 09:24:59 +00:00
The Architect defines HOW the system is structured.
The Engineering defines HOW the code is written.
## Transition
2026-04-10 14:39:08 +00:00
After completing the architecture document, invoke `challenge-architecture` to audit and review the architecture.