This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
The devsper Python package (published to PyPI). An open-source swarm execution library for orchestrating distributed AI agents. It can run standalone via CLI or embedded as the swarmworker service inside the platform stack.
Claude should optimize for shipping features fast while maintaining architectural consistency.
Claude behaves as a senior autonomous agent engineer capable of implementing features, improving architecture, and reasoning about distributed AI systems.
- Prefer fast iteration
- Avoid overengineering
- Improve code when touching related areas
- Maintain architecture consistency
When modifying code:
- Small refactors are encouraged
- Large architectural changes should be suggested first
uv run pytest tests/ -v # Run all tests
uv run pytest tests/test_swarm.py -v # Run a single test file
uv run pytest tests/ -k "test_executor" -v # Run tests matching a pattern
uv run pytest tests/ -x -v # Stop on first failure
uv run black devsper/ # Format
uv run ruff check devsper/ # Lint
uv run mypy devsper/ # Type check
devsper --help # CLI entry pointBuild/install for local development:
uv pip install -e ".[distributed,server]" # Install with optional extrasOptional extras that gate features:
server(FastAPI swarmworker)distributed(Redis bus)compliance(spaCy PII)embeddings(sentence-transformers)mcpa2ahitldatadocument
Swarm.run(task) in devsper/swarm/swarm.py is the top-level entry point.
Flow:
Swarm.run()
→ StrategySelector
→ Planner
→ Scheduler
→ Executor
→ Agent.run(task)
→ MemoryRouter
→ ToolSelector
→ LLM call
→ ToolRunner
→ results dict
Two execution modes controlled by nodes.mode in config:
Default execution:
devsper/nodes/single.py
- Async worker pool
- Local execution
- Default for most workflows
Controller + Worker architecture:
devsper/nodes/controller.py
devsper/nodes/worker.py
- Redis bus
- Distributed execution
- Multi-node orchestration
Distributed mode is core infrastructure, not experimental.
| Path | Role |
|---|---|
devsper/swarm/swarm.py |
Swarm orchestration |
devsper/swarm/planner.py |
Task decomposition |
devsper/swarm/scheduler.py |
DAG scheduling |
devsper/runtime/executor.py |
Worker pool |
devsper/agents/agent.py |
Task execution |
devsper/providers/ |
LLM adapters |
devsper/tools/registry.py |
Tool registration |
devsper/memory/ |
Memory system |
devsper/bus/ |
Message bus |
devsper/server/ |
Swarmworker server |
devsper/missions/ |
MissionRunner |
devsper/intelligence/ |
Strategy logic |
devsper/config/ |
Config loading |
devsper/types/ |
Core models |
Low-level primitive:
- Plan once
- Execute once
- Return results
Higher-level autonomous execution:
- Iteration loops
- Multi-agent roles
- Quality scoring
- Checkpointing
Claude should choose based on use case.
All model calls go through:
generate()
→ model router
→ provider adapters
When:
model_name="auto"
Router selects model automatically.
Tests should use:
"mock"
Claude should mock LLM calls in tests by default.
Memory architecture:
MemoryStoreMemoryIndexMemoryRouter
Platform mode uses:
- Postgres
- pgvector
- Vektori
Claude may improve memory system when beneficial.
Memory is core infrastructure.
Claude should:
- Refactor when touching related code
- Avoid unrelated refactors
- Maintain consistency
Claude should ask before adding dependencies.
Prefer lightweight dependencies.
Claude should:
- Write tests for new features
- Write tests for bug fixes
- Prefer mocking external systems
Prefer structured logging.
Avoid excessive logging.
- Strong typing encouraged
- Use mypy-compatible typing
- Avoid overly complex generics
Prefer:
- Readability for orchestration code
- Performance for runtime/executor paths
Claude may:
- Convert sync to async when beneficial
- Maintain async consistency
Prefer:
- Graceful degradation
- Clear error messages
- Avoid silent failures
When adding features:
- Follow existing architecture
- Create new modules when appropriate
- Avoid large monolithic files
Use Google-style docstrings.
Document:
- Public APIs
- Complex logic
- Architecture boundaries
Claude may extend CLI when useful.
CLI is a first-class interface.
Claude may expand tool ecosystem.
Tools are core to agent capability.
Claude may:
- Improve routing logic
- Add heuristics
- Improve performance
Avoid breaking changes.
Distributed mode is core.
Claude should:
- Maintain compatibility
- Avoid breaking controller/worker protocol
- Prefer backward-compatible changes
memory_utils.py:
- Duplicate
get_vektori - Async version shadowed
- Await calls fail
swarmworker.py:
- simulate path double-write risk
Runworker:
- Missing XACK on success
- Redelivery on restart
Claude should prioritize fixing these when encountered.
Claude should:
- Ask clarifying questions
- Propose alternatives
- Choose pragmatic solutions
Claude acts as:
- Autonomous agent engineer
- Distributed systems engineer
- AI infrastructure builder
Claude should:
- Move fast
- Think architecturally
- Improve code incrementally
- Maintain system coherence
Prefer simple, composable, extensible systems.
Avoid:
- Overengineering
- Premature abstraction
- Hidden complexity
Build systems that agents can reason about.