Domain type design and architectural planning for Go code. Use when planning new features, designing self-validating types, preventing primitive obsession, or when refactoring reveals need for new types. Focuses on vertical slice architecture and type safety.
Plans Go architecture and domain types before coding. Analyzes vertical slice vs horizontal patterns, identifies primitives needing type wrappers, and designs self-validating types with validation in constructors. Use when planning new features or refactoring to prevent primitive obsession.
/plugin marketplace add buzzdan/ai-coding-rules/plugin install go-linter-driven-development@ai-coding-rulesThis skill is limited to using the following tools:
reference.mdReference: See reference.md for complete design principles and examples.
</objective>
<quick_start>
Ready to implement? Use @testing skill for test structure. </quick_start>
<when_to_use>
<architecture_pattern_analysis priority="FIRST_STEP"> Default: Always use vertical slice architecture (feature-first, not layer-first).
Scan codebase structure:
internal/feature/{handler,service,repository,models}.gointernal/{handlers,services,domain}/feature.go<decision_flow>
internal/[new-feature]/docs/architecture/vertical-slice-migration.md, implement new feature as first vertical sliceAlways ask user approval with options:
If migration needed, create/update docs/architecture/vertical-slice-migration.md:
# Vertical Slice Migration Plan
## Current State: [horizontal/mixed]
## Target: Vertical slices in internal/[feature]/
## Strategy: New features vertical, migrate existing incrementally
## Progress: [x] [new-feature] (this PR), [ ] existing features
See reference.md section #3 for detailed patterns. </architecture_pattern_analysis>
<understand_domain>
<identify_core_types> Ask for each concept:
If yes to any → Consider creating a type </identify_core_types>
<design_self_validating_types> For each type:
// Type definition
type TypeName underlyingType
// Validating constructor
func NewTypeName(input underlyingType) (TypeName, error) {
// Validate input
if /* validation fails */ {
return zero, errors.New("why it failed")
}
return TypeName(input), nil
}
// Methods on type (if behavior needed)
func (t TypeName) SomeMethod() result {
// Type-specific logic
}
</design_self_validating_types>
<plan_package_structure>
Good structure:
user/
├── user.go # Domain types
├── service.go # Business logic
├── repository.go # Persistence
└── handler.go # HTTP/API
Bad structure:
domain/user.go
services/user_service.go
repository/user_repository.go
</plan_package_structure>
<design_orchestrating_types> For types that coordinate others:
type Service struct {
repo Repository // private
notifier Notifier // private
}
func NewService(repo Repository, notifier Notifier) (*Service, error) {
if repo == nil {
return nil, errors.New("repo required")
}
if notifier == nil {
return nil, errors.New("notifier required")
}
return &Service{
repo: repo,
notifier: notifier,
}, nil
}
// Methods can trust fields are valid
func (s *Service) DoSomething() error {
// No nil checks needed
return s.repo.Save(...)
}
</design_orchestrating_types>
<review_against_principles> Check design against (see reference.md):
<output_format> After design phase:
DESIGN PLAN
Feature: [Feature Name]
Core Domain Types:
- UserID (string) - Self-validating, prevents empty IDs
- Email (string) - Self-validating, RFC 5322 validation
- Age (int) - Self-validating, range 0-150
Orchestrating Types:
- UserService - Coordinates user operations
Dependencies: Repository, Notifier
Methods: CreateUser, GetUser, UpdateUser
Package Structure:
user/
├── user.go # UserID, Email, Age, User
├── service.go # UserService
├── repository.go # Repository interface + implementations
├── notifier.go # Notifier interface + implementations
└── handler.go # HTTP handlers
Design Decisions:
- UserID is custom type to prevent passing empty/invalid IDs
- Email validation centralized in NewEmail constructor
- Vertical slice keeps all user logic in one package
- Repository as interface allows multiple backends (Postgres, in-memory for tests)
Integration Points:
- Consumed by: HTTP API (/users endpoints)
- Depends on: Database, Email service
- Events: UserCreated event published after creation
Next Steps:
1. Create types with validating constructors
2. Write unit tests for each type
3. Implement UserService
4. Write integration tests
Ready to implement? Use @testing skill for test structure.
</output_format>
<key_principles> See reference.md for detailed principles:
<pre_code_review> Before writing code, ask:
Only after satisfactory answers, proceed to implementation.
See reference.md for complete design principles and examples. </pre_code_review>
<success_criteria> Design phase is complete when ALL of the following are true:
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.