Cursor AI Rules
Written during the Spring Boot era. Still valid: the global collaboration rules (sdlcwai.mdc), Docker base image policy, git-safety confirmation rule, Docusaurus docs rule, and the instructions for adding new .mdc rule files. Outdated: the Java/Spring Clean Code rules, DDD patterns in Java, and all code generation prompts (Spring Boot services, JUnit 5, Javadoc, OpenAPI annotations) — these do not apply to the current Node.js/Fastify backend.
This project includes custom rules for Cursor AI to ensure consistent, high-quality code generation.
Table of Contents
Installing Cursor
Download Cursor IDE
Download Cursor for your platform:
- Cursor Downloads - macOS, Windows, Linux
Install Cursor CLI (Optional)
The Cursor CLI enables terminal-based AI assistance:
macOS / Linux:
curl https://cursor.com/install -fsS | bash
Windows (PowerShell):
irm 'https://cursor.com/install?win32=true' | iex
Verify installation:
agent --version
See the CLI Installation Guide for full details.
Overview
Rules are stored in .cursor/rules/ and automatically applied based on file patterns. They guide the AI to follow project conventions, clean code principles, and security best practices.
| Rule File | Applies To | Purpose |
|---|---|---|
sdlcwai.mdc | All files | Global collaboration and quality standards |
java-spring-clean-code.mdc | *.java | Clean Code, SOLID, DDD, Spring Boot patterns |
code-review-formal.mdc | *.java, *.kt | Structured code review format |
docker.mdc | Dockerfile, docker-compose*.yml | Container configuration rules |
docusaurus-docs.mdc | docs-site/docs/*.md | Documentation page structure and TOC |
git-safety.mdc | All files | Require y/n confirmation before commit/push |
Active Rules
Global Rules (sdlcwai.mdc)
Applied to all files in the repository:
- Collaboration: Avoid reverting edits you didn't author; prefer incremental diffs
- Coding Workflow: Review context before editing; run tests after changes
- Style: Preserve formatting; keep functions small and composable
- Communication: Explain why before what; highlight uncertainties
Java/Spring Rules (java-spring-clean-code.mdc)
These rules apply to the original Spring Boot backend, which has been replaced by Node.js/Fastify.
Applied to all Java files:
Clean Code (Martin/Bloch):
- Intention-revealing names
- Functions: 5-20 lines, ≤3 parameters
- Single Responsibility Principle
- Never return null; use
Optional<T>
Spring Boot Patterns:
- Constructor injection only (no
@Autowiredon fields) @Transactionalat service layer- DTOs for API contracts, not entities
- Externalize all configuration
DDD Patterns (Evans):
- Entities for identity-based objects
- Value Objects for immutable data (
Money,AccountId) - Repositories as collection-like interfaces
- Layer separation: domain → application → infrastructure
Docker Rules (docker.mdc)
- Never change base images without explicit approval
- Base images are chosen for security, performance, and compatibility
Useful Prompts
The prompts below were written for Spring Boot. They do not apply to the current Node.js/Fastify backend.
Clean Code
Review this code for clean code violations
Refactor this method to follow Single Responsibility Principle
Suggest better names for these variables/methods
Code Generation
Create a Spring Boot service for [feature] following DDD patterns
Add a REST endpoint for [resource] with proper validation
Generate unit tests for this service using JUnit 5
Refactoring
Extract this logic into a value object
Split this class by responsibility
Replace these primitives with a domain type
Documentation
Add Javadoc to public methods in this class
Document this API endpoint with OpenAPI annotations
Code Review
Request a formal code review with severity-tagged findings:
Formal code review of this file
Review Output Format
The AI will produce a structured review with:
- Severity levels: P0 (Critical) through P4 (Info)
- Categories: SEC (Security), SOLID, CLEAN, DDD, SPRING, PERF, TEST, DOC
- Actionable findings with file locations and fix recommendations
- Overall assessment: APPROVED, APPROVED WITH COMMENTS, CHANGES REQUESTED, or BLOCKED
Severity Guide
| Priority | Label | Action Required |
|---|---|---|
| P0 | CRITICAL | Must fix before merge |
| P1 | HIGH | Should fix before merge |
| P2 | MEDIUM | Fix in current sprint |
| P3 | LOW | Fix when convenient |
| P4 | INFO | Optional consideration |
Example Review Request
Perform a formal code review of the AccountService class,
focusing on SOLID principles and Spring best practices
Adding New Rules
Create a new .mdc file in .cursor/rules/:
---
name: Rule Name
description: What this rule enforces
path: "**/*.ext" # or globs: for multiple patterns
---
# Rule Title
## Section
- Bullet points for quick parsing
- Keep under 120 characters per line
Rules are automatically loaded by Cursor based on the path or globs pattern.