Skills/swinject-to-factory/SKILL.md
Migrates runtime-based dependency injection using Swinject to compile-time–oriented dependency injection using Factory. Use when refactoring DI containers, composition roots, and dependency lifetimes in a Clean Architecture–oriented Swift project.
npx skillsauth add packtpublishing/ai-driven-swift-architecture swinject-to-factoryInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This project currently relies on Swinject, a runtime-based dependency injection framework. Dependencies are registered imperatively, resolved dynamically, and validated only at runtime.
The goal of this Skill is to guide a controlled migration toward Factory, a dependency injection approach that encodes dependency graphs declaratively and enables earlier validation through Swift’s type system.
This Skill must be applied with architectural awareness, not as a mechanical API replacement.
This migration is driven by the following architectural goals:
resolve calls from application codeFactory is treated as a composition mechanism, not as a service locator.
This Skill must NOT:
The migration must be consistent and complete within the affected scope.
Factory must be added as an external dependency using Swift Package Manager.
Rules:
Swinject pattern (before):
resolveFactory pattern (after):
Rules:
register calls with Factory<T> declarationsresolve inside Factory definitionsRules:
resolve(...) from application and feature code! or fallback logic)Missing dependencies should surface as compilation errors, not runtime crashes.
Translate Swinject scopes to Factory scopes as follows:
.transient → default Factory behavior.container (singleton) → .singleton.graph → .shared or .cached (depending on semantics)Rules:
Rules:
init() blocks whose sole purpose is to register dependenciesThe composition root remains conceptually at the application boundary, but its implementation becomes declarative rather than procedural.
Rules:
Container as a namespace for dependency declarationsFactories should be accessed in a controlled and explicit manner.
Factory does not provide a runtime Assembly mechanism.
Instead, dependency composition must be expressed statically through extensions on Container.
In this project, each module must declare its own factories. These declarations serve as logical assemblies, scoped by module and responsibility.
public extension Container to expose factories across module boundaries.Data modules:
Domain modules:
Utility modules:
App module:
Container extension containing all factories.This structure preserves:
While Factory eliminates the need for runtime assemblies, organizing factories by module provides the same architectural benefits as Swinject assemblies without reintroducing runtime indirection.
Before considering the migration complete:
register or resolve calls remainAfter applying this Skill:
This Skill prioritizes architectural clarity and safety over mechanical refactoring.
tools
--- name: spm-to-tuist description: Migrates a generative, enum-driven Swift Package Manager (SPM) modular architecture to Tuist while preserving architectural invariants and meta-structure. --- # Intent Migrate a Swift Package Manager (SPM) project to Tuist **without losing its generative architecture model**. The existing SPM setup is not flat. Targets and products are derived from enums, and dependencies are strongly typed through helper abstractions. This migration must preserve not on
development
Migrates RxSwift networking code to native Swift async/await. Use when refactoring Observable-based API code, removing RxSwift dependencies, or modernizing to Swift Concurrency.
development
Cleans and maintains Package.swift files in a Clean Architecture–oriented Swift project. Use when removing obsolete dependencies, refactoring module graphs, or enforcing architectural conventions encoded in Package.swift.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.