ai-observability
Use when adding Spring AI-specific model observations, token usage, latency, externally configured cost attribution, advisor…
Use when implementing tenant resolution, database or schema isolation, tenant-aware JPA, reactive tenant context, migrations, caching, jobs, or authorization in Spring Boot 3.
Claude Code
$ npx -y skills add rrezartprebreza/spring-boot-skills --skill multi-tenancy --agent claude-code
Codex
$ npx skills add rrezartprebreza/spring-boot-skills --skill multi-tenancy -a codex -y
Cursor
$ npx skills add rrezartprebreza/spring-boot-skills --skill multi-tenancy -a cursor -y
Gemini CLI
$ npx skills add rrezartprebreza/spring-boot-skills --skill multi-tenancy -a gemini-cli -y
GitHub Copilot
$ npx skills add rrezartprebreza/spring-boot-skills --skill multi-tenancy -a github-copilot -y
OpenCode
$ npx skills add rrezartprebreza/spring-boot-skills --skill multi-tenancy -a opencode -y
Windsurf
$ npx skills add rrezartprebreza/spring-boot-skills --skill multi-tenancy -a windsurf -y
name: multi-tenancy description: > Use when implementing tenant resolution, database or schema isolation, tenant-aware JPA, reactive tenant context, migrations, caching, jobs, or authorization in Spring Boot 3.
Treat tenant identity as an authorization boundary, not a query convenience.
The [TenantOrderStore](templates/TenantOrderStore.java) and [schema](examples/tenant-orders.sql) implement tenant-scoped reads, creates, updates and deletes. This example uses blocking JDBC, a verified resource-server JWT and an active-tenant registry. It is not a database/schema-routing or reactive implementation. Preserve the application's existing ID types and isolation model rather than copying this UUID model indiscriminately.
Wire [TenantScopeFilter](templates/TenantScopeFilter.java) into the security chain before `AuthorizationFilter` (after bearer authentication and exception translation). Supply a `RequestMatcher` for only the tenant-protected routes and a server-side predicate checking the tenant registry. Instantiate the filter inside the chain configuration, or disable its servlet auto-registration if it is a bean, so it does not run twice. Missing authentication is 401; missing, disabled or unknown tenant membership is 403. Do not read a public tenant header.
The verified `tenant_id` claim must be issued under a trusted tenant-membership policy; where revocation must take effect before token expiry, consult current membership as well as the active-tenant registry. Background jobs must similarly re-authorize tenant activity/membership at execution time. A captured ID is context propagation, not perpetual authorization.
[TenantContext](templates/TenantContext.java) scopes work with try/finally cleanup, preserves nested scopes and provides tenant-qualified cache keys:
TenantId tenant = TenantAccess.resolve(authentication, tenantRegistry::isActive);
try (var scope = TenantContext.open(tenant)) {
store.find(orderId);
String key = TenantContext.orderCacheKey(orderId);
executor.execute(TenantContext.capture(() -> store.find(orderId)));
}Open the tenant scope before invoking a separate transactional service proxy. The example does not propagate a transaction or SecurityContext to the worker; it starts its own unit of work. Do not use `InheritableThreadLocal` with pooled workers. Servlet async dispatches need explicit context propagation too. Scope every list, join and native query, and include `tenant_id` in child foreign keys. No Java repository wrapper protects against arbitrary unscoped SQL: restrict database credentials and consider PostgreSQL row-level security as defense in depth.
Verify same-ID records in two tenants, forbidden cross-tenant reads/updates/deletes, distinct cache keys, missing-context rejection, exception cleanup and sequential jobs on one worker.
The repository fixture targets Boot 3.5.16 with Java 17/21 and checks PostgreSQL 16 shared-schema access and blocking thread context; not Hibernate schema routing or Reactor. Check the [coverage matrix](https://github.com/rrezartprebreza/spring-boot-skills/blob/main/verification/MATRIX.md) before treating another minor version or an illustrative snippet as verified.
Production-grade Claude Code and Codex skills for Spring Boot developers
Use when adding Spring AI-specific model observations, token usage, latency, externally configured cost attribution, advisor…
Use when versioning Spring MVC or WebFlux APIs in Spring Boot 3 / Spring Framework 6. Covers explicit URL, header, and media-type…
Use when introducing or correcting grouped Spring Boot configuration, typed property binding, validation, profiles or secret…
Use when packaging a Spring Boot 3 application as an OCI image or GraalVM native executable. Covers buildpacks, layered images,…
Use when evolving aggregate invariants, value objects or domain events in an existing DDD-style Spring Boot 3 application, or…
Use when implementing Kafka, RabbitMQ, Pulsar, or JMS producers and consumers in Spring Boot 3. Covers event contracts,…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.