kotlin-style
Installation
SKILL.md
1. Class Layout & Order
To maintain readability, all Kotlin classes MUST follow this declaration order:
- Properties and Initializer Blocks: Grouped by visibility and purpose.
- Secondary Constructors: Following the primary constructor.
- Public/Internal Functions: The entry points and public API of the class.
- Private Functions: Helper methods and implementation details. These MUST be situated after all public functions to keep the API at the top.
- Companion Object: MUST be situated at the very end of the class, just before the closing brace.
The Step-down Rule
Organize functions so that they can be read as a narrative from top to bottom. A high-level function should be followed by the lower-level private functions it calls. If a private function is shared by multiple public ones, place it at the very bottom of the function block.
2. Naming Conventions
- Classes/Objects: PascalCase (e.g.,
RemoteConfigMapper). - Functions/Properties: lowerCamelCase (e.g.,
mapToThreshold). - Descriptive over Brief: Prioritize readability over brevity. Avoid abbreviations that obscure meaning. Property names MUST be descriptive and start with a lowercase letter (e.g., use
mediuminstead ofm,extraSmallinstead ofxs). - Constants: UPPER_SNAKE_CASE (e.g.,
DEFAULT_THRESHOLD).