springboot-patterns
Skill1 starsChanged 56 days agoMITView on GitHub
Spring Boot services end to end on blocking Spring MVC: controller, service and repository layering, RFC 7807 errors, RestClient wrapped in Resilience4j, caching and events, Spring Security 6 authentication, authorization, headers and rate limiting, JPA mapping, N+1 and HikariCP, JUnit 5 and Testcontainers tests, and the pre-merge build, scan and coverage pipeline. Use when you say \"structure this Spring Boot API\", \"add JWT auth to this endpoint\", \"lock this down to admins\", \"why does this query run two hundred times\", \"write a @WebMvcTest for this controller\", \"rate limit this endpoint\", or \"verify this before I open the PR\". Not for Java language style, naming, records and Optional usage, use `java-coding-standards`.
19 other projects use a version of this.
Adopted by
Most recently taken up by
- templetongroup/radianttheir own version, first seen Sep 17, 2026
- jdanigo/hydraiatheir own version, first seen Sep 12, 2026
- SamuelNDCE/claude-super-skill-librarytheir own version, first seen Aug 1, 2026
- JunMystery/Agent-Guidance-Pythontheir own version, first seen Jul 21, 2026
- Lukasbrujula/claude-code-frameworktheir own version, first seen Jul 6, 2026
- minghaoZhangZ/shipkittheir own version, first seen May 21, 2026
Used with
Projects with it also use springboot-verification, springboot-tdd and 6 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
FaisalAlqarniSkillspringboot-verification
Verification loop for Spring Boot projects: build, static analysis, tests with coverage, security scans, and diff review before release or PR.
Also in 5 projects that use this
FaisalAlqarniSkillspringboot-tdd
Test-driven development for Spring Boot using JUnit 5, Mockito, MockMvc, Testcontainers, and JaCoCo. Use when adding features, fixing bugs, or refactoring.
Also in 5 projects that use this
johnrtiptonSkilldjango-security
This skill should be used when conducting security reviews, auditing Django applications, hardening security settings, implementing OWASP Top 10 protections, managing secrets, or ensuring multi-tenant security isolation. Provides automated security auditor that scans settings, code, dependencies, and multi-tenant configurations with auto-fix capabilities.
Also in 5 projects that use this
WorldFlowAISkillclickhouse-io
ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.
Also in 4 projects that use this
- +4 more from FaisalAlqarni
Other versions19 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 19
- rohitg00/awesome-claude-code-toolkit★ 2.7ksame name
- xu-xiang/everything-claude-code-zh★ 2ksame name
- loulanyue/awesome-claude-notes★ 272same name
- tpavanipradeep/everything-claude-code★ 134same name
- templetongroup/radiant★ 113same name
- Jamkris/everything-gemini-code★ 87same name
- tranhieutt/software_development_department★ 72same name
- codelably/harmony-claude-code★ 43same name
- FaisalAlqarni/sp-ecc★ 9same name
- Infopibe/everything-claude-code★ 8same name
9 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository59 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- agentic-engineeringSkill
- ai-regression-testingSkill
- angularSkill
- ansibleSkill
- api-designSkill
- architecture-decision-recordsSkill
- ascend-memorySkill
- ascend-web-hunterSkill
- audio-scribeSkill
- automation-inventorySkill
- backend-patternsSkill
- bashSkill
- build-dependency-managementSkill
- code-formatterSkill
- code-reviewerSkill
- coding-standardsSkill
- dart-flutter-patternsSkill
- database-migrationsSkill
- deployment-patternsSkill
- design-systemSkill
- docker-patternsSkill
- e2e-runbooksSkill
- e2e-testingSkill
- embedded-c-arduinoSkill
- frontend-designSkill
- g-code-3d-printingSkill
- github-opsSkill
- git-workflowSkill
- golang-patternsSkill
- hexagonal-architectureSkill
- home-assistantSkill
- java-coding-standardsSkill
- jetbrains-ide-opsSkill
- jira-integrationSkill
- keycloak-patternsSkill
- kicadSkill
- markdown-writerSkill
- mongodb-patternsSkill
- nextjs-app-router-patternsSkill
- node-backend-patternsSkill
- observability-and-loggingSkill
- obsidianSkill
- performance-optimizationSkill
- postgres-patternsSkill
- powershellSkill
- project-trackingSkill
- python-patternsSkill
- pytorch-patternsSkill
- react-patternsSkill
- researchSkill
- review-duplicationSkill
- security-reviewSkill
- seoSkill
- soap-webservicesSkill
- tdd-workflowSkill
- unitySkill
- web-accessibilitySkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 14 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 90
Every error response is application/problem+json built from Spring's ProblemDetail, with type, title, status, and detail set, and field …
- Distinctive: line 196
Default to none. A Javadoc block is usually a sign that the code failed to explain itself.
- Distinctive: line 201
When one is still genuinely needed, the prose is capped at five lines and is usually one.
“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Spring Boot Patterns
How a production Spring Boot service is put together, from the controller down to the database, the security around it, the tests, and the pipeline that ships it. Each reference below carries the depth for one area.
Baseline
Java 21 LTS is the minimum and Java 25 LTS is the recommended target, so records, sealed types, pattern matching, and virtual threads are all available and expected. Spring Boot 3.x throughout, with Spring Security 6.x and the Hibernate 6 that ships with it. This targets blocking Spring MVC on virtual threads, and WebFlux is out of scope.
When to activate
- Building or restructuring a REST API on Spring MVC, and layering its controllers, services, and repositories.
- Adding validation, exception handling, or pagination to endpoints.
- Configuring caching, asynchronous processing, or Spring events.
- Calling another service over HTTP and making that call survive the other service.
- Adding authentication, authorization, CORS, response headers, or rate limiting.
- Designing entities, choosing a fetch strategy, chasing an N+1 query, or sizing the connection pool.
- Writing the tests, choosing a slice, wiring Testcontainers, or fixing a coverage gate.
- Running the build, analysis, and scan pipeline before a pull request or a deployment.
When not to activate
- Java language style, naming, immutability, and
Optional, usejava-coding-standards. - Ports and adapters layering across the whole service, use
hexagonal-architecture. - Log format, metrics, tracing, and the startup readiness banner, use
observability-and-logging. - Schema change and rollout mechanics, use
database-migrations. - PostgreSQL query planning and index internals, use
postgres-patterns. - Language-neutral security review checklists, use
security-review. Threat modelling goes to thesecurity-auditoragent. - Configuring Keycloak itself as the identity provider, use
keycloak-patterns. - Version catalogs, BOM imports, and dependency admission, use
build-dependency-management.
Keep the layers doing one job each
The controller parses and returns. The service holds the behaviour and the transaction. The repository talks to the database. A controller that touches a repository has skipped the layer where the rules live.
Pass: a thin controller delegating to a service that returns a project DTO.
@RestController
@RequestMapping("/api/v1/markets")
@Validated
class MarketController {
@PostMapping
ResponseEntity<MarketResponse> create(@Valid @RequestBody CreateMarketRequest request) {
Market market = marketService.create(request);
return ResponseEntity.status(HttpStatus.CREATED).body(MarketResponse.from(market));
}
}Fail: a controller injecting MarketRepository and building the response from an entity. Full controller, DTO, and
validation examples: references/rest-api-and-validation.md.
Never let a framework type into the API contract
Spring Data's Page serialises differently between versions and exposes internals no client asked for. Map it into
a project-owned envelope inside the service, so the wire contract belongs to the project.
Pass: the service returns PageResponse.from(page, MarketResponse::from), and the controller never sees Page.
Fail: ResponseEntity<Page<MarketEntity>>, which publishes the entity and the framework type in one move.
The same rule covers entities: a DTO is the contract, and an entity on the wire leaks the schema and every column somebody adds later.
Return RFC 7807 problem details
Every error response is application/problem+json built from Spring's ProblemDetail, with type, title,
status, and detail set, and field errors carried as a problem property. An ad-hoc error shape means each client
writes a parser for this service alone.
Pass: one @ControllerAdvice whose handlers each build a ProblemDetail and carry field errors in a problem
property, in full in references/rest-api-and-validation.md.
Fail: a try-catch in the controller returning Map.of("error", ex.getMessage()), which also leaks internals to the
caller.
Enable the framework's own problem responses with spring.mvc.problemdetails.enabled=true.
Call other services with RestClient, wrapped in Resilience4j
RestClient is the synchronous outbound client. Configure it as a bean with a base URL, explicit connect and read
timeouts, and shared default headers. Then accept that an external call fails eventually: retry with exponential
backoff and jitter, and open a circuit when the far end is clearly down. Never hand-roll a retry loop around a
Thread.sleep, and never retry at a fixed interval, because fixed intervals synchronise callers into one burst.
Pass: one bean per upstream, annotations plus configuration, and a fallback that degrades rather than throws.
@Retry(name = "externalApi")
@CircuitBreaker(name = "externalApi", fallbackMethod = "fallback")
public ResponseEntity<String> call() {
return restClient.get().uri("/endpoint").retrieve().toEntity(String.class);
}
public ResponseEntity<String> fallback(Exception ex) {
return ResponseEntity.status(503).body("Service unavailable");
}Fail: RestTemplate, which is in maintenance mode. It is not annotated deprecated and existing code keeps working,
but it receives only security and bug fixes, so no new call site should use it. WebClient is also wrong here,
because WebFlux is out of scope and there is no reactive path to justify it. Equally a fail: a while loop
counting attempts around a Thread.sleep, which has no jitter, no circuit, and no metrics.
The full Resilience4j configuration and timeout settings are in references/outbound-and-resilience.md.
Put the transaction on the service method
@Transactional belongs on service methods, never on a controller and never on a repository method. Mark query
paths readOnly = true. Remember that calling a transactional method from inside the same bean bypasses the proxy
entirely, so the annotation does nothing.
Pass: @Transactional(readOnly = true) on findById, and a plain @Transactional on createOrder.
Fail: a private helper annotated @Transactional, or a public method calling this.otherTransactionalMethod() and
expecting a new transaction. Extract it into a separate bean.
Cache with a TTL and an eviction path
Caching needs @EnableCaching, an explicit time to live, and a size bound. An unbounded cache is a memory leak
with a friendly name, and a cache of mutable state with no invalidation serves stale data until the next deploy.
Pass: @Cacheable(value = "market", key = "#id") on the read, with a matching
@CacheEvict(value = "market", key = "#id") written in the same change.
Fail: @Cacheable on a method whose result changes, with no @CacheEvict anywhere in the codebase.
Redis cache manager setup, @Async executors, transactional event listeners, and background jobs are in
references/caching-async-and-events.md.
Deny by default and validate at the edge
Two security rules apply to every endpoint, so they sit here rather than one reference away. Turn on
@EnableMethodSecurity and put the authorization rule next to the method it guards, so a new endpoint is closed
until somebody opens it, and constrain the request DTO so Bean Validation rejects the payload before any business
code runs.
Pass: @PreAuthorize("hasRole('ADMIN')") on the handler, and @Valid @RequestBody CreateUserDto dto where the
record carries @NotBlank, @Size, and @Email.
Fail: an ownership check written inside the method body, which every later caller of that service method skips, or an unconstrained DTO where the first thing to notice a bad value is a database constraint violation.
Tokens, hashing, CSRF, headers, CORS, secrets, uploads, rate limiting: references/security.md.
Write the failing test first
Red, green, refactor, in that order. A test written after the code passes on the first run, which proves nothing
about whether it would catch the regression it exists for. Pick the narrowest slice that can hold the behaviour:
plain JUnit with Mockito for service logic, @WebMvcTest for status codes and validation, @DataJpaTest with
Testcontainers for repositories, and @SpringBootTest only where the wiring itself is the subject.
Pass: the new test fails for the right reason, then the implementation makes it pass.
Fail: the implementation lands first and the test is written to match whatever it already does. Slice examples, Testcontainers wiring, builders, and the JaCoCo gate are in references/testing.md.
Javadoc
Default to none. A Javadoc block is usually a sign that the code failed to explain itself. Before writing one, extract the unclear block into a well-named method, rename the parameters so they carry their own meaning, and tighten the types. Do that first and most Javadoc blocks have nothing left to say, which is the outcome you want. Code that explains itself cannot go stale, a comment can.
When one is still genuinely needed, the prose is capped at five lines and is usually one. Every tag line is capped at
one line, @param and @return and @throws alike, and only appears when it genuinely adds something: if the note
does not fit on a single line, shorten it or drop the tag. Four rules decide what goes in.
- Prose. One sentence saying what it does, then only what a caller cannot infer from the signature. Nothing more.
@paramonly when the name and the type do not already convey it, meaning units, nullability, a valid range, or who owns the argument afterwards.@param orderId the wholesale order identifieris noise, delete it.@returnonly when it is non-obvious.@throwsalways, for every exception a caller can act on. Unchecked exceptions never appear in the signature, so this one is genuinely contract rather than decoration.
Going past the five-line prose cap is allowed only when the contract genuinely cannot be stated in fewer lines, for example a documented state machine, an ordering requirement, or a concurrency guarantee. It is an exception you justify in review, not a budget to spend. The one-line cap on a tag line has no exception at all: shorten it or delete it.
// GOOD: one sentence, then only what the signature cannot say
/**
* Publishes the order to the fulfilment topic once the transaction commits.
*
* @throws OrderPublishException when the broker rejects the message
*/
public void publish(OrderId orderId) { ... }
// BAD: restates the signature, and the first tag wraps onto a second line
/**
* Publishes an order.
*
* @param orderId the identifier of the order that should be published to the
* fulfilment topic
* @return nothing
*/
public void publish(OrderId orderId) { ... }Production defaults
- Constructor injection everywhere, no field injection.
spring.mvc.problemdetails.enabled=trueso framework errors match your own.spring.threads.virtual.enabled=true, since this skill targets blocking MVC on virtual threads.spring.jpa.hibernate.ddl-auto=validate, with the schema owned by Flyway or Liquibase migrations.- HikariCP sized for the workload with explicit timeouts, and
readOnly = trueon every query path. - Nullability enforced with
@NonNullandOptional, perjava-coding-standards. - The version in the path as
/api/v1/resource, and a computed futureSunsetdate on anything deprecated.
Startup readiness log
The banner and its format belong to observability-and-logging. What is Spring-specific is the hook: emit the block
from an @EventListener(ApplicationReadyEvent.class) method. Spring Boot sends that event after every application and
command-line runner has run, right before readiness moves to ACCEPTING_TRAFFIC, whereas ApplicationStartedEvent
fires before those runners.
Which reference to open for which task
| Task | Reference |
| Controllers, DTOs, validation, the pagination envelope, the exception handler, versioning, OpenAPI | references/rest-api-and-validation.md |
| RestClient beans, Resilience4j retry and circuit breaker settings, timeouts, fallbacks | references/outbound-and-resilience.md |
Redis cache manager, @Async executors, transactional events, scheduled jobs, request filters | references/caching-async-and-events.md |
| Authentication, method authorization, SQL injection, password hashing, CSRF, secrets, uploads, rate limiting | references/security.md |
| OAuth 2.1 flows, refresh token rotation, JWT claim validation, the auth filter, session cookies | references/oauth2-and-jwt.md |
| The full response header block, the CORS configuration source, mutual TLS between services | references/headers-cors-mtls.md |
| Entity mapping, fetch strategy, N+1, projections, transactions, paging, indexing, second-level cache | references/jpa.md |
| HikariCP sizing formula, pool configuration, utilisation alerts | references/connection-pooling.md |
| Test slices, MockMvc, Testcontainers, AssertJ, test data builders, the JaCoCo gate | references/testing.md |
| The six pre-merge phases, the scan commands, the report template, the re-run loop | references/verification-pipeline.md |
The startup banner and readiness log block, which observability-and-logging owns | ../observability-and-logging/references/startup-readiness-log.md |
Related skills
| Skill | What it owns |
java-coding-standards | Java naming, records, immutability, exceptions, and logging style. |
coding-standards | The cross-language engineering floor these patterns sit on. |
hexagonal-architecture | Ports and adapters layering, when the project has chosen it over layered packages. |
api-design | Resource naming, status codes, and versioning policy above the framework. |
database-migrations | Migration authoring, rollback, and zero-downtime schema change. |
postgres-patterns | PostgreSQL-specific indexing and query planning. |
observability-and-logging | Log format, metrics, tracing, health, and the startup banner. |
build-dependency-management | Version catalogs, BOM imports, and where the plugin versions live. |
keycloak-patterns | Configuring Keycloak as the identity provider behind these flows. |
code-reviewer | Reviewing a Spring Boot diff against all of the above. |
Checklist
- Controllers parse and return, services hold behaviour, repositories reach the database, nothing skips a layer.
- No entity and no Spring Data
Pageappears in a response body. - Every error response is a
ProblemDetailfrom one@ControllerAdvice. - Outbound HTTP goes through
RestClient, with a retry, a circuit breaker, and explicit timeouts. @Transactionalsits on service methods only, withreadOnly = trueon query paths.- Event listeners that must not run on a rollback use
AFTER_COMMIT. - Every cache has a TTL, a size bound, and an eviction path.
- Every sensitive path carries an authorization rule, and every request body is a validated DTO.
- No association is eager, every paged query has a sort, and no N+1 is left as a follow-up.
- Every behaviour change started with a test that failed for the right reason, in the narrowest slice.
- Repository tests run against the production database engine through Testcontainers.
- Javadoc is absent by default, and every surviving block clears the caps above.
- The verification pipeline ran in order and every gate is green before the pull request opens.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

