This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
just install # Update lock file and sync all extras + lint group
just lint # Format and lint (eof-fixer, ruff format, ruff check --fix, ty check)
just lint-ci # CI lint in check-only mode (no auto-fix)
just test # Run pytest with coverage
just test -- -k "test_name" # Run a single test
just test-branch # Run tests with branch coverageAll commands use uv run — do not invoke tools directly (e.g., use uv run pytest, not pytest).
lite-bootstrap bootstraps Python microservices with pre-configured observability instruments.
BaseConfig (dataclass, frozen, kw_only)
└── Framework configs compose multiple instrument configs via multiple inheritance
BaseInstrument (abstract)
└── Instrument subclasses: lifecycle via bootstrap() / teardown() / is_ready()
BaseBootstrapper (abstract)
├── FastAPIBootstrapper
├── LitestarBootstrapper
├── FastStreamBootstrapper
└── FreeBootstrapper
- Optional dependencies: Each instrument checks for its optional package via
import_checker.py(importlib.util.find_spec). Instruments are skipped silently if the package is absent. - Frozen dataclass configs: All configs are
@dataclasses.dataclass(kw_only=True, frozen=True).from_dict()andfrom_object()filter unknown keys before constructing. - Instrument registry:
BaseBootstrapperholds a list of instrument instances; it callsbootstrap()on each in order andteardown()in reverse during shutdown. - Logging ↔ Sentry integration:
logging_instrument.pyinjects structlog context into Sentry events.sentry_instrument.pychainsbefore_sendcallbacks viawrap_before_send_callbacks(). Theskip_sentryflag in log context suppresses events. - OTel ↔ Logging integration: The logging instrument injects span/trace IDs from the active OpenTelemetry context into every log record.
lite_bootstrap/bootstrappers/— framework-specific bootstrappers and their config classeslite_bootstrap/instruments/— individual instrument implementations (one file per tool)lite_bootstrap/helpers/— utility functions (fastapi_helpers.pyserves offline Swagger UI assets)lite_bootstrap/import_checker.py— detects installed optional packageslite_bootstrap/types.py— shared TypeVars
Install via pip install lite-bootstrap[<group>] or uv add lite-bootstrap[<group>]:
| Group | Contents |
|---|---|
fastapi-all |
fastapi + sentry + otl + logging + metrics |
litestar-all |
litestar + sentry + otl + logging |
faststream-all |
faststream + sentry + otl + logging |
free-all |
sentry + otl + logging |
pyroscope |
pyroscope-io (add to any group) |
- Line length: 120 characters (ruff enforced)
- Ruff ALL rules enabled; notable ignores: D1 (missing docstrings), S101 (assert), TCH (type-checking imports), FBT (boolean args)
- Type annotations required; checked with
ty