jspecify-skill

在 Java 项目中处理可空性与 JSpecify 支持:用于添加 JSpecify 支持、预防 NullPointerException、改进可空性处理;会添加 JSpecify 依赖并配置 Maven 或 Gradle 构建以自动进行可空性检查。

仓库最近推送
GitHub Stars
198
Forks
48
Issues / PRs
2

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "jspecify-skill":https://skillpi.com/zh/skills/deepskill-85343c7d8d34395cf1605238fe7c70bf40bc57df45ce26f939f2e5f31b9acc57。安装前核对上游来源和版本:https://github.com/sivaprasadreddy/sivalabs-agent-skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

在 Java 项目中处理可空性与 JSpecify 支持:用于添加 JSpecify 支持、预防 NullPointerException、改进可空性处理;会添加 JSpecify 依赖并配置 Maven 或 Gradle 构建以自动进行可空性检查。

0 下载

介绍来源: third_party · sivaprasadreddy · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: jspecify-skill
description: >
  Use this skill when asked to perform any of the following actions in a Java project:
    - To add jspecify support
    - To prevent NullPointerExceptions
    - To better handle Nullability

  This skill will add jspecify dependency, configure Maven or Gradle build to automatically use jspecify for checking Nullability issues.

Jspecify provides a set of annotations to explicitly declare the nullness expectations of the Java code.

Add jSpecify support in Maven projects

If you are using Maven, then add the jspecify dependency in pom.xml. In pom.xml, update or add the nullability-maven-plugin, to include the following configuration.

<dependencies>
    <dependency>
        <groupId>org.jspecify</groupId>
        <artifactId>jspecify</artifactId>
        <version>1.0.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>am.ik.maven</groupId>
            <artifactId>nullability-maven-plugin</artifactId>
            <version>0.4.2</version>
            <extensions>true</extensions>
            <configuration>
                <checking>tests</checking>
                <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
                <testOutputDirectory>${project.basedir}/src/test/java</testOutputDirectory>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>configure</goal>
                        <goal>generate-package-info</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Add jSpecify support in Gradle projects

If you are using Gradle, then add the jspecify dependency. In build.gradle or build.gradle.kts, update or add the following jspecify configuration.

plugins {
    id("net.ltgt.errorprone") version "5.1.0"
    id("net.ltgt.nullaway") version "3.1.0"
}

tasks.withType(JavaCompile).configureEach {
    options.errorprone {
        disableAllChecks = true // Other error prone checks are disabled
        error("RequireExplicitNullMarking") // Require @NullMarked or @NullUnmarked on everything
        nullaway {
            error()
        }
    }
    // Keep a JDK 25 baseline
    options.release = 25
}

nullaway {
    onlyNullMarked = true
    jspecifyMode = true
}

dependencies {
    implementation("org.jspecify:jspecify:1.0.0")
    errorprone("com.google.errorprone:error_prone_core:2.50.0")
    errorprone("com.uber.nullaway:nullaway:0.13.7")
}

Add @NullMarked to package-info.java files

In every java package under the application main source code (src/main/java), create package-info.java if not exists already, and add the @NullMarked annotation as follows:

@org.jspecify.annotations.NullMarked
package com.mycompnay.myproject;

If package-info.java file already exists, update the file to add @org.jspecify.annotations.NullMarked annotation. DO NOT REMOVE ANY OTHER EXISTING CODE IN package-info.java FILE.

Verify jSpecify support

If python is installed, after adding the jSpecify support, run scripts/verify_nullmarked.py to check if all non-empty packages has package-info.java file or not.

Migrating an existing codebase from other annotation libraries

If the project already uses another nullability annotation library (JSR-305 / javax, Jakarta, JetBrains, Spring, Android, FindBugs/SpotBugs, Checker Framework, or Eclipse JDT), migrate those annotations to JSpecify before adding @NullMarked. The OpenRewrite MigrateToJSpecify recipe automates the common cases (javax, Jakarta, JetBrains, Micrometer, Micronaut); the rest are a short manual mapping. See references/annotation-migration.md.

Incremental adoption for large codebases

Flipping every package to @NullMarked at once is impractical on a large or legacy codebase. @NullUnmarked lets you enforce NullAway on a growing perimeter while the rest stays untouched. Because the build above enables OnlyNullMarked mode, packages without @NullMarked are simply ignored — so adoption is driven purely by adding markers, one package at a time. Strategies, progress tracking, common NullAway errors, and redundant null-guard removal are in references/incremental-adoption.md.

Kotlin interop (optional)

If the project also has Kotlin sources, the Kotlin compiler (K2) reads JSpecify annotations on Java APIs and surfaces accurate nullability instead of platform types. See references/kotlin-interop.md.

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 针对 Java 项目中防止 NullPointerException 和增强可空性处理的明确需求,提供完整闭环操作
  • 涵盖 Maven 和 Gradle 两种主流构建工具的配置方案,实用性强
触发精准90/100

亮点

  • 触发词精准完整,覆盖添加 JSpecify 支持、防止 NPE、处理可空性等多种变体,边界清晰
结构规范80/100

亮点

  • 结构清晰,分多个 Phase 并提供完整代码示例,frontmatter 完整
执行可靠60/100

待提升项

  • 引用文件缺失 原报告严重程度:重大

    SKILL.md 引用了 scripts/verify_nullmarked.py 文件,但 ZIP 包中未提供,导致验证功能无法执行

    改进建议:请补充 scripts/verify_nullmarked.py 文件,或移除相关引用

  • 引用文件缺失 原报告严重程度:重大

    SKILL.md 引用了 references/annotation-migration.md 文件,但 ZIP 包中未提供,用户无法查阅迁移指南

    改进建议:请补充 references/annotation-migration.md 文件,或移除相关引用

  • 引用文件缺失 原报告严重程度:重大

    SKILL.md 引用了 references/incremental-adoption.md 文件,但 ZIP 包中未提供,用户无法查阅增量采用策略

    改进建议:请补充 references/incremental-adoption.md 文件,或移除相关引用

  • 引用文件缺失 原报告严重程度:重大

    SKILL.md 引用了 references/kotlin-interop.md 文件,但 ZIP 包中未提供,用户无法查阅 Kotlin 互操作说明

    改进建议:请补充 references/kotlin-interop.md 文件,或移除相关引用

亮点

  • 提供了 Maven/Gradle 的具体配置代码,参数明确,工具来源清晰
  • 覆盖了迁移现有注解库和增量采用等合理预期场景
证据可验 (前四项均值)79/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。