swe-programming-kotlin
Kotlin coding standards from authoritative docs/explanation/software-engineering/programming-languages/kotlin/ documentation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Kotlin coding standards from authoritative docs/explanation/software-engineering/programming-languages/kotlin/ documentation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
AI agent development standards including frontmatter structure, naming conventions, tool access patterns, model selection, and reference documentation structure
Comprehensive project planning standards for plans/ directory including folder structure (ideas/, backlog/, in-progress/, done/), stage-aware naming convention (done uses YYYY-MM-DD__identifier/; backlog and in-progress use identifier/ with no date prefix), five-document file organization (README.md, brd.md, prd.md, tech-docs.md, delivery.md for multi-file default; single README.md for trivially-small single-file exception), BRD/PRD content-placement rules, Gherkin acceptance criteria, and the mandatory structured multiple-choice grilling gates (pre-write and post-write) for resolving design decisions with the user. Essential for creating structured, executable project plans.
Trunk Based Development workflow - all development on main branch with small frequent commits, minimal branching, and continuous integration. Covers when branches are justified (exceptional cases only), commit patterns, feature flag usage for incomplete work, environment branch rules (deployment only), and AI agent default behavior (the repo-wide default delivery mode is `worktree-to-pr` -- a short-lived plan branch in a disposable worktree pushed to a draft PR; direct push to main remains available as an explicit selection). Essential for understanding repository git workflow and keeping branches short-lived
Workflow pattern standards for creating multi-agent orchestrations including YAML frontmatter (name, description, tags, status, agents, parameters), execution phases (sequential/parallel/conditional), agent coordination patterns, and Gherkin success criteria. Essential for defining reusable, validated workflow processes.
Common software development workflow patterns shared across all language developer agents
Three-stage content quality workflow pattern (Maker creates, Checker validates, Fixer remediates) with detailed execution workflows. Use when working with content quality workflows, validation processes, audit reports, or implementing maker/checker/fixer agent roles.
| name | swe-programming-kotlin |
| description | Kotlin coding standards from authoritative docs/explanation/software-engineering/programming-languages/kotlin/ documentation |
Progressive disclosure of Kotlin coding standards for agents writing Kotlin code.
Authoritative Source: docs/explanation/software-engineering/programming-languages/kotlin/README.md
Usage: Auto-loaded for agents when writing Kotlin code. Provides quick reference to idioms, best practices, and antipatterns.
IMPORTANT: This skill provides demo-specific style guides, not educational tutorials.
You MUST understand Kotlin fundamentals before using these standards. Complete the demo Kotlin learning path first:
What this skill covers: demo naming conventions, framework choices, repository-specific patterns, how to apply Kotlin knowledge in THIS codebase.
What this skill does NOT cover: Kotlin syntax, language fundamentals, generic patterns (those are in crud-fs-ts-nextjs).
Classes/Types: PascalCase - ZakatCalculator, MurabahaContract
Functions/Variables: camelCase - calculateZakat(), totalAmount
Constants: UPPER_SNAKE_CASE - MAX_NISAB_THRESHOLD, ZAKAT_RATE
Files: PascalCase matching primary class - ZakatCalculator.kt
// CORRECT: Safe call operator
val length = text?.length ?: 0
// CORRECT: Smart cast after null check
if (contract != null) {
println(contract.id) // Smart cast to non-null
}
// WRONG: Unsafe assertion without justification
val value = nullableValue!! // Crashes if null
// CORRECT: Structured concurrency with coroutineScope
suspend fun processPayments(payments: List<Payment>): List<Result<BigDecimal>> =
coroutineScope {
payments.map { payment ->
async { processPayment(payment) }
}.awaitAll()
}
// CORRECT: Flow for reactive streams
fun zakatCalculations(): Flow<ZakatResult> = flow {
repository.getAllContracts().forEach { contract ->
emit(calculateZakat(contract))
}
}
// WRONG: Blocking inside coroutine
suspend fun badExample() {
Thread.sleep(1000) // WRONG: blocks thread
delay(1000) // CORRECT: suspends coroutine
}
// CORRECT: Data class for value objects
data class ZakatCalculation(
val wealth: BigDecimal,
val nisab: BigDecimal,
val amount: BigDecimal,
val calculationDate: LocalDate = LocalDate.now()
)
// CORRECT: Sealed class for domain states
sealed class ZakatResult {
data class Due(val amount: BigDecimal) : ZakatResult()
data object BelowNisab : ZakatResult()
data class Error(val message: String) : ZakatResult()
}
// CORRECT: Exhaustive when expression
fun handleResult(result: ZakatResult): String = when (result) {
is ZakatResult.Due -> "Zakat due: ${result.amount}"
is ZakatResult.BelowNisab -> "Below nisab threshold"
is ZakatResult.Error -> "Error: ${result.message}"
}
// CORRECT: Result<T> for fallible operations
suspend fun calculateZakat(wealth: BigDecimal, nisab: BigDecimal): Result<BigDecimal> =
runCatching {
require(wealth >= BigDecimal.ZERO) { "Wealth cannot be negative" }
if (wealth >= nisab) wealth.multiply(BigDecimal("0.025"))
else BigDecimal.ZERO
}
// CORRECT: Sealed error hierarchy
sealed class ZakatError {
data class ValidationError(val field: String, val message: String) : ZakatError()
data class CalculationError(val reason: String) : ZakatError()
}
// CORRECT: MockK for Kotlin-native mocking
@Test
fun `calculateZakat returns 2_5 percent when above nisab`() = runTest {
val mockRepo = mockk<ZakatRepository>()
coEvery { mockRepo.getNisabThreshold() } returns BigDecimal("5000")
val calculator = ZakatCalculator(mockRepo)
val result = calculator.calculate(BigDecimal("10000"))
assertThat(result.getOrThrow()).isEqualByComparingTo("250.00")
coVerify { mockRepo.getNisabThreshold() }
}
Authoritative Index: docs/explanation/software-engineering/programming-languages/kotlin/README.md