java-contract SKILL.md skillA

java-contract from baixuanzhu/skills is an agent skill: a SKILL.md folder an AI agent loads when a task calls for it.

Install it, pinned
mdr add baixuanzhu/skills/java-contract@v2.7.1

Pins v2.7.1 in mdr.lock. Pin the fingerprint instead.

Audit grade
A, 17 of 17 checks passed
Kind
SKILL.md skill
Repository
baixuanzhu/skills
Path
plugins/java-standard/skills/java-contract/SKILL.md
Versions recorded
5
Latest version
v2.7.1, committed Oct 23, 2026
First version recorded
Oct 23, 2026
Size
9,105 bytes
Repository stars
3
License
MIT

为项目建立并执行 Java 编码契约:把需求没说明的边界决策(无结果 / null 参数 / 集合里的 null / 重复 key / 结果顺序与可变性 / 非法参数 / 静态还是实例 / 重复到达)落成 .claude/rules/java-contract.md, 动手前先读、写完编译验证;审存量代码时按失效模式七组追问。 在编写、修改、审查 Java 代码时使用;也用于决定某个方法该返回 null 还是空集合、 空集合聚合该返回 0 还是 Optional、为项目定下统一的边界处理规则。 触发信号:要为新方法定返回契约、项目里还没有 .claude/rules/java-contract.md、 put 与 putIfAbsent 混用、写操作可能被重复投递或重试、 cannot find symbol 且 symbol 是 var 或 JDK 9+ 方法名。 不适用:第三方库 API 用法与选型、Spring 分层与工程组织、测试框架、静态检查规则集、前端代码。.

Collected from public GitHub. Every version is saved exactly as it was and never changes. Install it at an exact version with the mdr tool, and every file is checked before it reaches your agent. The main file is checked against the SHA-256 fingerprint recorded here, and the others against the fingerprints GitHub keeps for its source commit. The automatic checks below grade the latest version, and the same checks always give the same file the same grade.

What the file says

# Java 编码契约

模型对 JDK 写法的判断已经够准(实测语法陷阱 3/3、7/7 全部避开),API 字典类内容不必再写。真正的分歧在
**需求文档不写、几个实现会给几种答案**的地方。本技能只做三件事:把这些决策定下来、动手前读一遍、写完验证。

## 两条原则

1. **契约先落盘,用前先读。** 第一次在项目里写 Java 时,把八项边界决策写进 `.claude/rules/java-contract.md`;
   之后每次动 `.java` 前先读它。它**不会自动进上下文**——实测里一个被要求不浏览其他文件的 agent
   虽然有这份契约,仍按自己的判断把该保留的记录丢了。不落盘的决策等于没定,落了盘没人读同样等于没定。
   **读不到它时**(文件不存在、只能看片段、子代理拿不到仓库),按本技能默认值写,并在回复里点明
   「按 java-contract 默认,未读到项目契约」。分歧摆在明面上,比静默按自己的判断做要好。
2. **写完即编译。** 目标版本从 `pom.xml` 的 `maven.compiler.release` / `<source>` / `sourceCompatibility` /
   `java.toolchain` 读,四者都读不到才问一次。一个类写完就 `mvn -q compile`(Gradle:`./gradlew compileJava`)。
   版本不匹配在这一步暴露,比背着规则表写 200 行再让 CI 拦下来便宜。

## 第一步:读项目

三件事都在仓库里,做完再动笔:

| 读什么 | 得到什么 |
|---|---|
| `pom.xml` / `build.gradle` | 目标 JDK;`<modules>` 说明是否多模块 |
| `.claude/rules/java-contract.md` | 已有契约。**读到才生效**,读到就遵守、不重新提议 |
| 同包下 2~3 个同类方法 | 既有惯例:返回 `Optional` 还是裸值、抛异常还是错误码 |

**项目惯例与下表默认冲突时,惯例优先。** 契约的作用是消除分歧,不是推行新风格。

## 契约八项

需求没说明时按下表取;项目已有不同做法就记进契约文件,不在代码里另搞一套。

| 分歧点 | 默认 |
|---|---|
| 无结果 | 单条 → `Optional`;列表 → 空集合;聚合值看 0 是否有业务含义(求和 → 0,平均 / 最大 → `Optional`)。不返回 null |
…

Read the whole file at its exact version.

How to install

The exact contents, by fingerprint
mdr add baixuanzhu/skills/java-contract@sha256:2689c806935d0d02

The line at the top of this page pins the label v2.7.1, which is what most people want. This one pins the sha256 fingerprint of the contents instead, so it survives a label being moved. Either way the exact version is written to mdr.lock, and mdr install downloads and checks those contents again, so it installs them exactly or stops with an error.

Badge

mdr badge

[![mdr](https://markdownregistry.com/badge/art_sbts2mkc63mnkeso.svg)](https://markdownregistry.com/a/art_sbts2mkc63mnkeso)

2 badge image fetches in 30 days. What the badge shows.

Versions

The registry has recorded 5 versions of this file, all committed on Oct 23, 2026.

versioncommittedcommitsizeaudit
v2.7.1 latest2026-10-23 efa870e 9,105 BA view · diff
v2.7.02026-10-23 5a88dd9 9,105 BA view · diff
v2.6.12026-10-23 625cef0 9,105 BA view · diff
v2.6.02026-10-23 163262d 9,242 BA view · diff
v2.5.12026-10-23 2deb1fb 8,783 BA view

Audit of the latest version

A  17 of 17 checks passed. Fixed automatic checks with no AI involved, so the same checks give the same answer every run.
  • pass: Frontmatter block present
  • pass: Frontmatter declares a name
  • pass: Frontmatter declares a description
  • pass: Size between 200 bytes and 200 KB (9105 bytes)
  • pass: No zero-width or bidi control characters
  • pass: No instruction hidden inside an HTML comment
  • pass: No link to an exfiltration or paste host
  • pass: No credential-shaped string
  • pass: No instruction to send local credentials anywhere
  • pass: No text hidden with inline styles
  • pass: No prompt-injection phrasing
  • pass: No curl or wget piped into a shell
  • pass: No recursive delete of root, home or parent
  • pass: No instruction to read or print local credentials
  • pass: No base64 blob over 200 characters
  • pass: No link to a raw IP address
  • pass: No script tag

Source

GitHub

baixuanzhu/skills · 3 stars · license MIT · pushed 2026-11-03 · branch main

API

GET https://markdownregistry.com/api/v1/artifacts/art_sbts2mkc63mnkeso
GET https://markdownregistry.com/api/v1/resolve?ref=baixuanzhu/skills/java-contract
GET https://markdownregistry.com/api/v1/blob/2689c806935d0d0298f3733b1e987e64055b1f2b61a5f7a8a38962869525f220

Your AI assistant does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.

Guides: the SKILL.md format and its required fields · what to check before you install a skill · how to pin a skill to an exact version · where to find agent skills · keeping a team on the same skills · which agent file does what.

More from baixuanzhu/skills

AGENTS.md AGENTS.md file
baixuanzhu/skills · AGENTS.md
git:20261027.6a2cc9a · audit A · 3 stars
CLAUDE.md CLAUDE.md file
baixuanzhu/skills · CLAUDE.md
git:20260822.070edce · audit B · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.4.0/snapshots/v3.3.0/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.3.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.4.0/snapshots/v3.4.0/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.4.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.4.0/snapshots/version1/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.3.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.4.0/snapshots/version2/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.4.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.4.0/snapshots/versionA/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.4.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.4.0/snapshots/versionB/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.3.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.5.0/snapshots/v3.4.1/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.4.1 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.5.0/snapshots/v3.5.0/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.5.0 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.5.0/snapshots/version1/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.4.1 · audit A · 3 stars
java-coding-guide-pro SKILL.md skill
baixuanzhu/skills · eval/java-coding-guide-pro/darwin-validation-v3.5.0/snapshots/version2/SKILL.md · Java 编码规范与避坑助手。在编写、修改、重构或审查任何 Java / Spring Boot 代码时使用本技能—— 无论用户是否提到编码规范或具体工具库(Java coding / code review / refactoring…
v3.5.0 · audit A · 3 stars

Every file in baixuanzhu/skills

Other files named java-contract

java-contract SKILL.md skill
baixuanzhu/skills · skills/java-contract/SKILL.md · 为项目建立并执行 Java 编码契约:把需求没说明的边界决策(无结果 / null 参数 / 集合里的 null / 重复 key / 结果顺序与可变性 / 非法参数 / 静态还是实例 / 重复到达)落成…
v2.7.1 · audit A · 3 stars

Browse by kind, by grade A, or by owner.