Provides dependency injection patterns for Spring Boot projects, including constructor-first design, optional collaborator handling, bean selection, and wiring validation.
SkillScore95Maintained
Automatic
◆Coding pack
Last verified 8/21/2026
What it changes
Passed 21 of 22 test cases with the skill, and 18 of 22 without it.
Without skill82%
With skill95%
Checks it passed that the model alone missed
Uses ObjectProvider with getIfAvailable in the service constructor.
Uses ObjectProvider or a no-op fallback for the optional MetricsCollector collaborator.
Uses ObjectProvider rather than Optional in the constructor for the optional collaborator.
and 1 more in the full report
3 fixed18 passed either way1 still failing0 broke
Pass-rate lift
+14 pp
Tokens
+35%
Agent turns
0%
Response time
-18%
Model gemini-3.6-flashMeasured 8/21/2026v121 of 22 cases passed with skill
Tokens, turns and time describe resource use, not a dollar price.
See it in action
One of 3 test cases the skill fixed. Same model, same prompt, with and without the skill.
1 of 3
Prompt
I'm updating a legacy Spring Boot `@Service` class that currently uses `@Autowired` field injection for its mandatory database repository and has a nullable `MetricsCollector` field. Can you rewrite this Java service class to follow modern Spring DI principles for both required and optional dependencies, and provide a lightweight test snippet to verify bean creation?
What was checked, without and with the skill
Checked
Without skill
With skill
Uses ObjectProvider or a no-op fallback for the optional MetricsCollector collaborator.
Missed
Passed
Uses @ContextConfiguration restricted to the service class for the lightweight bean verification test.
Missed
Passed
case-01 · gemini-3.6-flash · 8/21/2026 · answers are capped and redacted
What's inside
The instructions your model reads when the skill loads.
SKILL.md183 lines4 files
Spring Boot Dependency Injection
Overview
Provides constructor-first dependency injection patterns for Spring Boot:
mandatory collaborators via constructor injection
optional collaborators via ObjectProvider or no-op fallbacks
bean selection via @Primary and @Qualifier
validation via minimal context tests before full integration
When to Use
Use this skill when:
creating a new @Service, @Component, @Repository, or @Configuration class
replacing field injection in legacy Spring code
resolving multiple beans of the same type with qualifiers or primary beans
handling optional features, adapters, or integrations without null-driven wiring
reviewing circular dependencies or brittle context startup failures
preparing code for direct constructor-based unit testing
Instructions
1. Separate mandatory and optional collaborators
For each class, identify:
mandatory collaborators required for correct behavior
optional collaborators that enable integrations, caching, notifications, or feature-flagged behavior
Mandatory collaborators belong in the constructor. Optional ones need an explicit strategy such as ObjectProvider, conditional beans, or a no-op implementation.
2. Default to constructor injection
For application services and adapters:
inject mandatory dependencies through the constructor
keep injected fields final
instantiate the class directly in unit tests without starting Spring
A single constructor is usually enough; @Autowired is unnecessary in that case.
Provides fault tolerance patterns for Spring Boot 3.x using Resilience4j. Use when implementing circuit breakers, handling service failures, adding retry logic with exponential backoff, configuring rate limiters, or protecting services from cascading failures. Generates circuit breaker, retry, rate limiter, bulkhead, time limiter, and fallback implementations. Validates resilience configurations through Actuator endpoints.