kmp-code-quality

Configures Ktlint and Detekt as CI gates enforcing formatting and architecture rules for KMP projects.

2|Updated Jun 6, 2026
One-click install
npx skills add https://github.com/ronjunevaldoz/kmp-agent-skills --skill kmp-code-quality-ronjunevaldoz
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: kmp-code-quality
Source: https://github.com/ronjunevaldoz/kmp-agent-skills/tree/main/skills/kmp-code-quality
Command: npx skills add https://github.com/ronjunevaldoz/kmp-agent-skills --skill kmp-code-quality-ronjunevaldoz

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Kotlin Multiplatform projects lack consistent formatting, accumulate code smells, and suffer silent architecture violations (like :ui importing from :data) that Gradle dependency declarations alone cannot catch. This Skill wires Ktlint and Detekt into a KMP project as enforced CI gates, including the non-obvious KMP source-set wiring that makes Detekt actually analyze commonMain code. ## Core Features & Use Cases - Ktlint Setup: Convention-plugin-based Ktlint configuration with .editorconfig tuning, ktlintFormat locally and ktlintCheck as a CI gate. - Detekt Setup: Full detekt.yml with complexity, performance, naming, and comment rules, plus custom architecture rules (NoComposeInPresenter, NoDataInUi, NoDomainInUi) enforcing the 6-layer module boundary contract. - KMP Source-Set Wiring: Fixes the silent no-op where ./gradlew detekt reports BUILD SUCCESSFUL while scanning nothing on multiplatform modules, by wiring detektMetadataCommonMain and sibling tasks into check. - Conventions References: In-depth guides for Android Kotlin naming conventions, comment/KDoc conventions, scope functions, exception design, and library pattern choices. - Use Case: A team bootstrapping a KMP project runs this Skill to add both linters via build-logic convention plugins, then adds the provided GitHub Actions lint job so every PR fails on formatting or layer violations. ## Quick Start Set up Ktlint and Detekt with architecture rules as CI gates in my Kotlin Multiplatform project using convention plugins.

Frequently Asked Questions about kmp-code-quality

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

FAQPage Schema
How do I set up Detekt in a Kotlin Multiplatform project?▼

Apply the Detekt Gradle plugin via a convention plugin, point it at a root detekt.yml with buildUponDefaultConfig enabled, and wire per-source-set tasks like detektMetadataCommonMain into the check task. The plain detekt task is a silent no-op on KMP modules.

Ktlint vs Detekt — which should I use for Kotlin code quality?▼

Use both, since they solve different problems. Ktlint enforces formatting like indentation, imports, and line length with near-zero config, while Detekt catches code smells and architecture violations such as ui importing from data. Add Ktlint first, then Detekt.

Why does ./gradlew detekt report BUILD SUCCESSFUL but catch nothing?▼

On KMP modules the plain detekt task scans nothing because analysis lives on per-source-set tasks like detektMetadataCommonMain. Wire those tasks into check with an afterEvaluate block in the root build script, then run ./gradlew check instead.

How do I enforce architecture layer rules with Detekt?▼

Define custom rules in detekt.yml under the libraries section, such as NoComposeInPresenter, NoDataInUi, and NoDomainInUi, each scoped with includes patterns and forbidden import lists. These catch import-level coupling that Gradle dependency declarations miss.

Does Ktlint use the same configuration as Android Studio's formatter?▼

No, Android Studio's IDE formatter and Ktlint are separate tools with separate configuration. Set the IDE scheme under Preferences > Editor > Code Style > Kotlin, and configure Ktlint independently through .editorconfig keys like ktlint_code_style.

Why does Detekt fail on TODO comments in my Kotlin code?▼

Detekt's ForbiddenComment rule is active by default and forbids the literal strings TODO:, FIXME:, and STOPSHIP: regardless of format. Add an allowedPatterns regex exempting lines with an issue-tracker URL, or move the reasoning to a commit message.