Skip to main content

ClearFlow

PyPI Downloads Coverage Status PyPI Python License llms.txt

Correctness-first orchestration for probabilistic AI. Type-safe, deeply immutable, 100% code coverage.

Why ClearFlow?

  • Message-driven architecture – Commands trigger actions, Events record facts
  • 100% test coverage – Every path verified to work
  • Type-safe flows – Full static typing with pyright strict mode
  • Deep immutability – All state transformations create new immutable data
  • Minimal dependencies – Only Pydantic for validation and immutability
  • Single completion – Exactly one end message type per flow

How It Works

ClearFlow uses message-driven orchestration:

Command → Node → Event → Node → Event → End
  • Commands request actions: "analyze this portfolio"
  • Events record what happened: "risk assessment completed"
  • Nodes process messages and emit new ones
  • Flows route messages between nodes based on type

Every message knows where it came from (causality tracking), making complex AI orchestration debuggable and testable.

Quick Start

pip install clearflow

Note: ClearFlow is in alpha. Pin your version in production (clearflow==0.x.y) as breaking changes may occur in minor releases.

Real-World Examples

Example What It Shows
Chat OpenAI integration with conversation history
Portfolio Analysis Multi-agent coordination using DSPy
RAG Document chunking and FAISS vector search

AI Assistant Integration

ClearFlow provides comprehensive documentation in llms.txt format for optimal AI assistant support.

Claude Code Setup

Add ClearFlow documentation to Claude Code with one command:

claude mcp add-json clearflow-docs '{
    "type":"stdio",
    "command":"uvx",
    "args":["--from", "mcpdoc", "mcpdoc", "--urls", "ClearFlow:https://raw.githubusercontent.com/artificial-sapience/clearflow/main/llms.txt"]
}'

For IDEs (Cursor, Windsurf), see the mcpdoc documentation.

ClearFlow vs PocketFlow

Aspect ClearFlow PocketFlow
Architecture Message-driven (Commands/Events) State-based transformations
State Immutable messages with causality tracking Mutable, passed via shared param
Routing Message type-based explicit routes Action-based graph edges
Completion Single end message type Multiple exits allowed
Type safety Full static typing with pyright strict Dynamic (no annotations)

Development

Install uv

curl -LsSf https://astral.sh/uv/install.sh | sh

Clone and set up development environment

git clone https://github.com/artificial-sapience/clearflow.git
cd clearflow
uv sync --all-extras     # Creates venv and installs deps automatically
./quality-check.sh       # Run all checks

License

MIT

Acknowledgments

Inspired by PocketFlow's Node-Flow-State pattern.

Metadata

Release files for clearflow 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clearflow 0.6.0
File Size Uploaded
clearflow-0.6.0.tar.gz 86.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for clearflow 0.6.0
File Interpreter ABI Platform
clearflow-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 102.3 kB

Release files / clearflow-0.6.0.tar.gz

Download URL clearflow-0.6.0.tar.gz
Size 86.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0811e74d7ed20d9962708ca274fe5bf98383586e83c113f2e40b4850a5a560f4
BLAKE2b-256 checksum
How to use checksums
98301bbb55393f4f87abeb2a56459930b36e78a5fcb1e29e0213be48e353a2d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2025.

Transparency log

Release files / clearflow-0.6.0-py3-none-any.whl

Download URL clearflow-0.6.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61d274557d11be07a3e5d14df2ed068ce250b824aef329515eb033a66d6a248c
BLAKE2b-256 checksum
How to use checksums
c4b1673aa3480816000985f8a71d502395204b96dfa160c2de748a3c87131689
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2025.

Transparency log

Release history Release notifications | RSS feed

1.0.3

2 release files

1.0.1

2 release files

1.0.0

2 release files

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page