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.
Provide a set of Interactive Cursor rules for Java that help software engineers in their daily work.
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.
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
.
Review the following sequence diagram to understand the technical details.
According to the documentation from Google Gemini, Anthropic Claude & OpenAI ChatGPT, a prompt should be structured in the following way:
- Metadata
- Role
- Context (Optional)
- Goal
- Constraints (Optional)
- Examples (Optional)
- Output format (Optional)
- Safeguards (Optional)
With this structure in mind, the project uses an XML Schema to define the way that all System prompts are generated for Cursor AI. If you are interested, you could review the Schema.
Read the generated list of cursor rules for Java here. The set of cursor rules covers aspects like Build system based on Maven, Design, Coding, Testing, Refactoring, Performance with JMeter & Profiling with Async Profiler.
If you are interested in getting the benefits of these cursor rules for Java, you can manually download this repository and copy the './cursor' folder and paste it into your repository, download the rules from the last release in zip format or just 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:
Cursor Rule | Description | Prompt | Notes |
---|---|---|---|
100-java-checklist-guide | Create a comprehensive step-by-step guide for using cursor rules for Java | Create an java development guide using the cursor rule @100-java-checklist-guide |
This cursor rule is applied automatically without any interaction with the Software engineer. |
Type the following prompt in the cursor chat:
Create an java development guide using the cursor rule @100-java-checklist-guide
From the beginning, you need to know that results provided by the interaction with the different Cursor rules
are not deterministic due to the models' nature, but this fact should not be considered in a negative way because you could see it as an opportunity to run the rules multiple times and see how models offer additional points of view about your repository, package, or class in different ways to improve your Java software.
The modern rules are designed with safety in mind so any change proposed by the models will be verified:
<safeguards>
<safeguards-list>
<safeguards-item>verify changes with the command: `mvn validate` or `./mvnw validate`</safeguards-item>
</safeguards-list>
</safeguards>
And changes later will be reviewed by the Software engineer.
The rules were tested with the following examples:
- General: Maven Java project
- Microservices: Spring Boot application
- Microservices: Spring Boot application with Memory leaks
- Microservices: Spring Boot application with Performance Bottleneck
- Microservices: Spring Boot application with JMeter Load Testing
- Microservices: Quarkus application
- Serverless: AWS Lambda
- Serverless: Azure Function
Here, you can see Scenarios using the Cursor rules for Java
- Review the CHANGELOG for further details
Java uses JEPs as the vehicle to describe the new features to be added in the language. The repository continuously reviews which JEPs could improve any of the cursor rules present in this repository.
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.
- https://www.cursor.com/
- https://docs.cursor.com/context/rules
- https://docs.cursor.com/context/@-symbols/@-cursor-rules
- https://openjdk.org/jeps/0
- https://github.com/jabrena/101-cursor
- https://github.com/jabrena/pml
- https://github.com/jabrena/cursor-rules-methodology
- https://github.com/jabrena/cursor-rules-agile
- https://github.com/jabrena/cursor-rules-java
- https://github.com/jabrena/cursor-rules-spring-boot
- https://github.com/jabrena/cursor-rules-examples
- https://github.com/jabrena/cursor-rules-sandbox
- https://github.com/jabrena/plantuml-to-png-cli
- https://github.com/jabrena/setup-cli
- https://github.com/jabrena/jbang-catalog
Powered by Cursor