dishka
Use when editing Dishka dependency injection code, Provider, Scope, Container, FromDishka, Inject, DI scopes, providers, testing containers, or Litestar/FastAPI Dishka integrations.
Best use case
dishka is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Use when editing Dishka dependency injection code, Provider, Scope, Container, FromDishka, Inject, DI scopes, providers, testing containers, or Litestar/FastAPI Dishka integrations.
Teams using dishka should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/dishka/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How dishka Compares
| Feature / Agent | dishka | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Use when editing Dishka dependency injection code, Provider, Scope, Container, FromDishka, Inject, DI scopes, providers, testing containers, or Litestar/FastAPI Dishka integrations.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Dishka Dependency Injection Skill
## Overview
Dishka is a Python dependency injection framework built around Providers, Scopes, and typed containers. It supports async/sync workflows and integrates with web frameworks (Litestar, FastAPI) and CLI tools (Click).
---
<workflow>
## References Index
For detailed guides and configuration examples, refer to the following documents in `references/`:
- **[Providers, Scopes & Factory Functions](references/providers.md)**
- Core concepts, scope hierarchy, container creation, provider patterns, clean naming, and best practices.
- **[Litestar Integration](references/litestar.md)**
- Setup, controller injection, router integration, and manual resolution from connection.
- **[FastAPI Integration](references/fastapi.md)**
- Setup and route-level injection with FromDishka.
- **[CLI Integration](references/cli.md)**
- Click with async_inject decorator for Dishka-powered CLI commands.
- **[Testing Patterns](references/testing.md)**
- Test containers, mock providers, and override strategies.
</workflow>
<example>
## Example: Provider and Container Setup
```python
from dishka import Provider, Scope, make_async_container, provide
class AppProvider(Provider):
scope = Scope.APP
@provide
async def get_db_engine(self) -> AsyncEngine:
return create_async_engine("postgresql+asyncpg://...")
class RequestProvider(Provider):
scope = Scope.REQUEST
@provide
async def get_session(self, engine: AsyncEngine) -> AsyncSession:
return AsyncSession(engine)
container = make_async_container(AppProvider(), RequestProvider())
```
</example>
---
## Official References
- <https://dishka.readthedocs.io/en/stable/>
- <https://dishka.readthedocs.io/en/stable/integrations/litestar.html>
- <https://dishka.readthedocs.io/en/stable/integrations/fastapi.html>
- <https://dishka.readthedocs.io/en/stable/integrations/click.html>
- <https://github.com/reagento/dishka/releases>
- <https://pypi.org/project/dishka/>
## Shared Styleguide Baseline
- Use shared styleguides for generic language/framework rules to reduce duplication in this skill.
- [General Principles](https://github.com/cofin/flow/blob/main/templates/styleguides/general.md)
- [Dishka](https://github.com/cofin/flow/blob/main/templates/styleguides/frameworks/dishka.md)
- [Python](https://github.com/cofin/flow/blob/main/templates/styleguides/languages/python.md)
- Keep this skill focused on tool-specific workflows, edge cases, and integration details.
<guardrails>
## Guardrails
- **Explicitly manage Scopes (APP, REQUEST)** -- Always use the appropriate scope to avoid resource leaks or unnecessary object creation. Objects in `Scope.APP` live as long as the container; `Scope.REQUEST` lives only for the duration of a request.
- **Avoid global container access** -- Always use dependency injection to provide dependencies; never resolve objects from a global container instance in application logic.
- **Ensure Providers are stateless** -- Providers should only contain factory methods; any state should be managed within the injected objects themselves.
- **Check scope hierarchy** -- Objects in a wider scope (APP) cannot depend on objects in a narrower scope (REQUEST).
- **Use typed providers** -- Always use type hints for provider return values to ensure the container can correctly resolve and validate dependencies.
</guardrails>
<validation>
## Validation Checkpoint
- [ ] Providers are assigned the correct `Scope` (APP, REQUEST)
- [ ] No objects are resolved manually from a global container
- [ ] All factory methods in providers are correctly annotated with `@provide`
- [ ] Scope hierarchy is valid (no narrow-to-wide scope dependencies)
- [ ] Provider return types match the types expected by the consumers
- [ ] Async/sync providers are used consistently with the target framework
</validation>Related Skills
flow-memory-keeper
Use at task, phase, flow, sync, archive, finish, revise, or failure checkpoints to keep Flow specs clean, capture learnings and failures, elevate durable patterns, and refine this skill with project-specific nuances
vue
Use when editing Vue projects, .vue files, vue.config.js, Vue 3 components, Composition API, <script setup>, SFC state, deployment workflows, or Vue CI configuration.
vite
Use when editing Vite projects, vite.config.ts, vite.config.js, Vite plugins, HMR, asset bundling, frontend build settings, deployment config, or Litestar/Vite integration.
uvicorn
Use when deploying ASGI apps with uvicorn, editing uvicorn CLI commands, Config or Server usage, workers, reload, event loop selection, SSL, lifespan, logging, or development server behavior.
tracer
Use when tracing execution paths, mapping dependencies, understanding unfamiliar code, following data flow, investigating end-to-end behavior, debugging call chains, or deciding which files to read next.
testing
Use when writing or refactoring tests, editing test_*.py, *.test.ts, *.spec.ts, conftest.py, vitest.config.ts, pytest fixtures, mocks, coverage, async tests, anyio, or test failure debugging.
terraform
Use when creating, adopting, refactoring, or operating Terraform, *.tf files, .terraform.lock.hcl, terragrunt.hcl, root modules, backends, state, workspaces, imports, CI plan/apply, tests, or policy checks.
tanstack
Use when editing TanStack code, @tanstack imports, useQuery, createRouter, React Query, TanStack Router, Table, Form, Store, file-based routing, data fetching, or SPA state management.
tailwind
Use when styling with Tailwind CSS, editing tailwind.config.ts, tailwind.config.js, @tailwind directives, utility classes, responsive layouts, @apply, cn(), @theme config, dark mode, or forms.
svelte
Use when editing Svelte components, .svelte files, svelte.config.js, Svelte 5 runes, $state, $derived, SvelteKit, component state, or migrating away from Svelte 4 patterns.
sqlserver
Use when writing T-SQL, editing SQL Server .sql files, using sqlcmd, SQL Server connection strings, stored procedures, execution plans, indexes, Always On, JSON, security, or connector code.
sqlalchemy
Use when editing SQLAlchemy code, sqlalchemy imports, mapped_column, DeclarativeBase, ORM models, relationships, select() queries, async sessions, engines, events, or migrations.