| name | detailed-design |
| description | Skill for detailed design โ class diagrams, sequence diagrams, API contracts, database schema design, and error handling strategy. |
| stage | design |
| type | delivery-skill |
| version | 3.0 |
| category | delivery |
| scope | platform |
| tags | ["methodology","design","api","database","uml"] |
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 + size params; return totalElements and totalPages
- 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_at and updated_at timestamps
- 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