Skip to content

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.

License

Notifications You must be signed in to change notification settings

jabrena/cursor-rules-java

Repository files navigation

Cursor AI rules for Java

Stargazers over time

Stargazers over time

CI Builds

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.

Goal

Provide a set of Interactive Cursor rules for Java that help software engineers in their daily work.

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 by design to mitigate potential negative performance impact on communications with The Cursor platform.

Review the following sequence diagram to understand the technical details.

What is the structure of a System prompt?

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.

Cursor Rules

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.

Getting started

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

Limitations & Opportunities

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.

Safety guards

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.

Examples

The rules were tested with the following examples:

Here, you can see Scenarios using the Cursor rules for Java

Architectural decision records, ADR

Changelog

Java JEPS from Java 8

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.

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

Powered by Cursor

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.

Topics

Resources

License

Stars

Watchers

Forks