kotlin-backend-conventions

Applies BK-CI Kotlin coding conventions for file structure, naming, null safety, and function design.

2.5k|524|Updated May 29, 2019
One-click install
npx skills add https://github.com/TencentBlueKing/bk-ci --skill kotlin-backend-conventions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-backend-conventions
Source: https://github.com/TencentBlueKing/bk-ci/tree/main/ai/skills/kotlin-backend-conventions
Command: npx skills add https://github.com/TencentBlueKing/bk-ci --skill kotlin-backend-conventions

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

When writing or refactoring Kotlin backend code in the BK-CI project, developers often lack a single source of truth for project-specific style rules, leading to inconsistent formatting, naming, and null-safety practices across the codebase.

Core Features & Use Cases

  • File Structure and Formatting Rules: Enforces UTF-8 encoding, 4-space indentation, 120-character line width, and bans wildcard imports.
  • Naming and Function Design Guidance: Covers package, class, and variable naming, plus guidance on named arguments, early returns, and single-responsibility functions.
  • Null Safety and Project Conventions: Promotes ?. and ?: over !!, immutable collections, and BK-CI-specific practices like avoiding fully-qualified class path calls.
  • Use Case: When refactoring a .kt service file, consult this Skill to verify that long parameter lists use named arguments, imports contain no wildcards, and nullable values are handled idiomatically.

Quick Start

Review this Kotlin file against the BK-CI backend conventions and point out any violations in naming, formatting, or null safety.

Frequently Asked Questions about kotlin-backend-conventions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I apply Kotlin coding conventions in the BK-CI project?

Follow the three reference guides: file structure and imports, naming and function design, and null safety with project practices. Key rules include 4-space indentation, 120-character line width, no wildcard imports, and named arguments for multi-parameter calls.

What naming conventions does BK-CI use for Kotlin code?

Package names are all lowercase without underscores, classes use PascalCase, and functions, properties, and local variables use lowerCamelCase. Boolean values should prefer prefixes like is, has, can, or should.

When should I use named arguments in Kotlin function calls?

Use named arguments when a call has multiple parameters that are easy to confuse, and prefer them when instantiating data classes. This improves readability and reduces maintenance errors compared to positional arguments of the same type.

Does this convention guide cover Spring Boot configuration?

No, it focuses only on Kotlin language-level conventions such as formatting, naming, and null safety. Spring Boot framework usage, backend service layering, and unit testing practices are handled by separate skills.

When is the !! operator acceptable in Kotlin null safety?

The !! operator should only be used when there is a well-justified reason. Prefer safe calls (?.), the Elvis operator (?:), and the type system to express nullability, and use explicit exceptions or result types for failure scenarios.