Agent skill
ktlint
Format and lint Kotlin using ktlint; set up or update ktlint in Gradle/CLI/CI, configure .editorconfig, and troubleshoot ktlint failures or formatting changes in Kotlin projects.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/ktlint
SKILL.md
Ktlint
Use this skill to format and lint Kotlin code with ktlint, and to set up or maintain ktlint tooling in a project.
Quick start
- Detect how the project runs ktlint (Gradle tasks vs CLI).
- Run ktlint check or format on the target paths.
- Fix or configure rules via existing project config (usually
.editorconfig).
Determine the integration
- Prefer existing build tasks: look for
ktlintCheck/ktlintFormat(or custom ktlint tasks) in Gradle. - If there are no build tasks, fall back to the
ktlintCLI if it is installed. - Before changing setup, search for existing config and automation:
.editorconfigand anyktlintsectionsbuild.gradle/build.gradle.kts- CI files (GitHub Actions, GitLab CI, etc.)
- pre-commit hooks
Common tasks
Run ktlint check (no changes)
- Prefer Gradle: run the project’s ktlint check task.
- Otherwise use the CLI to lint specific files or directories.
Run ktlint format (apply fixes)
- Prefer Gradle: run the project’s ktlint format task.
- Otherwise use the CLI formatter.
Format only specific files
- Pass explicit paths to the task or CLI.
- If using Gradle, check whether the plugin supports path filters or separate source sets.
Configure rules
- Modify the project’s existing
.editorconfigrather than inventing a new location. - Keep changes minimal and explain why a rule is enabled/disabled.
- If the project pins a ktlint version, follow its supported rule IDs and config keys.
Add ktlint to a Gradle project
- Prefer the project’s existing Kotlin/Gradle conventions (versions catalog, buildSrc, convention plugins).
- Add the plugin and tasks in the standard place for that repository.
- Wire ktlint into CI the same way other quality checks are run.
Troubleshoot failures
- Identify the ktlint version and whether it is coming from Gradle or CLI.
- Reproduce locally with the same task or command used in CI.
- If a rule suddenly fails, check recent ktlint or rule-set updates in the project.
Scripts
scripts/ktlint.shprovides a lightweight wrapper to run check/format using Gradle tasks if present, or fall back to thektlintCLI.
Notes
- Avoid changing rule configuration unless the user asks; prefer formatting fixes.
- When updating setup, keep changes minimal and aligned with existing project conventions.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?