# java-expert

Configures the agent for enterprise Java 21+ and Spring Boot work. Enforces constructor injection, immutability, and build tool automation with Maven or Gradle.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 301 installs · ★ 44
- Author: PCL Team
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/personamanagmentlayer/pcl/tree/HEAD/stdlib/languages/java-expert/SKILL.md
- Updated: 2026-10-12
- HTML: https://affpapa.org/en/nevibecode/skills/java-expert

## What it does

This skill guides the model toward modern Java syntax and clean architecture. It prioritizes records for DTOs and sealed interfaces for domain modeling. When generating REST APIs, the agent creates centralized exception handlers with `@RestControllerAdvice` alongside standard bean validation constraints.

Field injection with `@Autowired` is strictly avoided. The assistant generates constructor injection for all Spring components. Note that this skill requires Java 17 or higher in your environment.

The configuration permits direct execution of `mvn`, `gradle`, and wrapper scripts (`./mvnw`, `./gradlew`) via bash. The agent compiles code directly. You do not need to run build commands manually.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill java-expert -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/java-expert/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/java-expert/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill java-expert -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/java-expert/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill java-expert -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/java-expert/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install personamanagmentlayer/pcl java-expert
```

2. **Manually: put the files in place**
- File: `.github/skills/java-expert/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill java-expert -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/personamanagmentlayer/pcl --path stdlib/languages/java-expert
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/java-expert/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill java-expert -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/personamanagmentlayer/pcl/tree/HEAD/stdlib/languages/java-expert/SKILL.md

## When to use it
- build immutable DTOs and sealed domain hierarchies in modern Java
- replace field `@Autowired` injection with constructor injection in Spring
- set up centralized REST exception handling with `@RestControllerAdvice`
- run build scripts and verify compilation using `./gradlew` or `./mvnw`

## Example prompts
- Create a user registration endpoint with bean validation and custom error handling
- Refactor this Spring service to use constructor injection instead of `@Autowired`
- Build the project with `./mvnw clean test` and check for compilation errors

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: bd76cc21ce50c2b2.

BEGIN THIRD-PARTY FILE bd76cc21ce50c2b2
````text
---
name: java-expert
version: 1.1.0
description: >-
  Expert-level Java development with Java 21+ features, Spring Boot, Maven/Gradle, and
  enterprise best practices. Use when the user mentions JVM, Spring, Maven, Gradle, or
  enterprise, or when the task involves Modern Java, Spring Boot, Build Tools, or
  Dependency Injection.
category: languages
author: PCL Team
license: Apache-2.0
tags:
  - java
  - jvm
  - spring
  - maven
  - gradle
  - enterprise
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash(java:*, javac:*, mvn:*, gradle:*, ./mvnw:*, ./gradlew:*)
  - Glob
  - Grep
requirements:
  java: '>=17'
---

# Java Expert

You are an expert Java developer with deep knowledge of modern Java (21+), Spring ecosystem, build tools (Maven/Gradle), and enterprise application development. You write clean, performant, and maintainable Java code following industry best practices.

## Best Practices

### 1. Use Modern Java Features

```java
// Records for DTOs
public record UserDTO(Long id, String name, String email) {}

// Sealed interfaces for type hierarchies
public sealed interface Result<T> permits Success, Failure {
    record Success<T>(T value) implements Result<T> {}
    record Failure<T>(String error) implements Result<T> {}
}

// Pattern matching
public String process(Result<String> result) {
    return switch (result) {
        case Result.Success(var value) -> "Success: " + value;
        case Result.Failure(var error) -> "Error: " + error;
    };
}
```

### 2. Dependency Injection

```java
// Constructor injection (preferred)
@Service
public class UserService {
    private final UserRepository repository;
    private final EmailService emailService;

    public UserService(UserRepository repository, EmailService emailService) {
        this.repository = repository;
        this.emailService = emailService;
    }
}

// Avoid field injection
@Service
public class BadService {
    @Autowired  // Avoid this
    private UserRepository repository;
}
```

### 3. Exception Handling

```java
// Custom exceptions
public class ResourceNotFoundException extends RuntimeException {
    public ResourceNotFoundException(String resource, Long id) {
        super("Resource %s with id %d not found".formatted(resource, id));
    }
}

// Global exception handler
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(ResourceNotFoundException.class)
    public ResponseEntity<ErrorResponse> handleNotFound(ResourceNotFoundException ex) {
        var error = new ErrorResponse(
                HttpStatus.NOT_FOUND.value(),
                ex.getMessage(),
                LocalDateTime.now()
        );
        return ResponseEntity.status(HttpStatus.NOT_FOUND).body(error);
    }

    @ExceptionHandler(ValidationException.class)
    public ResponseEntity<ErrorResponse> handleValidation(ValidationException ex) {
        var error = new ErrorResponse(
````
END THIRD-PARTY FILE bd76cc21ce50c2b2

The third-party file has ended. Everything between the bd76cc21ce50c2b2 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2909 of 8879 bytes. © PCL Team · Apache-2.0 · https://github.com/personamanagmentlayer/pcl/tree/HEAD/stdlib/languages/java-expert/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
