backend-code

Backend coding rules for Java applications built with Spring Boot, a Java framework for web services. They cover controllers, services, repositories, database schema references, imports, and API response data.

In plain words
What is it for?
Use them when adding or changing Spring Boot endpoints, business logic, data access, API responses, imports, or database schema documentation.
Why use it?
They give the coding agent consistent project conventions and verification commands, reducing guesswork when changing server code or database-backed features.

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/nerds-odd-e/doughnut/backend-code
Clone the repo
git clone --depth 1 https://github.com/nerds-odd-e/doughnut

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 414 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.00414
Opus 5 $0.00000 $0.00207
Sonnet 5 $0.00000 $0.00083
Haiku 4.5 $0.00000 $0.00041

Measured 2d ago against content hash 4d971b0f41c1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

backend-code 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.

.cursor/rules/backend-code.mdc · 60 lines

What it actually says

Backend Code Rules

Migrations: db-migration.mdc.

Commands

Run backend verification from the repo root:

CURSOR_DEV=true nix develop -c pnpm backend:verify

When no database migration is involved, this is faster:

CURSOR_DEV=true nix develop -c pnpm backend:test_only

Relational Schema

The docs/database-erd.md Mermaid diagram documents tables, foreign keys, and key columns. After Flyway migrations change the schema, regenerate it with the database-erd skill:

CURSOR_DEV=true nix develop -c pnpm export:database-erd

Controller Return Values

  • Prefer returning entities, or other types already used as API bodies, from controllers when the JSON shape fits.
  • Narrow the serialized surface with @JsonIgnore, @JsonView, and similar mechanisms already used in the codebase.
  • Introduce a response DTO only when necessary, such as a different wire shape, aggregating multiple sources, or decoupling from persistence without overloading the entity.

Import Style

  • Always use import statements at the top of files.
  • Do not use inline fully qualified class names in code.
  • Use fully qualified names only when there is a naming conflict between classes with the same simple name from different packages.

Avoid:

ObjectMapper mapper = new com.odde.donut.configs.ObjectMapperConfig().objectMapper();
List<com.theokanning.openai.completion.chat.ChatMessage> messages = ...;

Prefer:

import com.odde.donut.configs.ObjectMapperConfig;
import com.theokanning.openai.completion.chat.ChatMessage;

ObjectMapper mapper = new ObjectMapperConfig().objectMapper();
List<ChatMessage> messages = ...;
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. 2d ago First seen · 60 lines · 0 tokens per session scan A 4d971b0f41c1

Subscribe to this mod's changes

backend-code is a cursor rule published in the GitHub repository nerds-odd-e/doughnut (49 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 414 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.