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-retry-conventionsgit clone --depth 1 https://github.com/e-gov/cursor-promptsWrote 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.
[](https://agentmods.dev/rules/e-gov/cursor-prompts/spring-retry-conventions)<a href="https://agentmods.dev/rules/e-gov/cursor-prompts/spring-retry-conventions"><img src="https://agentmods.dev/badge/rules/e-gov/cursor-prompts/spring-retry-conventions.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.01729 |
| Opus 5 | $0.00000 | $0.00864 |
| Sonnet 5 | $0.00000 | $0.00346 |
| Haiku 4.5 | $0.00000 | $0.00173 |
Grade A, and why
spring-retry-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 5d 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 — 129 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Database Retry Conventions
Context
- Apply when implementing database operations in service classes (
src/main/java/**/service/**/*.java) that need resilience against transient database failures (e.g., connection issues, temporary unavailability, deadlocks). - Applies specifically to services interacting with the database via jOOQ within this application.
- This pattern relies on the
RetryConfig,AbstractDatabaseService, andDatabaseRetryPropertiescomponents configured in the project. - Note:
{base.package}represents your project's base package (e.g.,com.example.myapp). Projects must implement the referenced classes (AbstractDatabaseService,DatabaseRetryException, etc.).
Requirements
- Extend Base Class: Service classes performing database operations that should be retried MUST extend
{base.package}.service.common.AbstractDatabaseService. - Constructor Injection: Services extending
AbstractDatabaseServiceMUST receiveDSLContext,RetryTemplate, andPlatformTransactionManagervia constructor injection and pass them to thesuper(dsl, retryTemplate, txManager)constructor. - Use Retry Methods: ALL individual database operations within these services MUST be wrapped in one of the retry methods provided by the base class:
executeWithRetry(String operationName, DatabaseOperation<T> operation)— for write operationsexecuteReadOnlyWithRetry(String operationName, DatabaseOperation<T> operation)— for read-only operations (uses a read-onlyTransactionTemplate)
- No
@Transactionalon Methods: Do NOT annotate service methods with@Transactional. Transactions are managed programmatically inside each retry attempt usingTransactionTemplatewithPROPAGATION_REQUIRES_NEW. Each attempt gets a fresh transaction and connection, preventing poisoned-connection reuse after failures. - Provide Operation Name: A meaningful, unique
operationNamestring (typically matching the service method name or the specific action) MUST be provided as the first argument for clear logging and error reporting. - Use Logging Helpers (Optional): The base class provides
logOperationStart(String operation, String details)andlogOperationSuccess(String operation, String details)helpers. These can be used for additional debug-level logging outside the retry lambda if needed, butexecuteWithRetry/executeReadOnlyWithRetryalready handles INFO-level start/success logging and ERROR-level failure logging. - Exception Handling:
- Only transient database errors are retried. The recoverable SQLState classification is centralised in
PostgreSQLExceptionOverride.isRecoverableState(String):08xxx— Connection exceptions (connection lost, timeout)57Pxx— Operator intervention (admin shutdown, failover)40xxx— Transaction rollback (serialization failure, deadlock)53xxx— Insufficient resources (out of memory, too many connections)25006— Read-only transaction (PostgreSQL failover)
- Non-recoverable errors (constraint violations
23xxx, syntax errors42xxx, data errors22xxx) are not retried. - If all retries are exhausted, the retry method wraps the last thrown exception in a
{base.package}.exception.DatabaseRetryException. - Service methods should generally allow
DatabaseRetryExceptionto propagate upwards to be handled by theGlobalExceptionHandler.
- Only transient database errors are retried. The recoverable SQLState classification is centralised in
- HikariCP Connection Eviction:
PostgreSQLExceptionOverrideimplementsSQLExceptionOverrideand returnsMUST_EVICTfor recoverable SQLStates, ensuring stale connections are removed from the pool before the next retry acquires a fresh one. When adding new recoverable SQLStates, update onlyisRecoverableState(). - Configuration: Do not hardcode retry attempts or backoff periods. Rely on the centrally configured
RetryTemplatewhich uses settings fromDatabaseRetryProperties(defined inapplication.yml):database: retry: max-attempts: ${DB_RETRY_MAX_ATTEMPTS:3} initial-interval: ${DB_RETRY_INITIAL_INTERVAL:500} multiplier: ${DB_RETRY_MULTIPLIER:2.0} max-interval: ${DB_RETRY_MAX_INTERVAL:10000} timeout: ${DB_RETRY_TIMEOUT:30000}
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.
- 5d ago First seen · 129 lines · 1,729 tokens per session scan A a03cab446935
spring-retry-conventions is a cursor rule published in the GitHub repository e-gov/cursor-prompts (34 stars, last pushed 4mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,729 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-30.
Other cursor rules, from other repositories
gradle
Enforce modern Gradle build practices for Java and Android projects, focusing on Kotlin DSL, modularity, version catalogs, and performance optimizations.
mockito
This guide provides definitive best practices for writing robust, maintainable, and readable unit tests using Mockito with JUnit 5, focusing on modern patterns and common pitfalls.
backend
Backend Java — Spring Boot controllers/services, JUnit controller tests, MakeMe. Read this first for any backend work.
java-import-fqn
Java 禁止不必要的全限定类名,必须 import(类名冲突除外).
springboot-jpa-best-practices
Java Spring Boot + JPA 项目最佳实践,涵盖分层架构、注解、事务、异常处理、安全与代码风格等。.
component-parameter-key-no-dot
@ComponentParameter 的 key 禁止包含 ".",统一使用下划线 / 顶层扁平命名.