Skip to content

chubenli/cursor-rules-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cursor AI rules for Java

Stargazers over time

Stargazers over time

Motivation

Modern Java IDEs, such as Cursor AI, provide ways to customize how the Agent model behaves using reusable and scoped instructions. In cursor, the way to do it is named Cursor rule and you could see it as a System prompt if you use a generic term. This repository provides a collection of Cursor rules designed for Java development.

What is a System prompt?

A system prompt is a set of instructions given to an AI model that defines how it should behave, what role it should take on, and what guidelines it should follow when responding to users. Think of it as the "operating manual" that shapes the AI's personality, capabilities, and boundaries.

How to use the Cursor rules?

Using the Cursor rules is straightforward: simply drag and drop the cursor rule that you need into the chat textbox where you are typing your User prompt.

⚠️ Currently, the cursor rules are released with the manual scope on purpose by design to mitigate potential negative performance impact in communications with The Cursor platform.

Cursor Rules

Build system rules (Maven)

Cursor Rule Description Prompt Notes
110-java-maven-best-practices Maven Best Practices Help me to review the pom.xml following the best practices for dependency management and directory structure use the cursor rule @110-java-maven-best-practices Add in the context the pom.xml which you want to generate the documentation
111-java-maven-deps-and-plugins Maven Dependencies & Plugins Can you improve the pom.xml using the cursor rule @111-java-maven-deps-and-plugins Add in the context the pom.xml which you want to generate the documentation. Conversational approach
112-java-maven-documentation Maven Documentation Generate developer documentation with essential Maven commands using @112-java-maven-documentation Add in the context the pom.xml which you want to generate the documentation

Design rules

Cursor Rule Description Prompt Notes
121-java-object-oriented-design Object Oriented Design Review my code for object-oriented design using the cursor rule @121-java-object-oriented-design Add in the context a package to improve the design
122-java-type-design Type Design Help me improve my type design using the cursor rule @122-java-type-design Add in the context a package to improve the design

Coding rules

Cursor Rule Description Prompt Notes
123-java-general-guidelines General Java Guidelines Review my code for general Java best practices using the cursor rule @123-java-general-guidelines
124-java-secure-coding Secure Java Coding Check my code for security issues using the cursor rule @124-java-secure-coding
125-java-concurrency Concurrency Review my code for concurrency best practices using the cursor rule @125-java-concurrency
126-java-logging Logging Guidelines Help me improve logging using the cursor rule @126-java-logging

Testing rules

Cursor Rule Description Prompt Notes
131-java-unit-testing Unit Testing Can improve the unit tests using the cursor rule @131-java-unit-testing Add in the context a Test Class or the package

Refactoring rules

Cursor Rule Description Prompt Notes
141-java-refactoring-with-modern-features Add Modern Java Features Refactor my code to use modern Java features using the cursor rule @141-java-refactoring-with-modern-features
142-java-functional-programming Functional Programming Refactor my code to use functional programming using the cursor rule @142-java-functional-programming
143-java-data-oriented-programming Data Oriented Programming Refactor my code to use data oriented programming using the cursor rule @143-java-data-oriented-programming

Profiling rules

Activity Description Prompt Notes
151-java-profiling-detect Measure problems My Java application has performance issues - help me set up comprehensive profiling process using @151-java-profiling-detect.mdc and use the location YOUR-DEVELOPMENT/profiler Replace YOUR-DEVELOPMENT with your actual development path. Example: examples/spring-boot-memory-leak-demo/profiler
152-java-profiling-analyze Analyze results Analyze the results located in YOUR-DEVELOPMENT/profiler and use the cursor rule @152-java-profiling-analyze Replace YOUR-DEVELOPMENT with your actual development path. Example: examples/spring-boot-memory-leak-demo/profiler
- Code Refactoring Can you apply the solutions from @profiling-solutions-yyyymmdd.md in @/info to mitigate bottlenecks Make a refactoring with the notes from the analysis
154-java-profiling-compare Analyze results Review if the problems was solved with last refactoring using the reports located in @/results with the cursor rule 154-java-profiling-compare.mdc Put in the context the folder with the results

Getting started

If you are interested in getting the benefits from these cursor rules, you can manually download this repository and copy the './cursor' folder and paste it into your repository, or delegate this task to a specific command-line tool based on Jbang:

sdk install jbang
# Add cursor rules for Java in ./cursor/rules
jbang --fresh setup@jabrena init --cursor https://github.com/jabrena/cursor-rules-java

Once you have installed the cursor rules:

Phase Role Cursor Rule Description
Getting Started All Create Java Development Guide Cursor rule designed to help the user when using the whole set of cursor rules for Java in an easy way

Type the following prompt in the cursor chat:

Create an java development guide using the cursor rule @100-java-checklist-guide

Changelog

Examples

The rules was tested with the following examples:

Java JEPS from Java 8

Java use JEPS as the vehicle to describe the new features to be added in the language. The repository review in a continuous way what JEPS could be improved any of the cursor rules present in this repository.

What is the structure of a Cursor rule?

Review the template for details.

Contribute

If you have new ideas to improve any of the current Cursor rules or add a new one, please fork the repo and send a PR.

References

Cursor rules ecosystem

About

Modern Java IDEs, such as Cursor AI, provide ways to customize how the `Agent model` behaves using reusable and scoped instructions. In cursor, the way to do it is named `Cursor rule` and you could see it as a `System prompt` if you use a generic term. This repository provides a collection of Cursor rules designed for Java development.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors