Recursive task decomposition for Claude Code - domain-aware splitting and reunification
Project description
Cleave
Recursive task decomposition for Claude Code. Split complex directives along domain boundaries, execute in parallel, reunify with conflict detection.
Etymology
"Cleave" holds contradictory meanings: to split apart AND to hold fast together. This duality captures the tool's essence—we cleave tasks into independent pieces, then cleave the results back into a unified whole.
Installation
Both the CLI tool and Claude Code skill are required for full functionality.
Option 1: pipx (Recommended)
Install in isolated environment with automatic skill installation:
# Install from PyPI
pipx install styrene-cleave
# Install the skill (creates symlink or copy as needed)
cleave install-skill
# Verify
cleave --help
Updates:
pipx upgrade styrene-cleave
cleave install-skill # Auto-detects and updates stale installations
Option 2: pip
# Install from PyPI
pip install styrene-cleave
# Install the skill
cleave install-skill
# Verify
cleave --help
Option 3: Development (Editable)
# Clone the repo
git clone git@github.com:styrene-lab/cleave.git ~/projects/cleave
# Install in editable mode
pip install -e ~/projects/cleave
# Install the skill
cleave install-skill
# Verify
cleave --help
Updates:
cd ~/projects/cleave && git pull
cleave install-skill # Updates if version changed
Windows Users
On Windows 11, cleave install-skill will:
- Try to create a symlink (requires Developer Mode or admin privileges)
- Automatically fall back to directory copy if symlink fails
- Track version and auto-update on upgrades
To enable symlinks (optional, for better performance):
- Open Settings → System → For developers
- Enable "Developer Mode"
- Run
cleave install-skillagain
Interactive TUI (Optional)
Cleave includes an interactive terminal UI for task decomposition. This requires additional dependencies:
# TUI with Claude backend (default)
pipx install styrene-cleave[tui]
# TUI with local inference only (Ollama, vLLM, llama.cpp)
pipx install styrene-cleave[tui-local]
# All features
pipx install styrene-cleave[full]
Launch the TUI:
cleave tui [directory] # Launch in current directory or specified path
TUI Features
- Chat interface with Claude Agent SDK integration
- Multi-line input with history navigation (Up/Down arrows)
- Live streaming of LLM responses
- Tool use display with syntax highlighting
- Session management with persistent history
- CALF file support for directive management
- Retro CRT theme with purple accents
Keyboard Shortcuts
Enter- Submit messageShift+Enter- New line in inputUp/Down- Navigate input historyCtrl+L- Clear chatEscape- Cancel operationTab/Shift+Tab- Navigate between panelsq- Quit
Backend Configuration
Configure backends in ~/.cleave/settings.yaml:
# Active backend
backend: claude # or: ollama, openai, vllm, llamacpp
# Backend-specific settings
backends:
claude:
default_model: claude-sonnet-4-20250514
ollama:
base_url: http://localhost:11434/v1
default_model: qwen2.5-coder:7b
openai:
base_url: https://api.openai.com/v1
api_key_env: OPENAI_API_KEY
default_model: gpt-4o
Manage settings via CLI:
cleave config show # Display current settings
cleave config set backend ollama # Switch to Ollama backend
cleave config path # Show settings file location
Usage
Within Claude Code
Invoke via /cleave in any Claude Code session:
/cleave
Implement user authentication with JWT tokens, ensuring backwards
compatibility with existing session-based auth. Include migration
path and tests.
Claude will:
- Assess complexity
- Split into 2-3 child tasks if needed
- Execute children (parallel or sequential)
- Reunify results with conflict detection
CLI Commands
# Assess complexity of a directive
cleave assess --directive "Add user auth with JWT"
# Match against known patterns
cleave match --directive "Add Stripe payments"
# Initialize workspace for manual execution
cleave init --directive "Add auth" --children '["Backend", "Frontend"]'
# Detect conflicts between task results
cleave conflicts --results ".cleave/0-task.md,.cleave/1-task.md"
# Reunify completed tasks
cleave reunify --workspace .cleave
Concepts
Complexity Assessment
Formula: complexity = (1 + systems) × (1 + 0.5 × modifiers)
- Systems: Distinct architectural boundaries (UI, API, DB, external services)
- Modifiers: State coordination, error handling, concurrency, security, etc.
If complexity > threshold, the directive gets cleaved.
Splitting Strategy
- Binary (2): Clean frontend/backend or data/logic seams
- Ternary (3): Multi-layer stacks (UI/API/DB)
- Never 4+: Coordination overhead exceeds benefits
Workspace Structure
.cleave/
├── manifest.yaml # Intent, ancestry, children, assessment
├── siblings.yaml # Sibling coordination, file claims
├── 0-task.md # Child 0 task file
├── 1-task.md # Child 1 task file
├── metrics.yaml # Telemetry
├── merge.md # Reunification report
└── review.md # Adversarial review
Workspaces are auto-generated with unique names based on the directive to prevent collisions:
cleave init -d "Add JWT auth" -c '["A", "B"]'→.cleave-add-jwt-auth/cleave init -d "Optimize queries" -c '["X", "Y"]'→.cleave-optimize-queries/
If a workspace already exists, a numeric suffix is added (.cleave-add-jwt-auth-2/).
To override, use --output explicitly: cleave init -d "..." -c '[...]' -o .cleave-custom/
All .cleave* directories are gitignored; they are ephemeral artifacts consumed by cleave reunify
and should be removed once the workspace is closed.
Conflict Detection
Four conflict types detected during reunification:
- File Overlap - Multiple children modified same file
- Decision Contradiction - Incompatible choices (Redis vs Memcached)
- Interface Mismatch - Different signatures for same function
- Assumption Violation - Child assumption contradicts sibling decision
Configuration
Modes
- Lean (default): Terse output, fast-path assessment
- Robust: Verbose reasoning, sequential thinking for all assessments
Flags
--no-tdd: Skip TDD workflow instructions in task files--no-review: Skip adversarial review during reunification--infer-permissions: Detect required bash permissions upfront
Documentation
Guides
- Getting Started - Installation, first cleave session, reading reports
- TUI Usage - Interactive terminal UI guide
- Advanced Patterns - Custom patterns, calibration, multi-model workflows
- Contributing - Development setup, running tests, submitting PRs
Reference
- CALF Format - Complete specification for
.calfdirective files - Architecture Overview - System components and data flow
- Backend Interface - Implementing custom TUI backends
- Assessment Pipeline - Pattern matching and complexity calculation
Examples
- Basic Usage - Simple and complex directive examples
- Patterns - Real-world pattern examples with documentation
- TUI Examples - Backend configuration, session workflow, keyboard shortcuts
- CLI Workflows - Shell scripts for assessment, reunification, metrics
Requirements
- Python 3.11+
- Claude Code CLI (for skill usage)
- Sequential Thinking MCP server (recommended for complex assessments)
License
MIT
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 styrene_cleave-0.7.0.tar.gz.
File metadata
- Download URL: styrene_cleave-0.7.0.tar.gz
- Upload date:
- Size: 267.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7534c39d054ca26029abfa4442a8344c7c28936179377537e655644635de7c41
|
|
| MD5 |
c80a819401d5032cbbb8ab439f5fcf8a
|
|
| BLAKE2b-256 |
facea0fc443b49cf9ac454f77ea072b3c24371551e8dc74e6a86a12948a10deb
|
File details
Details for the file styrene_cleave-0.7.0-py3-none-any.whl.
File metadata
- Download URL: styrene_cleave-0.7.0-py3-none-any.whl
- Upload date:
- Size: 152.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b062b7c0e685f8d1871faf29b66d6e011fe5c5fb89d17ca52f5e824e9a367271
|
|
| MD5 |
4e632cbd07eec4e1df239556f3d8224c
|
|
| BLAKE2b-256 |
b27ccdbbb360215fbac060221c9595b99c962069c48dd7519a6fc29f7708f785
|