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.
npx agentmods add rules/e-gov/cursor-prompts/spring-conventionsgit clone --depth 1 https://github.com/e-gov/cursor-promptsWhat 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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.03560 | $0.03560 |
| Opus 5 | $0.01780 | $0.01780 |
| Sonnet 5 | $0.00712 | $0.00712 |
| Haiku 4.5 | $0.00356 | $0.00356 |
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 2d 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.
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@Transactionalfor write operations. - Input Validation:
- Annotate fields within request DTOs/models with Jakarta Bean Validation annotations (e.g.,
@NotNull,@Size,@Pattern,@Email,@Validfor nested objects). - Use the
@Validannotation on@RequestBodyparameters in controller methods to trigger validation.
- Annotate fields within request DTOs/models with Jakarta Bean Validation annotations (e.g.,
- Security Configuration: Configure
SecurityFilterChainbeans using the lambda DSL within an@Configurationclass annotated with@EnableWebSecurity. - Stateless Security: Disable CSRF and use
SessionCreationPolicy.STATELESSfor stateless JWT-based APIs. - Authorization: Define authorization rules using
authorizeHttpRequestswith specificrequestMatchers. UseanyRequest().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
@PreAuthorizeand@PostAuthorizefor fine-grained method-level access control when needed. - Enable Method Security: Enable method security via
@EnableMethodSecurityin a configuration class. - Exception Handling: Implement centralized exception handling using
@ControllerAdvice. Include an@ExceptionHandlerforMethodArgumentNotValidExceptionto return 400 Bad Request for validation failures (preferably using RFC 7807 Problem details). - Configuration Properties: Use
@ConfigurationPropertiesfor type-safe property binding. Enable validation with@Validatedand Jakarta Bean Validation annotations. - HTTP Clients: Prefer
RestClient(Spring Boot 3.2+) for synchronous clients andWebClientfor reactive. Spring Boot 4+:RestTemplateis deprecated; migrate toRestClient. Spring Boot 3.5:RestTemplateis still available butRestClientis preferred. Configure proper timeouts, error handling, and connection pooling. Use@RestClientTest/@WebFluxTestas appropriate. - Caching: Use Spring Cache abstraction (
@Cacheable,@CacheEvict,@CachePut) for expensive operations. Configure cache managers appropriately. - Async Processing: Use
@Asyncfor non-blocking operations. Configure customTaskExecutorbeans for better thread management. - Event Publishing: Use
ApplicationEventPublisherto publish domain events for loose coupling. Handle events with@EventListenermethods. Consider@TransactionalEventListenerfor 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
JwtAuthenticationConverterbeans when needing specific authority extraction logic (e.g., from scopes). - Controllers: Keep controllers lean, delegating business logic to services. Use
ResponseEntityfor explicit response control.
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.
- 2d ago First seen · 407 lines · 3,560 tokens per session scan A 28fcac754117
spring-conventions is a cursor rule published in the GitHub repository e-gov/cursor-prompts (34 stars, last pushed 4mo ago), licensed MIT. It adds 3,560 tokens to every session, about $0.0178 per session on Opus 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.
Other cursor rules, from other repositories
backend
Backend Java — Spring Boot controllers/services, JUnit controller tests, MakeMe. Read this first for any backend work.
springboot-jpa-best-practices
Java Spring Boot + JPA 项目最佳实践,涵盖分层架构、注解、事务、异常处理、安全与代码风格等。.
component-parameter-key-no-dot
@ComponentParameter 的 key 禁止包含 ".",统一使用下划线 / 顶层扁平命名.
java-openapi-annotations
生成 REST 接口时自动补充 OpenAPI 3(springdoc)注解.
com-example-utils-StringParser
AI rules for com.example.utils.StringParser.
java-springboot-jpa-cursorrules-prompt-file
description: "Cursor rules for Java development with Springboot and JPA integration." globs: / alwaysApply: false.