Reading the repo
Reading the repo
How to install on Linux
Claude-Code-Python: Reconstructing Claude Code in Python
Fresh setup, read just now
Will it work on my device?
CONTRIBUTING.mdThank you for your interest in contributing to Clawd Code! This document provides guidelines and instructions for contributing.
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.
uv (recommended) or pip# Fork the repo on GitHub, then:
git clone https://github.com/YOUR_USERNAME/Clawd-Code.git
cd Clawd-Code
uv venv --python 3.11
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -r requirements.txt
uv pip install -e ".[dev]"
uv pip install black isort mypy pytest
python -m src.cli login
# or use environment variables such as GLM_API_KEY / OPENAI_API_KEY / ANTHROPIC_API_KEY
python -m pytest tests/ -q
Clawd-Code/
├── 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 implementations
base.py: Abstract base class for providersanthropic_provider.py: Anthropic/Claude integrationopenai_provider.py: OpenAI/GPT integrationglm_provider.py: GLM/Zhipu AI integrationsrc/repl/: Interactive REPL implementation
core.py: Main REPL logicsrc/agent/: Session and conversation management
session.py: Session persistenceconversation.py: Message historysrc/config.py: Configuration management
src/cli.py: CLI command implementations
We follow PEP 8 with a few modifications:
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):
pass
Use 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.
"""
pass
We 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 tasksfeat(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
git checkout -b feature/your-feature-name
# 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
git add .
git commit -m "feat: your feature description"
git push origin feature/your-feature-name
# 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=html
We 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_<module>.pytest_<description>If you have questions, feel free to:
Thank you for contributing to Clawd Code!
Then run bash setup.sh. It stops at the first error and is safe to run again. Servers and tests aren't started; it lists them at the end. Read it first.
git clone https://github.com/GPT-AGI/Clawd-Code.git cd Clawd-Code
Python >=3.10
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync
uv run pytest
git clone https://github.com/GPT-AGI/Clawd-Code.git
cd Clawd-Code
# Create venv (uv recommended)
uv venv --python 3.11
source .venv/bin/activate
# Install
uv pip install -r requirements.txt
python -m src.cli login
This flow will:
The configuration file is saved in in ~/.clawd/config.json. Example structure:
{
"default_provider": "glm",
"providers": {
"anthropic": {
"api_key": "base64-encoded-key",
"base_url": "https://api.anthropic.com",
"default_model": "claude-sonnet-4-20250514"
},
"openai": {
"api_key": "base64-encoded-key",
"base_url": "https://api.openai.com/v1",
"default_model": "gpt-4"
},
"glm": {
"api_key": "base64-encoded-key",
"base_url": "https://open.bigmodel.cn/api/paas/v4",
"default_model": "glm-4.5"
}
}
}
python -m src.cli # Start REPL
python -m src.cli --help # Show help
That's it! Start chatting with AI in 3 steps.
No reports for Linux yet.
Opens a chat with this manual already filled in, for Linux. It uses your own account; gitmanual sends nothing.