# Dependency injection

> Dependency injection is an open-source agent skill for developer tools. Guides Guice dependency injection wiring in Sankhya Addon Studio addons. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/snk-devcenter/addon-studio/tree/main/plugins/addon-studio/skills/dependency-injection
- **Repository:** https://github.com/snk-devcenter/addon-studio
- **GitHub stars:** 7
- **License:** MIT
- **Skill name:** dependency-injection
- **Collection:** https://github.com/snk-devcenter/addon-studio
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

This skill helps an agent set up, review and debug Google Guice dependency injection inside Sankhya Addon Studio 2.0 projects. It explains which stereotype annotations the framework auto-scans, when to inject through constructors, how custom modules with Multibinder and factory methods are written, and when to use singleton scope or Provider for lazy or circular dependencies.

The guidance includes a checklist for new injectable classes and custom modules, and a table of common errors with their fixes. It covers deploy-time failures such as duplicate bindings for the same interface, which only surface when the injector is created on the server rather than during the build.

The material is written in Portuguese and assumes Java 8, Gradle and the Addon Studio SDK. It points to related skills for controllers, controller advice, MapStruct, Retrofit and configuration values.

## When your agent uses it

> Configura, revisa e debuga DI Guice em Sankhya Addon Studio — `@Inject` de `com.google.inject`, `@Component`, `@CustomModule`, `Provider<T>`, `Multibinder`, `@Singleton`, escopos. Use ao montar wiring, criar/alterar módulos Guice, ao injetar repository/service em controller, job ou listener (costura entre camadas), ao revisar/auditar dependências, quando o addon sobe (deploy) e reclama que não conseguiu criar/instanciar um componente, que "não achou como criar" o seu service, que falta implementação ligada ou que não achou construtor (`ConfigurationException`, `CreationException`, `No implementation bound`, `Could not find a suitable constructor`), ou ao tocar em código com `@Inject`/`@CustomModule`/`AbstractModule`. Erro de deploy que nomeia o componente que o Guice não conseguiu criar já é diagnóstico pronto: o dono é esta skill, não o sub-agent `troubleshooter`. NÃO usar quando o valor a injetar é parâmetro de configuração do Sankhya — isso é `@Value`, skill `value`.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/snk-devcenter/addon-studio/tree/HEAD/plugins/addon-studio/skills/dependency-injection)
- [License: MIT](https://github.com/snk-devcenter/addon-studio/tree/HEAD/plugins/addon-studio/skills/dependency-injection)

## Features

- **Constructor injection rules:** Covers the required use of Guice's Inject annotation on constructors and private final dependencies.
- **Stereotype reference:** Explains which annotations are auto-managed for controllers, repositories, components and advice.
- **Custom module patterns:** Shows Multibinder strategy registration and factory methods annotated with Provides and Singleton.
- **Provider and singleton scope:** Describes when to inject lazy providers for circular dependencies and when to use singleton scope.
- **Duplicate binding diagnosis:** Explains why two components implementing one interface break deployment and how to fix it.
- **Deploy error troubleshooting:** Lists common Guice exceptions and build problems with their corrections.

## Good for

- Wire a service into a REST controller using constructor injection
- Register several strategy implementations through a Multibinder module
- Fix a deploy failure caused by a Guice binding already set
- Make a singleton HTTP interceptor depend on a service without a circular reference
- Review an Addon Studio project for misused dependency injection annotations

## Install

### Claude Code

This skill ships in the `addon-studio` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add snk-devcenter/addon-studio
/plugin install addon-studio@snk-devcenter
```

Or copy only this skill to `~/.claude/skills/dependency-injection`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/dependency-injection &&
cp -R "$tmp/plugins/addon-studio/skills/dependency-injection" ~/.claude/skills/dependency-injection &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/dependency-injection` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/dependency-injection` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/dependency-injection &&
cp -R "$tmp/plugins/addon-studio/skills/dependency-injection" ~/.agents/skills/dependency-injection &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/dependency-injection` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/dependency-injection` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/dependency-injection &&
cp -R "$tmp/plugins/addon-studio/skills/dependency-injection" ~/.cursor/skills/dependency-injection &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/dependency-injection` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/snk-devcenter/addon-studio.git --path plugins/addon-studio/skills/dependency-injection
```

Or copy the folder to `~/.gemini/skills/dependency-injection` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/dependency-injection`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/dependency-injection &&
cp -R "$tmp/plugins/addon-studio/skills/dependency-injection" ~/.copilot/skills/dependency-injection &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/dependency-injection` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git
```

Then copy `addon-studio/plugins/addon-studio/skills/dependency-injection` into your agent's skills folder as `dependency-injection`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Which Inject annotation should be used?

The skill specifies com.google.inject.Inject and says javax.inject.Inject should not be used.

### Should @Component be added to a @Controller or @Repository?

No. Controllers and repositories are managed automatically, so the Component annotation should be removed from them.

### Why does deployment fail with BindingAlreadySet even when the build passes?

Two components implementing the same interface are both bound to it when the injector is created on deploy. The skill recommends removing the stereotype from one and providing it through a custom module.

### When should a dependency be injected as Provider instead of directly?

The skill recommends Provider for circular dependencies, singletons that need request-scoped services, and lazy initialization of costly objects.

### How do I install Dependency injection in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/dependency-injection to use it in all your projects, or to .claude/skills/dependency-injection in one project. Or install the addon-studio plugin, which includes it: /plugin marketplace add snk-devcenter/addon-studio, then /plugin install addon-studio@snk-devcenter.

### Does Dependency injection run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Dependency injection?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Dependency injection?

The closest alternatives to Dependency injection are Retrofit, Go dependency injection, Value, Mapstruct and Test.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Retrofit](https://ai-powered.com/skills/retrofit): Retrofit is an open-source agent skill for developer tools.
- [Go dependency injection](https://ai-powered.com/skills/go-dependency-injection): Go dependency injection is an open-source agent skill for developer tools.
- [Value](https://ai-powered.com/skills/value): Value is an open-source agent skill for developer tools.
- [Mapstruct](https://ai-powered.com/skills/mapstruct): Mapstruct is an open-source agent skill for developer tools.
- [Test](https://ai-powered.com/skills/test-snk-devcenter): Test is an open-source agent skill for developer tools.
- [Type adapter](https://ai-powered.com/skills/type-adapter): Type adapter is an open-source agent skill for developer tools.
- [Repository](https://ai-powered.com/skills/repository): Repository is an open-source agent skill for developer tools.
- [Sankhya js](https://ai-powered.com/skills/sankhya-js): Sankhya js is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/dependency-injection
