About kotlin-best-practices
A Kotlin quick-reference skill for developers working with a codebase that follows the listed conventions. It covers null safety, error handling, ORM usage, transactions, and DTO conversion patterns.
Key features
- 01Avoids non-null assertions and exception-based manager errors
- 02Uses enums instead of hardcoded values
- 03Defines Exposed ORM and soft-delete conventions
- 04Separates replica reads from primary writes
- 05Specifies response DTO conversion patterns
Use cases
- 01Reviewing Kotlin changes against project conventions
- 02Implementing manager and controller error handling
- 03Writing Exposed ORM tables and queries
- 04Structuring transactional multi-table writes
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ c0x12c/ ai-toolkit --skill kotlin-best-practicesAfter installing, type/kotlin-best-practicesin Claude Code to confirm it loaded.
Bundled filescode-patterns.md
Details
From the project READMEKotlin Best Practices — Quick Reference
Null Safety
!! is banned. Use ?., ?:, or null check for smart cast.
See code-patterns.md for all null safety examples.
Either Error Handling
Managers return Either<ClientException, T> -- never throw. Controllers unwrap with .throwOrValue().
See code-patterns.md for manager + controller examples.
Enum Usage
Never hardcode strings when an enum exists. Use EnumName.VALUE.value everywhere.
See code-patterns.md for enum definition and usage patterns.
Exposed ORM Patterns
Extend UUIDTable, use text() not varchar(). Always filter deletedAt.isNull(). Soft delete via timestamp update, never hard delete.
See code-patterns.md for table, query, and soft delete examples.
Transaction Rules
Reads use db.replica, writes use db.primary. Multi-table writes go in one transaction block -- all succeed or all rollback.
See code-patterns.md for transaction examples.
Conversion Pattern
Put companion object { fun from(entity) } inside Response DTOs. Never create separate mapper files.
See code-patterns.md for the full pattern.
What to Avoid
!!-- always use?.,?:, or null check@Suppress-- fix the root cause- Throwing exceptions -- return
Either.left()instead VARCHARin SQL -- useTEXT- Hardcoded strings for enum values
Tablebase class -- useUUIDTable- Field injection -- use constructor injection