plugin/skills/spring-jpa-patterns/SKILL.md
Use this skill when the agent is implementing Java backend services in Spring Boot projects, reviewing JPA entity models, configuring connection pools or caches, designing REST endpoints, writing repository/service/controller layers, or onboarding to Spring conventions — for Spring Boot 3 + JPA backend patterns covering Java 21+ features, layered architecture, Spring Data JPA, Hibernate fetch strategies, Flyway migrations, HikariCP pool tuning, Redis caching with Spring Cache, Spring Security 6 filter chains, REST API design (RFC 7807, pagination, versioning), Testcontainers + JUnit 5 + Mockito testing, Micrometer + Actuator observability, and virtual threads and performance tuning.
npx skillsauth add avav25/ai-assets spring-jpa-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Backend knowledge base for Java 21+ services built on Spring Boot 3 with PostgreSQL and Redis. Covers layered architecture, persistence with Spring Data JPA + Hibernate, Flyway-managed schema, HikariCP tuning, Spring Security 6, REST design, the JUnit 5 + Mockito + Testcontainers test stack, and Micrometer-based observability. Designed to be auto-loaded by java-engineer and referenced by reviewers and architects working on Java services.
Use layered or hexagonal architecture consistently across the project:
@RestController): HTTP mapping, request validation, response DTOs@Service, @Transactional): business logic, orchestration, transaction boundaries@Repository, extends JpaRepository): data access, custom queries@Entity): JPA-managed domain objects, lifecycle callbacks@Configuration): bean definitions, property binding, infrastructure setup@ControllerAdvice): global error handling with @ExceptionHandlerDependency injection rules:
final fields with @RequiredArgsConstructor or explicit constructor.@Autowired on fields).Configuration:
application.yml over .properties — structured, profile-aware.application-dev.yml, application-prod.yml, application-test.yml.${DB_URL}, ${REDIS_HOST}, ${JWT_SECRET}.@ConfigurationProperties + @Validated for type-safe binding.spring.threads.virtual.enabled=true for I/O-bound workloads (Java 21+).Entity design:
@Entity with explicit @Table(name = "...") — never rely on naming strategy alone.@GeneratedValue(strategy = IDENTITY) for serial, @UuidGenerator for UUID.@CreatedDate, @LastModifiedDate via @EntityListeners(AuditingEntityListener.class).@Column(nullable = false) matches DB constraints.equals() / hashCode() based on business key or ID — never on all fields.@Enumerated(EnumType.STRING) — never EnumType.ORDINAL.Query and fetch patterns:
@EntityGraph or JOIN FETCH in JPQL for association loading.@ManyToOne and @OneToMany use FetchType.LAZY.hibernate.jdbc.batch_size=25 for bulk inserts/updates.@Transactional(readOnly = true) enables Hibernate optimizations.src/main/resources/db/migration/.V{version}__{description}.sql (e.g., V1__create_users_table.sql).R__{description}.sql for views, functions, seed data.CREATE INDEX IF NOT EXISTS, ALTER TABLE ... ADD COLUMN IF NOT EXISTS).ddl-auto=update in production — Flyway owns schema.maximum-pool-size, connection-timeout, max-lifetime.(2 * CPU cores) + number_of_disks — tune via load testing.max-lifetime below PostgreSQL's idle_in_transaction_session_timeout.hikaricp.connections.active, hikaricp.connections.pending.leakDetectionThreshold in non-prod profiles.Declarative caching:
@EnableCaching + @Cacheable, @CachePut, @CacheEvict.{entity}:{id} or {entity}:list:{hash_of_params} — predictable, eviction-friendly.RedisCacheConfiguration.@CacheEvict on mutations; allEntries = true for list caches.GenericJackson2JsonRedisSerializer — human-readable, debuggable.Patterns:
@Cacheable flow — check cache, miss → load from DB → store.RedisTemplate + Lua scripts, or Redisson.SecurityFilterChain — never extend WebSecurityConfigurerAdapter (removed in Spring Security 6).OncePerRequestFilter.spring-boot-starter-oauth2-resource-server for JWT/opaque tokens.@PreAuthorize("hasRole('ADMIN')"), @Secured for role-based access.SecurityFilterChain — never @CrossOrigin("*").csrf(csrf -> csrf.disable())); keep enabled for session apps.BCryptPasswordEncoder. Never store plaintext./api/v1/users, /api/v1/users/{id}/orders.Pageable parameter → Page<T> with page, size, sort./api/v1/...).@Valid + Jakarta Bean Validation (@NotNull, @Size, @Email, @Pattern).{ timestamp, status, error, message, path, details[] }.BusinessException (4xx) → specific subclasses; SystemException (5xx).@ControllerAdvice with @ExceptionHandler per exception family.@DisplayName for readability.@Mock + @InjectMocks, @ExtendWith(MockitoExtension.class) for unit tests.verify(...) only when interaction matters; otherwise assert state.@WebMvcTest + MockMvc for controllers.@DataJpaTest for repositories (paired with Testcontainers PostgreSQL).@DataRedisTest for Redis-only slices.@SpringBootTest + MockMvc for end-to-end request-response cycles.@Testcontainers + @Container for PostgreSQL and Redis to match production runtimes.withReuse(true) and ~/.testcontainers.properties for local speed.@DynamicPropertySource to inject JDBC URL and Redis host./actuator/prometheus. Track latency, error rate, DB pool, cache hit ratio./actuator/health with custom indicators for PostgreSQL, Redis, external services.ReentrantLock over synchronized to avoid pinning carriers.EXPLAIN ANALYZE on slow queries. Add indexes. Paginate large results.@Async + custom TaskExecutor. CompletableFuture for parallel calls.| Workflow | Apply this knowledge |
|---|---|
| Agent(java-engineer) invocation | Auto-loaded |
| /develop with a Java work package | Spawned developer agent loads this |
| /code-review on Java PRs | Reviewer references these patterns |
| /architecture-design for a Java service | Architect references API + persistence patterns |
| /bugfix on a Spring/JPA defect | Developer + QA reference fetch + transaction patterns |
java-engineer (primary), software-engineer (when reviewing Java code), db-engineer (JPA model and migration review), solution-architect (REST + service-layer design).owasp-coverage skill for Spring Security threat coverage; test-strategy skill for layered test pyramid; observability-methods skill for Micrometer/OTel cross-stack patterns.development
Use this skill when running the recurring (daily) knowledge-base rescan for a repo that already has knowledge/.knowledge-sync.yml — the main-thread dispatcher that reads the config, computes the git delta since last_scanned_sha, maps changed paths to affected doc areas, early-exits cheaply when nothing changed, then fans out one Agent(content-writer) per affected area, applies the propose/direct update policy, advances the baseline only on success, and writes an L4 run log — all with the G1 untrusted-content choke-point, secret-scan, deny-list, and budget controls woven in. For first-time setup use /knowledge-sync-init.
development
Use this skill when bootstrapping scheduled knowledge-base sync for a repo that has no knowledge/.knowledge-sync.yml yet — to run one-time setup that detects the knowledge_root from CLAUDE.md/AGENTS.md, maps doc areas to source globs, records opt-in external sources (Linear/Notion/WebFetch, all disabled by default), captures a baseline last_scanned_sha, sets the per-area update policy, generates or seeds knowledge/CONVENTIONS.md, provisions the L4 memory dir, and offers to register the daily routine. Routes ongoing recurring sync operations to /knowledge-sync.
tools
Use this skill when bootstrapping a target repository to be ai-skills-aware — on the first run of any ai-skills workflow in a fresh repo, when adopting the ai-skills plugin in an existing repo, or after upgrading to a plugin version that adds new memory paths or templates, including when the user does not say "init" but asks to "set up" or "onboard" the repo — to detect codebase type, create CLAUDE.md + AGENTS.md scaffolding, initialize the .ai-skills-memory/ directory tree from L1 templates, and configure .gitignore. Idempotent — safe to re-run. Accepts `--codebase-type <type>` and `--overwrite`. Not for re-initializing only memory — use `/memory-init` instead.
tools
Use this skill when extending, repairing, or improving plugin assets, when ingesting a `/feedback` report as a fix-cycle backlog, or when you do not remember which lower-level command is right for the job — the umbrella workflow for ai-skills plugin-asset authoring and maintenance: creating, auditing, fixing, improving, refactoring, and migrating skills, agents, rules, hooks, prompts, schemas, and rubrics inside the plugin. Auto-classifies the request, loads the right knowledge skills (`@prompt-engineering`, `@context-engineering`, `@team-protocols`), and spawns the right subagents (`prompt-engineer`, `system-architect`, `python-engineer`, `software-engineer`, `qa-engineer`, `eval-judge`) via the `Agent` tool.