122-java-type-design

Refactor Java source code with domain-driven type-safe wrappers and BigDecimal.

Updated Jul 6, 2026
One-click install
npx skills add https://github.com/shirulot/codex-skill --skill 122-java-type-design-shirulot
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 122-java-type-design
Source: https://github.com/shirulot/codex-skill/tree/main/122-java-type-design
Command: npx skills add https://github.com/shirulot/codex-skill --skill 122-java-type-design-shirulot

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill addresses the common issues of primitive obsession, unclear type hierarchies, and inconsistent naming conventions in Java codebases, which often lead to fragile and hard-to-maintain software.

Core Features & Use Cases

  • Type-Safe Modeling: Replaces primitive types with domain-specific value objects like EmailAddress or Money to enforce invariants.
  • Hierarchy Refactoring: Organizes classes and interfaces into logical, readable structures using composition and inheritance.
  • API Design: Implements fluent interfaces and consistent method signatures to improve code readability and developer experience.

Quick Start

Apply the 122-java-type-design skill to review the current project and suggest refactorings for primitive obsession and type hierarchy improvements.

Frequently Asked Questions about 122-java-type-design

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

FAQPage Schema
How do I refactor Java code to fix primitive obsession?

Refactor primitive obsession in Java by replacing primitive types with domain-specific value objects like EmailAddress or Money. This enforces invariants and improves readability, transforming fragile code into maintainable, type-safe domain models.

What is domain-driven type design in Java?

Domain-driven type design in Java models business concepts as strict type hierarchies and type-safe wrappers. It organizes classes using composition and inheritance to establish logical structures, consistent naming, and interface-based contract design.

How do I use BigDecimal for financial logic in Java refactoring?

Use BigDecimal for financial logic during Java refactoring to ensure precision-sensitive numeric handling. This approach replaces error-prone primitive doubles, satisfying strict requirements for compilation-verified financial calculations.

Can I refactor legacy Java codebases for type safety?

Yes, you can refactor legacy Java codebases for type safety. The process applies domain-driven modeling and interface-based contracts to legacy projects, organizing unclear type hierarchies into logical, readable structures.

What is the best way to design fluent interfaces and consistent API methods in Java?

Design fluent interfaces and consistent method signatures in Java by implementing interface-based contracts. This refactoring approach improves API readability and developer experience through organized, type-safe wrapper implementations.

When do I need type-safe wrappers for Java code quality?

You need type-safe wrappers when Java code suffers from primitive obsession and inconsistent naming. Wrapping primitives in domain-specific value objects enforces invariants and prevents fragile, hard-to-maintain software structures.