Skip to content
FunCoding

conventions

Spring Boot project conventions and mandatory rules. Auto-loads when working with Spring Boot, Java, or Maven projects, and before a new Spring Boot project or REST API is generated - it asks for the architecture style (layered CRUD, CQRS, Event Sourcing) first. Enforces No-Lombok, constructor injection, RestClient, Flyway for relational databases, Problem Details errors, and other standards; adds OpenAPI contract rules when the API is built for a UI.

Star
1,473
Category
Data
License
Apache-2.0
Last commit
Nov 27, 2026

skills/conventions/SKILL.md

View on GitHub

Spring Boot Project Conventions

These conventions apply to ALL code generated or reviewed in the project. Follow them strictly.

Architecture Decision

Decide the architecture style before generating any code. The decision is recorded once in the project's CLAUDE.md (AGENTS.md in Codex and OpenCode) and followed in every later session.

SituationAction
New project: no build file (pom.xml, build.gradle*) and no architecture blockAsk, even when the prompt does not mention architecture
The prompt already states a choiceSkip that question, confirm the choice in one line, ask the remaining ones
The architecture block existsNever ask again; follow it
Existing project without the blockLayered CRUD; ask only when the user requests CQRS or Event Sourcing

The architecture block is a ## Architecture section that has a style: line. A ## Architecture heading without style: is a description, not a decision.

Who asks. The dialog runs in the main conversation, one question at a time, with the default listed first. A subagent that is started without a decision does not ask and does not generate code: it stops and returns the question to the main conversation.

#QuestionOptions (default first)Asked when
1Architecture styleLayered CRUD / CQRS / CQRS + Event Sourcingalways
2ScopeWhich aggregates or bounded contextsstyle is not CRUD
3TopologySeparate command and query services / Single servicestyle is not CRUD
4Event transportApache Kafka / In-process events (Spring Modulith)style is CQRS and topology is single service; separate services always use Kafka, and an event-sourced single service reads its event store directly
5Read model storePostgreSQL / another store named by the userstyle is not CRUD
6Event storePostgreSQL append-only table / Axon Frameworkstyle is Event Sourcing

With question 1, state the cost in two lines:

CQRS: a query right after a command may still return the old state (eventual consistency), and there is more code: commands, queries, handlers, events and projections. Event Sourcing adds event versioning: a published event is never changed, so every change to it needs a new version.

If the user picks layered CRUD, ask nothing else.

Not yet supported. Reply "not yet supported in this version of the plugin" and ask again between the supported options. Never fall back silently:

  • CQRS or Event Sourcing for an API built for a UI (see "REST API Built for a UI"): the UI contract expects one API that returns the full record on every write. Offer layered CRUD only.

Axon Framework. When the user picks it, the event-driven skill, references/axon.md, continues the dialog before any code: it selects the Axon version that fits the project's Spring Boot version, tells the user which one, and asks whether events are stored in Axon Server or in PostgreSQL.

Record the decision before generating code. Create the file if the project has none, and keep the rest of an existing file:

## Architecture
style: cqrs-event-sourcing
scope: Order, Payment
topology: separate-services
transport: kafka
read-store: postgresql
event-store: postgresql
KeyValues
stylelayered-crud, cqrs, cqrs-event-sourcing
scopeaggregate or bounded context names
topologyseparate-services, single-service
transportkafka, in-process (always in-process for an event-sourced single service)
read-storepostgresql, or the store the user named
event-storeEvent Sourcing only: postgresql, axon (then also axon-version, axon-event-store: axon-server or postgresql, and with postgresql the axon-storage-engine and its licence)

Layered CRUD is recorded as the single line style: layered-crud, so a subagent or a later session does not ask again. Record a decision only after the dialog ran: an existing project without the block is layered CRUD as it is, and gets no block added.

What each style replaces. Every rule in this skill applies to every style, except:

RuleLayered CRUDCQRSCQRS + Event Sourcing
Layering and packagesController → Service → Repository (spring-boot skill, Architecture Patterns)Controller → handler → repository, in command, query, domain, projection packagesas CQRS; handlers use the event store, not a repository
@Transactional(readOnly = true) at service class levelapplies@Transactional on command handlers, @Transactional(readOnly = true) on query handlersas CQRS
Request records<Resource>CreateRequest, <Resource>UpdateRequestcommand records (Create<Resource>Command, ...)command records named after what the user does (PayOrderCommand)
What a write returnsthe record (<Resource>Response)CommandResult with the id and the new version; only queries return <Resource>Responseas CQRS; 201 for a new aggregate, 202 for every other command
JPA entities with @Version, 409 on a lost updateappliesapplies on the write sideno JPA on the write side; a version conflict on append to the event store is the 409
Identity columns for idsevery tablewrite side only; a read-model table takes its id from the eventsnone; an aggregate id is a UUID created by the application

When the style is cqrs or cqrs-event-sourcing, load the event-driven skill and follow it. It holds the topology, the CQRS and Event Sourcing rules, Axon, Kafka and testing.

Mandatory Rules

  • No Lombok — write explicit constructors, getters, setters; use LoggerFactory.getLogger() for loggers
  • Constructor injection — no @Autowired on fields
  • RestClient over RestTemplate/WebClient for blocking HTTP calls
  • RestTestClient with @AutoConfigureRestTestClient for integration tests
  • Testcontainers with @ServiceConnection (not @DynamicPropertySource)
  • Jakarta Persistence (not javax.persistence)
  • Jackson 3 (tools.jackson): inject JsonMapper, not ObjectMapper; @JacksonComponent replaces @JsonComponent; only com.fasterxml.jackson.annotation keeps its old package
  • Boot 4 starters: spring-boot-starter-webmvc (not -web), spring-boot-starter-aspectj (not -aop), test starters spring-boot-starter-<technology>-test
  • Java records for DTOs: <Resource>Response, <Resource>CreateRequest, <Resource>UpdateRequest; controllers never expose entities
  • Maven for dependency management
  • Group ID: pl.piomin.services
  • Artifact name = parent directory name
  • Semantic versioning from 1.0.0 — PATCH by default, MINOR for a backward-compatible feature, MAJOR for a breaking API change; every OpenAPI contract change bumps the version
  • Docker Compose for local dependencies
  • CI pipeline — generate CI/CD config; detect existing CI setup (.github/workflows/, .circleci/, .gitlab-ci.yml) and match it, or default to a sensible choice
  • Tests — always write both positive and negative test cases
  • Update README.md on each new version

Code Quality Standards

  • Use latest Spring Boot 4.x and Java 21+
  • @Transactional(readOnly = true) at service class level, @Transactional on mutating methods
  • @Valid @RequestBody on all POST/PUT endpoints
  • @RestControllerAdvice for global exception handling
  • Return ResponseEntity with proper status codes (201 Created, 204 No Content)
  • @ConfigurationProperties for type-safe config (no raw @Value for groups)
  • @HttpExchange interfaces for declarative HTTP clients
  • Virtual threads enabled by default (spring.threads.virtual.enabled: true)
  • Problem Details enabled (spring.mvc.problemdetails.enabled: true); every error, including the catch-all 500, is RFC 9457 Problem Details, and the catch-all never returns the exception message
  • List endpoints return PagedModel; never Page/PageImpl
  • Optimistic locking with @Version; a lost update returns 409
  • Graceful shutdown configured (server.shutdown: graceful)
  • Actuator probes: permit /actuator/health/** (not only /actuator/health), so the liveness/readiness probes work behind security

REST API Built for a UI (OpenAPI Contract)

Decide first whether these rules apply. They are required only when the API is built for a UI (or another client) that is generated from its OpenAPI contract; they cost extra code and tests that a plain API does not need.

SituationAction
The user says the API backs a web UI or generated clients; the project's CLAUDE.md / AGENTS.md names a UI (e.g. a crud-ui-blueprint UI); the repo has contract/openapi.json, docs/API-CONTRACT.md or docs/DEPLOY-CONVENTION.mdLoad the spring-boot skill, references/ui-contract.md, and follow it
Service-to-service API, internal API, or no client is generated from the contractOptional - the general rules above are enough; use a rule from ui-contract.md only when the user asks for it
UnsureAsk once whether a UI or generated client will consume the API

references/ui-contract.md is the single source of these rules: /api base path without CORS, operationIds, the springdoc 3 contract exported to contract/openapi.json and checked in CI, the fixed FieldError codes, PUT with a required version, filters, Reference {id, label} relations, Keycloak realm layout, public health/info, the README "Connect a UI" section, and the deployment shared with the UI repo (deploy/ overlays, no host or secret in git). Where it differs from the defaults above (e.g. /api instead of /api/v1), it wins; the project's own copies of docs/API-CONTRACT.md and docs/DEPLOY-CONVENTION.md win over both.

Relational Database Schema (Flyway)

Decide first whether Flyway applies:

SituationAction
JDBC/JPA with a Flyway-supported relational database (PostgreSQL, MySQL, MariaDB, Oracle, SQL Server, DB2, H2, ...)Use Flyway
Project already uses LiquibaseKeep Liquibase, do not add Flyway
No persistence, NoSQL only (MongoDB, Redis, Cassandra, Elasticsearch), or a database Flyway does not supportSkip Flyway - no dependency, no db/migration, no spring.flyway.*

When Flyway applies:

  • Flyway owns the schema (src/main/resources/db/migration); Hibernate only validates it (spring.jpa.hibernate.ddl-auto: validate). Never use update/create outside tests
  • Dependencies: spring-boot-starter-flyway plus the database module (e.g. flyway-database-postgresql)
  • application.yml: ddl-auto: validate, open-in-view: false, and the database in the readiness probe (management.endpoint.health.group.readiness.include: readinessState,db). Flyway defaults need no spring.flyway.* keys (exception: a CQRS single service with command and query schemas sets spring.flyway.schemas, see the event-driven skill)
  • IDs are standard identity columns mapped with GenerationType.IDENTITY: GENERATED BY DEFAULT AS IDENTITY (PostgreSQL, Oracle, DB2, H2), AUTO_INCREMENT (MySQL/MariaDB), IDENTITY (SQL Server); not SERIAL/BIGSERIAL
  • Never edit an applied migration; every change is one new file V<n>__<description>.sql
  • Every entity change ships with its migration in the same commit
  • A new NOT NULL column gets a DEFAULT or a backfill, so existing rows keep working
  • Name constraints and indexes explicitly (pk_, uk_, ck_, fk_, ix_); index every foreign key column; a unique constraint the API reports as a 409 conflict is referenced by name from the exception handler
  • Column DEFAULTs match entity defaults; validation rules get a matching DB CHECK
  • Integration tests use Testcontainers with the production database and assert that all migrations were applied

Details and examples: spring-boot skill, references/data.md (Database Migrations).

Similar Skills

Featured

agentic-os

Build persistent multi-agent systems without external databases, using file-based memory and scheduled tasks.

AFaffaan-m/ECC315k4,381 new stars in the last 7 days

health

GAgarrytan/gstack143k598 new stars in the last 7 days

deprecation-and-migration

ADaddyosmani/agent-skills122k1,667 new stars in the last 7 days

ccs-align

THthedotmack/claude-mem121k1,626 new stars in the last 7 days

handoff

THthedotmack/claude-mem121k1,626 new stars in the last 7 days

mem-search

THthedotmack/claude-mem121k1,626 new stars in the last 7 days