/implicits:implicits-usage-guidefrom implicits
Guides usage of the Swift Implicits library for implicit parameter passing through call stacks, eliminating parameter drilling. Covers type-based and named keys, nested scopes, closures with #withImplicits, factory pattern, and stored properties.
Ships in implicits. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Implicits is a Swift library for implicit parameter passing through call stacks — eliminates "parameter drilling" (passing the same arguments through many function layers). Similar in spirit to implicit parameters in Scala or context receivers in Kotlin.
func start() {
let scope = ImplicitScope()
defer { scope.end() }
@Implicit var network = NetworkService() // declare
process(scope)
}
func process(_ scope: ImplicitScope) { fetch(scope) }
func fetch(_ scope: ImplicitScope) {
@Implicit() var network: NetworkService // retrieve
network.request()
}
Rules:
ImplicitScope — last argument, no parameter labeldefer { scope.end() } after creating a scope@Implicit var x = value (with initializer)@Implicit() var x: Type (no initializer, explicit type)Type-based (default) — the type itself is the key:
@Implicit() var network: NetworkService
Named keys — use when type alone doesn't explain meaning:
extension ImplicitsKeys {
static let guestMode = Key<Bool>()
}
@Implicit(\.guestMode) var guest = true // declare
@Implicit(\.guestMode) var isGuest: Bool // retrieve
Child scope inherits parent values, can override or add new (retrieval picks nearest):
func inner(_ outer: ImplicitScope) async {
let scope = outer.nested()
defer { scope.end() }
@Implicit var extra = ExtraService()
await extra.doWork(scope)
}
Async code is supported.
Closures don't inherit scope automatically. Use #withImplicits to capture implicits used in the body:
fetchData(completion: #withImplicits { result, scope in
@Implicit() var handler: ResultHandler
handler.process(result)
})
Effects (async/throws) are inferred. @MainActor is preserved on the result; other global actors aren't — use named wrappers for those.
#withImplicits takes an isolation: parameter: .mainActor selects the @MainActor variant explicitly when the compiler or the analyzer can't choose it.
For full details on #withImplicits, named wrappers, capture lists, and #implicits, see docs/closures.md in the Implicits repo.
Store context for later use:
class Component {
let implicits = #implicits
init(_ scope: ImplicitScope) {}
func createChild() -> Child {
withScope(with: implicits) { scope in
Child(scope)
}
}
}
@Implicit works as a stored property — the type needs a scope in its initializer:
struct View {
@Implicit() var theme: Theme
init(_ scope: ImplicitScope) {}
}
withScope AlternativewithScope handles scope lifecycle when indentation isn't a problem and the body is small:
withScope { scope in ... } // root scope
withScope(with: implicits) { scope in ... } // from captured implicits
withScope(nesting: outer) { scope in ... } // nested scope
Add the plugin to Package.swift:
.target(
name: "MyApp",
dependencies: [.product(name: "Implicits", package: "implicits")],
plugins: [.plugin(name: "ImplicitsAnalysisPlugin", package: "implicits")]
)
Plugin graph rule: Every module on the path from your code to the Implicits library must have the plugin. Example: if App → FeatureA → FeatureB → Implicits and FeatureB uses implicits, then FeatureB and FeatureA both need the plugin (App too if it uses implicits).
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub yandex/implicits --plugin implicitsOther plugins' skills for the same job