spring-context-di-reasoning
Skill18 starsChanged 9 months agoMITView on GitHub
Diagnose Spring application context startup failures, bean graph problems, missing or duplicate beans, circular dependencies, conditional auto-configuration mismatches, and profile-related wiring issues in Kotlin + Spring projects. Use when the app does not start, a bean is not created or is created unexpectedly, auto-configuration behaves strangely, or a minimal DI fix is needed instead of a broad rewrite.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- JetBrains/skillsedited, first seen Apr 28, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- JetBrains/skills★ 36097% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository24 other files it gives its agents.
- ci-cd-containerization-advisorSkill
- configuration-properties-profiles-kotlin-safeSkill
- dependency-conflict-resolverSkill
- domain-decomposition-api-design-advisorSkill
- error-model-validation-architectSkill
- gradle-kotlin-dsl-doctorSkill
- integration-resilience-engineerSkill
- jackson-kotlin-serialization-specialistSkill
- java-kotlin-migration-assistantSkill
- jpa-spring-data-kotlin-mapperSkill
- kotlin-idiomatic-refactorer-spring-awareSkill
- kotlin-spring-proxy-compatibilitySkill
- observability-integratorSkill
- performance-concurrency-advisorSkill
- production-incident-responderSkill
- project-context-ingestionSkill
- schema-migration-plannerSkill
- spring-kotlin-code-reviewSkill
- spring-mvc-webflux-api-builderSkill
- spring-security-configurator-auditorSkill
- stacktrace-log-triageSkill
- test-suite-builderSkill
- transaction-consistency-designerSkill
- upgrade-breaking-change-navigatorSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
31 rules. About 0 are common, 17 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈17
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Read the full exception chain, not only the top exception.
- Very specific: line 18
Read the startup log lines around the first failure and around any Caused by: entries.
- Very specific: line 19
Read the relevant @Configuration, component classes, @Bean methods, @ConfigurationProperties, and active profiles.
- Very specific: line 20
Read the build context if it is not already known.
- Distinctive: line 21
If a condition evaluation report or auto-configuration report exists, use it.
- Distinctive: line 35
Check these categories in order:
- Distinctive: line 67
Prefer fixes in this order:
- Very specific: line 74
Use @Lazy only as a deliberate escape hatch, and explain the tradeoff.
- Very specific: line 78
Check whether a @Configuration class uses proxyBeanMethods = false.
- Very specific: line 79
Check whether the missing bean is actually a FactoryBean product versus the factory itself.
- Very specific: line 80
Check generic type narrowing.
- Very specific: line 81
Check collection and map injection semantics.
- Very specific: line 82
Check whether ObjectProvider<T>, Optional<T>, or lazy lookup is masking a missing dependency until first use.
- Very specific: line 83
Check whether @ConditionalOnMissingBean, @ConditionalOnSingleCandidate, or ordering annotations caused an auto-configuration branch to back …
- Distinctive: line 84
Check for environment post-processors, imported configs, or test slices that change the bean graph compared with main runtime.
- Distinctive: line 85
If the project uses AOT or native image workflows, check whether reflection or generated context metadata, not the source annotations …
- Distinctive: line 89
Prefer following the bean creation path from the first failing constructor argument over scanning all annotations in the module.
- Distinctive: line 90
If one fix would "make startup pass" but leaves the graph semantically wrong, reject it and explain the deeper issue.
- Distinctive: line 91
When the problem surfaces only in tests, compare the test slice graph with the production graph before changing production code.
- Distinctive: line 92
If a bean exists but the wrong implementation is selected, explain the selection mechanism, not only the missing qualifier.
- Distinctive: line 93
If property binding and bean creation both fail, fix property binding first.
- Very specific: line 107
Do not suggest @ComponentScan("*"), giant scanBasePackages, or other "scan the world" fixes.
- Distinctive: line 108
Do not guess bean names or qualifiers that are not present in the code.
- Distinctive: line 109
Do not recommend disabling auto-configuration broadly to silence a symptom.
- Very specific: line 110
Do not use @Lazy as the default answer to cycles.
- Distinctive: line 111
Do not ignore profiles, conditions, or property sources when explaining bean behavior.
- Very specific: line 115
Verify @EnableConfigurationProperties or equivalent registration if properties beans are missing.
- Distinctive: line 116
Verify whether the failing type is an interface with multiple implementations.
- Distinctive: line 117
Verify whether a bean lives in another Gradle module that is not on the runtime classpath.
- Very specific: line 118
Verify whether a @TestConfiguration or test slice changes the graph only in tests.
- Distinctive: line 119
Verify whether the issue is really a classpath problem disguised as a bean problem.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Spring Context DI Reasoning
Source mapping: Tier 1 critical skill derived from Kotlin_Spring_Developer_Pipeline.md (SK-02).
Mission
Reconstruct why the Spring container made a specific decision and propose the narrowest fix that restores correct wiring. Assume the visible exception is often a wrapper, not the real cause.
Collect Evidence First
- Read the full exception chain, not only the top exception.
- Read the startup log lines around the first failure and around any
Caused by:entries. - Read the relevant
@Configuration, component classes,@Beanmethods,@ConfigurationProperties, and active profiles. - Read the build context if it is not already known. Reuse output from
project-context-ingestionwhen available. - If a condition evaluation report or auto-configuration report exists, use it.
Reconstruct The Bean Path
- Identify the bean that failed first.
- Walk constructor arguments, method parameters, and factory methods to build the dependency chain.
- Separate symptom from cause:
BeanCreationExceptionis usually a wrapper.UnsatisfiedDependencyExceptionusually points to a missing or ambiguous dependency one hop deeper.- property binding failures often surface as bean creation failures.
- Record whether the failing bean is user-defined, auto-configured, conditional, profile-specific, or imported from another module.
Diagnose By Category
Check these categories in order:
- Missing bean:
- package not scanned
- bean class not annotated
@Beanmethod not imported- wrong module dependency
- Ambiguous bean:
- multiple beans of same type
- missing
@Qualifier - missing
@Primary
- Conditional mismatch:
@Profilenot active@ConditionalOnPropertyfalse or missing- classpath condition not satisfied
- Configuration binding failure:
- wrong prefix
- missing required property
- invalid type conversion
- Circular dependency:
- constructor cycle
- configuration class cycle
- bean factory method recursion
- Auto-configuration collision:
- user bean unintentionally overrides or blocks auto-config
- excluded auto-config removes a dependency chain
- Lifecycle or initialization side effects:
- bean does work too early in
@PostConstruct - external system call during initialization
- bean does work too early in
Fix Hierarchy
Prefer fixes in this order:
- Correct the missing import, annotation, qualifier, or profile.
- Correct the configuration property source or binding model.
- Narrow the scan or import boundary to the intended package or module.
- Resolve ambiguity with
@Qualifieror@Primary. - Refactor an actual cycle into a cleaner dependency direction.
- Use
@Lazyonly as a deliberate escape hatch, and explain the tradeoff.
Advanced Container Traps
- Check whether a
@Configurationclass usesproxyBeanMethods = false. In that mode, direct calls between@Beanmethods do not return the managed singleton unless dependencies are expressed through method parameters. - Check whether the missing bean is actually a
FactoryBeanproduct versus the factory itself. - Check generic type narrowing.
Foo<Bar>andFoo<Baz>may both exist while raw-type reasoning makes the graph look ambiguous or missing. - Check collection and map injection semantics.
List<BeanType>ordering, bean names, and conditional registration can hide the real cause. - Check whether
ObjectProvider<T>,Optional<T>, or lazy lookup is masking a missing dependency until first use. - Check whether
@ConditionalOnMissingBean,@ConditionalOnSingleCandidate, or ordering annotations caused an auto-configuration branch to back off unexpectedly. - Check for environment post-processors, imported configs, or test slices that change the bean graph compared with main runtime.
- If the project uses AOT or native image workflows, check whether reflection or generated context metadata, not the source annotations alone, is the true source of failure.
Expert Heuristics
- Prefer following the bean creation path from the first failing constructor argument over scanning all annotations in the module.
- If one fix would "make startup pass" but leaves the graph semantically wrong, reject it and explain the deeper issue.
- When the problem surfaces only in tests, compare the test slice graph with the production graph before changing production code.
- If a bean exists but the wrong implementation is selected, explain the selection mechanism, not only the missing qualifier.
- If property binding and bean creation both fail, fix property binding first. Bean graph symptoms often disappear afterward.
Output Contract
Return these sections:
Diagnosis: the most probable root cause in one or two sentences.Evidence: the exact lines, bean path, condition, or configuration fact that supports the diagnosis.Minimal fix: the smallest code or config change that addresses the root cause.Alternatives: only if there is more than one legitimate fix.Verification: how to confirm the fix, such as./gradlew test,bootRun, or a specific startup assertion.
Guardrails
- Do not suggest
@ComponentScan("*"), giantscanBasePackages, or other "scan the world" fixes. - Do not guess bean names or qualifiers that are not present in the code.
- Do not recommend disabling auto-configuration broadly to silence a symptom.
- Do not use
@Lazyas the default answer to cycles. - Do not ignore profiles, conditions, or property sources when explaining bean behavior.
Common Spring-Specific Checks
- Verify
@EnableConfigurationPropertiesor equivalent registration if properties beans are missing. - Verify whether the failing type is an interface with multiple implementations.
- Verify whether a bean lives in another Gradle module that is not on the runtime classpath.
- Verify whether a
@TestConfigurationor test slice changes the graph only in tests. - Verify whether the issue is really a classpath problem disguised as a bean problem.
Quality Bar
A good run of this skill explains why Spring made the wrong decision and gives a minimal, testable fix. A bad run waves at annotations, suggests broad scans, or ignores the dependency chain that actually failed.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

