| 中文 | English |
This document provides detailed instructions for setting up the development environment, project structure, and contribution guidelines for developers.
git clone https://github.com/wangfumin1/claude-code-adapter-fastapi.git
cd claude-code-adapter-fastapi
# Using automated setup scripts
# Windows:
scripts\setup.bat
# Linux/macOS:
./scripts/setup.sh
# Or manual setup
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
pip install -r requirements-dev.txt
pre-commit install
claude-code-adapter-fastapi/
├── src/
│ └── claude_code_adapter/
│ ├── __init__.py # Package initialization
│ ├── app.py # FastAPI application main file
│ ├── config.py # Configuration management
│ ├── models.py # Data models
│ ├── services.py # Business logic services
│ └── utils.py # Utility functions
├── tests/ # Test files
│ ├── __init__.py
│ ├── test_app.py # Application tests
│ └── test_utils.py # Utility function tests
├── scripts/ # Script files
│ ├── setup.bat # Windows setup script
│ ├── setup.sh # Linux/macOS setup script
│ ├── check_env.py # Environment check
│ └── start.py # Startup script
├── docs/ # Documentation
├── docker/ # Docker-related files
├── .github/workflows/ # CI/CD configuration
├── config.yaml # Configuration file
├── requirements.txt # Production dependencies
├── requirements-dev.txt # Development dependencies
├── pyproject.toml # Project configuration
├── Makefile # Build scripts
└── README.md # Project description
# Run all tests
make test
# Or use pytest
pytest tests/ -v
# Run specific tests
pytest tests/test_utils.py -v
# Generate coverage report
make test-cov
# tests/test_example.py
import pytest
from src.claude_code_adapter.utils import example_function
def test_example_function():
"""Test example function"""
result = example_function("input")
assert result == "expected_output"
# Format code
make format
# Check formatting
make format-check
# Run all checks
make lint
# Run individually
flake8 src/ tests/
mypy src/
# Using Makefile
make run
# Or run directly
python -m uvicorn src.claude_code_adapter.app:app --host 0.0.0.0 --port 8000 --reload
The development server supports hot reloading, automatically restarting on code changes.
💡 Quick Contribution Guide: See CONTRIBUTING.md for a concise contribution process and guidelines.
Fork the project on GitHub to your account.
git checkout -b feature/your-feature-name
# Write code
# Add tests
# Update documentation
# Run tests and checks
make test
make lint
make format
git add .
git commit -m "feat: add new feature"
git push origin feature/your-feature-name
Create a Pull Request on GitHub.
Follow Conventional Commits standards:
feat: New featurefix: Bug fixdocs: Documentation updatestyle: Code formattingrefactor: Code refactoringtest: Test additionschore: Build process or auxiliary tool changesExamples:
feat: add support for conda environment
fix: resolve encoding issue in setup scripts
docs: update installation guide
docker build -t claude-code-adapter:dev .
docker run -p 8000:8000 -v $(pwd):/app claude-code-adapter:dev
docker-compose up -d
# Install performance profiling tool
pip install py-spy
# Profile performance
py-spy top --pid <process_id>
# Install memory profiling tool
pip install memory-profiler
# Profile memory usage
python -m memory_profiler script.py
import logging
# Set logging level
logging.basicConfig(level=logging.DEBUG)
# Use logger
logger = logging.getLogger(__name__)
logger.debug("Debug message")
# Using pdb
import pdb; pdb.set_trace()
# Or using ipdb
import ipdb; ipdb.set_trace()
# Start documentation server
make docs
# Build documentation
make docs-build
# Check Python path
export PYTHONPATH=$PWD:$PYTHONPATH
# Recreate virtual environment
rm -rf venv
python -m venv venv
pip install -r requirements-dev.txt
# Check test environment
python scripts/check_env.py
Follow Semantic Versioning:
MAJOR: Breaking API changesMINOR: Backward-compatible feature additionsPATCH: Backward-compatible bug fixes