Configurable document generation & audit framework built on Claude Agent SDK
Project description
Scrivai
Configurable document generation & audit framework built on Claude Agent SDK.
Scrivai wraps the Claude Agent SDK in a three-phase execution engine called PES (Plan→Execute→Summarize), where each phase produces file-contract outputs that the framework validates automatically. It ships three built-in agents — ExtractorPES, AuditorPES, and GeneratorPES — and includes a self-improving skill system that proposes, evaluates, and promotes better agent behaviors from trajectory feedback.
Install
pip install scrivai
Quick Start
import asyncio
from pathlib import Path
from pydantic import BaseModel
from scrivai import (
ExtractorPES,
ModelConfig,
WorkspaceSpec,
build_workspace_manager,
load_pes_config,
)
class KeyItems(BaseModel):
items: list[str]
async def main():
ws_mgr = build_workspace_manager()
ws = ws_mgr.create(WorkspaceSpec(run_id="demo", project_root=Path.cwd(), force=True))
config = load_pes_config(Path("scrivai/agents/extractor.yaml"))
pes = ExtractorPES(
config=config,
model=ModelConfig(model="claude-sonnet-4-20250514"),
workspace=ws,
runtime_context={"output_schema": KeyItems},
)
run = await pes.run("Extract all key items from data/source.md")
print(run.final_output)
asyncio.run(main())
Core Concepts
Every agent in Scrivai follows the same three-phase contract:
┌──────┐ ┌─────────┐ ┌───────────┐
│ plan │ ───▶ │ execute │ ───▶ │ summarize │
└──────┘ └─────────┘ └───────────┘
│ │ │
▼ ▼ ▼
plan.json findings/*.json output.json
Each phase declares required_outputs in a YAML config. The framework checks those file contracts at phase exit and automatically retries up to max_retries times on failure. This makes every PES unit testable and auditable without extra instrumentation.
Key APIs
| Symbol | Description |
|---|---|
BasePES |
Three-phase execution engine base class |
ExtractorPES |
Extract structured data from documents |
AuditorPES |
Audit documents against checkpoints |
GeneratorPES |
Generate documents from templates |
ModelConfig |
LLM provider configuration |
load_pes_config() |
Load PES config from YAML |
build_workspace_manager() |
Create isolated workspaces |
Examples
| Script | Covers | Estimated time |
|---|---|---|
examples/01_audit_single_doc.py |
AuditorPES checkpoint audit |
~2–3 min |
examples/02_generate_with_revision.py |
GeneratorPES template generation |
~1–2 min |
examples/03_evolve_skill_workflow.py |
Skill evolution end-to-end | ~3–5 min |
Documentation
Full API reference and guides: https://iomgaa-ycz.github.io/Scrivai/
Configuration
Required
export ANTHROPIC_API_KEY=sk-ant-...
Gateway override (optional — for private endpoints or alternative models)
export ANTHROPIC_BASE_URL=https://your-gateway.example.com
export SCRIVAI_DEFAULT_MODEL=your-model-name
These environment variables are read automatically at startup. You can also pass base_url, model, and api_key directly to ModelConfig to override them at the code level.
Contributing
See CONTRIBUTING.md for development setup, coding standards, and the pull-request workflow.
License
Apache 2.0 — see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scrivai-0.2.3.tar.gz.
File metadata
- Download URL: scrivai-0.2.3.tar.gz
- Upload date:
- Size: 83.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bd51b4f048b482736147f6bd965a8604ea6e99124016e0d49619a35eae4748f
|
|
| MD5 |
3f5e3002888eaa699da00f5616603435
|
|
| BLAKE2b-256 |
f8473ec9c9c06f1e74c45606826222c83b580fa579142ff0711508443c462ef4
|
File details
Details for the file scrivai-0.2.3-py3-none-any.whl.
File metadata
- Download URL: scrivai-0.2.3-py3-none-any.whl
- Upload date:
- Size: 105.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e26aa4491a32753234b7332f31e6b269d8817e7ffda9256476e1b45bdd302c9d
|
|
| MD5 |
a5c26f84dcbd9f72bd9b53f8cabfca2f
|
|
| BLAKE2b-256 |
b6b62041df7833ecb8f0e2dc2a40794181f46017cc532e6a3c16ad18ea3bc2fe
|