Message-driven workflows with observable flows for emergent AI
Project description
ClearFlow
Message-driven orchestration of AI workflows. Type-safe, immutable, 100% coverage.
Why ClearFlow?
- Message-driven architecture – Commands trigger actions, Events record facts
- 100% test coverage – Every path proven 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
- AI-Ready Documentation – llms.txt for optimal coding assistant integration
How It Works
ClearFlow uses Messages to orchestrate AI workflows:
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 workflows 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 | Message routing between user and AI |
| Portfolio Analysis | Multi-language model coordination with Events |
| RAG | Document processing pipeline with causality tracking |
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) |
ClearFlow provides message-driven orchestration with immutable causality tracking and type safety. PocketFlow emphasizes brevity and flexibility with minimal overhead.
Development
Install uv
- Please see official uv docs for other ways to 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
Acknowledgments
Inspired by PocketFlow's Node-Flow-State pattern.
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 clearflow-0.3.0.tar.gz.
File metadata
- Download URL: clearflow-0.3.0.tar.gz
- Upload date:
- Size: 86.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7598ffd2a72beeffc17658ebc06f0c34db70e662596d88bf6c511bed402fa47
|
|
| MD5 |
29c1294207b4c28b3c532f05693c1b3e
|
|
| BLAKE2b-256 |
21907d893070a6fd781a3489f24ebc04dbc15194a9052866fac541297d08594d
|
Provenance
The following attestation bundles were made for clearflow-0.3.0.tar.gz:
Publisher:
release.yml on artificial-sapience/clearflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clearflow-0.3.0.tar.gz -
Subject digest:
a7598ffd2a72beeffc17658ebc06f0c34db70e662596d88bf6c511bed402fa47 - Sigstore transparency entry: 531915570
- Sigstore integration time:
-
Permalink:
artificial-sapience/clearflow@12eb0029be6040f70a26a0cf013cee6f1af688b9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/artificial-sapience
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@12eb0029be6040f70a26a0cf013cee6f1af688b9 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file clearflow-0.3.0-py3-none-any.whl.
File metadata
- Download URL: clearflow-0.3.0-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed44f70f5a698139a54ba37116cd3cc663824dafb52f4825b7dfce9a34ede5eb
|
|
| MD5 |
e1ff1d4fcc24cc04ff12d05356ca3a09
|
|
| BLAKE2b-256 |
17cea9b14cf0536829456e40e87544854488510bce7bc104a3c50818d96f161e
|
Provenance
The following attestation bundles were made for clearflow-0.3.0-py3-none-any.whl:
Publisher:
release.yml on artificial-sapience/clearflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clearflow-0.3.0-py3-none-any.whl -
Subject digest:
ed44f70f5a698139a54ba37116cd3cc663824dafb52f4825b7dfce9a34ede5eb - Sigstore transparency entry: 531915589
- Sigstore integration time:
-
Permalink:
artificial-sapience/clearflow@12eb0029be6040f70a26a0cf013cee6f1af688b9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/artificial-sapience
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@12eb0029be6040f70a26a0cf013cee6f1af688b9 -
Trigger Event:
workflow_dispatch
-
Statement type: