1---2name: fn-args-deps3description: >-4 Enforces the fn(args, deps) pattern: business logic as functions with explicit5 dependency injection instead of service classes. Use this skill when writing6 or refactoring TypeScript business logic, replacing classes, structuring deps,7 or setting up a composition root. Do not use when/for React component8 structure (use react-development) or Result/error modeling alone (use9 result-types).10version: 1.2.011libraries: ["vitest-mock-extended"]12---1314# Functions Over Classes: fn(args, deps)1516## Critical rules1718- Business logic is `fn(args, deps)` — never service classes. `args` are per-call; `deps` are long-lived collaborators.19- Declare a per-function deps type. No god `AllServiceDeps` objects.20- Wire deps once at a composition root. Handlers call factories, not constructors mid-request.21- Inject only network/disk/clock collaborators. Import pure utilities directly.22- Use `import type` for infra interfaces; instances arrive via `deps`.23- Before writing examples or grouping choices, read [references/examples.md](references/examples.md) and [references/patterns.md](references/patterns.md).2425## Workflow26271. Identify business logic that should be a function (or extract it from a class).282. Split per-call data into `args` and collaborators into a named `XDeps` type.293. Before choosing individual vs grouped injection, read [references/patterns.md](references/patterns.md).304. Implement `fn(args, deps)`. Keep classes only as thin framework wrappers or stateful resources.315. Add a factory / composition-root wire-up so call sites never construct deps.326. Test with `mock<XDeps>()` — no class instantiation. See [references/examples.md](references/examples.md).3334## Resources3536- [references/examples.md](references/examples.md) — WRONG vs CORRECT signatures, composition root, NestJS wrapper, tests. Read when implementing or reviewing.37- [references/patterns.md](references/patterns.md) — grouping, migration, when classes are OK, enforcement, rationalizations. Read before structuring modules.3839## Validation4041- [ ] Every business function is `fn(args, deps)` with a per-function deps type42- [ ] No unused `deps` fields; no god deps bag43- [ ] Deps wired once at composition root44- [ ] Infra via `import type` only; instances via `deps`45- [ ] Pure utilities imported, not injected46- [ ] Remaining classes are wrappers, stateful resources, or builders47- [ ] Tests use `mock<XDeps>()` without instantiating a class4849## Constraints5051- Framework-mandated classes, connection pools, caches, and fluent builders may stay as thin wrappers over pure functions.52- Related: `result-types`, `validation-boundary`, `testing-strategy`, `writing-tests`, `observability`, `strict-typescript`, `pattern-enforcement`.