Skip to main content

Cursor AI Rules

Archive

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

↑ Back to top

Download Cursor IDE

Download Cursor for your platform:

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

↑ Back to top

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 FileApplies ToPurpose
sdlcwai.mdcAll filesGlobal collaboration and quality standards
java-spring-clean-code.mdc*.javaClean Code, SOLID, DDD, Spring Boot patterns
code-review-formal.mdc*.java, *.ktStructured code review format
docker.mdcDockerfile, docker-compose*.ymlContainer configuration rules
docusaurus-docs.mdcdocs-site/docs/*.mdDocumentation page structure and TOC
git-safety.mdcAll filesRequire y/n confirmation before commit/push

Active Rules

↑ Back to top

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)

Outdated

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 @Autowired on fields)
  • @Transactional at 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

↑ Back to top

Outdated

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

↑ Back to top

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

PriorityLabelAction Required
P0CRITICALMust fix before merge
P1HIGHShould fix before merge
P2MEDIUMFix in current sprint
P3LOWFix when convenient
P4INFOOptional consideration

Example Review Request

Perform a formal code review of the AccountService class,
focusing on SOLID principles and Spring best practices

Adding New Rules

↑ Back to top

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.