rules-java

Enforce Java coding conventions for naming, formatting, testing, and SQL safety.

4|1|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/NSObjects/specpowers --skill rules-java
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rules-java
Source: https://github.com/NSObjects/specpowers/tree/main/skills/rules-java
Command: npx skills add https://github.com/NSObjects/specpowers --skill rules-java

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Java projects often drift from universal style expectations because naming, formatting, and dependency strategies differ from common defaults, so this skill clarifies the Java conventions required by the workflow-driven SpecPowers process.

Core Features & Use Cases

  • Language-specific overrides: enumerates naming, file organization, formatting, and exception-handling rules that supersede the base directions and explains why each Java convention matters; use it when reviewing or extending Java code to ensure compliance.
  • Modern type and dependency guidance: recommends records, sealed hierarchies, judicious var usage, correct Optional handling, final-by-default immutability, and constructor-based dependency injection so new features stay idiomatic and testable.
  • Safety, testing, and cleanup practices: defines JUnit 5/Mockito testing strategies, try-with-resources cleanup, SQL injection prevention, and a set of red flags plus iron laws that keep Java code reliable under the SpecPowers workflow.

Quick Start

Ask the agent to apply the rules-java guidelines to your current Java files and highlight any departures from the documented conventions.

Frequently Asked Questions about rules-java

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What are the standard Java coding conventions for naming and formatting?

Standard Java coding conventions enforce specific naming, file organization, and formatting rules that supersede generic style defaults to resolve language-specific ambiguities and maintain structural consistency across Java projects.

How do I handle exceptions and resource cleanup safely in Java?

Safe Java error handling and resource cleanup require using try-with-resources for automatic closure and following specific exception-handling rules to ensure reliable execution under structured workflow processes.

When should I use modern Java type features like records and Optional?

Use modern Java type features like records, sealed hierarchies, and Optional to enforce final-by-default immutability and correct dependency injection, keeping new features idiomatic and testable.

What are the best practices for JUnit 5 and Mockito testing in Java?

Best practices for Java testing involve implementing defined JUnit 5 and Mockito testing strategies that ensure code reliability and compliance with modern coding guidelines during project extension or review.

How do I prevent SQL injection vulnerabilities in Java applications?

Preventing SQL injection in Java applications requires adhering to safe SQL handling rules and red flag checks defined by established coding guidelines to maintain database operation security.