This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
The project includes a Makefile with common development tasks. Run make help to see all available commands:
make setup # Install project with all development dependencies
make install # Install project with minimal dependencies
make test # Run all tests
make test-cov # Run tests with coverage report
make system-deps # Install external system dependencies (ffmpeg, etc.)
make check # Run all code checks (format + lint + typecheck)
make format # Format code with black and isort
make lint # Run flake8 linter
make typecheck # Run mypy type checker
make build # Build package
make clean # Clean build artifacts
make publish # Bump version, commit, tag, and push (triggers PyPI release)
make publish-patch # Publish patch version (same day increment)# Install for development (with all optional dependencies)
pip install -e ".[dev,rag,whisper,documents,tables,videos,audio,remote,tasks]"
# Format code
isort .
black .
# Lint and type check
flake8 .
mypy src/litemind
# Run all tests
pytest src/
# Run a single test file
pytest src/litemind/apis/tests/test_openai_api.py
# Run tests matching a pattern
pytest -k "tools" src/
# Run tests with coverage report
pytest --cov=src --cov-report=html:reports/coverage src/
# Build package
hatch clean && hatch buildPublishing is handled via GitHub Actions triggered by git tags. Use the Makefile commands:
# For a new day's release (bumps version to YYYY.M.D format)
make publish
# For same-day patch releases (bumps to YYYY.M.D.N format)
make publish-patchThese commands will:
- Update the version in
src/litemind/__init__.py - Commit the version bump
- Create a git tag (e.g.,
v2026.2.4) - Push to origin with tags
- GitHub Actions then automatically publishes to PyPI via OIDC trusted publishing
# Export repository to single file
litemind export --folder-path . --output-file exported.txt
# Validate model registry against live APIs
litemind validate --api openai gemini --models gpt-4o models/gemini-1.5-pro
# Discover features for unknown models
litemind discover --api openai --models new-model-nameLitemind is a unified API wrapper and agentic AI framework supporting multiple LLM providers (OpenAI, Anthropic, Google Gemini, Ollama).
API Layer (src/litemind/apis/):
BaseApi→DefaultApi→ Provider implementations (OpenAIApi, AnthropicApi, GeminiApi, OllamaApi)CombinedApi: Chains multiple APIs for fallback- Feature-based model selection via
ModelFeaturesenum andget_best_model(features=[...]) - Provider-specific code lives in
providers/<provider>/with standard methods:convert_messages,format_tools,process_response
Agent Layer (src/litemind/agent/):
Agent: Main orchestrator managing conversation state, tool execution, and augmentationsConversation: Manages system and user messagesMessage/MessageBlock: Multimodal message containersToolSet: Collection of tools (FunctionTool, AgentTool, BuiltinTool)AugmentationSet: RAG augmentations including vector databases
Media Layer (src/litemind/media/):
MediaBasesubclasses:Text,Code,Json,Image,Audio,Video,Table,Document,NdImageMediaConverter: Automatic format conversion pipeline for model compatibility- Conversion utilities in
media/conversion/
Augmentations (src/litemind/agent/augmentations/):
BaseVectorDB→InMemoryVectorDatabase,QdrantVectorDatabaseInformation: Knowledge units with metadata for RAG
- Abstract base classes define interfaces (
BaseApi,BaseTool,AugmentationBase,MediaBase) - Callback system throughout (
ApiCallbackManager,ToolCallbackManager) - Feature matrices describe model capabilities for intelligent selection
- Tests mirror source structure (e.g.,
apis/tests/,agent/tests/,media/tests/)
Model feature data is curated in YAML files (src/litemind/apis/model_registry/*.yaml) rather than auto-discovered via live API calls. This design decision was made because:
- Auto-discovery (the old scanner approach) produced false negatives and brittle tests
- Curated YAML provides accurate feature data, token limits, aliases, and metadata
- Each provider has a registry file:
registry_openai.yaml,registry_anthropic.yaml,registry_gemini.yaml,registry_ollama.yaml - Use
ModelRegistry.supports_feature(),get_model_info(), andresolve_alias()for feature lookups - The
litemind validateCLI can validate registry accuracy against live APIs when needed
User Message → Agent → Augmentation retrieval → Message formatting →
API call → Tool execution (if needed) → Response → Conversation history
OPENAI_API_KEY- OpenAI APIANTHROPIC_API_KEY- Anthropic/Claude APIGOOGLE_GEMINI_API_KEY- Google Gemini API- Ollama: No key required (local server)
- Use Black for formatting, isort for imports
- Numpy-style docstrings
- Type hints throughout
- Conventional commits:
feat:,fix:,docs:,refactor:,test:,chore:
- Always guard bug fixes with unit tests. When fixing a bug, add a regression test that would have caught the bug. Place tests in the corresponding
tests/directory next to the source (e.g.,media/tests/,agent/tests/). Useunittest.mockfor unit tests that would otherwise require live API calls.
IMPORTANT: Always use hatch to run tests, Python commands, and other development tasks.
The system Python environment is externally managed and pip cannot install packages directly. Use hatch for all Python operations:
# Run all tests
hatch test
# Run specific test file
hatch test -- src/litemind/agent/tests/test_agent.py -v
# Run tests matching a pattern
hatch test -- -k "tools" src/
# Run arbitrary Python code
hatch run python -c "from litemind import Agent; print('Works!')"
# Run a Python script
hatch run python myscript.py
# Install additional packages (into hatch environment)
hatch run pip install package-name
# Run linting tools
hatch run pip install flake8 && hatch run flake8 src/Docling compatibility: Docling is an important library for document conversion. It requires pandas>=2.1.4,<3.0.0 and has specific numpy constraints. Do NOT upgrade pandas to 3.x or numpy beyond what docling supports without checking compatibility first.
pytest-md-report: This package doesn't support pytest 9.x yet. It has been removed from the test dependencies until it's updated.
Some converters use lazy loading to avoid import-time dependency conflicts:
document_converter_docling.py- Docling converter is initialized lazily via_get_docling_converter()
This pattern allows the library to work even when optional dependencies aren't installed, while still supporting them when available.
Each major sub-package should have a README.md file explaining its purpose, structure, and usage. Current sub-packages with READMEs:
src/litemind/agent/README.md- Agentic AI framework (Agent, Messages, Tools, Augmentations)src/litemind/apis/README.md- API abstraction layer (providers, model registry, features)src/litemind/media/README.md- Multimodal media types and conversion systemsrc/litemind/utils/README.md- Utility functions (file handling, embeddings, etc.)src/litemind/tools/README.md- CLI commands (export, validate)src/litemind/workflow/README.md- Task workflow systemsrc/litemind/remote/README.md- Remote agent execution via RPyC
Each sub-package README should include:
- Package Structure - Directory tree showing key files
- Core Components - Classes and functions with brief descriptions
- Usage Examples - Code snippets demonstrating common patterns
- Docstring Coverage - Summary table of documentation completeness
- Dependencies - External libraries required (if applicable)
When updating the main README.md, use Claude Code directly. The README should follow this structure:
- Summary - Enthusiastic and complete description of the library, its purpose, and philosophy
- Features - List of main features including unique or standout capabilities
- Installation - How to install litemind
- Basic Usage - Several illustrative examples of the agent-level API (with multimodal inputs):
- Basic agent usage
- Agent with tools
- Agent with tools and augmentation (RAG)
- Complex example with multimodal inputs, tools and augmentations
- Concepts - Main classes, their purpose, and interactions. Explain the difference between the API wrapper layer versus the agentic API
- Multi-modality - Multimodal capabilities, ModelFeatures, how to request features, Media classes
- More Examples - Advanced use cases:
- CombinedAPI usage
- Agent that can execute Python code
- Wrapper API for structured outputs
- Agent with tool that generates images
- Command Line Tools - CLI tools with example command lines
- Caveats and Limitations - Known issues or areas for improvement
- Code Health - Unit test results from
test_report.md(total tests, passed, failed, assessment) - API Keys - How to obtain and configure API keys for each provider (OpenAI, Claude, Gemini). Which environment variables to set for each OS
- Roadmap - Use contents of TODO.md as starting point
- Contributing - Refer to CONTRIBUTING.md
- License
When writing code examples in the README:
- Use markdown code blocks
- Keep different examples in separate code blocks with text preambles
- Examples must be complete and runnable as-is
- Include all required imports
- Include expected output as comments where possible
- Make examples didactic, well-commented, and easy to understand
- Follow PEP-8 formatting
- Code examples using specific features must request models that have those features
- Use real URLs of files that exist (e.g., from the tests)
- Show that ModelFeatures can be provided as strings instead of enums (see normalisation code)
- Add badges for: PyPI, license, pepy.tech stats, GitHub stars
- The Pepy.tech badge image:
https://static.pepy.tech/badge/litemind - Explain that logging uses Arbol (http://github.com/royerlab/arbol) and can be deactivated with
Arbol.passthrough = True - Avoid hallucinating - Only document features that exist in the repository
- Litemind does NOT have a
ReActAgentclass or anything 'react' related - theAgentclass itself has all ReAct framework features - If unsure about something, don't make it up