java-springboot-standards

Coding standards for Java Spring Boot services in a monorepo, a repository containing multiple related projects or services. They define the expected Java and Spring Boot setup, service layers, dependency injection, error handling, and architecture.

In plain words
What is it for?
Use them when creating or modifying Java and Spring Boot controllers, services, repositories, clients, interfaces, dependency injection, and not-found error handling.
Why use it?
They keep services organized and consistent, while preventing controllers from containing business logic or external-system calls. Following them also gives new code a clear place and pattern to fit into.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/pallerana/agentic-loop-engineering-kit/java-springboot-standards
Clone the repo
git clone --depth 1 https://github.com/pallerana/agentic-loop-engineering-kit

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 9,343 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.09343
Opus 5 $0.00000 $0.04672
Sonnet 5 $0.00000 $0.01869
Haiku 4.5 $0.00000 $0.00934

Measured yesterday against content hash f059d1c066b4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

java-springboot-standards scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/java-springboot-standards.mdc · 840 lines

How it starts

The opening of the file, as written. The whole thing — 840 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Java Spring Boot Standards (your monorepo)

Apply these standards when writing or modifying Java/Spring Boot code in this workspace (Agentic Loop / your service services and related APIs). Patterns are derived from the SpringBootProdTemplate reference and existing Agentic Loop services.

Toolchain baseline: Java 25 (Corretto), Spring Boot 4.x, Gradle 9.x. Do NOT add explicit version pins — the BOM/platform manages versions.

1. Architecture & layering

Controller -> Orchestration service -> granular services -> repository/client. Keep controllers thin (no business logic). Program to interfaces.

  • Each service has an interface (IFooService) and an impl (impl/FooService).
  • Inject collaborators via constructor with @RequiredArgsConstructor. Never use field @Autowired.
  • No try-catch or Azure/external SDK calls inside controllers. Move all I/O to the service layer and let exceptions surface to GlobalExceptionHandler.
  • Centralize domain not-found handling in the service layer — controllers must not repeat orElseThrow(() -> new EntityNotFoundException(...)). See §7 Service-layer not-found and Optional lookups.
// GOOD
@Service
@RequiredArgsConstructor
@Slf4j
public class FooOrchestrationService implements IFooOrchestrationService {
    private final ICreateFooService createFooService;
    private final IFooRetrievalService fooRetrievalService;
}

// BAD
@Service
public class FooService {
    @Autowired private CreateFooService createFooService; // field injection, concrete type
}

2. Java 25 language features — prefer modern syntax

Actively use Java 25 constructs instead of verbose equivalents:

  • Records for all immutable value types, DTOs, config holders, internal results:
    public record ErrorDetail(String field, String message) { }
    public record AppHealthSummary(String resourceId, String status, Instant checkedAt) { }
    
  • Sealed classes for closed domain hierarchies (e.g. health check result variants):
    public sealed interface CheckResult permits OkResult, DegradedResult, DownResult { }
    
  • Pattern matching for instanceof — no explicit cast:
    // GOOD
    if (result instanceof DegradedResult dr) { log.warn("Degraded: {}", dr.reason()); }
    // BAD
    if (result instanceof DegradedResult) { DegradedResult dr = (DegradedResult) result; }
    
  • Pattern matching for switch (finalized):
    String label = switch (result) {
        case OkResult ok      -> "UP";
        case DegradedResult d -> "DEGRADED: " + d.reason();
        case DownResult dn    -> "DOWN";
    };
    
  • Text blocks for multi-line strings (JSON templates, SQL, YAML snippets):
    String body = """
        {"resourceId": "%s", "status": "DOWN"}
        """.formatted(resourceId);
    
  • var for local variables where the type is obvious from the right-hand side. Do not use var for fields or where it obscures the type.
  • Virtual threads — Spring Boot 4 enables virtual threads by default (spring.threads.virtual.enabled=true). Do NOT create raw Thread objects or tune thread-pool sizes for I/O-bound work; let the container manage concurrency.

Read the full file on GitHub · 840 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 840 lines · 9,343 tokens per session scan A f059d1c066b4

Subscribe to this mod's changes

java-springboot-standards is a cursor rule published in the GitHub repository pallerana/agentic-loop-engineering-kit (4 stars, last pushed 2mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 9,343 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.