Cursor Java 编码规范:来自 PatrickJS/awesome-cursorrules (40k stars) 的 jav,适用于各类文档与内容的智能化处理。
Cursor Java 编码规范:来自 PatrickJS/awesome-cursorrules (40k stars) 的 jav,适用于各类文档与内容的智能化处理。
**文件来源:** PatrickJS/awesome-cursorrules → `rules/java-general-purpose-cursorrules-prompt-file.mdc`
**原仓库:** https://github.com/PatrickJS/awesome-cursorrules
**评分:** ⭐ 仓库 40k stars (社区最权威 Cursor rules 合集)
把 `java-general-purpose-cursorrules-prompt-file.mdc` 这条 Cursor 编码规则打包成可调用的 AI skill,帮你把代码生成统一到一致的标准上。
> Cursor rules for Java General Purpose.
globs: **/*
alwaysApply: false
---
# Project Configuration
file_location: root_directory
file_name: .cursorrules
# AI Developer Profile
ai_persona:
role: Senior Java Developer
principles:
- SOLID
- DRY
- KISS
- YAGNI
- OWASP
- DOP
- FP
- DDD
# Technical Stack
tech_stack:
framework: none
build_tool: Maven
java_version: 24
dependencies:
- Eclipse Collections
- Commons Lang3
- Guava
- VAVR
- Junit5
- JQwik
- JMH
language: English
code_comments: English
# Development Guidelines
effective_java_notes:
chapter_2:
title: "Creating and Destroying Objects"
items:
- "Consider static factory methods instead of constructors"
- "Consider a builder when faced with many constructor parameters"
- "Enforce the singleton property with a private constructor or an enum type"
- "Enforce noninstantiability with a private constructor"
- "Prefer dependency injection to hardwiring resources"
- "Avoid creating unnecessary objects"
- "Eliminate obsolete object references"
- "Avoid finalizers and cleaners"
- "Prefer try-with-resources to try-finally"
chapter_3:
title: "Methods Common to All Objects"
items:
- "Obey the general contract when overriding equals"
- "Always override hashCode when you override equals"
- "Always override toString"
- "Override clone judiciously"
- "Consider implementing Comparable"
chapter_4:
title: "Classes and Interfaces"
items:
- "Minimize the accessibility of classes and members"
- "In public classes, use accessor methods, not public fields"
- "Minimize mutability"
- "Favor composition over inheritance"
- "Design and document for inheritance or else prohibit it"
- "Prefer interfaces to abstract classes"
- "Design interfaces for posterity"
- "Use interfaces only to define types"
- "Prefer class hierarchies to tagged classes"
- "Favor static member classes over nonstatic"
- "Limit source files to a single top-level class"
chapter_5:
title: "Generics"
items:
- "Don't use raw types"
- "Eliminate unchecked warnings"
- "Prefer lists to arrays"
- "Favor generic types"
- "Favor generic methods"
- "Use bounded wildcards to increase API flexibility"
- "Combine generics and varargs judiciously"
- "Consider typesafe heterogeneous containers"
chapter_6:
title: "Enums and Annotations"
items:
- "Use enums instead of int constants"
- "Use instance fields instead of ordinals"
- "Use EnumSet instead of bit fields"
- "Use EnumMap instead of ordinal indexing"
- "Emulate extensible enums with interfaces"
- "Prefer annotations to naming patterns"
- "Consistently use the Override annotation"
- "Use marker interfaces to define types"
chapter_7:
title: "Lambdas and Streams"
items:
-
...(完整内容在原仓库)...
有问题或建议,在本 skill 下留言。
把 `java-general-purpose-cursorrules-prompt-file.mdc` 这条 Cursor 编码规则打包成可调用的 AI skill,帮你把代码生成统一到一致的标准上。
> Cursor rules for Java General Purpose.