spring-conventions

spring-conventions is a cursor rule for Cursor from e-gov/cursor-prompts. It costs 3,560 tokens per session, scanned A, original, MIT.

A set of project rules for Spring Boot, a Java framework for web applications and services, including its security, dependency injection, validation, and transaction patterns.

In plain words
What is it for?
Use it when changing Spring controllers, services, configuration, exception handlers, validation, transactions, or Gradle dependencies.
Why use it?
It helps new code follow the project's established structure instead of introducing different ways to configure services, controllers, or database work.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when changing Spring controllers, services, configuration, exception handlers, validation, transactions, or Gradle dependencies.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/e-gov/cursor-prompts/spring-conventions
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.

Clone the repo
git clone --depth 1 https://github.com/e-gov/cursor-prompts

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for spring-conventions

README.md
[![agentmods](https://agentmods.dev/badge/rules/e-gov/cursor-prompts/spring-conventions/github.svg)](https://agentmods.dev/rules/e-gov/cursor-prompts/spring-conventions)
Your own site
<a href="https://agentmods.dev/rules/e-gov/cursor-prompts/spring-conventions"><img src="https://agentmods.dev/badge/rules/e-gov/cursor-prompts/spring-conventions/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for spring-conventions

Your own site · 80×15
<a href="https://agentmods.dev/rules/e-gov/cursor-prompts/spring-conventions"><img src="https://agentmods.dev/badge/rules/e-gov/cursor-prompts/spring-conventions.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 3,560 This file is loaded in full into every session.
When invoked 3,560 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.03560 $0.03560
Opus 5.5 $0.01424 $0.01424
Sonnet 5.5 $0.00712 $0.00712
Haiku 4.5 $0.00356 $0.00356

Measured 3mo ago against content hash 28fcac754117, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

spring-conventions 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 3mo ago.

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.

rules/java-spring-boot/spring-conventions.mdc · 407 lines

How it starts

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

Project Spring Boot & Security Conventions

Context

  • Apply when writing or modifying Spring Boot application code, especially configuration, controllers, services, and exception handlers within this project.
  • Ensures adherence to established patterns for security, dependency injection, validation, transaction management, exception handling, and configuration.
  • Note: This project uses Gradle for build automation and dependency management.
  • Note: Some requirements are Spring Boot 4+ specific (marked accordingly). This project supports both Spring Boot 3.5 and 4.0.
  • For comprehensive security best practices, see [security.mdc](mdc:rules/common/security.mdc).
  • For jOOQ DSL usage, see mdc:rules/java-common/jooq-database-access.mdc.
  • For database retry logic, see mdc:rules/java-spring-boot/spring-retry-conventions.mdc.

Requirements

  • Dependency Injection: Use constructor injection for all Spring-managed dependencies.
  • Transaction Management: Define transactions at service method level using @Transactional. Use @Transactional(readOnly = true) for read-only methods and default @Transactional for write operations.
  • Input Validation:
    • Annotate fields within request DTOs/models with Jakarta Bean Validation annotations (e.g., @NotNull, @Size, @Pattern, @Email, @Valid for nested objects).
    • Use the @Valid annotation on @RequestBody parameters in controller methods to trigger validation.
  • Security Configuration: Configure SecurityFilterChain beans using the lambda DSL within an @Configuration class annotated with @EnableWebSecurity.
  • Stateless Security: Disable CSRF and use SessionCreationPolicy.STATELESS for stateless JWT-based APIs.
  • Authorization: Define authorization rules using authorizeHttpRequests with specific requestMatchers. Use anyRequest().authenticated() as a fallback. Ensure non-public Actuator endpoints (beyond /health) are appropriately secured (e.g., require authentication or specific roles).
  • Method-Level Security: Use @PreAuthorize and @PostAuthorize for fine-grained method-level access control when needed.
  • Enable Method Security: Enable method security via @EnableMethodSecurity in a configuration class.
  • Exception Handling: Implement centralized exception handling using @ControllerAdvice. Include an @ExceptionHandler for MethodArgumentNotValidException to return 400 Bad Request for validation failures (preferably using RFC 7807 Problem details).
  • Configuration Properties: Use @ConfigurationProperties for type-safe property binding. Enable validation with @Validated and Jakarta Bean Validation annotations.
  • HTTP Clients: Prefer RestClient (Spring Boot 3.2+) for synchronous clients and WebClient for reactive. Spring Boot 4+: RestTemplate is deprecated; migrate to RestClient. Spring Boot 3.5: RestTemplate is still available but RestClient is preferred. Configure proper timeouts, error handling, and connection pooling. Use @RestClientTest/@WebFluxTest as appropriate.
  • Caching: Use Spring Cache abstraction (@Cacheable, @CacheEvict, @CachePut) for expensive operations. Configure cache managers appropriately.
  • Async Processing: Use @Async for non-blocking operations. Configure custom TaskExecutor beans for better thread management.
  • Event Publishing: Use ApplicationEventPublisher to publish domain events for loose coupling. Handle events with @EventListener methods. Consider @TransactionalEventListener for events that should only fire after successful transaction commits.
  • Logging: Use SLF4J (org.slf4j.Logger) for logging within application components.
  • API Implementation: Implement OpenAPI generated interfaces in Controllers when applicable. NEVER modify files in src/generated/ — they are overwritten on every build.
  • JWT Converters: Define custom JwtAuthenticationConverter beans when needing specific authority extraction logic (e.g., from scopes).
  • Controllers: Keep controllers lean, delegating business logic to services. Use ResponseEntity for explicit response control.

Read the full file on GitHub · 407 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. 3mo ago First seen · 407 lines · 3,560 tokens per session scan A 28fcac754117

Subscribe to this mod's changes

spring-conventions is a cursor rule published in the GitHub repository e-gov/cursor-prompts (35 stars, last pushed 7mo ago), licensed MIT. It adds 3,560 tokens to every session, about $0.0142 per session on Opus 5.5. 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-30.

Related

spring-conventions compared with cursor rules from other repositories

spring-conventions next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
spring-conventionse-gov/cursor-promptsCursor rule357mo agoMITA3,560Cursor
springboot-jpa-best-practicesholtwood/awesome-cursorrules-zhCursor rule2441mo agoMITA0Cursor
graftcode-javagrft-dev/graftcodeCursor rule1.2k9d agononeA4,704Cursor
spring-boot-architecturelsampaioweb/ai-instructionsCursor rule111d agoMITA0Cursor
spring-boot-http-clientlsampaioweb/ai-instructionsCursor rule111d agoMITA0Cursor
java-springboot-standardspallerana/agentic-loop-engineering-kitCursor rule45mo agoApache-2.0A0Cursor
spring-bootnedcodes-ok/cursorrules-collectionCursor rule389mo agoMITA478Cursor