Python quick start
The typed SDK calls the same Zig engine as the native CLI, with Python-owned artifacts and context-managed native handles. Install it in a Python 3.12+ project:
uv add contextcraft-ai
Generate context
from pathlib import Path
from contextcraft import Config, Engine
config = Config(budget_tokens=8000, focus_query="authentication", output_format="json")
with Engine(config) as engine:
artifact = engine.run(Path("."))
print(artifact.content)
print(artifact.tokens)
run returns an Artifact without writing a file. Its content, scores, selected
tiers, and findings remain available after the engine closes. Each run reads and
analyzes the repository again, while engine resources such as parsers and the
tokenizer are reused.
Save the result
The SDK returns text and metadata rather than writing an output file:
Path("context.json").write_text(artifact.content, encoding="utf-8")
Review the selected source before sharing it. Continue with analysis reuse to try several requests without scanning again, or in-memory files to provide source directly.