resolve-context
Provides safe extraction methods for resolving dependencies within Rust closures and Axum extractors.
Install
mkdir -p .claude/skills/resolve-context && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14425" && unzip -o skill.zip -d .claude/skills/resolve-context && rm skill.zipInstalls to .claude/skills/resolve-context
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Uses ResolveContext to extract services inside factory closures or custom extractors. Use when needing to resolve types inside DynProvider::with_ctx or Axum FromRequestParts implementations.Key capabilities
- →Extract services using `ctx.extract::<T>()`
- →Resolve external types with `ctx.resolve_external::<T>()`
- →Use `FactoryCtx` within `DynProvider::with_ctx`
- →Implement custom Axum extractors with `ResolveContext`
- →Access `ResolveContext` from `InjectableState`
- →Ensure scope-safe operations for service resolution
How it works
The skill guides the use of `ResolveContext` to safely extract services and resolve types within factory closures or custom extractors. It ensures scope-safe operations by going through the `Extract` machinery.
Inputs & outputs
When to use resolve-context
- →Resolving database connections in Axum
- →Extracting app config in factory closures
- →Managing dependency injection in Rust
About this skill
ResolveContext
ResolveContext is the framework's resolution engine. Direct user access is
restricted to scope-safe operations.
Safe API
// ctx.extract::<T>() — scope-safe, goes through Extract machinery
let cfg: Inject<AppConfig> = ctx.extract().await?;
let db: Arc<Database> = ctx.extract().await?;
let opt: Option<Inject<Cache>> = ctx.extract().await?;
// ctx.resolve_external::<T>() — for DynProvider-registered types
let pool: sqlx::SqlitePool = ctx.resolve_external().await?;
In DynProvider::with_ctx (use FactoryCtx)
DynProvider::with_ctx(|ctx| async move {
// ctx is FactoryCtx — exposes extract() and resolve_external()
let cfg: Inject<AppConfig> = ctx.extract().await?;
let pool: sqlx::SqlitePool = ctx.resolve_external().await?;
Ok(MyService::new(cfg, pool))
})
In custom Axum extractors
use axum::{async_trait, extract::FromRequestParts, http::request::Parts};
use injectable::axum::InjectableState;
struct AuthUser { email: String }
#[async_trait]
impl FromRequestParts<AppState> for AuthUser {
type Rejection = StatusCode;
async fn from_request_parts(parts: &mut Parts, state: &AppState) -> Result<Self, StatusCode> {
let ctx = state.resolve_context();
let auth: Inject<AuthService> = Inject::extract(ctx)
.await.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
let api_key = parts.headers.get("x-api-key")
.and_then(|v| v.to_str().ok())
.ok_or(StatusCode::UNAUTHORIZED)?;
auth.validate(api_key).await
.map(|email| AuthUser { email })
.ok_or(StatusCode::UNAUTHORIZED)
}
}
What is intentionally private
ctx.resolve::<T>() and ctx.resolve_singleton_arc::<T>() are pub(crate).
They bypass the singleton cache and can violate scope semantics. Use ctx.extract()
instead — it goes through the full Extract machinery and respects all scopes.
When not to use it
- →When directly using `ctx.resolve::<T>()` or `ctx.resolve_singleton_arc::<T>()`
- →When bypassing the singleton cache
- →When violating scope semantics
Limitations
- →`ctx.resolve::<T>()` and `ctx.resolve_singleton_arc::<T>()` are `pub(crate)`.
- →They bypass the singleton cache and can violate scope semantics.
- →Use `ctx.extract()` instead , it goes through the full Extract machinery and respects all scopes.
How it compares
This skill provides a structured and safe way to manage dependency injection and service resolution in Rust frameworks, differing from direct, potentially unsafe, resolution methods.
Compared to similar skills
resolve-context side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| resolve-context (this skill) | 0 | 3mo | No flags | Advanced |
| tauri | 76 | 1mo | Review | Advanced |
| arm-cortex-expert | 29 | 4mo | No flags | Advanced |
| blockchain-developer | 6 | 4mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
tauri
EpicenterHQ
Tauri path handling, cross-platform file operations, and API usage. Use when working with file paths in Tauri frontend code, accessing filesystem APIs, or handling platform differences in desktop apps.
arm-cortex-expert
sickn33
Senior embedded software engineer specializing in firmware and driver development for ARM Cortex-M microcontrollers (Teensy, STM32, nRF52, SAMD). Decades of experience writing reliable, optimized, and maintainable embedded code with deep expertise in memory barriers, DMA/cache coherency, interrupt-driven I/O, and peripheral drivers.
blockchain-developer
sickn33
Build production-ready Web3 applications, smart contracts, and decentralized systems. Implements DeFi protocols, NFT platforms, DAOs, and enterprise blockchain integrations. Use PROACTIVELY for smart contracts, Web3 apps, DeFi protocols, or blockchain infrastructure.
rust-async-patterns
wshobson
Master Rust async programming with Tokio, async traits, error handling, and concurrent patterns. Use when building async Rust applications, implementing concurrent systems, or debugging async code.
rust-errors
EpicenterHQ
Rust to TypeScript error handling patterns for Tauri apps. Use when defining Rust errors that will be passed to TypeScript, handling Tauri command errors, or creating discriminated union error types.
domain-web
actionbook
Use when building web services. Keywords: web server, HTTP, REST API, GraphQL, WebSocket, axum, actix, warp, rocket, tower, hyper, reqwest, middleware, router, handler, extractor, state management, authentication, authorization, JWT, session, cookie, CORS, rate limiting, web 开发, HTTP 服务, API 设计, 中间件, 路由