skills/dev-java/SKILL.md
Enforce production-grade Java development standards when writing, reviewing, or architecting Java code. Covers commenting, core Java idioms (Stream, collections, concurrency, generics), 23 GoF design patterns, SonarQube/Alibaba p3c/Lombok rules, Spring Boot MVC structure, Spring Cloud DDD microservices, MyBatis/JPA/transaction management, exception handling, logging, REST API design, testing, and security. Trigger whenever the user writes Java code, reviews Java code, designs a Spring Boot or Spring Cloud project, implements a design pattern, fixes code smells, discusses architecture, or asks about Java best practices. Also trigger when Java code is pasted for feedback or the user asks about package structure, DTO/VO/PO conventions, or coding standards.
npx skillsauth add Refinex-Space/Refinex-Skills dev-javaInstall 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.
This skill ensures every line of Java code produced follows battle-tested, production-grade standards drawn from the Alibaba Java Coding Guidelines, Effective Java, SonarQube rules, Spring ecosystem conventions, and DDD principles.
Without this skill, AI-generated Java code tends toward "compiles and runs" quality — it works but violates naming conventions, ignores thread safety, swallows exceptions, uses raw types, nests logic too deeply, mixes concerns across layers, produces anemic domain models, and omits Javadoc. The code passes a smoke test but fails a code review. This skill exists to close the gap between "working code" and "production-ready code that a senior engineer would approve."
This skill operates in two modes:
When writing new Java code, before you start coding, identify which domains apply and read the corresponding reference files. Then write code that satisfies every applicable standard. Do not write code first and retrofit standards later — the standards shape the design.
When reviewing or refactoring existing Java code, read the relevant reference files, then systematically check the code against each applicable rule. Report violations grouped by severity: Blocker (must fix before merge), Critical (should fix in this PR), Major (fix soon), Suggestion (consider improving).
Every Java task touches one or more domains. Read the reference file before writing or reviewing code in that domain. If multiple domains apply (they usually do), read all of them.
| The task involves… | Read this reference |
| ------------------------------------------------------------- | ------------------------------------------------ |
| Any Java code (always read this first) | references/core-java-standards.md |
| Comments, Javadoc, XML/YAML/Properties annotations | references/commenting-standards.md |
| Choosing or implementing a design pattern | references/design-patterns-standards.md |
| Static analysis, code smells, Lombok, formatting | references/static-analysis-standards.md |
| Spring Boot monolith / MVC layered project | references/spring-boot-mvc-standards.md |
| Spring Cloud microservices / DDD architecture | references/spring-cloud-ddd-standards.md |
| Database access: MyBatis, JPA, JdbcTemplate, transactions | references/data-access-standards.md |
| Exception handling, logging, error responses | references/exception-logging-standards.md |
| RESTful API design, versioning, pagination, HATEOAS | references/api-design-standards.md |
| Unit tests, integration tests, mocking, TDD | references/testing-standards.md |
| Authentication, authorization, input validation, secrets | references/security-standards.md |
| Build tools, CI/CD, Docker, dependency management | references/devops-build-standards.md |
Always-read rule: references/core-java-standards.md applies to every Java task. For any non-trivial class, also read references/commenting-standards.md. These two are the baseline — skip them only for one-liner utility answers.
These principles are so fundamental that they live here in the SKILL.md rather than in reference files, because they must be in context for every task.
Names carry intent. A reader should understand what code does from its names alone, without reading the implementation.
OrderFactory, LoginProxy, ResourceObserver).is/has/can/should.static final qualifies.com.company.project.module).data, info, temp, obj, result without qualification are code smells.strName, iCount), no single-letter variables except loop indices and lambdas.Objects.requireNonNull() for non-null contracts.throw new Exception() or throw new RuntimeException() with a bare message.catch (Exception e) { } is a Blocker-level violation.final for fields, parameters, and local variables.List.of(), Map.of(), Collections.unmodifiableList()) for return values.static.private constructor and only static methods.Before delivering any Java code to the user, verify:
Optional for genuinely optional values. Validate inputs.java.util.concurrent constructs.Closeable/AutoCloseable resources use try-with-resources.System.out.println() or e.printStackTrace().When reviewing code, classify violations:
Blocker — Production incident risk. Must fix before merge. Examples: swallowed exceptions, thread-unsafe shared mutable state, SQL injection vectors, hardcoded credentials, resource leaks.
Critical — Correctness or maintainability risk. Should fix in this PR.
Examples: raw types, missing null checks on external input, overly broad exception catches, missing @Transactional on service methods that need atomicity.
Major — Code quality issue. Fix within the sprint. Examples: missing Javadoc on public API, god class (>500 lines), deep nesting (>3 levels), magic numbers, copy-paste code.
Suggestion — Improvement opportunity. Consider for next iteration. Examples: could use a design pattern, could extract a helper method, could use a more specific collection type, could add a builder.
These are the most frequent violations in AI-generated and junior-developer Java code. Be vigilant:
String for email, phone, money instead of value objects.catch (Exception e) { log.error("error"); } — loses the stack trace. Always log e as the second argument.Optional or throw.if (status == 1) instead of if (status == OrderStatus.ACTIVE).@Transactional on a private method (doesn't work with Spring proxies) or on a controller (too broad).JOIN FETCH or batch fetching.Each reference file begins with a scope declaration and a table of contents. They are self-contained for their domain. Here is a summary of what each covers, so you can decide which to read:
core-java-standards.md (~400 lines) — Java language-level standards: generics, collections, Stream API, Optional, concurrency (java.util.concurrent, virtual threads), I/O (NIO.2, try-with-resources), reflection, SPI, records, sealed classes, pattern matching. The foundation everything else builds on.
commenting-standards.md (~200 lines) — Javadoc for classes/interfaces/methods/fields, POJO annotation comments, inline comments, XML/YAML/Properties file comments, TODO/FIXME conventions, changelog headers.
design-patterns-standards.md (~400 lines) — All 23 GoF patterns + Builder variant, organized by creation/structural/behavioral. For each: one-sentence definition, when to use, when NOT to use, Java/Spring idiomatic implementation, and common misuses.
static-analysis-standards.md (~250 lines) — SonarQube critical rules, Alibaba p3c plugin alignment, Lombok safe usage (which annotations to use and which to avoid), Checkstyle/SpotBugs key rules, code formatting standards.
spring-boot-mvc-standards.md (~350 lines) — Project structure (layer-based and feature-based), Controller/Service/Repository conventions, configuration management, profile strategy, auto-configuration, starter dependencies, actuator, graceful shutdown.
spring-cloud-ddd-standards.md (~400 lines) — DDD tactical patterns (Entity, Value Object, Aggregate, Domain Event, Repository, Domain Service, Application Service), bounded context mapping, hexagonal architecture layout, Spring Cloud component selection (Gateway, Config, Circuit Breaker, Service Discovery), inter-service communication patterns, CQRS/Event Sourcing basics.
data-access-standards.md (~300 lines) — MyBatis XML mapper standards, MyBatis-Plus code generation and wrapper usage, JPA entity mapping and query optimization, JdbcTemplate usage patterns, transaction management (@Transactional semantics, propagation, isolation, read-only), N+1 prevention, connection pool configuration.
exception-logging-standards.md (~200 lines) — Exception hierarchy design, global exception handling (@ControllerAdvice), error response format, SLF4J + Logback configuration, log level semantics, structured logging, MDC for distributed tracing, log rotation and retention.
api-design-standards.md (~200 lines) — RESTful URL naming, HTTP method semantics, status code selection, request/response DTO design, pagination/sorting/filtering, API versioning, idempotency, rate limiting, OpenAPI/Swagger documentation.
testing-standards.md (~250 lines) — JUnit 5 conventions, Mockito usage patterns, Spring Boot test slicing (@WebMvcTest, @DataJpaTest), integration testing strategy, test naming, test data management, coverage expectations, contract testing basics.
security-standards.md (~200 lines) — Spring Security configuration, authentication/authorization patterns, input validation (@Valid, custom validators), OWASP Top 10 in Java context, secrets management, CORS, CSRF, SQL injection prevention, XSS prevention.
devops-build-standards.md (~200 lines) — Maven/Gradle conventions, multi-module project structure, dependency management (BOM, version catalogs), Docker image optimization, CI/CD pipeline stages, environment configuration, health checks.
development
Deep initialization of project AGENTS.md hierarchy and control plane for AI coding agents. Use this skill whenever the user wants to set up, initialize, bootstrap, or create AGENTS.md / CLAUDE.md files for their project, or when they mention "init-deep", "harness setup", "control plane", "agent context", "project initialization for agents", or want to make their codebase agent-ready. Also trigger when a user says things like "set up my repo for Claude Code", "make this project work better with agents", "create agent instructions", "bootstrap harness", or "initialize agent docs". This skill handles both existing large codebases (where hierarchical, module-scoped AGENTS.md files are needed) and new/small projects (where brainstorming with the user comes first). Do NOT use this skill for routine code changes, bug fixes, or general documentation — it is specifically for creating the structured agent control plane.
development
Detect and fix drift in project AGENTS.md files and agent control plane. Use this skill whenever the user wants to audit, recalibrate, refresh, update, or fix their existing AGENTS.md files, or when they mention "drift", "stale AGENTS.md", "outdated agent instructions", "recalibrate", "sync agents", "audit control plane", "AGENTS.md is wrong/old/broken", or when they suspect their agent harness has fallen out of sync with the codebase. Also trigger when a user says things like "my agents keep making wrong assumptions", "Claude doesn't understand the new structure", "we refactored but the AGENTS.md is old", "check if my AGENTS.md is still accurate", or "update my agent docs". This skill is the companion to init-deep — init-deep creates the control plane from scratch, drift-doctor maintains it over time. Do NOT use for initial creation of AGENTS.md (use init-deep instead). Do NOT use for general code review or documentation updates unrelated to agent context.
development
Use when adding, fixing, reviewing, or generating code comments, docstrings, Javadoc, JSDoc/TSDoc, rustdoc, SQL comments, or documentation comments for source, markup, configuration, or database files.
development
Use when starting Harness implementation work that needs an isolated git worktree, especially before executing an approved plan or beginning a scoped feature/fix branch. Select the repository's worktree directory, verify ignored project-local directories, create a `codex/`-prefixed branch by default, run setup and baseline checks, and prevent plan execution on main/master unless the user explicitly allows it.