skills/java/SKILL.md
Use when writing, modifying, or reviewing Java code - applies SOLID principles, clean code practices, minimal documentation, and pragmatic abstraction to create maintainable Java applications
npx skillsauth add mbarbieri/my-claude 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.
Write clean, maintainable Java code following SOLID principles and pragmatic practices. No Javadoc on private methods. Favor self-documenting code over comments.
NEVER add Javadoc to private methods or constructors
Private methods are implementation details. If they need documentation, refactor for clarity instead.
Javadoc on public APIs only when:
Don't document obvious methods:
// ❌ BAD
/**
* Gets the customer count
*/
public int getCustomerCount() { return customers.size(); }
// ✅ GOOD - self-documenting, no comment needed
public int getCustomerCount() { return customers.size(); }
Provide clean overloads for optional parameters:
// ✅ GOOD
public void process(Data data) {
process(data, ProcessingOptions.DEFAULT);
}
public void process(Data data, ProcessingOptions options) {
// implementation
}
// ❌ BAD - forcing clients to pass null
public void process(Data data, ProcessingOptions options) {
if (options == null) options = ProcessingOptions.DEFAULT;
}
Don't create utility methods that always return the same value:
// ❌ BAD
private static String getDefaultFormat() {
return "yyyy-MM-dd";
}
// ✅ GOOD
private static final String DEFAULT_FORMAT = "yyyy-MM-dd";
Keep comments minimal. Use them only for:
Don't comment what code obviously does.
| Mistake | Fix | |---------|-----| | Javadoc on private methods | Remove it. Refactor for clarity. | | Documenting obvious getters/setters | Remove Javadoc. Code is self-documenting. | | Forcing null parameters | Provide overloads with defaults. | | Utility method returning constant | Use a constant field instead. | | Inheritance for code reuse | Use composition instead. | | Creating interfaces prematurely | Wait until multiple implementations exist. |
| Excuse | Reality | |--------|---------| | "This private method is complex so I should document it" | If it's complex, refactor it into smaller, clearer methods. Don't document complexity. | | "This helps IDE tooltips" | IDE tooltips are for public APIs. Private methods are implementation details. | | "Just brief Javadoc won't hurt" | Any Javadoc on private methods violates clean code. No exceptions. | | "This algorithm needs explanation" | Use self-documenting method names and clear variable names instead. | | "Future maintainers will thank me" | Future maintainers want clear code, not documented unclear code. | | "This getter has side effects so it needs docs" | If a getter has side effects, it shouldn't be named 'get'. Rename it. |
Before finalizing Java code:
// ✅ GOOD
public class EmailNotifier {
private final MessageFormatter formatter;
private final EmailSender sender;
public EmailNotifier(MessageFormatter formatter, EmailSender sender) {
this.formatter = formatter;
this.sender = sender;
}
public void notify(User user, String message) {
String formatted = formatter.format(message);
sender.send(user.getEmail(), formatted);
}
}
// ✅ GOOD - clear without comments
public boolean isEligibleForDiscount(Customer customer) {
return customer.getOrderCount() >= 10
&& customer.getAccountAge().isAfter(oneYearAgo());
}
// ❌ BAD - needs comment to explain
public boolean check(Customer c) {
// Check if customer has 10 orders and account older than 1 year
return c.getOrderCount() >= 10 && c.getAccountAge().isAfter(oneYearAgo());
}
development
Use when writing or refactoring Spock tests in Java projects - enforces data-driven testing with where blocks, proper mock/stub placement, and descriptive test names following Spock best practices
tools
Use when user provides Jira issue URLs or mentions Jira tickets - fetches issue details and comments from Jira Cloud using local jira tool, outputs AI-optimized markdown for context gathering
development
Use when the user asks to implement a feature, add a class or method, fix a bug, refactor code, add test coverage, or run autonomously to drive work forward. Supports explicit phase selection via the first argument (red | green | refactor | forever) and infers the phase from conversation and test state when no phase is given. With no arguments at all, defaults to forever (autonomous loop). Do NOT use for code review, CI/CD setup, testing questions, infrastructure, or documentation tasks.
testing
Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".