This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
uv sync --locked --dev # Install package in development mode with dev dependenciesuv run ruff format . # Format code
uv run ruff format --check . # Check formatting without making changes
uv run ruff check . # Lint code
uv run mypy # Type checkingThe SDK uses nox with nox-uv for multi-version Python testing. This ensures compatibility across all supported Python versions (3.8-3.14).
Quick testing with the test script:
./scripts/test.sh # Run tests on all Python versions
./scripts/test.sh 3.12 # Run tests on Python 3.12 only
./scripts/test.sh 3.11 3.12 # Run tests on Python 3.11 and 3.12
./scripts/test.sh --coverage # Run tests with coverage on all versions
./scripts/test.sh --ci # Run full CI checks (lint, type, tests)
./scripts/test.sh --fresh # Recreate virtual environments
./scripts/test.sh 3.12 -- -k "test_sso" -v # Pass pytest argumentsDirect nox commands:
uv run nox # Run tests on all Python versions
uv run nox -s tests-3.12 # Run tests on specific Python version
uv run nox -s coverage # Run tests with coverage
uv run nox -s lint # Run linting
uv run nox -s typecheck # Run type checking
uv run nox -s ci # Run all CI checks
uv run nox -l # List all available sessionsSingle-version testing (faster for development):
uv run pytest # Run all tests on current Python
uv run pytest tests/test_sso.py # Run specific test file
uv run pytest -k "test_name" # Run tests matching pattern
uv run pytest --cov=workos # Run tests with coverageuv build --sdist --wheel # Build distribution packages
bash scripts/build_and_upload_dist.sh # Build and upload to PyPIThe SDK provides both synchronous and asynchronous clients:
WorkOSClient(sync) andAsyncWorkOSClient(async) are the main entry points- Both inherit from
BaseClientwhich handles configuration and module initialization - Each feature area (SSO, Directory Sync, etc.) has dedicated module classes
- HTTP clients (
SyncHTTPClient/AsyncHTTPClient) handle the actual API communication
Each WorkOS feature has its own module following this pattern:
- Module class (e.g.,
SSO) - main API interface - Types directory (e.g.,
workos/types/sso/) - Pydantic models for API objects - Tests (e.g.,
tests/test_sso.py) - comprehensive test coverage
- All models inherit from
WorkOSModel(extends PydanticBaseModel) - Strict typing with mypy enforcement (
strict = Truein mypy.ini) - Support for both sync and async operations via
SyncOrAsynctyping
- Uses pytest with custom fixtures for mocking HTTP clients
@pytest.mark.sync_and_async()decorator runs tests for both sync/async variants- Comprehensive fixtures in
conftest.pyfor HTTP mocking and pagination testing - Test utilities in
tests/utils/for common patterns
- Base HTTP client (
_BaseHTTPClient) with sync/async implementations - Request helper utilities for consistent API interaction patterns
- Built-in pagination support with
WorkOSListResourcetype - Automatic retry and error handling
- Dual client support: Every module supports both sync and async operations
- Type safety: Extensive use of Pydantic models and strict mypy checking
- Pagination: Consistent cursor-based pagination across list endpoints
- Error handling: Custom exception classes in
workos/exceptions.py - Configuration: Environment variable support (
WORKOS_API_KEY,WORKOS_CLIENT_ID)
When adding new features:
- Create module class with both sync/async HTTP client support
- Add Pydantic models in appropriate
types/subdirectory - Implement comprehensive tests using the sync_and_async marker
- Follow existing patterns for pagination, error handling, and type annotations