detailed-design
Skill for detailed design — class diagrams, sequence diagrams, API contracts, database schema design, and error handling strategy.
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
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
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-03-11
- Index updated
- 2026-03-11
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!