0-deps-wiring — Claude Code rule: dependency wiring and install
The 0-deps-wiring rule sets where application dependencies are composed and how the graph is reused. It fits TypeScript projects with command handlers and use cases.
MIT ★ 571 updated 2026-10-29
.claude/rules/0-deps-wiring.mdWhat 0-deps-wiring does
The rule covers command files, src/cli.ts, and modules under src/runtime/wiring/. createDeps(projectRoot, options, output) builds the full dependency graph. Call it from a command action after program.parse(), not beforehand. The menu has a separate factory, createMenuDeps(projectRoot), which provides a ManifestRepository and a Prompter.
Keep one wiring module per context, then compose those modules in runtime/wiring/framework.ts. In cli.ts, create only the version reader and CLIOutput; adapters belong elsewhere. createDeps caches by projectRoot, while the preAction hook warms the graph for process.cwd(). Setting AIDD_SKIP_UPDATE_CHECK skips that hook, so a command file should not add another cache.
What it helps with
- build a command's dependency graph through one factory
- prepare menu dependencies separately from command dependencies
- split wiring by context and compose it in the framework module
- avoid adding a second cache in a command file
Example prompts for the agent
- Check that the command calls
createDepsfrom its action afterprogram.parse(). - Move the menu setup into
createMenuDeps(projectRoot). - Split the wiring modules by context and compose them in
runtime/wiring/framework.ts.
How to install 0-deps-wiring
Manually: put the files in place
.claude/rules/0-deps-wiring.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/0-deps-wiring.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/0-deps-wiring.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/0-deps-wiring.mdManually: put the files in place
.clinerules/0-deps-wiring.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about 0-deps-wiring
How do I install 0-deps-wiring in Claude Code?
Add the rule at .claude/rules/0-deps-wiring.md.
What does 0-deps-wiring do?
It defines where command and menu dependencies are created, how wiring is split by context, and how the dependency graph is cached.
When should createDeps run, and what skips preAction?
Call createDeps from a command action after program.parse(). The preAction hook warms dependencies for process.cwd(), unless AIDD_SKIP_UPDATE_CHECK is set.
Source text
0-deps-wiring.md · MIT
--- description: Apply when a command or use case needs a collaborator; every dependency is built once, in the composition root. paths: - "src/presentation/commands/**/*.ts" - "src/cli.ts" - "src/runtime/wiring/**/*.ts" --- # Dependency Wiring ## Factories - `createDeps(projectRoot, options, output)` builds the full graph. - Call it from a command action, never before `program.parse()`. - `createMenuDeps(projectRoot)` serves the menu: a `ManifestRepository`, a `Prompter`. - Extend that factory for a pre-parse need. - Never instantiate an adapter in `cli.ts`. - One wiring module per context under `runtime/wiring/`. - `runtime/wiring/framework.ts` composes them. - `cli.ts` builds two things: the version reader, the `CLIOutput`. ## Once - `createDeps` memoizes on `projectRoot`. - The `preAction` hook warms it for `process.cwd()`. - `AIDD_SKIP_UPDATE_CHECK` short-circuits that hook. - No second cache in a command file. ## Not an area - The composition root never counts as a caller (`0-shared-modules.md`).
© ai-driven-dev · MIT · ai-driven-dev/framework