aggregation

A set of rules for a backend-for-frontend service, which combines data from several backend services into responses designed for a user interface.

In plain words
What is it for?
Designing response aggregation with CompletableFuture, mapping backend data into response objects, and handling failures, fallbacks, logging, and metrics.
Why use it?
It clarifies when backend calls should run one after another or at the same time, and how to handle timeouts, errors, and partial results.

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/goranerhartic/cursor-development-rules/aggregation
Clone the repo
git clone --depth 1 https://github.com/GoranErhartic/cursor-development-rules

Made for: Cursor.

Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 332 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.00017 $0.00332
Opus 5 $0.00009 $0.00166
Sonnet 5 $0.00003 $0.00066
Haiku 4.5 $0.00002 $0.00033

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

Security

Grade A, and why

aggregation 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/languages/java/aggregation.mdc · 32 lines

What it actually says

Response Aggregation (BFF)

When

  • BFF calls multiple backends and combines results; handle sequential (when one call depends on another) vs parallel (independent calls).

Sequential

  • Call A, then use result to call B; combine and transform to response DTO.
  • Use Resilience4j (e.g. @CircuitBreaker) on client calls; fallback for optional data (e.g. preferences) with default or empty.

Parallel

  • CompletableFuture.allOf: Submit all calls; CompletableFuture.allOf(cf1, cf2, cf3).thenApply(v -> combine(cf1.join(), cf2.join(), cf3.join())); handle timeouts and exceptions per future.
  • Partial failures: Use CompletableFuture.exceptionally or handle to return partial response (e.g. main data + null for failed optional); or fail fast if all required.
  • Timeout: Use orTimeout on each future or overall; cancel on timeout.

Conventions

  • Use RestClient or declarative client per backend; inject into aggregation service; map backend DTOs to BFF response DTOs; log and metric failures.
  • Do not run blocking calls in parallel without dedicated executor if needed (RestClient is async-friendly).

Anti-Patterns

  • Blocking in parallel path; no timeout; no partial failure handling when appropriate; mixing sequential and parallel incorrectly

See also: http-clients.mdc, resilience.mdc, bff-architecture.mdc

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 · 32 lines · 17 tokens per session scan A 2ae30012d972

Subscribe to this mod's changes

aggregation is a cursor rule published in the GitHub repository GoranErhartic/cursor-development-rules (19 stars, last pushed 6mo ago), licensed MIT. It adds 17 tokens to every session and 332 once invoked, about $0.0001 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.