factory

Manage Swift dependency injection with compile-time-safe containers and factories.

2.9k|192|Updated Jun 1, 2022
One-click install
npx skills add https://github.com/hmlongco/Factory --skill factory-hmlongco
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: factory
Source: https://github.com/hmlongco/Factory/tree/main/.claude/skills/factory
Command: npx skills add https://github.com/hmlongco/Factory --skill factory-hmlongco

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Swift apps often suffer from tangled dependencies, hard-to-test wiring, and boilerplate from manual registrations. The Factory skill provides a container-based, compile-time-safe dependency injection system that simplifies registration, resolution, and testing for Swift and SwiftUI projects.

Core Features & Use Cases

  • Type-safe factories and containers that avoid runtime registration boilerplate
  • Support for standard and parameterized factories, scopes, contexts, and auto-registering
  • Cross-module wiring and testing integrations (FactoryKit, FactoryTesting)

Quick Start

Register a simple service in a Container extension and resolve it to observe a type-safe dependency being provided.

Frequently Asked Questions about factory

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage dependency injection in SwiftUI without runtime registration boilerplate?

Container-based dependency injection in Swift eliminates runtime boilerplate by using type-safe factories that resolve dependencies at compile time. You register services in a Container extension and resolve them to observe type-safe wiring without manual setup.

What is the best way to resolve parameterized dependencies in a Swift application?

Parameterized dependencies in Swift are resolved using ParameterFactory<P,T>, which allows you to pass arguments directly to the factory. This approach maintains compile-time safety while providing flexible dependency construction for your Swift apps.

Does compile-time safe dependency injection work with cross-module wiring in Swift?

Compile-time safe dependency injection supports cross-module wiring in Swift through container extensions and contexts. Modules expose their dependencies via factory registrations, allowing seamless integration and modular architecture across different Swift and SwiftUI components.

How do I test dependencies in a Swift app using container-based injection?

Testing dependencies in a container-based Swift app is handled through FactoryTesting integrations. You can override factory registrations within a test context to inject mock services, ensuring your Swift and SwiftUI components are fully testable without altering production wiring.

When should I use auto-registering containers for Swift dependency injection?

Auto-registering containers are used for Swift dependency injection when you want to minimize manual registration code. They automatically resolve and register dependencies at startup, reducing boilerplate while maintaining compile-time safety for your application's wiring.