Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
affaan-m avatar

Java Coding Standards

  • 1.5k installs
  • 238k repo stars
  • Updated August 5, 2026
  • affaan-m/ecc

This is a copy of java-coding-standards by affaan-m - installs and ranking accrue to the original listing.

java-coding-standards is an agent skill that enforces consistent Java 17+ coding conventions across Spring Boot and Quarkus services for developers who need maintainable JVM backend code with framework-specific patterns.

About

java-coding-standards is an ECC agent skill that enforces readable, maintainable Java 17+ conventions across Spring Boot and Quarkus microservices. The skill automatically applies framework-specific rules for naming, immutability, Optional usage, streams, exception handling, generics, CDI, reactive patterns, and project package layout. It activates when writing or reviewing Java backend code, structuring records and sealed classes, applying pattern matching, or aligning Quarkus and Spring Boot services to shared ECC standards. java-coding-standards covers Optional and stream idioms, exception boundaries, and reactive service patterns so agents produce consistent JVM code instead of ad hoc style per file. Developers reach for java-coding-standards when onboarding agents onto existing Spring Boot or Quarkus repos that need enforced conventions during implementation and review.

  • Framework-aware detection that applies Spring Boot or Quarkus specific conventions from your build file
  • Enforces immutability by default, fail-fast exceptions, Optional usage, streams, generics, and records
  • Defines clear project layout, package structure, and naming conventions for Java 17+
  • Includes Quarkus-specific rules for CDI scopes, Panache entities, and reactive pipelines
  • Supports sealed classes, pattern matching, and build-time processing preferences

Java Coding Standards by the numbers

  • 1,466 all-time installs (skills.sh)
  • +96 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/affaan-m/ecc --skill java-coding-standards

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1.5k
repo stars238k
Last updatedAugust 5, 2026
Repositoryaffaan-m/ecc

How do you enforce Java coding standards in Spring Boot?

Automatically enforce consistent, maintainable Java coding standards across Spring Boot and Quarkus services.

Who is it for?

Developers writing or reviewing Java 17+ Spring Boot and Quarkus backend services who want agents to enforce consistent ECC coding conventions automatically.

Skip if: Developers working in Kotlin-only, Python, or frontend TypeScript codebases without Java 17+ Spring Boot or Quarkus backend services to standardize.

When should I use this skill?

A developer writes or reviews Java code in Spring Boot or Quarkus and needs naming, Optional, streams, immutability, CDI, reactive, or package-structure conventions enforced.

What you get

Java service code aligned to ECC naming, immutability, Optional, streams, generics, CDI, reactive, and package-layout conventions for Spring Boot or Quarkus.

  • Convention-aligned Java code
  • Review feedback on JVM idioms
  • Package structure guidance

Files

SKILL.mdMarkdownGitHub ↗

Java Coding Standards

Standards for readable, maintainable Java (17+) code in Spring Boot and Quarkus services.

When to Use

  • Writing or reviewing Java code in Spring Boot or Quarkus projects
  • Enforcing naming, immutability, or exception handling conventions
  • Working with records, sealed classes, or pattern matching (Java 17+)
  • Reviewing use of Optional, streams, or generics
  • Structuring packages and project layout
  • [QUARKUS]: Working with CDI scopes, Panache entities, or reactive pipelines

How It Works

Framework Detection

Before applying standards, determine the framework from the build file:

  • Build file contains quarkus → apply [QUARKUS] conventions
  • Build file contains spring-boot → apply [SPRING] conventions
  • Neither detected → apply shared conventions only

Core Principles

  • Prefer clarity over cleverness
  • Immutable by default; minimize shared mutable state
  • Fail fast with meaningful exceptions
  • Consistent naming and package structure
  • [QUARKUS]: Favor build-time over runtime processing; avoid runtime reflection where possible

Examples

The sections below show concrete Spring Boot, Quarkus, and shared Java examples for naming, immutability, dependency injection, reactive code, exceptions, project layout, logging, configuration, and tests.

Naming

// PASS: Classes/Records: PascalCase
public class MarketService {}
public record Money(BigDecimal amount, Currency currency) {}

// PASS: Methods/fields: camelCase
private final MarketRepository marketRepository;
public Market findBySlug(String slug) {}

// PASS: Constants: UPPER_SNAKE_CASE
private static final int MAX_PAGE_SIZE = 100;

// PASS: [QUARKUS] JAX-RS resources named as *Resource, not *Controller
public class MarketResource {}

// PASS: [SPRING] REST controllers named as *Controller
public class MarketController {}

Immutability

// PASS: Favor records and final fields
public record MarketDto(Long id, String name, MarketStatus status) {}

public class Market {
  private final Long id;
  private final String name;
  // getters only, no setters
}

// PASS: [QUARKUS] Panache active-record entities use public fields (Quarkus convention)
@Entity
public class Market extends PanacheEntity {
  public String name;
  public MarketStatus status;
  // Panache generates accessors at build time; public fields are idiomatic here
}

// PASS: [QUARKUS] Panache MongoDB entities
@MongoEntity(collection = "markets")
public class Market extends PanacheMongoEntity {
  public String name;
  public MarketStatus status;
}

Optional Usage

// PASS: Return Optional from find* methods
// [SPRING]
Optional<Market> market = marketRepository.findBySlug(slug);

// [QUARKUS] Panache
Optional<Market> market = Market.find("slug", slug).firstResultOptional();

// PASS: Map/flatMap instead of get()
return market
    .map(MarketResponse::from)
    .orElseThrow(() -> new EntityNotFoundException("Market not found"));

Streams Best Practices

// PASS: Use streams for transformations, keep pipelines short
List<String> names = markets.stream()
    .map(Market::name)
    .filter(Objects::nonNull)
    .toList();

// FAIL: Avoid complex nested streams; prefer loops for clarity

Dependency Injection

// PASS: [SPRING] Constructor injection (preferred over @Autowired on fields)
@Service
public class MarketService {
  private final MarketRepository marketRepository;

  public MarketService(MarketRepository marketRepository) {
    this.marketRepository = marketRepository;
  }
}

// PASS: [QUARKUS] Constructor injection
@ApplicationScoped
public class MarketService {
  private final MarketRepository marketRepository;

  @Inject
  public MarketService(MarketRepository marketRepository) {
    this.marketRepository = marketRepository;
  }
}

// PASS: [QUARKUS] Package-private field injection (acceptable in Quarkus — avoids proxy issues)
@ApplicationScoped
public class MarketService {
  @Inject
  MarketRepository marketRepository;
}

// FAIL: [SPRING] Field injection with @Autowired
@Autowired
private MarketRepository marketRepository; // use constructor injection

// FAIL: [QUARKUS] @Singleton when interception or lazy init is needed
@Singleton // non-proxyable — use @ApplicationScoped instead
public class MarketService {}

Reactive Patterns [QUARKUS]

// PASS: Return Uni/Multi from reactive endpoints
@GET
@Path("/{slug}")
public Uni<Market> findBySlug(@PathParam("slug") String slug) {
  return Market.find("slug", slug)
      .<Market>firstResult()
      .onItem().ifNull().failWith(() -> new MarketNotFoundException(slug));
}

// PASS: Non-blocking pipeline composition
public Uni<OrderConfirmation> placeOrder(OrderRequest req) {
  return validateOrder(req)
      .chain(valid -> persistOrder(valid))
      .chain(order -> notifyFulfillment(order));
}

// FAIL: Blocking call inside a Uni/Multi pipeline
public Uni<Market> find(String slug) {
  Market m = Market.find("slug", slug).firstResult(); // BLOCKING — breaks event loop
  return Uni.createFrom().item(m);
}

// FAIL: Subscribing more than once to a shared Uni
Uni<Market> shared = fetchMarket(slug);
shared.subscribe().with(m -> log(m));
shared.subscribe().with(m -> cache(m)); // double subscribe — use Uni.memoize()

Exceptions

  • Use unchecked exceptions for domain errors; wrap technical exceptions with context
  • Create domain-specific exceptions (e.g., MarketNotFoundException)
  • Avoid broad catch (Exception ex) unless rethrowing/logging centrally
throw new MarketNotFoundException(slug);

Centralised Exception Handling

// [SPRING]
@RestControllerAdvice
public class GlobalExceptionHandler {
  @ExceptionHandler(MarketNotFoundException.class)
  public ResponseEntity<ErrorResponse> handle(MarketNotFoundException ex) {
    return ResponseEntity.status(404).body(ErrorResponse.from(ex));
  }
}

// [QUARKUS] Option A: ExceptionMapper
@Provider
public class MarketNotFoundMapper implements ExceptionMapper<MarketNotFoundException> {
  @Override
  public Response toResponse(MarketNotFoundException ex) {
    return Response.status(404).entity(ErrorResponse.from(ex)).build();
  }
}

// [QUARKUS] Option B: @ServerExceptionMapper (RESTEasy Reactive)
@ServerExceptionMapper
public RestResponse<ErrorResponse> handle(MarketNotFoundException ex) {
  return RestResponse.status(Status.NOT_FOUND, ErrorResponse.from(ex));
}

Generics and Type Safety

  • Avoid raw types; declare generic parameters
  • Prefer bounded generics for reusable utilities
public <T extends Identifiable> Map<Long, T> indexById(Collection<T> items) { ... }

Project Structure

[SPRING] Maven/Gradle

src/main/java/com/example/app/
  config/
  controller/
  service/
  repository/
  domain/
  dto/
  util/
src/main/resources/
  application.yml
src/test/java/... (mirrors main)

[QUARKUS] Maven/Gradle

src/main/java/com/example/app/
  config/              # @ConfigMapping, @ConfigProperty beans, Producers
  resource/            # JAX-RS resources (not "controller")
  service/
  repository/          # PanacheRepository implementations (if not using active record)
  domain/              # JPA/Panache entities, MongoDB entities
  dto/
  util/
  mapper/              # MapStruct mappers (if used)
src/main/resources/
  application.properties   # Quarkus convention (YAML supported with quarkus-config-yaml)
  import.sql               # Hibernate auto-import for dev/test
src/test/java/... (mirrors main)

Formatting and Style

  • Use 2 or 4 spaces consistently (project standard)
  • One public top-level type per file
  • Keep methods short and focused; extract helpers
  • Order members: constants, fields, constructors, public methods, protected, private

Code Smells to Avoid

  • Long parameter lists → use DTO/builders
  • Deep nesting → early returns
  • Magic numbers → named constants
  • Static mutable state → prefer dependency injection
  • Silent catch blocks → log and act or rethrow
  • [QUARKUS]: @Singleton where @ApplicationScoped is intended — breaks proxying and interception
  • [QUARKUS]: Mixing quarkus-resteasy-reactive and quarkus-resteasy (classic) — pick one stack
  • [QUARKUS]: Panache active-record + repository pattern in the same bounded context — pick one

Logging

// [SPRING] SLF4J
private static final Logger log = LoggerFactory.getLogger(MarketService.class);
log.info("fetch_market slug={}", slug);
log.error("failed_fetch_market slug={}", slug, ex);

// [QUARKUS] JBoss Logging (default, zero-cost at build time)
private static final Logger log = Logger.getLogger(MarketService.class);
log.infof("fetch_market slug=%s", slug);
log.errorf(ex, "failed_fetch_market slug=%s", slug);

// [QUARKUS] Alternative: simplified logging with @Inject
@Inject
Logger log; // CDI-injected, scoped to declaring class

Null Handling

  • Accept @Nullable only when unavoidable; otherwise use @NonNull
  • Use Bean Validation (@NotNull, @NotBlank) on inputs
  • [QUARKUS]: Apply @Valid on @BeanParam, @RestForm, and request body parameters

Configuration

// [SPRING] @ConfigurationProperties
@ConfigurationProperties(prefix = "market")
public record MarketProperties(int maxPageSize, Duration cacheTtl) {}

// [QUARKUS] @ConfigMapping (type-safe, build-time validated)
@ConfigMapping(prefix = "market")
public interface MarketConfig {
  int maxPageSize();
  Duration cacheTtl();
}

// [QUARKUS] Simple values with @ConfigProperty
@ConfigProperty(name = "market.max-page-size", defaultValue = "100")
int maxPageSize;

Testing Expectations

Shared

  • JUnit 5 + AssertJ for fluent assertions
  • Mockito for mocking; avoid partial mocks where possible
  • Favor deterministic tests; no hidden sleeps

[SPRING]

  • @WebMvcTest for controller slices, @DataJpaTest for repository slices
  • @SpringBootTest reserved for full integration tests
  • @MockBean for replacing beans in Spring context

[QUARKUS]

  • Plain JUnit 5 + Mockito for unit tests (no @QuarkusTest)
  • @QuarkusTest reserved for CDI integration tests
  • @InjectMock for replacing CDI beans in integration tests
  • Dev Services for database/Kafka/Redis — avoid manual Testcontainers setup when Dev Services suffice
  • @QuarkusTestResource for custom external service lifecycle
// [SPRING] Controller test
@WebMvcTest(MarketController.class)
class MarketControllerTest {
  @Autowired MockMvc mockMvc;
  @MockBean MarketService marketService;
}

// [QUARKUS] Integration test
@QuarkusTest
class MarketResourceTest {
  @InjectMock
  MarketService marketService;

  @Test
  void should_return_404_when_market_not_found() {
    given().when().get("/markets/unknown").then().statusCode(404);
  }
}

// [QUARKUS] Unit test (no CDI, no @QuarkusTest)
@ExtendWith(MockitoExtension.class)
class MarketServiceTest {
  @Mock MarketRepository marketRepository;
  @InjectMocks MarketService marketService;
}

Remember: Keep code intentional, typed, and observable. Optimize for maintainability over micro-optimizations unless proven necessary.

Related skills

How it compares

Pick java-coding-standards over generic style skills when the codebase is Java 17+ Spring Boot or Quarkus and ECC JVM conventions must apply framework-specifically.

FAQ

Which Java frameworks does java-coding-standards cover?

java-coding-standards covers Spring Boot and Quarkus services on Java 17+, applying ECC conventions for naming, immutability, Optional, streams, generics, CDI, reactive patterns, and package layout.

What Java 17+ features does java-coding-standards enforce?

java-coding-standards enforces use of records, sealed classes, pattern matching, Optional idioms, streams, generics, exception handling boundaries, and reactive service patterns in maintainable JVM backend code.

When should java-coding-standards be activated?

java-coding-standards should be activated when writing or reviewing Java code in Spring Boot or Quarkus projects, enforcing naming and immutability conventions, or structuring packages for readable microservice layouts.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.