Thank you for your interest in contributing to Claw Codex! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Development Setup
- Project Structure
- Coding Standards
- Commit Guidelines
- Pull Request Process
- Testing
This project follows the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
- Python 3.10 or higher (3.11 recommended for local development)
uv(recommended) orpip- git
- A valid API key from at least one provider (Anthropic, OpenAI, or GLM)
- Fork and clone the repository
# Fork the repo on GitHub, then:
git clone https://github.com/YOUR_USERNAME/clawcodex.git
cd clawcodex- Create a virtual environment
uv venv --python 3.11
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies
uv pip install -r requirements.txt
uv pip install -e ".[dev]"- Install development tools
uv pip install black isort mypy pytest- Configure your API key
python -m src.cli login
# or use environment variables such as GLM_API_KEY / OPENAI_API_KEY / ANTHROPIC_API_KEY- Run tests to verify setup
python -m pytest tests/ -qclawcodex/
├── src/ # Source code
│ ├── providers/ # LLM provider implementations
│ ├── repl/ # Interactive REPL
│ ├── agent/ # Session management
│ ├── skills/ # SKILL.md loading and creation
│ ├── tool_system/ # Tool registry, loop, validation
│ ├── config.py # Configuration management
│ └── cli.py # CLI commands
├── tests/ # Test files
├── .github/ # GitHub workflows and templates
├── requirements.txt # Python dependencies
├── pyproject.toml # Project metadata
└── README.md # Project overview
-
src/providers/: LLM provider implementationsbase.py: Abstract base class for providersanthropic_provider.py: Anthropic/Claude integrationopenai_provider.py: OpenAI/GPT integrationglm_provider.py: GLM/Zhipu AI integration
-
src/repl/: Interactive REPL implementationcore.py: Main REPL logic
-
src/agent/: Session and conversation managementsession.py: Session persistenceconversation.py: Message history
-
src/config.py: Configuration management- Load/save configuration
- API key management
- Provider settings
-
src/cli.py: CLI command implementations
We follow PEP 8 with a few modifications:
- Line length: 88 characters (Black default)
- Quotes: Double quotes for strings, single quotes for dict keys
- Imports: Sorted with isort
All public functions must have type hints.
# Good
def get_provider_config(provider: str) -> dict[str, Any]:
"""Get configuration for a specific provider."""
pass
# Bad
def get_provider_config(provider):
passUse Google-style docstrings for all public functions and classes:
def calculate_cost(tokens: int, model: str) -> float:
"""Calculate the cost for a given number of tokens.
Args:
tokens: Number of tokens used.
model: Model name to determine pricing.
Returns:
Total cost in USD.
Raises:
ValueError: If model is not recognized.
"""
passWe use Black for code formatting and isort for import sorting:
# Format code
black src/ tests/
# Sort imports
isort src/ tests/
# Or both at once
black src/ tests/ && isort src/ tests/We use mypy for static type checking:
mypy src/Aim for zero mypy errors in new code.
We follow Conventional Commits:
<type>(<scope>): <subject>
<body>
<footer>
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
feat(repl): add tab completion support
fix(provider): handle API rate limiting correctly
docs(readme): update installation instructions
test(config): add tests for API key encoding- Use imperative mood ("add feature" not "added feature")
- Keep the first line under 72 characters
- Reference issues and PRs in the footer
- Write clear, descriptive commit messages
- Create a feature branch
git checkout -b feature/your-feature-name- Make your changes
- Write clean, well-documented code
- Add tests for new functionality
- Ensure all tests pass
- Run quality checks
# Format code
black src/ tests/
isort src/ tests/
# Type check
mypy src/
# Run tests
python -m pytest tests/ -q
# Test your changes manually
python -m src.cli- Commit your changes
git add .
git commit -m "feat: your feature description"- Push to your fork
git push origin feature/your-feature-name- Go to GitHub and create a Pull Request
- Fill in the PR template
- Link any related issues
- Request review from maintainers
- All tests must pass
- Code must be formatted with Black and isort
- No mypy errors
- New code must have type hints and docstrings
- New features must have tests
- Documentation must be updated (if applicable)
- At least one maintainer must approve
- All CI checks must pass
- No merge conflicts
- PR will be squashed and merged
# Run all tests
python -m pytest tests/ -q
# Run specific test file
python -m pytest tests/test_tool_system_tools.py -q
# Run with coverage
python -m pytest tests/ --cov=src --cov-report=htmlWe use pytest for testing:
import pytest
from src.config import load_config, save_config
def test_load_config_default():
"""Test that load_config returns a valid config."""
config = load_config()
assert "providers" in config
assert "default_provider" in config
def test_save_and_load_config(tmp_path):
"""Test config persistence."""
config = {
"default_provider": "glm",
"providers": {
"glm": {
"api_key": "test_key",
"base_url": "https://example.com",
"default_model": "glm-4"
}
}
}
save_config(config)
loaded = load_config()
assert loaded["default_provider"] == "glm"- Test file naming:
test_<module>.py - Test function naming:
test_<description> - One test per concern: Keep tests focused
- Use fixtures: For common setup
- Test edge cases: Not just happy paths
- Make tests independent: No test should depend on another
If you have questions, feel free to:
- Open an issue on GitHub
- Start a discussion in the Discussions tab
- Reach out to maintainers
Thank you for contributing to Claw Codex!