
128 Java Generics
This is a comprehensive refactoring assistant for cleaning up Java generics across your codebase. It walks you through eliminating raw types, applying PECS (Producer Extends Consumer Super) for wildcards, fixing unsafe casts, and integrating generics with modern Java features like Records and sealed types. The workflow is strict: it forces a compile check before touching anything, then guides you through the reference material with good/bad code examples, then verifies everything still builds. Honestly, the mandatory compile gates are smart because generics refactoring can spiral into type errors fast. Best used when you have legacy code that compiles but is littered with warnings, or when you're tightening up API boundaries and want proper variance.
- skills.sh installs
- 135
- GitHub stars
- 393
- last updated
- Jun 3, 2026
Install
$ npx -y skills add jabrena/cursor-rules-java --skill 128-java-generics --agent claude-codeInstalls into .claude/skills of the current project.
Files
Java Generics Best Practices
Review and improve Java code using comprehensive generics best practices that enforce compile-time type safety and enable flexible, reusable APIs.
What is covered in this Skill?
- Type safety: avoiding raw types, eliminating unsafe casts
- Code reusability: generic methods and types for multiple type contexts
- PECS wildcards:
? extendsfor producers,? superfor consumers - Diamond operator for type inference
- Type erasure awareness: type tokens, factory patterns, array creation
- Generic inheritance and variance: invariance, covariance, contravariance
@SafeVarargsfor heap pollution prevention- Wildcard capture helpers, self-bounded generics (CRTP) for fluent builders
- Proper wildcard API design:
Comparator<? super T>,Function<? super T, ? extends R> - Arrays-vs-generics covariance pitfalls, serialization with
TypeReference/TypeToken - Generic naming conventions (
T,E,K/V,?), typesafe heterogeneous containers - Integration with Records, sealed types, and pattern matching
Sponsors
Details
- Repository
- github.com/jabrena/cursor-rules-java
- Category
- Java & JVM
- First seen
- Jun 3, 2026
More from jabrena/cursor-rules-java
All 16- 141 Java Refactoring With Modern Features135
- 142 Java Functional Programming135
- 131 Java Testing Unit Testing134
- 112 Java Maven Plugins133
- 143 Java Functional Exception Handling133
- 122 Java Type Design132
- 144 Java Data Oriented Programming129
- 170 Java Documentation129
- 132 Java Testing Integration Testing128
- 113 Java Maven Documentation125
- 110 Java Maven Best Practices160
- 121 Java Object Oriented Design153
- 124 Java Secure Coding146
- 111 Java Maven Dependencies136
- 125 Java Concurrency135