Progress
0 / 0
// Team AI Engineering Workflows · Java Edition · June 2026

From ticket to production.
Every day. Every role.

Cursor 3.x + Claude 4 workflows for your whole team. Requirements, code, tests, design, architecture, multi-repo context with Confluence MCP — and a complete token efficiency guide so your team doesn't burn budget.

7
Workflows
50+
Prompts
Token
Efficiency Guide
\u2713 UPDATED JUNE 2026 \u2014 Claude 4 / Cursor 3.x / MCP 2025-06-18
Workflow 1

Requirements → Code — TDD Pipeline

From Jira ticket to merged PR. Claude reads the ticket, finds gaps, writes failing tests first, then implements. Each prompt is tuned for minimal tokens.

5
Stages
TDD
First
01
Analyse the Ticket — Find Gaps First
5 minutes now saves 5 hours later
Claude Chat
Model: Haiku 4.5 ($1/$5) — this is classification/analysis, not generation. Use the cheapest model that works.
Requirement Analysis — EfficientClaude Chat · Haiku 4.5~50 tokens in
Analyse this ticket before I code: [PASTE TICKET] Stack: Java 21/Spring Boot/React/PostgreSQL/AWS. Respond as tables only: AMBIGUITIES: question | why_it_blocks_coding MISSING_ACS: scenario | risk_if_ignored ASSUMPTIONS: assumption | confirm_with_PO? ESTIMATE: XS/S/M/L/XL | main_risk No prose. If none in a category, write NONE.
Takes ambiguities back to PO BEFORE touching Cursor. Eliminates most requirement-related rework.
Break into Atomic TasksClaude Chat · Haiku 4.5~35 tokens in
Break into dev tasks: [TICKET TITLE] ACs: [PASTE ACS] Format: NUM | TASK | LAYER(Controller/Service/Repo/FE/Infra) | HOURS(0.5/1/2/4) | DEPS(task nums) Order by dependency. Mark [PARALLEL] where tasks can run simultaneously.
02
Write Failing Tests First
Commit the spec before writing the code
Cursor · Sonnet 4.6
Generate Tests from ACs — Code OnlyCursor Chat ⌘L · Sonnet 4.6~55 tokens in
JUnit 5 test class for this AC set. NO implementation — tests only. ACs: [PASTE ACS] Rules: - Naming: should_[result]_when_[condition] - @ExtendWith(MockitoExtension), @Mock deps, @InjectMocks target - AAA structure with // Arrange // Act // Assert - @ParameterizedTest where multiple inputs test same behaviour - Cover: happy path, each exception, null inputs, empty collections, boundary values - AssertJ (assertThat), not JUnit assertions - @TODO comment per test explaining what impl must do - No prose explanations — code only
Commit these failing tests: "test: failing tests for TICKET-123". This is your executable specification.
03
Implement to Pass Tests
Minimum code — nothing extra
Cursor Agent · Sonnet 4.6
Implement from Failing TestsCursor Agent · Sonnet 4.6~45 tokens in
Implement minimum code to make @file [TestClass.java] pass. Java 21, Spring Boot 3.x, Spring AI 1.1. Rules: records for DTOs, no Lombok, Javadoc on public methods, log INFO happy path / ERROR exceptions. Do not write code that isn't needed to pass tests. Run tests. Fix failures.
Production Readiness CheckCursor Chat · Sonnet 4.6~40 tokens in
Production check @file [ChangedFile.java]: PERF: N+1 queries, missing indexes, unbounded queries RELIABILITY: missing null checks, uncaught exceptions, no @Transactional where needed SECURITY: SQL injection, sensitive data in logs, missing input validation MAINT: magic numbers, methods > 20 lines, missing Javadoc Format: SEVERITY(CRITICAL/HIGH/MEDIUM) | CATEGORY | LINE | FIX CRITICAL and HIGH only. One-line fix snippets.
Generate PR DescriptionClaude Chat · Haiku 4.5~35 tokens in
PR description for: [TICKET-123] [title] Changed: [list main files] What: [2-sentence summary] Sections: Summary(non-technical) / What changed(bullets) / How to test(steps) / Checklist. Max 200 words. No filler.

// Workflow 1 Checkpoint

Used requirement analysis prompt this sprint — found at least one gap before coding
Committed failing tests before writing any implementation code
Using Haiku 4.5 for ticket analysis, Sonnet 4.6 for code generation
Workflow 2

Unit Testing with JUnit 5 + Mockito

Comprehensive test generation, coverage gap analysis, integration tests. All prompts tuned for minimal token usage — code output only, no prose.

JUnit 5
+ Mockito
01
Full Service Test Suite
Every method, every path
Cursor · Sonnet 4.6
Full test suite generationCursor ⌘L · Sonnet 4.6~60 tokens in
Full JUnit 5 test suite for @file [Service.java]. @ExtendWith(MockitoExtension), @Mock all deps, @InjectMocks target. Per public method: happy path, each exception, null params, empty collections, boundary values (0/1/MAX). Use verify() for expected mock calls, verifyNoInteractions() where downstream skipped. ArgumentCaptor for inspecting mock arguments. @Nested inner class per method. @ParameterizedTest + @CsvSource for multi-input behaviour. Naming: should_[result]_when_[condition]. AssertJ. No explanations — code only.
Coverage gap analysisCursor ⌘L · Haiku 4.5~40 tokens in
JaCoCo gaps for @file [Service.java]: [PASTE UNCOVERED LINES] Existing tests: @file [ServiceTest.java] For each gap: SCENARIO | WHY_MISSING | TEST_SIGNATURE Then add the missing @Test methods. Code only.
02
Integration Tests — MockMvc + Testcontainers
Controller and repository layers
Cursor
Controller integration testsCursor ⌘L · Sonnet 4.6~55 tokens in
@WebMvcTest integration tests for @file [Controller.java]. @MockBean all services. Per endpoint: test all HTTP status codes (200/201/400/401/403/404/500). Use ObjectMapper for JSON, jsonPath() for assertions, Content-Type headers. Test with valid and missing/invalid auth. No explanations — code only.
Repository tests with TestcontainersCursor ⌘L · Sonnet 4.6~50 tokens in
@DataJpaTest + Testcontainers PostgreSQL for @file [Repository.java]. @AutoConfigureTestDatabase(replace=NONE). Per custom query: correct results, empty when no match, pagination, ordering, soft-delete exclusion. Use TestEntityManager for setup. @Sql annotation for complex fixtures. Code only.
Convention table:
ScenarioNaming patternExample
Happy pathshould_[result]_when_[condition]should_returnUser_when_validIdProvided
Exceptionshould_throw_[Ex]_when_[condition]should_throw_NotFound_when_idMissing
Null inputshould_throw_[Ex]_when_[param]IsNullshould_throw_IllegalArg_when_emailNull
Side effectshould_call_[method]_when_[condition]should_callEmailService_when_userCreated
No side effectshould_not_call_[method]_when_[condition]should_not_callEmail_when_userExists

// Workflow 2 Checkpoint

JaCoCo in CI — PRs below 80% line coverage fail automatically
All tests follow should_X_when_Y naming — enforced in .cursor/rules
Workflow 3

Solution Design & Architecture

Claude as a principal engineer — architecture critique, ADR generation, STRIDE threat modelling. Get decisions, not essays.

ADR
+ STRIDE
01
Architecture Critique
Find blockers before you build
Claude Chat · Sonnet 4.6
Architecture review — structured outputClaude Chat · Sonnet 4.6~70 tokens in
Principal engineer review of this design. Stack: Java/Spring Boot/PostgreSQL/AWS. Scale: [RPS]. [DESCRIBE DESIGN] Issues table: RATING(BLOCKER/MAJOR/MINOR) | CATEGORY(Scale/SPOF/Data/Security/Ops) | PROBLEM(1 sentence) | ALTERNATIVE(1 sentence) BLOCKER and MAJOR only. No prose.
ADR generatorClaude Chat · Sonnet 4.6~60 tokens in
Write ADR for: [DECISION] Context: [2 sentences] Options: [list 3 alternatives] Sections: Status(Proposed) / Context / Decision / Consequences(pos + neg bullets) / Alternatives(pros/cons per option) / Review Date. Max 350 words. Bullets not prose. Include downsides of chosen option.
STRIDE threat modelClaude Chat · Sonnet 4.6~65 tokens in
STRIDE analysis: [COMPONENT NAME] Purpose: [what it does] Trust boundaries: [e.g. internet -> API gateway -> services -> DB] Auth: [JWT/OAuth/API key] Data sensitivity: [PII/financial/public] Per STRIDE category: THREAT | LIKELIHOOD(H/M/L) | IMPACT(H/M/L) | MITIGATION | OWNER H/M likelihood only. Table format.
02
Database Schema Design
Indexes, constraints, audit fields
Cursor
Schema reviewCursor ⌘L · Sonnet 4.6~40 tokens in
Schema review: @file [Entity classes or schema.sql] Check: missing indexes, wrong types, missing NOT NULL/UNIQUE/CHECK, missing audit fields (created_at/updated_at), soft-delete candidates, unbounded growth columns. Format: SEVERITY | TABLE.COLUMN | ISSUE | FIX(ALTER TABLE or annotation)

// Workflow 3 Checkpoint

Architecture critique run before building a significant feature — found a MAJOR issue
At least one ADR written for a design decision this quarter
Workflow 4

Multi-Repo Knowledge + Confluence MCP

Cursor Memories (not Notepads — deprecated), .cursor/rules/*.mdc (not .cursorrules), Confluence MCP via 2025-06-18 spec, and onboarding to any codebase in hours.

MCP
2025-06-18
01
Cursor Multi-Repo Setup — 2026
Memories replaces Notepads
Setup
Breaking change from 2025: Notepads are deprecated. Use Cursor Memories for persistent cross-session context. Rules now live in .cursor/rules/*.mdc files (not .cursorrules).
1
Open all repos in one workspace
File → Add Folder to Workspace per repo. Save as .code-workspace. Now @folder and @Codebase search across ALL repos. Share the .code-workspace file with your team.
2
Seed Cursor Memories with your system map
In a new chat, describe your architecture and say: "Remember this as our system map." Memories persist automatically. No manual curation. Start a new session — the context is there.
3
Create .cursor/rules/conventions.mdc
Project-level rules in .cursor/rules/*.mdc. Use alwaysApply: true for universal constraints. Use autoApply with file glob for context-specific rules (e.g. auto-apply Java rules when *.java files are open). Keep total rules under 3k tokens.
4
Set .cursorignore per repo
Exclude target/, build/, generated code, *.class, node_modules/. See Token Efficiency tab for the full template.
Cross-repo feature developmentCursor Chat · Sonnet 4.6contextual
Implement [FEATURE] spanning order-service and payment-service. Order service: @folder [order-service/src/main/java] Payment service: @folder [payment-service/src/main/java] Show: API contract between services, data flow, error handling for payment failure. Implement order-service changes first (with tests), then payment-service. Follow patterns in @file [order-service/src/main/java/com/acme/order/service/OrderService.java]
02
Confluence MCP — 2025-06-18 Spec
Ask Claude questions about your internal docs
MCP
MCP 2025-06-18: Use Streamable HTTP transport (replaces old SSE). OAuth 2.0 for auth. The Atlassian MCP server now supports the latest spec. Configure in Cursor Settings → MCP Servers.
MCP server config (Cursor)JSON CONFIG
{ "name": "confluence", "transport": "streamable-http", "url": "https://mcp.atlassian.com/v1/mcp", "auth": { "type": "oauth2", "clientId": "your-client-id" } }
Use the 2025-06-18 Streamable HTTP transport — not the old SSE transport from the 2024 spec.
Query Confluence docsCursor Chat + MCP · Sonnet 4.6~35 tokens in
Search Confluence space [SPACE_KEY] for: [TOPIC] I need: [specific question 1] / [specific question 2] If docs are outdated vs @file [CodeFile.java], flag the discrepancy. Answer in bullets. Include page name per answer.
Generate Confluence page from codeCursor Chat + MCP · Sonnet 4.6~50 tokens in
Read @folder [service/src] and generate a Confluence API reference page. Include: endpoints (method/path/auth/request/response), error codes, data model. Format: Confluence wiki markup. Tables for endpoints and error codes.
03
Codebase Onboarding — Hours not Weeks
Understand any service deeply
Onboarding
Service architecture overviewCursor Chat · Sonnet 4.6~45 tokens in
I'm new to this service. @folder [src/] Answer: 1) Entry points (controllers, listeners, scheduled jobs) 2) Core domain entities + relationships 3) Layer structure 4) External dependencies (DBs, queues, APIs) 5) Top 3 gotchas for new developers 6) Which 5 files to read first for: [FEATURE AREA] Bullets only. No prose.
Trace a request end-to-endCursor Chat · Sonnet 4.6~40 tokens in
Trace: [HTTP METHOD] [PATH] [body/params] @file [Controller.java] @file [Service.java] @file [Repository.java] Show each hop: CLASS.METHOD() → what happens → next class. Include: validation, DB queries (show JPQL), events published, response shape. One line per hop. If unsure, say "unsure at X" — don't guess.

// Workflow 4 Checkpoint

All repos in one Cursor workspace with shared .code-workspace file
Switched from Notepads to Cursor Memories for persistent context
Rules in .cursor/rules/*.mdc (not .cursorrules) — reviewed and under 3k tokens
Confluence MCP connected with 2025-06-18 Streamable HTTP transport
Workflow 5

Full Stack Understanding

Backend (Spring Boot 3.x, Spring AI 1.1), frontend (React/Angular/Vue), infrastructure (Terraform, Kubernetes) — prompts for understanding every layer.

BE+FE
+Infra
01
Backend Deep Dive
Spring Boot 3.x, Spring AI 1.1, JPA
Backend
API contract documentationCursor · Sonnet 4.6~40 tokens in
API docs for @folder [controller/]. Per endpoint: METHOD PATH | AUTH(role) | REQUEST(body/params) | RESPONSES(status+schema) | SIDE_EFFECTS Table format. Flag deprecated or inconsistently named endpoints.
Spring AI 1.1 integration auditCursor · Sonnet 4.6~35 tokens in
@folder [src/] — find all AI/LLM integration points. List: CLASS | AI_FRAMEWORK(Spring AI/LangChain4j/direct HTTP) | MODEL_USED | PROMPT_CACHED? | ADAPTIVE_THINKING? Flag: any use of deprecated budget_tokens on Sonnet 4.6/Opus 4.6+ models.
External integrations mapCursor · Haiku 4.5~30 tokens in
@folder [src/] — list all external integrations. Table: TYPE(HTTP/Queue/Cache/S3/Email/SDK) | ENDPOINT/TOPIC | SYNC/ASYNC | TESTED? Flag any without integration tests.
02
Infrastructure Understanding
Terraform, Kubernetes, CI/CD pipelines
Infra
Terraform infrastructure mapCursor · Sonnet 4.6~45 tokens in
@folder [terraform/] Map: COMPUTE | NETWORKING | DATA(DBs/queues/caches) | IAM roles | SECRETS management | MONITORING Then: what's the blast radius if [main service] goes down? Flag: SPOFs, overly permissive IAM (Action:*), unencrypted data at rest.
CI/CD pipeline explanationCursor · Haiku 4.5~30 tokens in
@file [.github/workflows/main.yml] (or Jenkinsfile/gitlab-ci.yml) List: TRIGGER | STAGES(seq/parallel) | QUALITY_GATES | DEPLOY_ENVS | APPROVAL_GATES | ROLLBACK How do I add a new service? What needs changing?

// Workflow 5 Checkpoint

AI integration audit run — no deprecated budget_tokens on 4.6+ models
Full data flow map generated and shared in Confluence
Workflow 6

Daily Team Practices

Code review, debugging, sprint planning, incident response, documentation. The recurring tasks where AI saves hours every week. Prompts tuned for minimum token spend.

Daily
Ops
01
Code Review
Pre-PR self-check + reviewer briefing
Review
Pre-PR self reviewCursor · Sonnet 4.6~40 tokens in
Review @file [Changed1.java] @file [Changed2.java] for: [TICKET-123 description]. Check: correctness for requirement, all error cases, test coverage, performance (N+1/indexes), security (injection/auth), naming consistency with @file [ExistingService.java]. Format: MUST_FIX | SHOULD_FIX | NICE. MUST_FIX and SHOULD_FIX only. One-line fix per issue.
Reviewer quick briefCursor · Haiku 4.5~30 tokens in
Reviewer brief for @file [File1.java] @file [File2.java] @file [Tests.java]: 1) What does this change in 2 sentences? 2) Riskiest part and why? 3) Are tests adequate? What's missing? 4) Does implementation match PR description: [paste description]? Bullets only.
02
Debugging
Root cause in seconds
Debug
Incident triageClaude Chat · Sonnet 4.6~55 tokens in
INCIDENT. Fast response needed. Symptom: [what users see] Error logs: [paste last 20 lines] Recent deploys: [list] Code: @file [SuspectedClass.java] Answer: MOST_LIKELY_CAUSE | FASTEST_MITIGATION | DIAGNOSTIC_COMMAND | ROLLBACK_RISK One line each. Now.
Post-incident PIRClaude Chat · Sonnet 4.6~60 tokens in
Blameless PIR. Timeline: [paste]. Root cause: [your diagnosis]. Impact: [users/duration]. Sections: Executive summary(3 sentences) / Timeline(table) / 5 Whys / Contributing factors / Action items(owner+date) / What went well. Max 500 words.
03
Standup & Sprint Ceremonies
AI prep, not AI replacement
Planning
Sprint ticket estimationClaude Chat · Haiku 4.5~45 tokens in
Estimate for Java/Spring Boot team. Stack maturity: [beginner/familiar/expert]. [PASTE TICKET] Answer: POINTS(1/2/3/5/8/13) | T-SHIRT(XS/S/M/L/XL) | CONFIDENCE(H/M/L) | MAIN_RISK | QUESTIONS_TO_CLARIFY One line each.
Retro analysisClaude Chat · Haiku 4.5~50 tokens in
Sprint retro analysis. Goal: [what we aimed for] Done: [tickets] Not done: [tickets + reason] Incidents: [list] Output: WENT_WELL(3 specific items) / DIDN'T(3 with root cause) / ACTIONS(3 concrete, measurable, with owner) Bullets. No filler.
04
Documentation Generation
Keep docs in sync automatically
Docs
Runbook from codeCursor · Sonnet 4.6~45 tokens in
@folder [src/] — operations runbook for on-call team. Sections: Overview / Start&Stop / Config(env vars table) / Health checks / Common errors+fixes / DB migrations / Logging / Rollback. Confluence wiki markup. Tables for env vars and errors.
Doc-code drift checkCursor · Haiku 4.5~35 tokens in
@file [Controller.java was changed — show diff or describe changes] Current Confluence docs: [paste relevant section] What's wrong/missing/outdated in the docs? Format: ISSUE | DOC_SECTION | CORRECT_INFO. Table only.

// Workflow 6 Checkpoint

Pre-PR Claude review in team PR template — run before requesting human review
Team has a shared prompt library in Confluence with 15+ tested prompts
Workflow 7 — Token Efficiency

⚡ Cut Your Claude Bill by 60–75%

A 6-person team reduced Claude Code spend from $2,400/month to $680 by applying prompt caching, model routing, and session focus. These techniques apply to every workflow on this page.

72%
Avg saving
9
Techniques
Current pricing (June 2026): Verify at anthropic.com/pricing before budgeting — prices change. Batch API is 50% off all models.
ModelInput per 1MOutput per 1MCached inputBest for
Haiku 4.5$1.00$5.00~$0.10CHEAPEST Classification, routing, simple summaries
Sonnet 4.6$3.00$15.00~$0.30DEFAULT Most coding, RAG, analysis, generation
Opus 4.8$5.00$25.00~$0.50Complex agents, architecture, long tasks
Opus 4.8 Fast$10.00$50.00~$1.00Opus quality at 2.5x speed — latency-sensitive Opus work
Any model — Batch50% off all tiers — use for offline workloadsBEST RATIO
// 9 techniques — apply all of them
01
Route to the cheapest model that works
Haiku 4.5 costs 1/3 of Sonnet 4.6. Use it for: classifying tickets, routing queries, simple summarisation, generating test names, checking if a PR description is complete. Build a task complexity classifier — send only complex tasks to Sonnet.
Saving: up to 67% on classification workloads
02
Enable prompt caching — 1-hour TTL
Repeated system prompts cost ~90% less when cached. With the 1-hour TTL in 2026, long agent sessions stay warm. Cache your large system prompt once, pay ~$0.30/1M instead of $3/1M. Works with Spring AI 1.1 and LangChain4j 1.x automatically.
Saving: ~90% on cached system prompt tokens
03
Use execution-focused prompts
Prompts that ask for explanations generate 3–4x more output tokens than prompts that ask for structured results. "List 3 issues as: ISSUE|FILE:LINE|FIX" generates 5x fewer tokens than "Please provide a detailed review of all issues..."
Saving: 60–75% on output tokens
04
Manage conversation context aggressively
Claude re-reads the entire conversation history on every message. A 20-turn conversation can cost 10x more than turn 1. Use sliding window (keep last 10 turns) or summarise after 15 turns. In Cursor: start a new chat when the topic changes — don't let sessions accumulate.
Saving: prevents 10x cost explosion on long sessions
05
Use @file not @Codebase when you know what you need
@Codebase does semantic search and includes multiple files. @file includes exactly one file. When you know which class is relevant, use @file — it's 5–20x fewer tokens than a broad @Codebase search. Use @Codebase only when you genuinely don't know which file contains what you need.
Saving: 5–20x on context tokens per query
06
Use Batch API for offline workloads
Any non-interactive task (nightly doc summaries, bulk test generation, code analysis across many files, classification jobs) should use the Batch API. Same models, 50% cheaper, async. Build a scheduler that routes all non-realtime tasks to Batch.
Saving: 50% on all async workloads
07
Use adaptive thinking with effort:low for simple tasks
With adaptive thinking on Sonnet 4.6, simple queries at effort:low may not think at all. Old budget_tokens approach allocated tokens even for trivial tasks. Audit which tasks genuinely need deep reasoning — most don't. Use effort:high only for architecture decisions and complex agents.
Saving: 30–40% on thinking tokens vs fixed budget
08
Set CLAUDE.md / .cursor/rules to under 5k tokens
Every rule file is injected into every request. A bloated .cursor/rules file costs tokens on every single prompt. Audit each rule: does it actually change output? Delete rules that don't. CLAUDE.md (Claude Code) should stay under 5k tokens — it loads on every session start.
Saving: proportional — bad rules are pure waste
09
Use .claudeignore / .cursorignore ruthlessly
Exclude everything Claude doesn't need: target/, build/, node_modules/, generated code, *.class files, test fixtures, large data files. In Claude Code: .claudeignore works exactly like .gitignore. A well-tuned ignore file can reduce @Codebase token usage by 60%+.
Saving: 20–60% on codebase indexing tokens
// Token comparison — same task, very different cost
❌ High-token prompt (~80 tokens in, ~400 out)
I need you to please take a look at this Java file and do a comprehensive review of everything you can find. Check for security vulnerabilities, performance issues, code quality problems, missing null checks, potential N+1 database queries, missing indexes, and anything else that might be a problem. For each issue, please explain it in detail and show me the code to fix it with a full explanation of why the fix works.
~$0.0072 per request at Sonnet 4.6 rates
✓ Efficient prompt (~35 tokens in, ~90 out)
Review @file for: 1. Security (SQL injection, auth bypass) 2. N+1 queries, missing indexes 3. Unchecked nulls Format: SEVERITY | LINE | ISSUE | FIX CRITICAL and HIGH only. Code snippets only, no prose.
~$0.0015 per request — 79% cheaper
❌ Vague codebase search (~expensive)
@Codebase how does authentication work in this application? Can you explain the whole auth flow from start to finish including all the different parts?
Loads 5–15 files, ~8,000 input tokens
✓ Targeted file reference (~cheap)
@file SecurityConfig.java @file JwtService.java Summarise the auth flow: entry point, token validation, session management. 3 bullet points max.
~400 input tokens — 20x cheaper
// Efficient prompt library — copy and use
T1
Code review — minimal tokens
CRITICAL issues only, structured output
~30 tokens
Pre-PR Code ReviewCursorLOW TOKENS
Review @file for production issues. Format: SEVERITY | LINE | ISSUE | FIX(1 line) Only CRITICAL and HIGH. No prose. Code snippets only.
Generates ~80 tokens vs ~400 for a verbose review. Use for pre-PR self-check.
Security scanCursorLOW TOKENS
Security scan @file: - SQL injection (parameterised queries?) - Auth bypass (missing @PreAuthorize?) - Sensitive data in logs (PII, tokens?) - Insecure deserialization List: VULN | LINE | FIX. Skip if none found.
T2
Unit test generation — structured
Tests only, no explanations
~40 tokens in
Generate JUnit 5 testsCursorLOW TOKENS
JUnit 5 tests for @file [ClassName.java]. Rules: @ExtendWith(MockitoExtension), @Mock deps, @InjectMocks target. Cover: happy path, each exception, null inputs, empty collections. Naming: should_[result]_when_[condition]. AAA structure. AssertJ. No explanations — code only.
Adding "no explanations — code only" typically reduces output by 50%+.
Find missing test casesCursorLOW TOKENS
@file [TestClass.java] — what test cases are missing? List: MISSING_SCENARIO | WHY_IT_MATTERS | TEST_METHOD_SIGNATURE No code bodies. I'll write the implementations.
T3
Requirement analysis — structured gaps
Pre-sprint, find gaps before coding
~50 tokens
Ticket pre-analysisClaude ChatLOW TOKENS
Analyse this ticket before I start coding: [PASTE TICKET] List: AMBIGUITIES: [question] | [why it blocks me] MISSING_ACS: [scenario] | [risk if ignored] ASSUMPTIONS: [what I assumed] | [confirm with PO?] ESTIMATE: S/M/L/XL | [main risk] No prose. Tables only.
Gets the same analysis in ~60 output tokens vs ~300 with a verbose prompt.
Break ticket into tasksClaude ChatLOW TOKENS
Break into dev tasks: [PASTE TICKET] Format: TASK | LAYER(Controller/Service/Repo/FE/Infra) | HOURS | DEPS Order by dependency. Flag parallelisable tasks with [PARALLEL].
T4
Architecture review — decisions not prose
Get the call, not the essay
~60 tokens
Architecture critiqueClaude ChatMED TOKENS
Critique this design. Stack: Java/Spring Boot/PostgreSQL/AWS. Scale: [N RPS]. [PASTE DESIGN] Issues: SEVERITY(BLOCKER/MAJOR/MINOR) | CATEGORY | PROBLEM | FIX Categories: Scale, SPOF, Cost, Security, Ops. Blockers and Majors only. One sentence per issue. Code snippet if relevant.
ADR generatorClaude ChatMED TOKENS
Write an ADR for: [DECISION] Context: [2 sentences] Options considered: [list 3] Sections: Status / Context / Decision / Consequences(+/-) / Alternatives / Review Date. Bullets not prose. Max 400 words.
T5
Debugging — root cause only
Skip the explanation, get the fix
~45 tokens
Stack trace diagnosisCursorLOW TOKENS
Debug this error. @file [RelevantClass.java] [PASTE STACK TRACE] Answer: ROOT_CAUSE | AFFECTED_LINE | MINIMAL_FIX | TEST_TO_ADD One line each. No prose.
Adding "one line each, no prose" reduces output from ~300 tokens to ~60.
Performance investigationCursorLOW TOKENS
Slow endpoint: [METHOD]. @file [Service.java] @file [Repo.java] Slow query log: [PASTE] Find: N+1 queries, missing indexes, eager loading, external calls in loops. Format: ISSUE | LINE | FIX(SQL or code, 1 line)
T6
Codebase understanding — targeted
Get answers without loading everything
~25 tokens
Trace a request (targeted)CursorLOW TOKENS
Trace: POST /api/orders @file [OrderController.java] @file [OrderService.java] @file [OrderRepository.java] Show: entry → validation → business logic → DB query → response. Format: CLASS.METHOD() → next step. One line per hop.
Using @file for known relevant files instead of @Codebase cuts tokens 10-20x.
Domain model extractionCursorLOW TOKENS
@file [Order.java] @file [Product.java] @file [User.java] List relationships: Entity → Relationship → Entity | Cardinality Then: which are aggregate roots? Which are value objects? Table format. No prose.
// Cursor settings for token efficiency
C1
.cursor/rules — keep under 3k tokens
Current format: .mdc files (not .cursorrules)
Setup
Notepads are deprecated. Replaced by Cursor Memories. Rules now live in .cursor/rules/*.mdc files. Each rule file has a scope: Always / Auto / Agent-requested / Manual.
.cursor/rules/java-conventions.mdcRULES FILE
--- description: Java coding conventions for this project alwaysApply: true --- Java 21. Spring Boot 3.x. Maven. - Records over POJOs for DTOs - No Lombok - Spring AI 1.1 for LLM integration - Optional over null returns - No checked exceptions in services - Javadoc on all public methods - Test naming: should_[result]_when_[condition] - AssertJ not JUnit assertions
Rule under 100 tokens. Delete any rule you can't verify changes actual output.
.cursor/rules/output-style.mdcRULES FILE
--- description: Output format to minimise token waste alwaysApply: true --- - Code only unless I ask for explanation - For issue lists: SEVERITY|LINE|ISSUE|FIX format - No "Great question!" or "Certainly!" preambles - No "Let me know if you need anything else" endings - Minimal comments in code — only where non-obvious
This single rule typically cuts output tokens 30–40% across all sessions.
C2
.cursorignore — exclude everything irrelevant
What Cursor can't see it won't load
Setup
.cursorignore for Java/Spring Boot projectsCONFIG
# Build output — never relevant target/ build/ out/ *.class *.jar *.war # Dependencies — Cursor knows these from imports .m2/ node_modules/ # Generated code — Claude shouldn't see or modify **/generated/ **/gen/ **/__generated__/ # Test data and fixtures — usually large, rarely useful context src/test/resources/large-*.json src/test/resources/fixtures/ # IDE files .idea/ *.iml .vscode/ # Logs and reports logs/ *.log surefire-reports/ jacoco/
A well-tuned .cursorignore reduces @Codebase token usage by 40–60%.
C3
Session management — start fresh often
Conversation history multiplies costs
Habit
Rule: Start a new Cursor chat when you switch tasks. Each message in an existing chat re-sends the full history. A 20-turn chat on "fix the login bug" costs 10–15x more per message than turn 1 — and all that auth context is irrelevant to your new task about order processing.
1
One chat per task
New Cursor chat for each Jira ticket. Don't let conversations sprawl across multiple tasks.
2
Summarise before continuing
For long-running tasks, ask Claude: "Summarise what we've done in 3 bullets." Start a new chat with that summary as the first message. Cuts context by 80%.
3
Use Cursor Memories for persistence
Things that should persist across sessions (conventions, patterns you've established) go into Memories — not into every conversation. Memories are injected efficiently, not as raw chat history.
4
Team token budget policy
Set a monthly budget per developer. Use Langfuse or similar to track actual usage. Review weekly in standups. The team that went from $2,400 to $680/month did this as a team discipline, not individual optimization.

// Token Efficiency Checklist

Haiku 4.5 is used for all classification, routing, and simple summarisation tasks
Prompt caching enabled with 1-hour TTL — system prompt cache hit rate > 60%
Output-style rule added to .cursor/rules — "code only, no prose preamble"
.cursorignore excludes target/, build/, generated code, large fixtures
Batch API used for all non-interactive workloads — saving 50% on those jobs
Team has a monthly token budget and reviews usage weekly