home / skills / nonameplum / agent-skills / swift-dependencies

swift-dependencies skill

/swift-dependencies

This skill helps you reason about and implement controlled, testable dependencies in Swift apps using a structured environment-inspired approach.

npx playbooks add skill nonameplum/agent-skills --skill swift-dependencies

Review the files below or copy the command above to add this skill to your agents.

Files (26)
SKILL.md
2.4 KB
---
name: swift-dependencies
description: A dependency management library for Swift with controlled, testable dependencies
---

# Dependencies

A dependency management library inspired by SwiftUI's "environment."

## Documentation Structure

### Getting started

- **Quick start** ([Articles/QuickStart.md](Articles/QuickStart.md)): Learn the basics of getting started with the library before diving deep into all of its features.
- **What are dependencies?** ([Articles/WhatAreDependencies.md](Articles/WhatAreDependencies.md)): Learn what dependencies are, how they complicate your code, and why you want to control them.

### Essentials

- **Using dependencies** ([Articles/UsingDependencies.md](Articles/UsingDependencies.md)): Learn how to use the dependencies that are registered with the library.
- **Registering dependencies** ([Articles/RegisteringDependencies.md](Articles/RegisteringDependencies.md)): Learn how to register your own dependencies with the library so that they immediately become
- **Live, preview, and test dependencies** ([Articles/LivePreviewTest.md](Articles/LivePreviewTest.md)): Learn how to provide different implementations of your dependencies for use in the live application,
- **Testing** ([Articles/Testing.md](Articles/Testing.md)): One of the main reasons to control dependencies is to allow for easier testing. Learn some tips and

### Advanced

- **Designing dependencies** ([Articles/DesigningDependencies.md](Articles/DesigningDependencies.md)): Learn techniques on designing your dependencies so that they are most flexible for injecting into
- **Overriding dependencies** ([Articles/OverridingDependencies.md](Articles/OverridingDependencies.md)): Learn how dependencies can be changed at runtime so that certain parts of your application can use
- **Dependency lifetimes** ([Articles/Lifetimes.md](Articles/Lifetimes.md)): Learn about the lifetimes of dependencies, how to prolong the lifetime of a dependency, and how
- **Single entry point systems** ([Articles/SingleEntryPointSystems.md](Articles/SingleEntryPointSystems.md)): Learn about "single entry point" systems, and why they are best suited for this dependencies

### Dependency management


## Usage Notes

- Documentation is organized progressively from getting started to advanced topics
- Start with the Introduction or Getting Started section
- Consult specific guides for detailed information

## License & Attribution

This skill contains content converted from DocC documentation format.

Overview

This skill documents swift-dependencies, a lightweight dependency management library for Swift that makes dependencies explicit, testable, and swappable. It presents progressive guides from quick start to advanced topics, plus a converter for DocC-formatted documentation. The material helps teams design, register, override, and test dependencies in Swift applications.

How this skill works

The documentation explains how to register dependencies into a central container and access them where needed, similar in spirit to SwiftUI’s environment. It shows how to provide multiple implementations (live, preview, test), control dependency lifetimes, and override implementations at runtime or during tests. The content is organized so readers can start with basics and progressively adopt advanced patterns like single-entry-point systems.

When to use it

  • When you want to make side-effecting services explicit and injectable instead of using globals.
  • When you need to swap implementations for previews, tests, or platform-specific behavior.
  • When writing unit or integration tests that require deterministic, stubbed, or mocked dependencies.
  • When structuring an app with a single-entry-point or modular architecture.
  • When you need to manage lifetime and scope of shared services across an app.

Best practices

  • Start with the Quick Start and What Are Dependencies articles to align team understanding.
  • Design dependencies as small, focused protocols or structs to encourage easy swapping and testing.
  • Register live, preview, and test implementations consistently so switching contexts is predictable.
  • Prefer overriding dependencies at well-defined boundaries (e.g., app entry point or test setup) instead of ad-hoc global mutation.
  • Document lifetime expectations for each dependency to avoid unexpected retention or recreation.

Example use cases

  • Injecting a network client and providing a fast in-memory stub for unit tests.
  • Swapping persistence implementations between Core Data, SQLite, or an in-memory store for previews.
  • Providing a deterministic clock or scheduler in tests to simplify timing-related assertions.
  • Overriding analytics or feature-flag services during UI previews to avoid external calls.
  • Using a single-entry-point pattern to compose app modules with explicit dependency wiring.

FAQ

Is this library a full dependency injection framework?

No. It focuses on a simple, testable approach to registering and accessing dependencies with controlled lifetimes rather than a heavy DI container.

How do I test code that uses these dependencies?

Provide test implementations during test setup or use the provided testing guides. The docs show patterns for stubbing, overriding at runtime, and controlling lifetimes to keep tests deterministic.