Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add cass-2003/local-workflow-skill --skill dependency-injectiongit clone --depth 1 https://github.com/cass-2003/local-workflow-skillWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/cass-2003/local-workflow-skill/dependency-injection)<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/dependency-injection"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/dependency-injection/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/dependency-injection"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/dependency-injection.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00162 | $0.03252 |
| Opus 5.5 | $0.00065 | $0.01301 |
| Sonnet 5.5 | $0.00032 | $0.00650 |
| Haiku 4.5 | $0.00016 | $0.00325 |
Grade A, and why
dependency-injection scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 458 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Dependency Injection Skill — DI 模式
何时使用
- 设计模块化应用(让组件可测试 / 可替换)
- 选择手动 DI 还是用框架(NestJS / Spring / Inversify)
- 调试循环依赖
- 区分 singleton / scoped / transient 生命周期
- 评审 PR 中"new XXX()"是否合适
一、核心思想
依赖注入进来,不是依赖主动获取。
// ❌ 主动依赖(hard-coded)
class UserService {
private db = new PostgresClient() // 改实现要改这
private logger = console // 测试无法 mock
getUser(id: string) { return this.db.query(...) }
}
// ✅ 依赖注入(构造器)
class UserService {
constructor(private db: Database, private logger: Logger) {}
getUser(id: string) {
this.logger.info({ id }, 'fetching user')
return this.db.query(...)
}
}
// 调用方决定具体实现
const svc = new UserService(new PostgresClient(), pino())
收益:
- 可测试:注入 fake / mock
- 可替换:切 SQLite / Mock DB / Redis
- 显式依赖:构造器签名是合同
- 解耦:组件不知道依赖如何创建
二、何时不用 DI 框架
多数小项目不需要框架。手动 DI 在 composition root(main / 启动文件)一处装配就够:
// composition-root.ts
export function buildApp() {
const db = new PostgresClient(env.DATABASE_URL)
const logger = pino({ level: env.LOG_LEVEL })
const cache = new RedisClient(env.REDIS_URL)
const userRepo = new UserRepo(db)
const userSvc = new UserService(userRepo, cache, logger)
const authSvc = new AuthService(userRepo, logger, env.JWT_SECRET)
// ...
return { userSvc, authSvc }
}
只在以下情况上框架:
- 大量服务(> 30 个)相互依赖,手装配维护痛
- 需要按请求 scope 注入(NestJS / Spring Web)
- 团队习惯 / 框架要求(Spring Boot / NestJS / Angular)
三、四种注入方式
1. Constructor Injection(首选)
class Service {
constructor(private db: Database) {}
}
依赖立即可见 / 不可变 / 强制必填。
2. Setter Injection(次选)
class Service {
private db?: Database
setDb(db: Database) { this.db = db }
}
适合可选依赖。但用前必须检查 null。
3. Property Injection(框架专用)
// NestJS
class Service {
@Inject('DB') private db: Database
}
// Spring
@Autowired private Database db;
简洁但隐藏依赖(看不出有哪些)。
4. Method Injection(罕见)
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3mo ago First seen · 458 lines · 162 tokens per session scan A 4fe8b0863831
dependency-injection is a skill published in the GitHub repository cass-2003/local-workflow-skill (12 stars, last pushed 4mo ago), licensed MIT. It adds 162 tokens to every session and 3,252 once invoked, about $0.0006 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
dependency-injection compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| dependency-injectioncass-2003/local-workflow-skill | Skill | 12 | 4mo ago | MIT | A | 162 | Claude Code, Codex |
| mem0-oss-to-platformmem0ai/mem0 | Skill | 70k | 6d ago | Apache-2.0 | A | 217 | Claude Code, Codex |
| tao-run-inference-serviceNVIDIA/skills | Skill | 4.3k | today | Apache-2.0 | A | 92 | Claude Code |
| azure-mgmt-botservice-dotnetmicrosoft/skills | Skill | 3.3k | today | MIT | A | 78 | Claude Code |
| fastapi-router-pymicrosoft/skills | Skill | 3.3k | today | MIT | A | 46 | Claude Code |
| dev-runtimelangwatch/langwatch | Skill | 5.1k | today | Apache-2.0 | A | 172 | Claude Code |
| api-designericrisco/rsc-harness | Skill | 707 | yesterday | MIT | A | 105 | Claude Code, Codex |