Authula/authula / .agents/skills/services-and-interfaces
services-and-interfaces
UnverifiedDefine and implement services that encapsulate business logic with proper constructor-based dependency injection.
Services & Interface Design
When to use this skill
- Create services that encapsulate business logic
- Implement business operations that delegate to repositories for data access (Database)
- Add authentication or domain-specific features as services
Key principles
- Concrete struct design: Services are defined as interfaces and implemented by concrete structs with the same name lowercase and with a constructor (e.g.,
TodoServiceandtodoServicewithNewTodoServiceconstructor) - Constructor-based injection: Dependencies passed at construction
- Single responsibility: Each service handles one domain concern
- Repository delegation: Services delegate all data access to repositories
- Context-aware: All public methods accept
context.Context - Interface return types: Constructors return interfaces, not concrete types
- Single File Exports: Each service implementation is in its own file. However, all service interfaces are exported from
interfaces.gounder theservices/folder. - Sentinel pass-through: Services delegate data access and pass repository sentinels through unchanged. Callers test them with
errors.Is.
Pattern
Services handle business logic:
- Define interface for service with methods representing business operations
- Implement as concrete struct with repository dependencies
- Constructor function injects all dependencies
- Methods are thin wrappers that validate, transform, and delegate to repositories
- Return interfaces from constructors
Example
See examples/todo_service.go for:
- TodoService interface definition
- todoService implementation with constructor
- Validation and repository delegation patterns
Common mistakes
- Service-to-service direct calls without interfaces
- Putting queries in services (repositories own data access)
- Missing context parameter
- Exporting implementation struct instead of interface
- Not testing with mocks
References
- services/core.go - Core service interfaces
- core/services/user_service.go
- core/services/account_service.go
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |