From litestar
Discovers Litestar controllers, event listeners, and tasks from domain packages automatically, reducing manual router wiring for projects with stable package conventions.
How this skill is triggered — by the user, by Claude, or both
Slash command
/litestar:litestar-autowireThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
`litestar-autowire` 0.2.0 discovers Litestar controllers and event listeners
litestar-autowire 0.2.0 discovers Litestar controllers and event listeners
from domain packages. It can also load optional integration modules without
turning application setup into a central list of every domain component.
Use Autowire when the project already groups features into stable Python
packages. Keep manual Router and plugin composition when the app is small,
route registration is intentionally explicit, or packages do not follow a
consistent convention.
domain_packages; never use the removed
packages name.litestar_autowire.integrations, never the rejected extensions compatibility argument.clear_autowire_cache() when tests create, replace, or remove modules.pip install litestar-autowire==0.2.0
Install only the integrations already used by the project:
pip install "litestar-autowire[dishka]==0.2.0"
pip install "litestar-autowire[queues]==0.2.0"
my_app/
└── domains/
├── accounts/
│ ├── controllers.py
│ ├── events.py
│ └── jobs.py
└── billing/
└── routes.py
Regular packages and PEP 420 namespace packages are supported. Autowire checks the configured root and each direct child package. Read Discovery before changing module conventions or debugging a missing component.
from litestar import Litestar
from litestar_autowire import AutowireConfig, AutowirePlugin
autowire = AutowirePlugin(
AutowireConfig(domain_packages=["my_app.domains"]),
)
app = Litestar(plugins=[autowire])
The default component modules are:
| Component | Module names | Enabled |
|---|---|---|
| Controllers | controllers, routes, controller, route | Yes |
| Event listeners | events, listeners | Yes |
| Litestar Queues tasks | jobs | Only with integrations=["queues"] |
Customize module names without changing the domain layout:
config = AutowireConfig(
domain_packages=["my_app.domains"],
controller_modules=["http"],
listener_modules=["subscribers"],
discover_listeners=False,
)
By default, discovered controller classes are appended directly to
AppConfig.route_handlers. Set router_class=Router when the project needs a
wrapper for router-level before_request or after_response hooks:
from litestar import Router
from litestar_autowire import AutowireConfig
config = AutowireConfig(
domain_packages=["my_app.domains"],
router_class=Router,
before_request=set_request_context,
after_response=record_response,
)
The wrapper is constructed with path="/", the discovered controller classes,
and the configured hooks. Use integrations=["dishka"] instead when the
project already uses Dishka and needs DishkaRouter. See
Integrations.
AutowirePlugin(AutowireConfig(...)) in the app plugin list.Controller subclasses and EventListener objects.queues integration
must be selected and its optional dependency installed.router_class and expect Dishka to replace it.
DishkaIntegration preserves an already selected router class.dishka or queues. Built-in
name collisions fail during configuration.domain_packages contains importable dotted package roots.AutowireIntegration and use unique names.router_class.clear_autowire_cache() around dynamic module changes.# my_app/domains/accounts/controllers.py
from litestar import Controller, get
class AccountController(Controller):
path = "/accounts"
@get()
async def list_accounts(self) -> list[dict[str, str]]:
return [{"name": "primary"}]
# my_app/app.py
from litestar import Litestar
from litestar_autowire import AutowireConfig, AutowirePlugin
app = Litestar(
plugins=[
AutowirePlugin(
AutowireConfig(
domain_packages=["my_app.domains"],
discover_controllers=True,
discover_listeners=True,
)
)
],
)
Autowire imports my_app.domains.accounts.controllers, registers
AccountController, and checks the configured listener module names. It does
not load jobs.py until the queues integration is selected.
AutowireLoader, router selection, Dishka, and Litestar QueuesGuides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Enforces test-driven development: write failing test first, then minimal code to pass. Use when implementing features or bugfixes.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
npx claudepluginhub litestar-org/litestar-skills --plugin litestar