跳到正文
cccskills
免费在 GitHub 公开中文介绍

code-style

按 IntelliJ 项目规范编写或审查 Kotlin 和 Java 代码,涵盖语言选择、格式、密封类型、线程注解及控制流异常处理。

原文查看原文说明

Apply IntelliJ Kotlin and Java code style when writing or reviewing.

JetBrains/intellij-community星标 20,685(GitHub 20,685 + cccskills 0)

实测评分 未实测

查看安装方法

适用场景

  • 按 IntelliJ 规范编写 Kotlin
  • 审查 Java 代码
  • 检查异常处理和密封类型分支

中文介绍

功能

本技能会按照 IntelliJ 编码指南,协助编写和审查 Kotlin 与 Java 代码。新建文件默认使用 Kotlin;已有 Java 文件通常继续使用 Java,除非任务需要转换。它会检查扩展函数、数据类和空安全等 Kotlin 惯用写法,并要求为实验性 API 添加 @ApiStatus.Experimental。检查格式时会参考适用的 .editorconfig。

技能也会检查密封类型和枚举是否使用穷尽式 when 分支、线程要求注解的默认值,以及异常处理规则。捕获 Throwable 或 Exception 时,应先调用 rethrowControlFlowException,避免将控制流异常写入日志。它还涵盖构建脚本中的 Kotlin 规范。

适用场景

在 IntelliJ 代码库中添加功能、审查现有代码或调整格式时,可以用它核对语言选择、密封类型分支、线程注解和异常处理是否符合项目约定。

使用示例

  • “请按 IntelliJ 规范审查这段 Kotlin 代码。”
  • “请检查异常处理和密封类型分支是否有问题。”

注意事项

创建或审查 Java 代码前,请先阅读 references/modern-java.md。处理构建脚本时,请另行参考指定的 Kotlin 风格建议。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

文档检查

AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。

安全性发送数据、删除文件、执行命令等是否有说明
A良好未提及外部发送或破坏性操作,并说明了异常处理规则。
安装难易度所需工具和 API 密钥是否少且有说明
A良好无需 API 密钥或额外工具,并指定了 Java 参考文档。

不计入评分。 由 AI(OpenAI Codex)于 2026年10月28日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(3)

  • SKILL.md3.2 KB
  • references/modern-java.LICENSE.txt1.0 KB
  • references/modern-java.md8.2 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

<!-- Generated by community/.ai/render-guides.mjs; edit community/.agents/skills/code-style/SKILL.md -->

Code Style

Follow the IntelliJ Coding Guidelines with these IntelliJ-specific rules.

Language

  • Use Kotlin for new files unless the user explicitly requests Java.
  • Keep existing Java files in Java unless the task requires a language conversion.
  • Before writing or reviewing Java, read Modern Java.
  • Use idiomatic Kotlin: extension functions, data classes, null safety
  • Mark experimental APIs with @ApiStatus.Experimental
  • Build scripts Kotlin style: Follow community/platform/build-scripts/kotlin-style-recommendations.md for build-scripts code:
    • Use @JvmField for internal data class fields
    • Use .put()/.get() instead of [] operator
    • Use explicit HashMap/HashSet/LinkedHashMap instead of mutableMapOf()/mutableSetOf()

Sealed hierarchies

  • Before you list several subtypes in a when branch, an is check, or a catch, open the declaration of the type.
  • If a common supertype covers exactly those subtypes, use the supertype. It stays correct when someone adds a new subtype.
  • Check the value of a sealed type or an enum with an exhaustive when. Do not use an is check, an as? cast, an == comparison, or else. In Eel and IJent code, this is a rule, also for a private type. See community/platform/eel/docs/api/exhaustive-when.md.

Formatting

  • Read every applicable .editorconfig before you review or change formatting.
  • Use the effective .editorconfig value for each setting. If no file defines a setting, use these defaults:
    • Indentation: 2 spaces (4 for Go files)
    • Line length: 140 characters max
    • Braces: else, catch, and finally on new lines
  • Only in /rustrover directory you must always use standard Kotlin formatting rules with 4 spaces indentation.

Threading annotations

  • When you add @RequiresEdt, @RequiresBackgroundThread, @RequiresReadLock, @RequiresWriteLock, or @RequiresReadLockAbsence, do not pass generateAssertion. Keep the default value unless the user explicitly requests a different one.
  • Never write generateAssertion = false /* IJPL-115548 */. It is a legacy mass-migration marker. Do not copy it from existing code.
  • Set generateAssertion = false only when the user explicitly requests it, or when the runtime assertion is known to fail. State the reason in a comment.
@RequiresEdt
fun updateUi() { ... }

Error handling

  • In a catch block for Throwable or Exception, call com.intellij.diagnostic.rethrowControlFlowException(e) first. It rethrows a control flow exception, such as CancellationException. A control flow exception must never reach the log.
  • Do not catch or rethrow CancellationException explicitly, and do not test the exception type by hand.
  • In Java, static-import com.intellij.diagnostic.ControlFlowExceptionsKt.rethrowControlFlowException.
  • Do not use the deprecated com.intellij.openapi.diagnostic.rethrowControlFlowException.
try {
  doWork()
}
catch (e: Throwable) {
  rethrowControlFlowException(e)
  LOG.error(e)
}

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

actions

免费有简介

实现或修改 IntelliJ `AnAction`,并在 `plugin.xml` 中注册。将显示名称和说明写入消息资源文件,按需设置图标,并通过事件协程作用域启动挂起任务,避免同步处理阻塞 IDE。

  • 为 IDE 菜单添加操作
  • 修改操作注册或图标
  • 整理操作名称和说明
JetBrains/intellij-community2.1万2026年10月29日 更新

bazel-test-migration

免费有简介

将 IntelliJ JPS 测试模块迁移到 Bazel,并排查仅在 Bazel 中出现的失败。根据症状检查依赖、插件、测试数据和 runfiles,重新生成并验证目标。

  • 将 JPS 测试模块迁移到 Bazel
  • 排查仅在 Bazel 中失败的测试
  • 检查测试依赖和数据配置
JetBrains/intellij-community2.1万2026年10月29日 更新

commits

免费有简介

本指南帮助您按 IntelliJ 项目规则拆分更改并撰写提交信息:有工单时使用编号和变更说明,无工单时使用标签与子系统名,并在需要时说明原因和决定。

  • 按项目格式编写带工单号的提交信息
  • 整理测试或文档提交并选择合适标签
  • 按规则修改已有提交信息
JetBrains/intellij-community2.1万2026年10月29日 更新

使用多个 Python 类型检查器比较代码片段或文件的类型推断和报错判断,并汇总各工具的结论、耗时与诊断信息,可保存为 Markdown 报告。

  • 比较不同检查器的类型推断
  • 确认代码是否会被判为类型错误
  • 查看多个工具的诊断差异
JetBrains/intellij-community2.1万2026年10月29日 更新

整理 Compose Desktop 界面中的状态和副作用,让可组合函数负责绘制,由展示器或协调器处理应用决策。了解状态归属、Effect、可复用组件接口、延迟列表键、动画和性能,适用于单项界面修改。

  • 分离界面绘制与展示器决策
  • 整理界面状态的归属
  • 检查 Effect 键和协程用法
JetBrains/intellij-community2.1万2026年10月29日 更新

compose-ui-audit

免费有简介

审查 Compose Desktop 界面代码的架构和运行时问题,检查状态管理、副作用、协程、延迟列表、动画与重组,并按优先级列出发现。

  • 审查 Compose 界面的状态管理
  • 检查副作用和协程用法
  • 调查延迟列表或重组性能
JetBrains/intellij-community2.1万2026年10月29日 更新

查看 JetBrains 的全部技能

报告此技能的问题