Thank you for contributing to ai-kit! This guide will help you get started.
- Environment Setup
- Code Quality
- Testing
- Pull Request Process
- Monorepo Guidelines
- Common Tasks
- Troubleshooting
- Getting Help
Install the following tools:
-
uv - Python package manager
curl -LsSf https://astral.sh/uv/install.sh | sh -
just - Command runner
# macOS brew install just # Linux curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/bin
-
Volta - Node.js version manager
curl https://get.volta.sh | bash -
TruffleHog - Secret scanning tool (required for pre-commit hooks)
# macOS brew install trufflehog # Linux/macOS/Windows (WSL) curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/bin
# Clone the repository
git clone https://github.com/your-org/ai-kit.git
cd ai-kit
# Run automated setup
just setup
# Verify everything works
just lint
just testSetup time: Should complete in <10 minutes
We use ruff for both linting and formatting:
# Run linting
just lint
# Auto-fix linting issues
uv run ruff check --fix .
# Format code
just format
# Check formatting without changes
uv run ruff format --check .Pre-commit hooks run automatically on every commit to enforce code quality and security:
Hooks that run:
- ruff check - Linting
- ruff format - Code formatting
- nbstripout - Strip notebook outputs (for
.ipynbfiles) - TruffleHog - Secret scanning (blocks commits with credentials)
- Notebook metadata validation - Validates required metadata fields
- Notebook size check - Warns at 5MB, blocks at 10MB
# Manually run pre-commit on all files
uv run pre-commit run --all-files
# Run specific hook
uv run pre-commit run trufflehog --all-files
# Skip hooks (NOT recommended - will fail in CI)
git commit --no-verifyNote: CI will catch skipped hooks, so it's better to fix issues locally.
TruffleHog automatically scans for hardcoded credentials:
- Blocks commits containing API keys, tokens, passwords
- Detects 700+ secret types (AWS keys, GitHub tokens, private keys, etc.)
- Defense in depth: GitHub Secret Scanning also monitors pushes
If TruffleHog blocks your commit:
- Remove the secret from your code
- Use environment variables instead:
os.getenv("API_KEY") - Never commit
.envfiles with real credentials
- Line length: 100 characters
- Python version: 3.12+ features allowed
- Type hints: Required for public APIs
- Docstrings: Required for all public functions/classes (Google style)
Example:
def hello(name: str = "World") -> str:
"""Return a greeting message.
Args:
name: The name to greet. Defaults to "World".
Returns:
A greeting message.
Examples:
>>> hello()
'Hello, World!'
>>> hello("Alice")
'Hello, Alice!'
"""
return f"Hello, {name}!"# Run all tests
just test
# Run tests for specific package
uv run --package ai-kit-core pytest packages/core/tests/
# Run with coverage
uv run pytest --cov=src --cov-report=html- Place tests in
tests/directory - Name test files
test_*.py - Name test functions
test_* - Use descriptive test names
- Aim for >80% coverage
Example:
def test_hello_with_custom_name():
"""Test hello function with custom name."""
result = hello("Alice")
assert result == "Hello, Alice!"# Create feature branch
git checkout -b feature/your-feature-name
# Create bugfix branch
git checkout -b fix/bug-description- Write code following our style guide
- Add tests for new functionality
- Update documentation as needed
- Run
just lintandjust testbefore committing
# Stage changes
git add .
# Commit (pre-commit hooks will run)
git commit -m "feat: add new feature"Commit Message Format:
<type>(<scope>): <description>
[optional body]
[optional footer]
Types: feat, fix, docs, style, refactor, test, chore
# Push to your fork
git push origin feature/your-feature-name
# Create PR on GitHub
# - Fill in the PR template
# - Link related issues
# - Request reviewsAll PRs must pass:
- ✅ Linting (ruff check)
- ✅ Formatting (ruff format --check)
- ✅ Tests (pytest)
- ✅ Build (uv build)
- ✅ Pre-commit hooks (including TruffleHog secret scanning)
- ✅ GitHub Secret Scanning (push protection)
# Create package structure
mkdir -p packages/my-package/src/ai_kit_my_package packages/my-package/tests
# Create pyproject.toml
cat > packages/my-package/pyproject.toml <<EOF
[project]
name = "ai-kit-my-package"
version = "0.1.0"
description = "Description of my package"
requires-python = ">=3.12"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
EOF
# Create package.json for Turborepo
cat > packages/my-package/package.json <<EOF
{
"name": "@ai-kit/my-package",
"version": "0.1.0",
"private": true,
"scripts": {
"lint": "uv run ruff check src/",
"format": "uv run ruff format src/",
"test": "uv run pytest",
"build": "uv build"
}
}
EOF
# Sync workspace
uv sync --all-packagesSame structure as library, but add entry point in pyproject.toml:
[project.scripts]
my-cli = "ai_kit_my_app.main:main"To depend on another workspace package:
# In apps/cli/pyproject.toml
[project]
dependencies = [
"ai-kit-core",
]
[tool.uv.sources]
ai-kit-core = { workspace = true }[project]
dependencies = [
"requests>=2.31.0",
"pydantic>=2.0.0",
]Tasks are defined in turbo.json and run via pnpm turbo:
# Run lint across all packages (parallel)
pnpm lint
# Run tests (respects dependencies)
pnpm test
# Build all packages
pnpm build# Update Python dependencies
uv sync --upgrade
# Update Node.js dependencies
pnpm update
# Update pre-commit hooks
uv run pre-commit autoupdate# Clear all caches and artifacts
just clean
# Clear Turborepo cache only
rm -rf .turbo
# Clear uv cache
uv cache clean# Run CLI app
uv run --package ai-kit-cli ai-kit
# Run tests for specific package
uv run --package ai-kit-core pytest packages/core/tests/Solution: Install the missing tool (see Prerequisites)
Solution: Sync dependencies
uv sync --all-packagesSolution: Run hooks manually and fix issues
uv run pre-commit run --all-files
just format
just lintPossible causes:
- Undeclared dependency: CI uses strict package isolation
- Fix: Add missing dependency to
pyproject.toml
- Fix: Add missing dependency to
- Formatting differences: Different ruff version
- Fix: Run
uv syncto match versions
- Fix: Run
- Platform differences: macOS vs Linux
- Fix: Test in Docker or check CI logs
Solution: Clear cache and rebuild
rm -rf .turbo
pnpm build --forceSolution: Ensure workspace dependency is declared
[tool.uv.sources]
ai-kit-core = { workspace = true }- Documentation: Check specs/ for detailed guides
- Issues: Search existing issues
- Discussions: Ask in GitHub Discussions
- CI Troubleshooting: See .github/CI_TESTING.md
Be respectful, inclusive, and professional. We follow the Contributor Covenant.
By contributing, you agree that your contributions will be licensed under the MIT License.