detailed-design
Skill for detailed design — class diagrams, sequence diagrams, API contracts, database schema design, and error handling strategy.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Detailed Design Skill
Purpose
Translates architecture-level decisions into implementation-ready detailed designs: class structures, interaction flows, API contracts, database schemas, and error handling.
Class Diagram Design
When to Create
- New domain model classes or significant refactoring
- Design patterns being introduced (Strategy, Observer, Factory, etc.)
- Complex service layer with multiple collaborating classes
Design Principles
- Single Responsibility: each class has one reason to change
- Dependency Inversion: depend on abstractions, not concrete classes
- Composition over Inheritance: favor composition for code reuse
- Interface Segregation: prefer small, focused interfaces
Guidelines
- Show relationships clearly: association (-->), composition (*--), aggregation (o--), inheritance (--|>)
- Include visibility modifiers: + public, - private, # protected
- Show method signatures with parameter and return types
- Focus on design intent — show important relationships, not every field
Sequence Diagram Design
When to Create
- Every API endpoint's primary flow (happy path + error paths)
- Complex multi-service interactions
- Asynchronous flows (event-driven, message queue)
Guidelines
- Show both happy path and error paths using
alt/else - Label every message with method name and key parameters
- Show return values on return arrows
- One diagram per use case or API endpoint
- Show database operations explicitly
- Include async patterns where applicable
API Contract Design
Design Rules
-
Resource naming: plural nouns (
/orders,/users), not verbs - HTTP methods: GET (read), POST (create), PUT (full update), PATCH (partial), DELETE
- Status codes: use specific codes (201 Created, 404 Not Found, 422 Unprocessable)
-
Pagination:
page+sizeparams; returntotalElementsandtotalPages - Error format: consistent ErrorResponse with code, message, correlationId, details
- Validation: define constraints in schema (min, max, pattern, required)
-
Versioning: URL path versioning (
/api/v1/) - Examples: include request/response examples for every endpoint
For full OpenAPI template, see reference/openapi-template.md.
Database Schema Design
Process
- Identify entities from domain model
- Map relationships: one-to-one, one-to-many, many-to-many
- Define columns: types, constraints, defaults, indices
- Design indices based on expected query patterns
- Plan migrations with forward and rollback scripts
Rules
- Use UUIDs for primary keys (distributed-system friendly)
- Always include
created_atandupdated_attimestamps - Use CHECK constraints for enums and ranges
- Index based on WHERE clauses and JOIN conditions
- Normalize to 3NF; denormalize for read-heavy patterns
- Version migrations sequentially (V001, V002) with descriptive names
- Every migration must have a corresponding rollback script
Error Handling Design
Exception Hierarchy Pattern
ApplicationException (abstract base)
├── BusinessException (HTTP 422) — domain rule violations
├── ValidationException (HTTP 400) — input validation errors
├── AuthenticationException (HTTP 401)
├── AuthorizationException (HTTP 403)
└── InfrastructureException (HTTP 503) — external service failures
Rules
- Map exceptions to HTTP status codes consistently
- Never expose internal details in error responses
- Use machine-readable error codes (e.g.,
ORDER_NOT_FOUND) - Log full exception server-side with correlation ID
- Return correlation ID in error response for debugging
- Validate at the boundary: validate input in controllers before passing to services
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-03-11
- 索引更新时间
- 2026-03-11
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!