Agent skill

Spring Boot Dependency Injection

by giuseppe-trisciuoglio in giuseppe-trisciuoglio/developer-kit

Provides dependency injection patterns for Spring Boot projects, including constructor-first design, optional collaborator handling, bean selection, and wiring validation.

MITAuto-check: notesBackend & APIs

Install Spring Boot Dependency Injection

skills CLI
$ npx skills add giuseppe-trisciuoglio/developer-kit --skill spring-boot-dependency-injection -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install giuseppe-trisciuoglio/developer-kit spring-boot-dependency-injection --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/giuseppe-trisciuoglio/developer-kit.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/developer-kit-java/skills/spring-boot-dependency-injection .claude/skills/spring-boot-dependency-injection && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
spring-boot-dependency-injection
GitHub stars
357
Token cost
~1.7k tokens
SKILL.md length
598 words
Files
4 (incl. references)
Skills in repo
115
Repo updated
First seen
Licence
MIT

At a glance

Provides dependency injection patterns for Spring Boot projects, including constructor-first design, optional collaborator handling, bean selection, and wiring validation.

  • Works in 6 steps: Separate mandatory and optional… → Default to constructor injection → Resolve optional behavior intentionally → …
  • Creating services and configurations
  • SKILL.md covers Overview, When to Use, Instructions and Examples, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Spring Boot Dependency Injection is an agent skill from giuseppe-trisciuoglio/developer-kit. Provides dependency injection patterns for Spring Boot projects, including constructor-first design, optional collaborator handling, bean selection, and wiring validation. Use when creating services and configurations, replacing field injection, or troubleshooting ambiguous or fragile Spring wiring.

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/examples.md`, `references/reference.md` and `references/spring-official-dependency-injection.md`).

It sits in Backend & APIs, covering Backend development and Design patterns. It works with Spring Boot. The repository describes itself as: Modular plugin marketplace for Claude Code and agentic CLIs, with validated, spec-driven skills, agents, commands, and workflows for Java, TypeScript, Python, PHP, AWS, and AI. The licence is MIT.

When your agent uses it

  • Creating services and configurations
  • Replacing field injection
  • Troubleshooting ambiguous
  • Fragile Spring wiring

Example prompts

  • “Use the spring-boot-dependency-injection skill to provide dependency injection patterns for Spring Boot projects, including constructor-first…”
  • “/spring-boot-dependency-injection”

Requirements

  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash, Glob, Grep

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Separate mandatory and optional collaborators
  2. Default to constructor injection
  3. Resolve optional behavior intentionally
  4. Use bean selection annotations only when needed
  5. Keep wiring in configuration, not business code
  6. Validate wiring explicitly

What it can do on your machine

Read from SKILL.md and the folder at commit fe73fb3. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Bash
    • Glob
    • Grep

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are java).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Spring Boot Dependency Injection loads about 1.7k tokens when it runs, and up to ~9.9k if it reads all its reference files. Until then it costs about 83 tokens; SKILL.md has 598 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~83
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~9.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Write, Edit, Bash, Glob, Grep

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from giuseppe-trisciuoglio/developer-kit at commit fe73fb3, republished under its MIT licence (© giuseppe-trisciuoglio). 598 words, ~1,674 tokens.

Download SKILL.mdSave it as .claude/skills/spring-boot-dependency-injection/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
spring-boot-dependency-injection
description
Provides dependency injection patterns for Spring Boot projects, including constructor-first design, optional collaborator handling, bean selection, and wiring validation. Use when creating services and configurations, replacing field injection, or troubleshooting ambiguous or fragile Spring wiring.
allowed-tools
Read, Write, Edit, Bash, Glob, Grep

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.

3. Resolve optional behavior intentionally

Good options include:

  • ObjectProvider<T> when lazy access is useful
  • @ConditionalOnProperty or @ConditionalOnMissingBean when wiring should change by configuration
  • a no-op implementation when the caller should not care whether the feature is enabled

Avoid nullable collaborators that leave runtime behavior ambiguous.

4. Use bean selection annotations only when needed

When multiple beans share the same type:

  • use @Primary for the default implementation
  • use @Qualifier for named variants
  • keep the qualifier names stable and easy to grep

If selection rules become complex, move them into a dedicated configuration class instead of spreading them across services.

5. Keep wiring in configuration, not business code

Use @Configuration and @Bean methods when:

  • the object comes from a third-party library
  • conditional creation logic is needed
  • you need environment-specific wiring or explicit composition

Business services should not know how infrastructure collaborators are instantiated.

Show full SKILL.md (282 more words)Show less
6. Validate wiring explicitly

After writing a new service or configuration:

  1. Verify the bean loads with a minimal context test:
    java
    @SpringBootTest
    @ContextConfiguration(classes = UserService.class)
    class UserServiceWiringTest {
        @Autowired UserService userService;
        @Test void serviceIsInstantiated() { assertNotNull(userService); }
    }
  2. Run constructor-based unit tests for service behavior (no Spring needed).
  3. Add slice tests only when MVC, JPA, or messaging integration must be verified.
  4. Reserve @SpringBootTest for container-wide wiring validation.

Failures at step 1 indicate wiring issues before business logic is added.

Examples

Example 1: Constructor-first application service
java
@Service
public class UserService {

    private final UserRepository userRepository;
    private final EmailSender emailSender;

    public UserService(UserRepository userRepository, EmailSender emailSender) {
        this.userRepository = userRepository;
        this.emailSender = emailSender;
    }

    public User register(UserRegistrationRequest request) {
        User user = userRepository.save(User.from(request));
        emailSender.sendWelcome(user);
        return user;
    }
}

This class is easy to instantiate directly in a unit test with mocks.

Example 2: Optional dependency with a no-op fallback
java
@Service
public class ReportService {

    private final ReportRepository reportRepository;
    private final NotificationGateway notificationGateway;

    public ReportService(
        ReportRepository reportRepository,
        ObjectProvider<NotificationGateway> notificationGatewayProvider
    ) {
        this.reportRepository = reportRepository;
        this.notificationGateway = notificationGatewayProvider.getIfAvailable(NotificationGateway::noOp);
    }
}

This keeps optional behavior explicit without leaking null handling through the rest of the class.

Example 3: Multiple beans with clear selection
java
@Configuration
public class PaymentConfiguration {

    @Bean
    @Primary
    PaymentGateway stripeGateway() {
        return new StripePaymentGateway();
    }

    @Bean
    @Qualifier("fallbackGateway")
    PaymentGateway mockGateway() {
        return new MockPaymentGateway();
    }
}

Use @Primary for the default path and @Qualifier only where a specific variant is required.

Best Practices

  • Prefer constructor injection for mandatory dependencies.
  • Keep service constructors small; if a class needs too many collaborators, the design probably wants another abstraction.
  • Use no-op or conditional beans instead of nullable optional dependencies.
  • Keep framework-specific creation logic in configuration classes.
  • Test services without Spring first, then add container tests only where they add value.
  • Remove field injection during refactors instead of extending it.

Constraints and Warnings

  • Field injection hides dependencies and makes tests harder to write.
  • Circular dependencies are usually a design problem, not a wiring trick to solve with @Lazy.
  • Overusing qualifiers can make the codebase hard to reason about; prefer better abstractions or clearer configuration.
  • Optional collaborators still need deterministic behavior when absent.
  • Full-context tests can hide the real source of wiring failures if used too early.

References

  • references/reference.md
  • references/examples.md
  • references/spring-official-dependency-injection.md
  • spring-boot-crud-patterns
  • spring-boot-rest-api-standards
  • unit-test-service-layer

© giuseppe-trisciuoglio, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in plugins/developer-kit-java/skills/spring-boot-dependency-injection of giuseppe-trisciuoglio/developer-kit.

  • SKILL.md
  • references/examples.md
  • references/reference.md
  • references/spring-official-dependency-injection.md

Open the folder on GitHubat commit fe73fb3

Compare with similar skills

Spring Boot Dependency Injection next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Spring Boot Dependency Injection compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Spring Boot Dependency Injection this skillgiuseppe-trisciuoglio/developer-kit357—~1.7kAutomated safety check: NotesMIT
Java Rulessoftspark/ai-toolkit179—~3.1kAutomated safety check: PassApache-2.0
Spring Boot Best PracticesHoangNguyen0403/agent-skills-standard572—~598Automated safety check: PassMIT
Node Backend Development Guidelinesdiet103/claude-code-infrastructure-showcase10k2 repos~2kAutomated safety check: PassMIT
Spring Bootpiomin/claude-ai-spring-boot1.3k—~2kAutomated safety check: PassApache-2.0
Dr Jskilljdubois/dr-jskill342—~4.6kAutomated safety check: NotesApache-2.0

Similar skills

  • Java Rules

    softspark/ai-toolkit

    Java coding rules: style, patterns, security, testing. An agent skill from softspark/ai-toolkit.

    179 GitHub stars~3.1k tokensUpdated 2 days ago
    Backend & APIsAuto-check passed
  • Spring Boot Best Practices

    HoangNguyen0403/agent-skills-standard

    Apply core coding standards, dependency injection, and configuration for Spring Boot 3.

    572 GitHub stars~598 tokensUpdated yesterday
    Backend & APIsAuto-check passed
  • Node Backend Development Guidelines

    diet103/claude-code-infrastructure-showcase

    Sets layered architecture and coding rules for Node.js, Express and TypeScript microservices, covering routes, controllers, services, repositories, Prisma, Sentry and Zod.

    10k GitHub starsUsed in 2 repos~2k tokens
    Backend & APIsAuto-check passed
  • Spring Boot

    piomin/claude-ai-spring-boot

    Spring Boot 3.x development - REST APIs, JPA, Security, Testing, and Cloud-native patterns.

    1.3k GitHub stars~2k tokensUpdated 5 mo ago
    Backend & APIsAuto-check passed
  • Dr Jskill

    jdubois/dr-jskill

    Creates Java + Spring Boot projects: Web applications, full-stack apps with Vue.js or Angular or React or vanilla JS, PostgreSQL, REST APIs, and Docker.

    342 GitHub stars~4.6k tokensUpdated 11 days ago
    Backend & APIsAuto-check: notes
  • Avoid AI Design

    sunkaifei/FlyCms

    Audit and rewrite frontend UI to remove generic AI design patterns ("AI slop"), both the first-order defaults (purple gradients, Inter, a centered hero over three cards, untouched shadcn) and the…

    656 GitHub stars~3.5k tokensUpdated 2 days ago
    Frontend & DesignAuto-check passed

More from giuseppe-trisciuoglio/developer-kit

All 115 skills in this repo
  • Nestjs Drizzle Crud Generator

    giuseppe-trisciuoglio/developer-kit

    Generates complete CRUD modules for NestJS applications with Drizzle ORM.

    357 GitHub stars~1.3k tokensUpdated 1 mo ago
    Auto-check: notes
  • Spring Boot Actuator

    giuseppe-trisciuoglio/developer-kit

    Provides patterns to configure Spring Boot Actuator for production-grade monitoring, health probes, secured management endpoints, and Micrometer metrics across JVM services.

    357 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check: notes
  • Spring Boot Crud Patterns

    giuseppe-trisciuoglio/developer-kit

    Provides and generates complete CRUD workflows for Spring Boot 3 services.

    357 GitHub stars~2.5k tokensUpdated 1 mo ago
    Auto-check: notes
  • Spring Boot Security JWT

    giuseppe-trisciuoglio/developer-kit

    Provides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based…

    357 GitHub stars~3.9k tokensUpdated 1 mo ago
    Auto-check: notes
  • AWS CLI Beast

    giuseppe-trisciuoglio/developer-kit

    Provides advanced AWS CLI patterns for managing EC2, Lambda, S3, DynamoDB, RDS, VPC, IAM, and CloudWatch.

    357 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check: notes
  • PR Review Comments

    giuseppe-trisciuoglio/developer-kit

    Posts review findings from a JSON file as inline comments on a GitHub Pull Request, attaching each comment to its file and line.

    357 GitHub stars~1k tokensUpdated 1 mo ago
    Auto-check: notes

Works with

Categories

Questions about Spring Boot Dependency Injection

What does Spring Boot Dependency Injection do?

Provides dependency injection patterns for Spring Boot projects, including constructor-first design, optional collaborator handling, bean selection, and wiring validation. Spring Boot Dependency Injection is an agent skill from giuseppe-trisciuoglio/developer-kit. Provides dependency injection patterns for Spring Boot projects, including constructor-first design, optional collaborator handling, bean selection, and wiring validation.

When should I use Spring Boot Dependency Injection?

Spring Boot Dependency Injection fits situations like: creating services and configurations; replacing field injection; troubleshooting ambiguous; fragile Spring wiring.

How do I install Spring Boot Dependency Injection in Claude Code?

Run `npx skills add giuseppe-trisciuoglio/developer-kit --skill spring-boot-dependency-injection -a claude-code`. Or copy the skill folder (plugins/developer-kit-java/skills/spring-boot-dependency-injection in giuseppe-trisciuoglio/developer-kit) into .claude/skills/spring-boot-dependency-injection in your project. Claude Code loads it when a task matches its description.

How do I install Spring Boot Dependency Injection in Codex?

Run `npx skills add giuseppe-trisciuoglio/developer-kit --skill spring-boot-dependency-injection -a codex`. Or copy the skill folder (plugins/developer-kit-java/skills/spring-boot-dependency-injection in giuseppe-trisciuoglio/developer-kit) into .agents/skills/spring-boot-dependency-injection in your project. Codex loads it when a task matches its description.

Can I use Spring Boot Dependency Injection in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add giuseppe-trisciuoglio/developer-kit --skill spring-boot-dependency-injection -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/spring-boot-dependency-injection, .gemini/skills/spring-boot-dependency-injection, .github/skills/spring-boot-dependency-injection and .opencode/skills/spring-boot-dependency-injection in your project.

What does Spring Boot Dependency Injection need to run?

SKILL.md names no scripts, command-line tools or credentials: Spring Boot Dependency Injection is instructions for the agent only. Its frontmatter pre-approves these tools: Read, Write, Edit, Bash, Glob, Grep.

Does Spring Boot Dependency Injection access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Spring Boot Dependency Injection safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Spring Boot Dependency Injection use?

Spring Boot Dependency Injection is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Spring Boot Dependency Injection use?

About 1.7k tokens (SKILL.md is roughly 6.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 8.2k tokens, read only when the agent opens those files.

What are the alternatives to Spring Boot Dependency Injection?

Skills that share tags, products or a category with Spring Boot Dependency Injection: Java Rules (softspark/ai-toolkit, 179 stars), Spring Boot Best Practices (HoangNguyen0403/agent-skills-standard, 572 stars), Node Backend Development Guidelines (diet103/claude-code-infrastructure-showcase, 10k stars) and Spring Boot (piomin/claude-ai-spring-boot, 1.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Spring Boot Dependency Injection?

giuseppe-trisciuoglio (a GitHub user) maintains it in giuseppe-trisciuoglio/developer-kit, which has 357 GitHub stars. The repository holds 115 skills in this directory. The repository was last updated on September 10, 2026.

Source: giuseppe-trisciuoglio/developer-kit on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.