spring-boot-repository

spring-boot-repository is a cursor rule for Cursor from lsampaioweb/ai-instructions. It costs 0 tokens per session (898 once invoked), scanned A, original, MIT.

Rules for repository classes, which are code components that read and change data in a database.

In plain words
What is it for?
Naming repository interfaces and implementations, choosing JDBC for relational databases, defining SQL properties, and checking queries and updates.
Why use it?
They keep database access, names, SQL settings, and safety practices consistent across a Spring Boot project.

Cursor rule for Cursor

Written for Cursor: installed under .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/lsampaioweb/ai-instructions/spring-boot-repository
Clone the repo
git clone --depth 1 https://github.com/lsampaioweb/ai-instructions

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-boot-repository

README.md
[![agentmods](https://agentmods.dev/badge/rules/lsampaioweb/ai-instructions/spring-boot-repository.svg)](https://agentmods.dev/rules/lsampaioweb/ai-instructions/spring-boot-repository)
Your own site
<a href="https://agentmods.dev/rules/lsampaioweb/ai-instructions/spring-boot-repository"><img src="https://agentmods.dev/badge/rules/lsampaioweb/ai-instructions/spring-boot-repository.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 898 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.1 $0.00000 $0.00898
Opus 5 $0.00000 $0.00449
Sonnet 5 $0.00000 $0.00180
Haiku 4.5 $0.00000 $0.00090

Measured 5d ago against content hash 0ed0d5fc0fa4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

spring-boot-repository 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.

.cursor/rules/spring-boot-repository.mdc · 48 lines

How it starts

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

Spring Boot Repository Engine

Naming Conventions

  • Name repository interfaces with the *Repository suffix (e.g., HolidayRepository).
  • Name repository implementations with the *RepositoryImpl suffix (e.g., HolidayRepositoryImpl).
  • Name SQL configuration property records with the *SqlConfigurationProperties suffix (e.g., HolidaySqlConfigurationProperties).
  • Use resource entity names in repository identifiers (never DataRepository or PersistenceRepository).
  • Name SQL property keys with the pattern sql.<resource>.<operation> (e.g., sql.holidays.find-by-id).
  • Name SQL column name constant classes with the *SqlColumns suffix (e.g., UserSqlColumns, AccountSqlColumns).

Rules

  • Defer the global ORM ban to spring-boot-architecture.mdc and ORM dependency bans to spring-boot-pom.mdc.
  • Use findById, findAll, findBy*, save, update, and deleteById as the standard method name prefixes for repository interface methods.
  • Keep method names consistent with operation semantics across all repositories.
  • Keep JDBC or JdbcClient as the default for relational persistence modules.
  • Use interface + implementation separation (XyzRepository interface + XyzRepositoryImpl) for modules with multiple persistence adapters or higher domain complexity.
  • Use a single @Repository class without a separate interface for focused modules with a single persistence adapter.
  • Allow non-relational repository implementations only when the module is explicitly scoped to an approved non-relational store.
  • Declare SQL column name constants in a *SqlColumns utility class within the feature package.
  • Use *SqlColumns constants as all named parameter keys in SQL method calls.
  • Declare SQL result-set column-label constants in the repository implementation and reuse them for all ResultSet reads.
  • Return Optional<T> from all single-resource lookup methods (e.g., findById).
  • Keep business orchestration out of repository methods.
  • Parameterize all SQL executed by repositories.
  • Build SQL parameter containers to be null-tolerant by omitting null entries or binding typed null values explicitly.
  • Accept pagination parameters (offset, limit, sort column) as explicit method parameters for paginated queries.
  • Keep SQL statements straightforward and readable; prefer simple joins, predicates, and direct projections over expression-heavy control-flow in SQL.
  • Implement sortable pagination in SQL only when the user explicitly requires database-side sorting or the expected data volume makes application-side sorting unsuitable.
  • When the user prefers simpler SQL and data volume constraints do not require database-side sorting, perform sorting in Java after retrieval using an allowlisted set of sortable fields.
  • Externalize SQL statements into @PropertySource-backed XML property files, one file per feature.
  • Declare @PropertySource on the @Configuration class that owns the JdbcClient bean.
  • Access SQL statements through a @ConfigurationProperties record named XyzSqlConfigurationProperties within the feature package.
  • Register XyzSqlConfigurationProperties using one explicit pattern: either @Component + @ConfigurationProperties on the record, or @EnableConfigurationProperties on the owning @Configuration class.
  • Annotate *SqlConfigurationProperties records with @Validated and annotate each SQL field with @NotBlank.
  • Validate generated-key fallback results explicitly and throw a deterministic data-retrieval exception when no key is returned.
  • Use Locale.ROOT for case normalization in machine-parsed string comparisons (e.g., SQL error-message feature detection).
  • Catch SQL exceptions at the repository boundary and wrap them in a feature-scoped exception; services must not re-wrap the same SQL failure.
  • Fall back from INSERT/UPDATE ... RETURNING only when exception evidence indicates the database does not support RETURNING.
  • Rethrow unrelated SQL grammar errors.

Read the full file on GitHub · 48 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. 5d ago First seen · 48 lines · 0 tokens per session scan A 0ed0d5fc0fa4

Subscribe to this mod's changes

spring-boot-repository is a cursor rule published in the GitHub repository lsampaioweb/ai-instructions (1 stars, last pushed 13d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 898 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.