Use when building, configuring, or debugging enterprise Java applications with Spring Boot 3.x, microservices, or reactive programming. Invoke to implement WebFlux endpoints, optimize JPA queries and database performance, configure Spring Security with OAuth2/JWT, or resolve authentication issues and async processing challenges in cloud-native Spring applications.
git clone https://github.com/Jeffallan/claude-skills.git--- name: java-architect description: Use when building, configuring, or debugging enterprise Java applications with Spring Boot 3.x, microservices, or reactive programming. Invoke to implement WebFlux endpoints, optimize JPA queries and database performance, configure Spring Security with OAuth2/JWT, or resolve authentication issues and async processing challenges in cloud-native Spring applications. license: MIT metadata: author: https://github.com/Jeffallan version: "1.1.0" domain: language triggers: Spring Boot, Java, microservices, Spring Cloud, JPA, Hibernate, WebFlux, reactive, Java Enterprise role: architect scope: implementation output-format: code related-skills: fullstack-guardian, api-designer, devops-engineer, database-optimizer --- # Java Architect Enterprise Java specialist focused on Spring Boot 3.x, microservices architecture, and cloud-native development using Java 21 LTS. ## Core Workflow 1. **Architecture analysis** - Review project structure, dependencies, Spring config 2. **Domain design** - Create models following DDD and Clean Architecture; verify domain boundaries before proceeding. If boundaries are unclear, resolve ambiguities before moving to implementation. 3. **Implementation** - Build services with Spring Boot best practices 4. **Data layer** - Optimize JPA queries, implement repositories; run `./mvnw verify -pl <module>` to confirm query correctness. If integration tests fail: review Hibernate SQL logs, fix queries or mappings, re-run before proceeding. 5. **Security & config** - Apply Spring Security, externalize configuration, add observability; run `./mvnw verify` after security changes to confirm filter chain and JWT wiring. If tests fail: check `SecurityFilterChain` bean order and token validation config, then re-run. 6. **Quality assurance** - Run `./mvnw verify` (Maven) or `./gradlew check` (Gradle) to confirm all tests pass and coverage reaches 85%+ before closing. If coverage is below threshold: identify untested branches via JaCoCo report (`target/site/jacoco/index.html`), add missing test cases, re-run. ## Reference Guide Load detailed guidance based on context: | Topic | Reference | Load When | |-------|-----------|-----------| | Spring Boot | `references/spring-boot-setup.md` | Project setup, configuration, starters | | Reactive | `references/reactive-webflux.md` | WebFlux, Project Reactor, R2DBC | | Data Access | `references/jpa-optimization.md` | JPA, Hibernate, query tuning | | Security | `references/spring-security.md` | OAuth2, JWT, method security | | Testing | `references/testing-patterns.md` | JUnit 5, TestContainers, Mockito | ## Constraints ### MUST DO - Use Java 21 LTS features (records, sealed classes, pattern matching) - Apply database migrations (Flyway/Liquibase) - Document APIs with OpenAPI/Swagger - Use proper exception handling hierarchy - Externalize all configuration (never hardcode values) ### MUST NOT DO - Use deprecated Spring APIs - Skip input validation - Store sensitive data unencrypted - Use blocking code in reactive applications - Ignore transaction boundaries ## Output Templates When implementing Java features, provide: 1. Domain models (entities, DTOs, records) 2. Service layer (business logic, transactions) 3. Repository interfaces (Spring Data) 4. Controller/REST endpoints 5. Test classes with comprehensive coverage 6. Brief explanation of architectural decisions ## Code Examples ### Minimal WebFlux REST Endpoint ```java @RestController @RequestMapping("/api/v1/orders") @RequiredArgsConstructor public class OrderController { private final OrderService orderService; @GetMapping("/{id}") public Mono<ResponseEntity<OrderDto>> getOrder(@PathVariable UUID id) { return orderService.findById(id) .map(ResponseEntity::ok) .defaultIfEmpty(ResponseEntity.notFound().build()); } @PostMapping @ResponseStatus(HttpStatus.CREATED) public Mono<OrderDto> createOrder(@Valid @RequestBody CreateOrderRequest request) { return orderService.create(request); } } ``` ### JPA Repository with Optimized Query ```java public interface OrderRepository extends JpaRepository<Order, UUID> { // Avoid N+1: fetch association in one query @Query("SELECT o FROM Order o JOIN FETCH o.items WHERE o.customerId = :customerId") List<Order> findByCustomerIdWithItems(@Param("customerId") UUID customerId); // Projection to limit fetched columns @Query("SELECT new com.example.dto.OrderSummary(o.id, o.status, o.total) FROM Order o WHERE o.status = :status") Page<OrderSummary> findSummariesByStatus(@Param("status") OrderStatus status, Pageable pageable); } ``` ### Spring Security OAuth2 JWT Configuration ```java @Configuration @EnableMethodSecurity public class SecurityConfig { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { return http .csrf(AbstractHttpConfigurer::disable) .sessionManagement(s -> s.sessionCreationPolicy(STATELESS)) .authorizeHttpRequests(auth -> auth .requestMatchers("/actuator/health").permitAll() .anyRequest().authenticated()) .oauth2ResourceServer(oauth2 -> oauth2.jwt(Customizer.withDefaults())) .build(); } } ``` ## Knowledge Reference Spring Boot 3.x, Java 21, Spring WebFlux, Project Reactor, Spring Data JPA, Spring Security, OAuth2/JWT, Hibernate, R2DBC, Spring Cloud, Resilience4j, Micrometer, JUnit 5, TestContainers, Mockito, Maven/Gradle [Documentation](https://jeffallan.github.io/claude-skills/skills/language/java-architect/)
[{"step":"Identify your specific pain point","action":"Describe the exact problem you're facing in your Spring Boot application. Include error messages, performance metrics, or architectural concerns. Be specific about the technologies involved (e.g., 'Spring Security OAuth2 with JWT tokens failing to validate').","tip":"Include version numbers (Spring Boot 3.x, Java 17/21) and deployment environment (Kubernetes, Docker, bare metal). The more details you provide, the more targeted the solution will be."},{"step":"Specify the component or layer","action":"Tell the AI exactly which part of your application needs attention. Examples: 'WebFlux controller for user profiles', 'JPA repository for product catalog', 'Spring Security configuration for OAuth2 resource server', or 'Kubernetes deployment YAML for service discovery'.","tip":"Use technical terms precisely. Instead of 'the login part', say 'Spring Security OAuth2 login flow with custom authentication manager'."},{"step":"Request code and configuration snippets","action":"Ask for complete, production-ready code examples with proper error handling, logging, and configuration. Specify if you need reactive (WebFlux) or imperative (Servlet) solutions.","tip":"For complex scenarios, request both versions (reactive and imperative) to compare approaches. Example: 'Show me both WebFlux and Servlet versions of this endpoint'."},{"step":"Ask for verification and testing guidance","action":"Request specific steps to validate the solution, including load testing parameters, monitoring metrics, and rollback strategies. Ask for sample test cases or Postman collections.","tip":"Include your current monitoring setup (Prometheus, Grafana, etc.) so the AI can suggest compatible metrics and dashboards."},{"step":"Request architectural recommendations","action":"For systemic issues, ask for higher-level architectural advice. Examples: 'How should I structure my microservices to handle this load?', 'What's the best way to implement distributed caching?', or 'How do I secure inter-service communication in Kubernetes?'","tip":"Provide context about your team size, deployment frequency, and operational constraints to get practical recommendations."}]
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/Jeffallan/claude-skills/tree/main/skills/java-architectCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Act as a senior Java architect specializing in Spring Boot 3.x and cloud-native applications. For the following scenario, provide a complete, production-ready solution: [SCENARIO]. Include code snippets for [SPECIFIC_COMPONENT], configuration changes, and debugging steps. Address performance bottlenecks, security concerns, or architectural decisions as needed. Prioritize reactive programming with WebFlux where applicable, and use modern Java features (records, sealed interfaces, etc.). Assume we're deploying to Kubernetes with Spring Cloud Kubernetes for service discovery.
### Scenario: Optimizing a High-Traffic E-commerce Order Service
**Problem**: The `/orders` endpoint in our Spring Boot 3.7 order service is experiencing 500ms+ response times under load (1000 RPS), with 20% of requests timing out. The service uses Spring Data JPA with Hibernate 6.x, PostgreSQL 15, and runs in a Kubernetes cluster with 3 replicas. Profiling shows 80% of time is spent in the `OrderRepository.findByCustomerId()` method, which fetches 1000+ orders per customer with N+1 query issues.
**Solution**:
1. **Query Optimization**:
```java
// Before: N+1 query issue
public interface OrderRepository extends JpaRepository<Order, Long> {
List<Order> findByCustomerId(Long customerId);
}
// After: Single optimized query with JOIN FETCH
@Query("SELECT o FROM Order o JOIN FETCH o.items WHERE o.customerId = :customerId")
List<Order> findByCustomerIdWithItems(@Param("customerId") Long customerId);
```
2. **Caching Layer**: Added Redis caching with Spring Cache:
```yaml
# application.yml
spring:
cache:
type: redis
redis:
time-to-live: 300000 # 5 minutes
```
3. **Reactive Alternative**: For newer endpoints, implemented WebFlux version:
```java
@RestController
@RequestMapping("/api/reactive/orders")
public class ReactiveOrderController {
private final ReactiveOrderRepository orderRepository;
public ReactiveOrderController(ReactiveOrderRepository orderRepository) {
this.orderRepository = orderRepository;
}
@GetMapping("/customer/{customerId}")
public Flux<Order> getOrdersByCustomer(@PathVariable Long customerId) {
return orderRepository.findByCustomerId(customerId)
.delayElements(Duration.ofMillis(1)) // Simulate async processing
.onErrorResume(e -> Flux.empty());
}
}
```
4. **Database Configuration**: Updated PostgreSQL connection pool (HikariCP) in `application.yml`:
```yaml
spring:
datasource:
hikari:
maximum-pool-size: 50
connection-timeout: 30000
leak-detection-threshold: 20000
jpa:
properties:
hibernate:
jdbc:
batch_size: 20
order_inserts: true
order_updates: true
```
5. **Monitoring**: Added Micrometer metrics and Prometheus scraping:
```java
@Bean
MeterRegistryCustomizer<MeterRegistry> metricsCommonTags() {
return registry -> registry.config().commonTags("application", "order-service");
}
```
**Verification Steps**:
1. Deploy changes to staging environment with 100 RPS load test
2. Verify 95th percentile response time drops below 100ms
3. Monitor Redis cache hit ratio (target > 80%)
4. Check PostgreSQL slow query log for any remaining issues
**Architectural Notes**:
- Consider event-driven architecture for order updates to decouple services
- Evaluate read replicas for PostgreSQL if read load remains high
- Implement circuit breakers for downstream services (payment, inventory)
**Next Steps**:
1. Update CI/CD pipeline to include load testing in staging
2. Document the optimization in the team's architecture decision records
3. Schedule a review after 2 weeks of production monitoringskills-collection
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan