A solid reference for the patterns you actually use: Factory, Builder, Strategy, Observer, and the rest. It shows both the classic Java approach and modern alternatives with Spring and Lombok, which is helpful since you probably don't want to write boilerplate builders by hand in 2024. The examples are practical, like swapping payment methods at runtime with Strategy or avoiding telescoping constructors with Builder. It's opinionated in the right ways, steering you toward dependency injection over Singleton and showing antipatterns alongside solutions. Best for when you know a pattern would help but can't remember the exact implementation, or when you're teaching someone why their seven-parameter constructor is a code smell.

skills.sh installs
372
GitHub stars
771
last updated
Feb 8, 2026

Install

$ npx -y skills add decebals/claude-code-java --skill design-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

Design Patterns Skill

Practical design patterns reference for Java with modern examples.

When to Use

  • User asks to implement a specific pattern
  • Designing extensible/flexible components
  • Refactoring rigid code structures
  • Code review suggests pattern usage

Quick Reference: When to Use What

ProblemPattern
Complex object constructionBuilder
Create objects without specifying classFactory
Multiple algorithms, swap at runtimeStrategy
Add behavior without changing classDecorator
Notify multiple objects of changesObserver
Ensure single instanceSingleton
Convert incompatible interfacesAdapter
Define algorithm skeletonTemplate Method

Creational Patterns

Builder

Use when: Object has many parameters, some optional.

// ❌ Telescoping constructor antipattern
public class User {
    public User(String name) { }
    public User(String name, String email) { }
    public User(String name, String email, int age) { }
    public User(String name, String email, int age, String phone) { }
    // ... explosion of constructors
}

Sponsors

Details

Repository
github.com/decebals/claude-code-java
Categories
Java & JVM, Design & UI/UX
License
MIT
First seen
Jun 11, 2026

More from decebals/claude-code-java

All 18

Recommended

More Java & JVM
1mryll avatarvertical-slice-architecturemryll/skillsEnforce Vertical Slice Architecture (VSA) when building applications in any language (Go, .NET/C#, Java, Kotlin, TypeScript, Python, etc.) and any type (web API327skills.sh installs
2decebals avatarlogging-patternsdecebals/claude-code-javaJava logging best practices with SLF4J, structured logging (JSON), and MDC for request tracing. Includes AI-friendly log formats for Claude Code debugging. Use 300skills.sh installs
3decebals avatargit-commitdecebals/claude-code-javaGenerate conventional commit messages for Java projects. Use when user says "commit", "create commit", "commit changes", or after completing code changes that n249skills.sh installs
4decebals avatarclean-codedecebals/claude-code-javaClean Code principles (DRY, KISS, YAGNI), naming conventions, function design, and refactoring. Use when user says "clean this code", "refactor", "improve reada427skills.sh installs
5decebals avatarsolid-principlesdecebals/claude-code-javaSOLID principles checklist with Java examples. Use when reviewing classes, refactoring code, or when user asks about Single Responsibility, Open/Closed, Liskov,384skills.sh installs
6decebals avatartest-qualitydecebals/claude-code-javaWrite high-quality JUnit 5 tests with AssertJ assertions. Use when user says "add tests", "write tests", "improve test coverage", or when reviewing/creating tes336skills.sh installs