java

A set of coding and engineering guidelines for modern Java, including Java 17 and 21. It covers project structure, dependencies, naming, errors, testing, security, databases, APIs, deployment, and code quality.

In plain words
What is it for?
Use it when building or reviewing Java applications and services. It helps shape package structure, dependency choices, error handling, concurrency, transactions, configuration, tests, and API design.
Why use it?
It gives a shared way to write and review Java code, reducing inconsistent decisions and common maintenance, security, and delivery problems.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/mywand/cusrsor-do-it/java
Clone the repo
git clone --depth 1 https://github.com/mywand/cusrsor-do-it

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 10,544 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.10544
Opus 5 $0.00000 $0.05272
Sonnet 5 $0.00000 $0.02109
Haiku 4.5 $0.00000 $0.01054

Measured yesterday against content hash 902ebf2f8e85, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

java scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/languages/java.mdc · 993 lines

How it starts

The opening of the file, as written. The whole thing — 993 lines — stays where its author put it; the contents beside it link to each section on GitHub.

最近更新: 2025-10-17 最近审阅: 2025-10-17

Java 编码与工程规约(增强版)

核心目标:提升代码一致性、可维护性、可观测性与交付质量

技术基线:覆盖现代 Java (17/21 LTS) 特性,提供"可执行 / 可验证"规则

文件编码:所有源代码文件统一使用 UTF-8 编码,无 BOM

适用范围:本规约与 coding-standards.mdc / quality.mdc / security.mdc 协同使用;冲突时以本文件中"专用 Java 细则"优先

目录

  1. 语言与版本策略
  2. 项目结构
  3. 依赖与制品管理
  4. 命名与基本编码
  5. 语言特性与风格
  6. 面向对象与设计
  7. 异常与错误码
  8. 日志与可观测性
  9. 并发与线程模型
  10. 性能与资源优化
  11. 测试策略
  12. 安全与合规
  13. 序列化与 JSON
  14. 构建与质量守护
  15. 配置与环境管理
  16. 数据访问与持久化
  17. API 设计与契约
  18. 版本控制与分支
  19. 代码质量度量
  20. 事务管理
  21. 工具类与通用组件
  22. 缓存策略
  23. 部署与运行
  24. 扩展与演进建议

(章节已重新编号,去除重复与缺失;测试/性能/安全/配置的重复内容已合并。)

使用指南

快速导航

按场景使用

  • 新项目启动:重点阅读 1-5章(语言特性、项目结构、编码规范)
  • API 开发:重点阅读 17-18章(API 设计、版本控制)
  • 数据层开发:重点阅读 16、20章(数据访问、事务管理)
  • 测试编写:重点阅读 11章(测试策略、测试规范)
  • 性能优化:重点阅读 10、22章(性能优化、缓存策略)
  • 安全加固:重点阅读 12章(安全规范、合规要求)
  • 日志监控:重点阅读 8章(日志规范、监控指标)
  • 部署运维:重点阅读 23章(部署规范、运行时保护)

Read the full file on GitHub · 993 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 993 lines · 0 tokens per session scan A 902ebf2f8e85

Subscribe to this mod's changes

java is a cursor rule published in the GitHub repository mywand/cusrsor-do-it (2 stars, last pushed 7mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 10,544 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.