Skip to content
Back to skills

Stack Java

ASecurity

Java coding standards for Spring Boot and Quarkus services — naming, immutability, Optional, streams, DI

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 6, 2026
ai-agentsjavaspring

Security analysis

A100/100

Scanned November 20, 2026

npx -y skills add Snakeblack/ospec-workflow --skill stack-java --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Stack Java?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Stack Java
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/snakeblack-stack-java/badge)](https://www.skillsdirectory.com/skills/snakeblack-stack-java)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: stack-java
description: "Java coding standards for Spring Boot and Quarkus services — naming, immutability, Optional, streams, DI"
license: MIT AND Commons-Clause
metadata:
  author: "affaan-mustafa, manuel-retamozo-garcia"
  version: "1.0"
capabilities: [java]
---

## Critical Rules

- Any executor sub-agent using this skill must first determine the framework from the build file (e.g., Maven `pom.xml` or Gradle `build.gradle`):
  - If build file contains `quarkus` -> apply **[QUARKUS]** conventions.
  - If build file contains `spring-boot` -> apply **[SPRING]** conventions.
  - If neither is detected -> apply shared conventions only.
- Prefer clarity over cleverness. Java 17+ features (records, sealed classes, pattern matching) should be used where appropriate.
- Minimize shared mutable state; prefer immutability by default.
- Fail fast with meaningful, domain-specific exceptions.
- **[QUARKUS]**: Favor build-time processing over runtime processing. Avoid runtime reflection where possible.

## Naming & Code Style

- Classes & Records must use `PascalCase` (e.g., `MarketService`, `Money`).
- Methods & fields must use `camelCase` (e.g., `marketRepository`, `findBySlug`).
- Constants must use `UPPER_SNAKE_CASE` (e.g., `MAX_PAGE_SIZE = 100`).
- **[QUARKUS]**: Name JAX-RS resources as `*Resource` (e.g., `MarketResource`), not `*Controller`.
- **[SPRING]**: Name REST controllers as `*Controller` (e.g., `MarketController`).

## Immutability

- Favor records and final fields for data transfer objects (DTOs) and value objects:
  ```java
  public record MarketDto(Long id, String name, MarketStatus status) {}
  ```
- **[QUARKUS]**: Panache active-record entities use public fields (as idiomatic Quarkus behavior since Quarkus generates accessors at build time):
  ```java
  @Entity
  public class Market extends PanacheEntity {
      public String name;
      public MarketStatus status;
  }
  ```

## Optional & Streams Best Practices

- Return `Optional` from `find*` query methods instead of returning null or throwing immediate exceptions.
- Prefer mapping and chaining operations over calling `.get()` directly:
  ```java
  return market
      .map(MarketResponse::from)
      .orElseThrow(() -> new EntityNotFoundException("Market not found"));
  ```
- Keep Stream pipelines short and readable. Use them primarily for clean transformations. Do not use complex nested streams; prefer structured loops for readability when logic is complex.

## Dependency Injection

- **[SPRING]**: Use constructor injection for dependencies; avoid field-level `@Autowired` injection:
  ```java
  @Service
  public class MarketService {
      private final MarketRepository marketRepository;

      public MarketService(MarketRepository marketRepository) {
          this.marketRepository = marketRepository;
      }
  }
  ```
- **[QUARKUS]**: Use constructor injection with `@Inject`:
  ```java
  @ApplicationScoped
  public class MarketService {
      private final MarketRepository marketRepository;

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

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.