Skip to content

Add a new-broker skill that scaffolds a fully wired messaging backend - #10

Merged
sovikroy merged 1 commit into
mainfrom
claude/dreamy-maxwell-7w25tx
Nov 4, 2026
Merged

sovikroy merged 1 commit into
mainfrom
claude/dreamy-maxwell-7w25tx

Conversation

@sovikroy

@sovikroy sovikroy commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a new-broker Claude Code skill for adding a messaging transport (NATS, SQS, a custom protocol, ...) to packages/messaging. It works like the existing new-service skill: a script does the wiring, and the developer (or Claude) writes the transport logic, tests and docs. No service code changes.

.claude/skills/new-broker/

  • SKILL.md has the steps:
    1. Check that the transport fits the Broker contract: each message goes to one consumer, in order per topic, and receive stops waiting after the timeout. Includes notes on log-based systems like Kafka, and a rule not to loosen the contract tests.
    2. Run the scaffold.
    3. Implement the backend, following the RabbitMQ and Redis backends (lazy connection, a lock, reconnect once, a pattern for asyncio-only clients).
    4. Add tests, verify, and update the docs.
  • scripts/scaffold.py (standard library only; --dry-run prints a unified diff). In one command it:
    • creates backends/<module>.py (a Broker subclass whose publish/receive are stubs) and tests/test_<module>.py
    • registers the scheme(s) in broker.py (_BACKENDS, _EXTRAS, the docstring's URL list)
    • adds the client extra to packages/messaging and the root dev group, plus an optional mypy override
    • adds the extra to every app that carries broker extras, and to their Dockerfile BROKER_EXTRAS
    • updates compose.yaml: the BROKER_EXTRAS defaults, a server under its own profile, and the x-broker-depends entry; and writes brokers/<name>.env
    • adds a REAL_BROKERS entry, so the contract tests also run against a real server when its URL is set
    • adds to ci.yml: a service container and test URL in the brokers job, and an entry in the compose matrix
    • refuses to run if the scheme, extra, module, compose service or test file name already exists

Small refactors so the script can edit files reliably

  • packages/messaging/tests/conftest.py: the real-server brokers are now a REAL_BROKERS table (same test ids and skips as before).
  • The new-service scaffold reads the broker extras from packages/messaging/pyproject.toml instead of hard-coding redis/rabbitmq, so new services pick up added brokers automatically. Its output is unchanged apart from one example comment.
  • scripts/ci/compose_smoke.sh: the usage message lists brokers/*.env instead of a fixed set.
  • README.md and ARCHITECTURE.md point to the skill.

Test plan

  • uv run ruff check ., ruff format --check ., mypy, pytest (81 passed, 20 skipped), uv lock --check on this branch
  • In a throwaway worktree, ran the scaffold for an example NATS backend (nats-py, nats:2-alpine). Then uv lock, ruff, mypy and the full pytest run all passed. The generated compose.yaml and ci.yml parse correctly, and docker compose --env-file brokers/nats.env config resolves only the NATS profile.
  • With MESSAGING_TEST_NATS_URL set, the contract tests run against the stub and fail as expected until it is implemented. Re-running the scaffold is refused.
  • The new-service scaffold's dry-run output before and after the refactor differs only in the example comment.
  • Not run: a real NATS server. The NATS command in the docs is only an example, and its health check is untested.

Generated by Claude Code

.claude/skills/new-broker/ has a SKILL.md (check that the transport fits the
Broker contract, scaffold, implement, test, verify, update the docs) and a
stdlib-only scaffold.py. In one command it creates the backend module and
its test file, then registers the scheme(s) in broker.py (_BACKENDS,
_EXTRAS, docstring) and adds the client extra to packages/messaging and
the dev group (with an optional mypy override). It also adds the extra to
every app that carries broker extras, plus their Dockerfile BROKER_EXTRAS;
adds the compose BROKER_EXTRAS defaults, a profile-gated server and the
x-broker-depends anchor; writes brokers/<name>.env; adds the REAL_BROKERS
contract-test entry; and adds a CI service container, test URL and
compose-matrix entry. --dry-run prints a diff of every change.

To make those edits reliable:
- tests/conftest.py: the real-server brokers are now a REAL_BROKERS
  table (same test ids and skips as before).
- The new-service scaffold reads the broker extras from
  packages/messaging/pyproject.toml instead of hard-coding redis/rabbitmq.
- compose_smoke.sh's usage lists brokers/*.env instead of a fixed set.

README and ARCHITECTURE point to the skill.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SE2PhJQLSccvNwV1Eoauuj
@sovikroy
sovikroy merged commit 85b7ba3 into main Nov 4, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants