ai-observability
Use when adding Spring AI-specific model observations, token usage, latency, externally configured cost attribution, advisor…
Use when implementing caching, session storage, rate limiting, or any Redis integration. Covers cache-aside pattern, key naming, TTL strategy, and serialization config.
Claude Code
$ npx -y skills add rrezartprebreza/spring-boot-skills --skill spring-data-redis --agent claude-code
Codex
$ npx skills add rrezartprebreza/spring-boot-skills --skill spring-data-redis -a codex -y
Cursor
$ npx skills add rrezartprebreza/spring-boot-skills --skill spring-data-redis -a cursor -y
Gemini CLI
$ npx skills add rrezartprebreza/spring-boot-skills --skill spring-data-redis -a gemini-cli -y
GitHub Copilot
$ npx skills add rrezartprebreza/spring-boot-skills --skill spring-data-redis -a github-copilot -y
OpenCode
$ npx skills add rrezartprebreza/spring-boot-skills --skill spring-data-redis -a opencode -y
Windsurf
$ npx skills add rrezartprebreza/spring-boot-skills --skill spring-data-redis -a windsurf -y
name: spring-data-redis description: > Use when implementing caching, session storage, rate limiting, or any Redis integration. Covers cache-aside pattern, key naming, TTL strategy, and serialization config.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>@Configuration
@EnableCaching
public class RedisConfig {
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(jsonSerializer()); // JSON, not Java serialization
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(jsonSerializer());
return template;
}
@Bean
public RedisCacheManager cacheManager(RedisConnectionFactory factory) {
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
.entryTtl(Duration.ofMinutes(10))
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()))
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jsonSerializer()))
.disableCachingNullValues();
return RedisCacheManager.builder(factory)
.cacheDefaults(config)
.transactionAware() // put/evict only after the surrounding transaction commits
.withCacheConfiguration("orders", config.entryTtl(Duration.ofMinutes(5)))
.withCacheConfiguration("products", config.entryTtl(Duration.ofHours(1)))
.build();
}
// Records are final, so DefaultTyping.NON_FINAL writes no type id for them and every
// cache read fails ("missing type id property '@class'"). The builder's defaultTyping(true)
// types user classes too; the validator limits type ids to an allow-list instead of
// LaissezFaire's "any class". BigDecimal is non-final, so java.math must be allowed.
private GenericJackson2JsonRedisSerializer jsonSerializer() {
ObjectMapper mapper = JsonMapper.builder()
.addModule(new JavaTimeModule())
.polymorphicTypeValidator(BasicPolymorphicTypeValidator.builder()
.allowIfSubType("com.example.") // your DTO packages
.allowIfSubType("java.util.")
.allowIfSubType("java.math.")
.allowIfSubType("java.time.")
.build())
.build();
return GenericJackson2JsonRedisSerializer.builder()
.objectMapper(mapper)
.defaultTyping(true)
.build();
}
}{app}:{domain}:{id} → orders:order:uuid-here
{app}:{domain}:list:{filter} → orders:order:list:status:PENDING
{app}:session:{userId} → orders:session:uuid-here
{app}:ratelimit:{ip} → orders:ratelimit:192.168.1.1@Service
@RequiredArgsConstructor
public class ProductService {
@Cacheable(value = "products", key = "#id")
public ProductResponse findById(UUID id) {
return productRepository.findById(id)
.map(ProductResponse::from)
.orElseThrow(() -> new EntityNotFoundException("Product not found: " + id));
}
@CachePut(value = "products", key = "#result.id") // update cache after write
@Transactional
public ProductResponse update(UUID id, UpdateProductRequest request) {
Product product = productRepository.findById(id).orElseThrow();
product.update(request);
return ProductResponse.from(productRepository.save(product));
}
@CacheEvict(value = "products", key = "#id") // invalidate on delete
@Transactional
public void delete(UUID id) {
productRepository.deleteById(id);
}
@CacheEvict(value = "products", allEntries = true) // clear all
public void clearCache() {}
}@Service
@RequiredArgsConstructor
public class OrderCacheService {
private final RedisTemplate<String, Object> redisTemplate;
private final ObjectMapper objectMapper;
private static final Duration TTL = Duration.ofMinutes(5);
public Optional<OrderResponse> get(UUID orderId) {
String key = "orders:order:" + orderId;
Object cached = redisTemplate.opsForValue().get(key);
if (cached == null) return Optional.empty();
return Optional.of(objectMapper.convertValue(cached, OrderResponse.class));
}
public void put(OrderResponse order) {
String key = "orders:order:" + order.id();
redisTemplate.opsForValue().set(key, order, TTL);
}
public void evict(UUID orderId) {
redisTemplate.delete("orders:order:" + orderId);
}
}Use [AtomicWindowLimiter](templates/AtomicWindowLimiter.java) with StringRedisTemplate. It runs a single-key Lua script: the first allowed request creates the counter and expiry in one SET; later requests increment only below the limit and do not extend the window. Separate INCR and EXPIRE calls can leave a permanent counter if the client fails between them.
This is a first-request-anchored fixed window, not a sliding window or token bucket; bursts across expiry are possible. The example restricts windows to 1ms through one day. Derive the bounded bucket from trusted tenant/principal and operation data, not arbitrary client keys. Keep quota/window settings consistent across callers, bound key cardinality and use a dedicated namespace. The v2 prefix avoids reusi
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.