cqrs-cor
БесплатноБез исполняемых скриптовНе проверенRoutes one python-cqrs request through handlers until one returns. Use when several independent decisions exist and exactly one should handle it.
от vadikko2314 установок в других каталогахОб этом скилле
Chain of responsibility
Read cqrs-setup before writing a chain. Use a chain when one request has several alternative strategies and exactly one of them should handle it. The first handler that applies returns the result.
The package is already installed. Do not add an install step.
Put the request in app/commands.py and the handlers in app/handlers.py. The ordered bind stays in app/bootstrap.py. Do not add a directory for the chain.
Steps
- Declare one
cqrs.Request[Result]. Every handler in the chain sees that same request and returns that same result type. - Each step subclasses
cqrs.handlers.CORRequestHandler[ThatRequest]. Do not annotatehandlewith-> Result. - A handler that does not apply returns
await self.next(request). A handler that applies returns the result and does not callnext. - The last handler is the default.
It returns a result and does not call
next. - Register once:
mapper.bind(RequestType, [First, Second, Default]). That list is the one handler for the request type. A secondbindof the same request raisesKeyError. - Build the ordinary
cqrs.bootstrap.requests.bootstraponce. The caller usesawait mediator.send(request). There is no stream and no saga in this path.
build_chain assembles a chain in a test without the mediator. Application startup uses bind.
What the list means
Order is the order of the list. The first handler whose condition matches returns. Handlers after it do not run. Put the narrow strategies first and the default last.
A handler that forgets return await self.next(request) and also returns nothing stops the chain with None. That is not a skip. Either return the result or pass the request on.
The list is still one registration. commands_mapper and queries_mapper both fill one RequestMap. Binding the same request from both raises KeyError.
Skip this skill when every step must run, or when the handler itself is the only decision. cqrs-setup already says that. This file only builds the chain.
A payment method, a file type, or a tenant policy is the usual split. The condition is a field on the request. The handler does not choose by reading a global. Exactly one handler returns. The others must call next.
Do not reorder the list to "run the important step last" unless that step is the default. Earlier handlers never see a request the default already answered, because the default is last.
How to test
Assert the step whose handle ran with invocations.assert_entered. Assert the step it did not call with assert_not_entered. There is no separate chain bus. Detail is cqrs-testing.
Do not
- Use a chain when every step must run. That is one handler, or a command plus domain events. See
cqrs-eda. - Use a chain of one handler. Bind that handler alone.
- Use a chain for logging or metrics. Those are
cqrs.middlewares.Middlewareon bootstrap. - Treat HTTP CORS as this feature. A browser preflight is not a
CORRequestHandler. - Call the mediator from inside
handle. - Add a
Commandbase or aCommandBus. The request is stillcqrs.Request.
The chain stops at the first result. Later handlers do not see a request that an earlier handler already answered.
Short shape: assets/payment_chain.py.
Full example: examples/cor/typed_cor_request_handler.py.
Установить cqrs-cor в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл cqrs-cor?
Routes one python-cqrs request through handlers until one returns. Use when several independent decisions exist and exactly one should handle it.
Как установить скилл cqrs-cor?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cqrs-cor запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic