The power of Cursor rules in Java Enterprise development

Juan Antonio Breña Moral

Stenographic Figure, Jackson Pollock (1943)
Museum of Modern Art (MoMA)
Abstract expressionism

Who I am

Juan Antonio Breña Moral
Software Engineering Manager @ Capital One, C1

Twitter | Github | LinkedIn
"Make it work, make it right, make it fast."
- Kent Beck

"Lead me, follow me, or get out of my way.",
"Pressure makes diamonds."
- George S. Patton Jr.
Source: Leavitt's Alignment Model (1965) >> People, Process and Technology Framework

Agenda (30 min)

  • Introduction
  • WH Questions
  • Demo
  • Where is works?
  • References
  • Q&A

Introduction

Software Development workflow has evolved with the raise of AI tools enhancements.

WH Questions

about System prompts

What is a Prompt?

A prompt is an instruction, question, or input given to an AI system to generate a response. It's essentially how you communicate with AI to get it to do what you want.

Example:


                            Can you create a JMH benchmark
                            in order to know what is the best implementation?
                        

What is a Prompt?

A prompt could be enahanced with the help of a system prompt or a context.

What is a System prompt?

A system prompt is a set of instructions given to an AI model that defines how it should behave. Think of it as the "operating manual" that shapes the AI's personality, capabilities, and boundaries.

What is a System prompt?

A system prompt can include the following elements:

Role Context Goal
Constraints Instructions Examples
Output format Safeguards Metadata

Valid for:
Anthropic Claude Sonnet, OpenAI ChatGPT, Google Gemini & xAI Grok.

What is a System prompt?

Examples:

128-java-generics.md
131-java-unit-testing.md
2003-agile-create-user-story.mdc
2006-adr-create-functional-requirements-for-rest-api-development.mdc

Why use System prompts?

System prompts can help Engineering teams reduce ambiguity in the way that models answer their questions while increasing the homogeneity and consistency of results across different interactions and team members.

When use System prompts?


Source: XP Core practices

How to use System prompts?

Lets see with a Live demo.

Demo

Goal: Implement Result Type prototype in Java in the development to avoid Java exceptions propagation.

Demo

Step 1: Create a Result Type based on a User prompt

User prompt:


                            Create an Result type in java
                        

Demo

Step 2: Refactor the first implementation taking ideas from Kotlin

User prompt:


                            Evolve the first implementation of Result Type
                            taking ideas from Kotlin:
                            https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-result/
                        

Demo

Step 3: Refactor the second implementation using a System prompt

User prompt:


                            Refactor the second implementation
                            using the cursor rule @128-java-generics from the url:
                            https://raw.githubusercontent.com/jabrena/cursor-rules-java/refs/heads/main/.cursor/rules/128-java-generics.md
                            and not make any question
                        

Demo

Step 4: Verify results


                            Explain why the third version is better than the second one
                            and the second one is better from the first one
                            Use a table to explain the benefits between all 3 versions
                        

Where is works?

System prompts works in main Java IDEs/CLI tools:


Cursor

Cursor CLI

Claude Code

GitHub Copilot

JetBrains Junie

References

🙏 🙏 🙏

Thanks