From codelens
Use when the user's goal is checking or fixing the style/formatting of existing Kotlin (.kt) code. Triggers: asking whether Kotlin follows its coding conventions or a team style guide; formatting or reformatting a file, directory, or whole project; finding or fixing style violations (indentation, import ordering, wildcard imports, blank lines, trailing commas, max line length); making a ktlint or lint gate pass before a commit/PR or in CI; or diagnosing why a ktlint check is failing. Applies even when "ktlint" isn't named — e.g. "does this Kotlin match the style guide?", "check MyViewModel.kt for style violations," or "auto-format my changed .kt before the PR." Do NOT use for Java or other-language formatting, detekt static analysis / code smells / complexity, writing or generating new Kotlin, navigating or finding Kotlin types, or upgrading ktlint/Gradle versions.
How this skill is triggered — by the user, by Claude, or both
Slash command
/codelens:codelens-kotlin-lintingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill provides Kotlin code style checking and formatting using ktlint.
This skill provides Kotlin code style checking and formatting using ktlint.
Ensure the CodeLens server is running for your project:
codelens start --project /path/to/project
Output: in a terminal, lint check/lint format print human-readable
summaries; pass --json for the structured payload (violations with line/rule
detail), which is also auto-selected when output is piped or captured. Exit
codes are unaffected by the format — lint check exits non-zero when there are
violations either way.
codelens lint check <file-path>
Example:
codelens lint check src/main/kotlin/com/example/MyService.kt
Output:
src/main/kotlin/com/example/MyService.kt
Line 15:1 Missing blank line before declaration (standard:blank-line-before-declaration)
Line 23:5 Unexpected indentation (4) (should be 8) (standard:indent)
Line 45:80 Exceeded max line length (100) (standard:max-line-length)
Found 3 violations in 1 file
codelens lint check
Options:
--pattern <glob> - Filter files by pattern (e.g., **/handlers/**/*.kt)--include-tests - Include test files (excluded by default in some configs)Examples:
# All Kotlin files
codelens lint check
# Only files in specific package
codelens lint check --pattern "**/handlers/**/*.kt"
# Include test files
codelens lint check --include-tests
codelens lint format <file-path>
Applies auto-fixes directly to the file.
Preview changes without modifying files:
codelens lint format <file-path> --dry-run
Output:
Would format: src/main/kotlin/com/example/MyService.kt
--- Before
+++ After
@@ -15,6 +15,7 @@
class MyService {
+
fun process() {
codelens lint format
Options:
--pattern <glob> - Filter files by pattern--include-tests - Include test files--dry-run - Preview changes without applyingExamples:
# Format all Kotlin files
codelens lint format
# Preview project-wide changes
codelens lint format --dry-run
# Format specific directory
codelens lint format --pattern "**/api/**/*.kt"
<file-path>
Line <line>:<column> <message> (<rule-id>)
| Category | Examples |
|---|---|
standard:indent | Indentation issues |
standard:max-line-length | Lines exceeding limit |
standard:no-wildcard-imports | Star imports |
standard:no-unused-imports | Unused imports |
standard:blank-line-before-declaration | Missing blank lines |
standard:trailing-comma | Trailing comma requirements |
| Code | Meaning |
|---|---|
| 0 | No violations found (check) or formatting successful (format) |
| 1 | Violations found (check) or formatting made changes (format) |
Some violations can be auto-fixed, others require manual intervention:
Auto-fixable:
Manual fixes required:
The output indicates which violations are auto-fixable:
Line 15:1 Missing blank line (standard:blank-line-before-declaration) [auto-fix available]
Line 23:100 Line too long (standard:max-line-length) [manual fix required]
# Check changed Kotlin files
codelens lint check $(git diff --name-only --cached -- '*.kt')
# Fail if any violations
codelens lint check || exit 1
# Format all Kotlin files
codelens lint format
# Stage formatted files
git add -u
ktlint uses .editorconfig for configuration. Common settings:
# .editorconfig
[*.kt]
max_line_length = 120
indent_size = 4
insert_final_newline = true
[*.{kt,kts}]
ktlint_code_style = android_studio # or intellij_idea, ktlint_official
--dry-run first to preview changes before formatting--pattern to focus on specific areas during incremental adoption.editorconfig to match team preferencescodelens-jvm-analysis - Find Kotlin classes to lintcodelens-source-lookup - View Kotlin source codenpx claudepluginhub charliek/codelens --plugin codelensProvides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Fetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.