/everything-claude-code:kotlin-buildfrom everything-claude-code
Diagnoses and fixes Kotlin/Gradle build errors, compiler warnings, and dependency issues by running diagnostics, parsing errors, and applying incremental, verified fixes one at a time.
Ships in everything-claude-code. Installing the plugin adds it to Claude Code.
此命令调用 kotlin-build-resolver 智能体,以最小化变更增量修复 Kotlin 构建错误。
./gradlew build、detekt、ktlintCheck在以下情况下使用 /kotlin-build:
./gradlew build 失败并报错./gradlew detekt 报告违规# 主要构建检查
./gradlew build 2>&1
# 静态分析
./gradlew detekt 2>&1 || echo "detekt not configured"
./gradlew ktlintCheck 2>&1 || echo "ktlint not configured"
# 依赖问题
./gradlew dependencies --configuration runtimeClasspath 2>&1 | head -100
# 当缓存或依赖元数据可疑时,可选深度刷新
./gradlew build --refresh-dependencies
用户:/kotlin-build
智能体:
# Kotlin 构建修复
## 初始诊断
```bash
$ ./gradlew build
e: src/main/kotlin/com/example/service/UserService.kt:25:15 Unresolved reference: UserRepository
e: src/main/kotlin/com/example/routes/UserRoutes.kt:42:9 Type mismatch: inferred type is String but Int was expected
e: src/main/kotlin/com/example/routes/UserRoutes.kt:58:5 'when' expression must be exhaustive
```
发现错误:3 个
## 修复 1:未解析的引用
文件:src/main/kotlin/com/example/service/UserService.kt:25
错误:Unresolved reference: UserRepository
原因:缺少导入
```kotlin
// 添加了导入
import com.example.repository.UserRepository
```
```bash
$ ./gradlew build
# 剩余 2 个错误
```
## 修复 2:类型不匹配
文件:src/main/kotlin/com/example/routes/UserRoutes.kt:42
错误:Type mismatch: inferred type is String but Int was expected
```kotlin
// 修改前
val count = call.parameters["count"]
// 修改后
val count = call.parameters["count"]?.toIntOrNull()
?: return@get call.respond(HttpStatusCode.BadRequest, "Invalid count")
```
```bash
$ ./gradlew build
# 剩余 1 个错误
```
## 修复 3:when 语句不完整
文件:src/main/kotlin/com/example/routes/UserRoutes.kt:58
错误:'when' expression must be exhaustive
```kotlin
// 添加了缺失的分支
when (user.role) {
Role.ADMIN -> handleAdmin(user)
Role.USER -> handleUser(user)
Role.MODERATOR -> handleModerator(user) // 已添加
}
```
```bash
$ ./gradlew build
# 构建成功!
```
## 最终验证
```bash
$ ./gradlew detekt
# 无问题
$ ./gradlew test
# 所有测试通过
```
## 总结
| 指标 | 数量 |
|------|------|
| 修复的构建错误 | 3 |
| 修复的 Detekt 问题 | 0 |
| 修改的文件 | 2 |
| 剩余问题 | 0 |
构建状态:PASS: SUCCESS
| 错误 | 典型修复 |
|---|---|
Unresolved reference: X | 添加导入或依赖 |
Type mismatch | 修复类型转换或赋值 |
'when' must be exhaustive | 添加缺失的 sealed class 分支 |
Suspend function can only be called from coroutine | 添加 suspend 修饰符 |
Smart cast impossible | 使用局部 val 或 let |
None of the following candidates is applicable | 修复参数类型 |
Could not resolve dependency | 修复版本或添加仓库 |
智能体将在以下情况停止并报告:
/kotlin-test - 构建成功后运行测试/kotlin-review - 审查代码质量verification-loop 技能 - 完整验证循环agents/kotlin-build-resolver.mdskills/kotlin-patterns/What the command file sets; muted values are Claude Code's defaults
kotlin, gradle, build-errors, detekt, ktlint, compiler-warnings
7-day visitors to each command page
Claude Code refuses to install this plugin
.claude-plugin/plugin.json: agents: Invalid string: must end with ".md"
Checked against Claude Code 2.1.332's install rules. The listing below is what the repository ships; Claude Code cannot install it as published.
97 commands in this plugin
/asideAside 命令回答一个快速的旁注问题,而不中断或丢失当前任务的上下文。回答后自动恢复工作。/auto-update自动更新拉取最新的 ECC 仓库变更并重新安装当前管理的目标。/build-fix构建和修复 (Build and Fix)检测项目构建系统并通过最小安全更改增量修复构建/类型错误。/checkpointCheckpoint 命令在运行验证检查后创建、验证或列出工作流检查点。/code-review代码审查 (Code Review)代码审查 — 本地未提交的更改或 GitHub PR(传入 PR 编号/URL 进入 PR 模式)/cost-report成本报告从 cost-tracker SQLite 数据库生成本地 Claude Code 成本报告。Other plugins' commands for the same job