Sequential task execution for Claude Code - Enables orchestration of complex AI workflows with fresh context for each task.
Quick Start Guide - Get running in 2 minutes!
- No API keys needed
- Special authentication handling
- Docker deployment guide
"I want to call Claude from my Python code"
# Install: pip install cc-executor
from cc_executor.client.cc_execute import cc_execute
# Simple usage - returns string
result = cc_execute("Create a fibonacci function")
print(result)
# JSON mode - returns structured dict
result = cc_execute(
"Create a fibonacci function",
json_mode=True # Returns dict with 'result', 'files_created', etc.
)
print(result['files_created'])π Full Python API Documentation
"I need my AI agent to orchestrate complex workflows"
# Start the MCP WebSocket server
cc-executor start
# Your agent connects to: ws://localhost:8003/ws/mcp
# Then uses cc_execute.md prompt for orchestration- Direct Python API - No WebSocket server needed
- Automatic prompt amendment - Fixes problematic prompts automatically
- Streaming support - Real-time output as tasks execute
- JSON response mode - Structured responses for programmatic use
- Assessment reports - Detailed execution reports with verification
- Intelligent timeout prediction - RedisTaskTimer with ML-style learning (default)
- No ANTHROPIC_API_KEY needed - Uses browser authentication
- Token limit protection - Auto-truncates prompts exceeding 190k tokens
- Rate limit retry - Automatic retry with exponential backoff using tenacity
- Ambiguous prompt detection - Warns about problematic prompts
- Execution history export - Export task history from Redis in JSON/CSV
- Progress callbacks - Real-time progress updates during execution
- Sequential orchestration - Forces tasks to execute in order
- Fresh context per task - Each task gets full 200K context
- Process control - PAUSE/RESUME/CANCEL support
- Real-time streaming - See output as it happens
- Hook integration - UUID verification and custom hooks
THE PROBLEM: When a Claude orchestrator tries to manage multi-step tasks, it can't control execution order - tasks run in parallel, breaking dependencies.
THE SOLUTION: CC Executor + cc_execute.md enables:
- Claude Orchestrator manages the overall workflow
- Fresh Claude instances (200K context each) handle individual tasks
- WebSockets force the orchestrator to WAIT for each task before spawning the next
This allows Claude to:
- Orchestrate complex workflows - Main Claude manages the task sequence
- Fresh context per task - Each task gets a full 200K context window
- Guaranteed sequential execution - Task 2 waits for Task 1 to complete
- No context pollution - Each Claude instance starts clean
- Handle massive workflows - 10+ hour workflows with 50+ sequential tasks
- True task dependencies - Task N can use outputs from Tasks 1 through N-1
# For Python developers who want to call Claude directly
from cc_executor.client import cc_execute, cc_execute_list
import asyncio
async def main():
# Simple call - just like OpenAI/Anthropic SDKs
result = await cc_execute("Create a Python function to calculate prime numbers")
print(result)
# Execute multiple tasks in sequence
results = await cc_execute_list([
"Create a REST API with FastAPI",
"Add authentication endpoints",
"Write comprehensive tests"
])
# Advanced: Get structured JSON responses with new features
result = await cc_execute(
"Create a todo list manager",
json_mode=True, # Returns: {"result": "...", "files_created": [...]}
stream=True, # See output as it generates
generate_report=True, # Get detailed execution report
progress_callback=lambda msg: print(f"[Progress] {msg}"), # Real-time updates
amend_prompt=True # Auto-fix ambiguous prompts
)
# Export execution history for analysis
from cc_executor.client.cc_execute import export_execution_history
history = await export_execution_history(format="json", limit=10)
print(f"Recent executions: {history}")
asyncio.run(main())# For complex agent workflows with WebSocket orchestration
cc-executor server start # Start the WebSocket server
# Quickstart - Single task in 2 minutes
cd examples/quickstart
python quickstart.py
# Basic - Sequential task execution
cd examples/basic
python run_example.py
# Medium - Concurrent execution patterns
cd examples/medium
python concurrent_tasks.py
# Advanced - Production patterns with mixed execution
cd examples/advanced
python run_example.pyCC Executor includes built-in verification to ensure executions are real:
# Via MCP: Use the verify_execution tool
result = await mcp_client.call_tool("verify_execution", {"last_n": 5})
# Manual verification
python -m cc_executor.reporting.hallucination_check reportEvery execution creates verifiable artifacts:
- JSON response files with UUIDs
- Markdown receipts for audit trails
- Redis timing history
See MCP Verification Tool for details.
Example Task Lists:
Basic Usage (all cc_execute):
Task 1: Create TODO API β Fresh 200K context
Task 2: Write tests β New context, reads Task 1's output
Task 3: Add feature β Clean context, builds on previous work
Advanced Usage (mixed patterns):
Task 1: Research (Direct) β Quick MCP tool call
Task 2: Create Tutorial (cc_execute) β Complex generation
Task 3: External Review (cc_execute) β Fresh perspective
Task 4: Create Exercises (cc_execute) β Interactive content
What The Examples Demonstrate:
Basic Usage:
- All cc_execute: Simple approach for learning the system
- Sequential execution: Each task waits for previous to complete
- Fresh context always: Every task gets full 200K tokens
- Automatic UUID4: Verification happens transparently
Advanced Usage:
- Mixed patterns: Optimize between direct and cc_execute
- Tool integration: MCP tools, external models
- Smart selection: Use cc_execute only when beneficial
- Real workflows: Research β Build β Review β Improve
Note: See the
examples/directory for complete working examples:
examples/quickstart/- Get started in 2 minutesexamples/basic/- Learn cc_execute fundamentalsexamples/medium/- Concurrent execution patternsexamples/advanced/- Production patterns with mixed executiondocs/GAMIFICATION_EXPLAINED.md- Understanding self-improving featuresClaude Max Plan? See:
docs/QUICK_START_CLAUDE_MAX.md- 2-minute setupdocs/DEPLOYMENT_GUIDE_CLAUDE_MAX.md- Complete guidedocs/CLAUDE_MAX_AUTHENTICATION_FIX.md- Troubleshooting
See examples/redis_cache_advanced_task_list.md for a complete Research β Build β Review β Improve workflow that demonstrates:
- Integration with perplexity-ask for research
- Building based on researched best practices
- AI model review with LiteLLM
- Iterative improvement based on feedback
This shows the FULL power of orchestrated task execution with external tools.
# Advanced workflow with external tools (simplified view)
Task 1: Research with perplexity-ask β Save findings
Task 2: Build Redis cache based on research β Fresh context
Task 3: Review code with LiteLLM/Gemini β Fresh perspective
Task 4: Apply improvements and test β Final iteration
# Full orchestrated example in: examples/redis_cache_advanced_task_list.mdThe Magic:
- Orchestrator Claude: Manages workflow, tracks progress, handles errors
- Worker Claudes: Fresh 200K context each, focused on single tasks
- WebSocket: Forces orchestrator to wait between spawning instances
- RedisTaskTimer: Sophisticated ML-style timeout prediction is now the default system
- Automatic Classification: Tasks categorized as calculation, code, data, general, or file operations
- Complexity Analysis: Determines task complexity from trivial to extreme
- Historical Learning: Builds knowledge from past executions to improve predictions
- 90th Percentile Calculations: Outlier-resistant predictions for reliability
- System Load Awareness: Dynamic adjustments based on current system performance
- Redis Integration: Execution times automatically saved for continuous improvement
- Token limit protection: Automatically truncates prompts exceeding 190k tokens to prevent failures
- Rate limit retry: Automatic retry with exponential backoff (5-60s) using tenacity
- Ambiguous prompt detection: Warns about problematic prompts before execution
- Execution history export: Export Redis-stored task history in JSON/CSV formats
- Progress callbacks: Real-time progress updates during long-running tasks
- Non-blocking async execution: All subprocess calls now use
asyncio.create_subprocess_execto prevent event loop blocking - Industry-standard API: Migrated from
return_jsontojson_modeparameter (matching OpenAI/LiteLLM conventions) - Robust JSON parsing: Automatic handling of markdown-wrapped JSON and malformed responses with
clean_json_string
- MCP Verification Tool: New
verify_executiontool exposed via MCP for checking execution authenticity - Automatic Receipts: Every cc_execute call generates a markdown receipt for audit trails
- JSON Response Files: Physical evidence on disk with UUIDs for every execution
- Built-in Reporting: Generate anti-hallucination verification reports on demand
- Receipt Integration: Execution receipts automatically created alongside response files
- Temporary files archived: All test scripts and temporary files moved to
archive/temp_files_20250109/ - 43 unreferenced files archived: Cleaner, more maintainable codebase
- Duplicate implementations removed: Single canonical source for each component
- Test structure reorganized: Clear separation of unit, integration, and proof-of-concept tests
- Clean project root: Only essential configuration and documentation files remain
- validation_prompt parameter: Spawn fresh Claude instance to validate results
- Simple design: No internal retry logic - orchestrator controls retry strategy
- Non-blocking: Defaults to
is_valid=Trueon validation errors - Example: See
examples/validation_pattern.pyfor best practices
Beyond sequential execution, this project provides a reliable Claude Code SDK that:
- Implements a working hook system (addressing challenges with the official hook implementation)
- Works with Claude Max ($200/month Claude Max subscribers)
- Allows Claude Code to be called programmatically without hanging
- Provides consistent subprocess execution that doesn't mysteriously fail
- Works around known Claude CLI limitations (like the missing
--printflag bug)
The official SDK currently focuses on API-key workflows and does not support browser-authenticated Claude Max users, so they can't:
- Use the API (Claude Max uses browser auth, not API keys)
- Run hooks reliably (implementation challenges exist)
- Integrate Claude into any automated workflow
After extensive testing with these limitations, this WebSocket-based approach emerged as a reliable way to integrate Claude Code.
I hope Anthropic will eventually provide full official support for Claude Max subscribers, making this community workaround unnecessary. Until then, this project aims to fill the gap.
β A Claude Max user (ok, it's me)
from cc_executor import cc_execute_task_list
# CC Executor is for MULTI-STEP workflows, not single calls
tasks = [
"Task 1: Create the FastAPI app structure with routers",
"Task 2: Add SQLAlchemy models and database setup",
"Task 3: Implement CRUD endpoints for users",
"Task 4: Add authentication middleware",
"Task 5: Write comprehensive tests"
]
results = cc_execute_task_list(tasks)β DON'T DO THIS:
# WRONG - Don't use CC Executor for single tasks!
result = some_single_claude_call("Write a function") # Just use claude -pCC Executor is an unofficial Python SDK and WebSocket service for Claude Code Max users. It provides a flexible, optional execution pattern (like numpy vs math) for complex tasks that need fresh context isolation.
- Sequential task execution - WebSockets maintain persistent connections for multi-step workflows
- Optional execution pattern - Use cc_execute when you need it, direct execution when you don't
- Automatic UUID4 verification - Built-in anti-hallucination hooks (always enabled)
- WebSocket JSON-RPC server (
src/cc_executor/core/websocket_handler.py) β reliable streaming command execution. - Async Python client SDK (
src/cc_executor/client/client.py) β programmatic access for Python scripts. - Automatic hooks - UUID4 injection and verification happens transparently
- Token-limit detection & adaptive retry (logic in
websocket_handler.py- detects multiple token limit patterns). - Redis-backed session state & execution history (
src/cc_executor/core/session_manager.py- fully implemented with Redis support). - Shell consistency with Claude Code (default shell configured in
src/cc_executor/core/config.py).
| Capability | CC Executor (Unofficial SDK) | Official Anthropic SDK |
|---|---|---|
| Sequential multi-step task execution | β (via persistent WebSocket) | β |
| Works with Claude Max (browser-auth) | β | β |
| Python async client & CLI | β
client/client.py, cli/main.py |
β (API only) |
| WebSocket streaming JSON-RPC | β
core/websocket_handler.py |
β |
| Automatic UUID4 hooks | β Always enabled | β (hooks broken) |
| Optional execution pattern | β Use when needed | N/A |
| Token-limit detection & adaptive retry | β | β |
| Redis-backed session & history | β
core/session_manager.py |
β |
Shell consistency (zsh) |
β | N/A |
The project follows a clean, self-contained directory structure:
src/cc_executor/
βββ core/ # Core server implementation
β βββ websocket_handler.py # Main WebSocket server
β βββ process_manager.py # Subprocess execution management
β βββ stream_handler.py # Output stream handling
β βββ resource_monitor.py # Resource monitoring
β βββ client.py # WebSocket client for connecting to server
βββ cli/ # Command-line interface
β βββ main.py # Typer-based CLI with all commands
βββ hooks/ # Hook system for extensibility
β βββ hook_integration.py # Main hook integration (ProgrammaticHookEnforcement)
β βββ setup_environment.py # Environment setup hooks
β βββ record_execution_metrics.py # Execution metrics recording
β βββ review_code_changes.py # Code review hooks
βββ templates/ # Self-improving prompt templates
flowchart LR
A[Client] -->|WebSocket| B[Handler]
B --> C[Hooks]
B --> D[Process]
B --> E[(Redis)]
D -->|output| B
B -->|stream| A
Execution Flow:
- Client connects via WebSocket and sends command
- Pre-execution hooks validate and wrap the command
- Redis provides timeout estimates from historical data
- ProcessManager spawns subprocess with proper isolation
- Output streams in real-time to client
- Post-execution hooks update metrics in Redis
CC Executor can be installed locally or deployed via Docker. Choose the method that best suits your needs.
Docker provides isolation, easier deployment, and better security for running CC Executor as a service.
# Clone the repository
git clone https://github.com/grahama1970/cc_executor.git
cd cc_executor/deployment
# IMPORTANT: Authenticate Claude on your host machine first
# Claude Code uses web authentication, not API keys
claude /login # Follow the browser authentication flow
# Start services with Docker Compose
docker compose up -d
# Verify services are running
docker compose ps
# Test the deployment
curl http://localhost:8001/health | jq .Docker Features:
- Isolated execution environment - Commands run in containers
- FastAPI REST wrapper - HTTP endpoints at port 8001
- Redis for session state - Port 6380 (to avoid conflicts)
- Health checks - Automatic container monitoring
- Volume mounts - Persists logs and Claude authentication
Docker Endpoints:
http://localhost:8001- REST API (FastAPI)ws://localhost:8004/ws/mcp- WebSocket (direct)http://localhost:6380- Redis (if needed)
Install CC Executor directly in your Python environment. This is the most tested and reliable method.
# Clone the repository
git clone https://github.com/grahama1970/cc_executor.git
cd cc_executor
# Create virtual environment and install dependencies
uv sync
# Install for development
uv pip install -e .
# Start the WebSocket server
cc-executor server startInclude CC Executor as a dependency in your own project:
# In your pyproject.toml
[project]
dependencies = [
"cc-executor @ git+https://github.com/grahama1970/cc_executor.git",
# ... other dependencies
]
# Or install directly
pip install git+https://github.com/grahama1970/cc_executor.gitThen use programmatically:
from cc_executor import cc_execute_task_list
# Use in your codeCC Executor now includes lightweight MCP support, making it easier to use as a tool with Claude or other LLMs that support the protocol.
- Tool Discovery: Manifest endpoint at
/.well-known/mcp/cc-executor.json - Direct WebSocket: Connect to
ws://localhost:8003/ws/mcpfor execution - Standard Methods: Supports
execute,control, andhook_status - Streaming Output: Real-time command output via JSON-RPC
- Backward Compatible: Original WebSocket interface still works
# Configure Claude to discover CC Executor
# Add to your .mcp.json or Claude configuration:
{
"tools": {
"cc-executor": {
"url": "http://localhost:8001/.well-known/mcp/cc-executor.json"
}
}
}
# Then use in Claude:
# "Use the cc-executor tool to run 'echo Hello from MCP'"
results = cc_execute_task_list([
"Task 1: Create API endpoints",
"Task 2: Add authentication",
"Task 3: Write tests"
])| Feature | Docker Deployment | Local Installation |
|---|---|---|
| Isolation | β Full container isolation | β Runs in your environment |
| Setup complexity | Medium (needs Docker) | Simple (just Python) |
| Resource usage | Higher (containers) | Lower (native) |
| Port management | Managed by Docker | Manual configuration |
| Production ready | β Ready | |
| REST API wrapper | β Included (port 8001) | β WebSocket only |
| Auto-restart | β Via restart policies | β Manual |
- Claude authentication: Must authenticate Claude on host first (
claude /login) - Docker & Docker Compose: Version 20.10+ recommended
- Ports: 8001 (API), 8004 (WebSocket), 6380 (Redis)
- Volume:
~/.claudedirectory mounted for OAuth authentication
For Docker Users:
-
You MUST authenticate on your host machine first:
# On your host machine (not in Docker) claude /login # This opens a browser for authentication
-
The Docker container reuses your host authentication by mounting
~/.claude:volumes: - ~/.claude:/home/appuser/.claude
-
No API endpoint for authentication exists because Claude /login requires interactive browser access
For New Users Without Claude CLI:
-
Install Claude Code on your host first:
npm install -g @anthropic-ai/claude-code
-
Authenticate once:
claude /login
-
Then use Docker or local installation
Note: The /auth/claude API endpoint exists but doesn't work because Claude's authentication cannot be done programmatically. This is a limitation of Claude Code's web-based authentication system.
Authentication Issues:
# If Claude commands fail with authentication errors:
# 1. Ensure you're authenticated on the host
claude /login # Complete browser auth
# 2. Verify credentials exist
ls -la ~/.claude/.credentials.json
# 3. Check volume mount in container
docker exec cc_executor_websocket ls -la /home/appuser/.claude/Port Conflicts:
# If ports are already in use, modify docker-compose.yml:
# Change: "8001:8000" to "8081:8000" for API
# Change: "8003:8003" to "8013:8003" for WebSocket
# Change: "6380:6379" to "6381:6379" for RedisView Logs:
# Check all services
docker compose logs -f
# Check specific service
docker compose logs websocket -f
docker compose logs api -fRestart Services:
# Full restart
docker compose down
docker compose up -d
# Restart specific service
docker compose restart websocketThink of cc_execute like numpy - you don't need it for simple math, but it's invaluable for complex operations:
- Simple tool calls: MCP tools like perplexity-ask, GitHub operations
- Quick queries: Tasks under 30 seconds
- No isolation needed: When context accumulation is beneficial
- Basic commands: File reads, simple edits, status checks
- Fresh context needed: Each task needs full 200K token window
- Complex generation: Multi-file creation, architecture design
- Long-running tasks: Operations over 1 minute (WebSocket keeps alive)
- Anti-hallucination critical: Automatic UUID4 verification
- Task isolation required: No pollution from previous operations
# Task 1: Direct - Quick MCP tool call
Use perplexity-ask to research Redis caching patterns
# Task 2: cc_execute - Complex implementation
Using cc_execute.md: Create a Redis cache module with connection pooling,
error handling, and automatic retry logic based on the research
# Task 3: cc_execute - External review
Using cc_execute.md: Review the implementation with gemini-2.0-flash-exp
via LiteLLM and suggest improvements
# Task 4: Direct - Simple test run
Run pytest on the generated testsCC-Executor includes MCP tools that help orchestrators manage multi-step workflows intelligently:
# 1. Check WebSocket server health
status = mcp__cc-orchestration__check_websocket_status()
# 2. Analyze task complexity
complexity = mcp__cc-orchestration__get_task_complexity("Build FastAPI app")
# 3. Validate task list before execution
validation = mcp__cc-orchestration__validate_task_list(tasks)
# 4. Get execution strategy recommendations
strategy = mcp__cc-orchestration__suggest_execution_strategy(tasks)
# 5. Monitor running executions via logs
monitor = mcp__cc-orchestration__monitor_execution()
# 6. Review execution history
history = mcp__cc-orchestration__get_execution_history()
# 7. Check hook status
hooks = mcp__cc-orchestration__get_hook_status()## Task List Example with MCP Support
Task 1: Check infrastructure
Use cc-orchestration tools to verify WebSocket server status
Task 2: Analyze and plan
Validate task list and get execution strategy recommendations
Task 3: Execute based on strategy
For complex tasks: Use cc_execute.md (fresh 200K context)
For simple tasks: Execute directly
Task 4: Monitor progress
Use monitor_execution() to track via logsAdd to your .mcp.json:
{
"mcpServers": {
"cc-orchestration": {
"command": "uv",
"args": ["run", "python", "src/cc_executor/servers/mcp_cc_execute.py"],
"env": {"CC_EXECUTOR_PORT": "8005"}
}
}
}Note: These examples show cc_execute.md in its proper context - orchestrating multi-step task lists. For single commands, just use Claude Code directly.
Orchestrate a complete workflow where each task gets fresh context:
# Task List: Build Quantum Computing Tutorial
cc-executor run "claude -p 'You are the ORCHESTRATOR. Execute this task list:
Task 1 (Direct): Use perplexity-ask to research quantum entanglement breakthroughs from 2024-2025
Task 2 (cc_execute.md): Based on the research, create a beginner-friendly tutorial on quantum
entanglement with code examples in Python. Save as quantum_tutorial.md
Task 3 (cc_execute.md): Review the tutorial and create interactive Jupyter notebook exercises
that demonstrate the concepts. Each exercise should build on the previous one.'"Build complex systems where each component needs fresh context:
# Task List: Build Secure API with Authentication
cc-executor run "claude -p 'ORCHESTRATE these sequential tasks:
Task 1 (cc_execute.md): Create a FastAPI application structure with proper project layout,
dependency injection, and configuration management. Include a main.py and config.py
Task 2 (cc_execute.md): Add JWT-based user authentication to the FastAPI app. Include
registration, login, and protected endpoints. Implement proper password hashing.
Task 3 (cc_execute.md): Review the complete implementation using ./prompts/ask-litellm.md
with gemini-2.0-flash-exp to identify security vulnerabilities and suggest improvements.
Task 4 (cc_execute.md): Implement the security improvements suggested in Task 3 and add
comprehensive test coverage for all authentication flows.'"Combine parallel and sequential patterns in a workflow:
# Task List: Algorithm Implementation Comparison
cc-executor run "claude -p 'ORCHESTRATE this workflow:
Phase 1 - Parallel Generation (Direct):
Spawn 3 parallel tasks to implement binary search:
- Task A: Iterative implementation with performance focus
- Task B: Recursive implementation with clarity focus
- Task C: Generic implementation supporting any comparable type
Phase 2 - Sequential Analysis (cc_execute.md):
Task 4: Analyze all three implementations for time/space complexity and create a
comparison table. Include Big-O analysis and practical performance considerations.
Task 5: Create a comprehensive test suite that validates all three implementations
with edge cases, large datasets, and different data types.
Task 6: Write a technical blog post explaining when to use each implementation,
with benchmarks and real-world examples.'"When using Docker deployment, interact via the FastAPI REST endpoints:
# Health check
curl http://localhost:8001/health | jq .
# Check authentication status (NEW!)
curl http://localhost:8001/auth/status | jq .
# Returns either:
# - {"status": "authenticated", "message": "Claude Code is authenticated and ready to use"}
# - {"status": "not_authenticated", ...} with setup instructions
# Execute a task list
curl -X POST http://localhost:8001/execute \
-H "Content-Type: application/json" \
-d '{
"tasks": [
"Create a Python function to calculate fibonacci numbers",
"Add comprehensive tests for the function",
"Optimize the function for performance"
],
"timeout_per_task": 60
}' | jq .
# Check execution status
curl http://localhost:8001/executions/{execution_id}/status | jq .
# Get full results
curl http://localhost:8001/executions/{execution_id}/results | jq .Docker API Endpoints:
POST /execute- Execute a task listGET /executions/{id}/status- Check execution statusGET /executions/{id}/results- Get execution resultsDELETE /executions/{id}- Cancel executionGET /health- Health checkGET /auth/status- Check authentication status and get setup instructionsPOST /auth/claude-β οΈ Deprecated (authentication requires host browser)
CC Executor provides a comprehensive CLI with the following commands:
# Start the server
cc-executor server start
# Check server status
cc-executor server status
# Execute a command
cc-executor run "echo Hello, World!"
# Run Claude commands with automatic retry
cc-executor run "claude -p 'What is 2+2?'"
# View execution history
cc-executor history list
# Run assessments
cc-executor test assess core
# Initialize environment
cc-executor initFor both Docker and local installations, you can use the Python client:
from cc_executor.client.client import WebSocketClient
import asyncio
async def main():
# For Docker: use host="localhost" (default)
# For local: use host="localhost" (default)
client = WebSocketClient(host="localhost", port=8003)
# Execute a command
result = await client.execute_command(
command='claude -p "What is 2+2?"',
timeout=30
)
if result["success"]:
print(f"Output: {result['output_data']}")
else:
print(f"Error: {result['error']}")
asyncio.run(main())# Docker deployment (from host)
client = WebSocketClient(host="localhost", port=8004) # Docker WebSocket port
# Local installation
client = WebSocketClient(host="localhost", port=8003) # Local WebSocket portCC Executor works best as a prompt-based tool using cc_execute.md. After exploring MCP integration, we determined that the prompt-based approach is superior for this use case.
- Proven Reliability: 10:1 success ratio with prompt-based approach
- Simplicity: No additional servers, protocols, or dependencies
- Flexibility: Prompts can evolve and self-improve
- No Added Value: MCP would add complexity without solving real problems
If you need an orchestrator to use multiple tools (cc_execute, perplexity-ask, etc.), use structured prompts:
## Task Execution Plan
1. Implementation Phase:
- Use cc_execute.md: "Create a FastAPI app with user authentication"
- Timeout: 300s
- Tools: Read, Write, Edit, Bash
2. Research Phase:
- Use perplexity-ask: "Latest FastAPI security best practices"
3. Review Phase:
- Use Claude task tool: "Review the generated code"This gives you structure and flexibility without brittleness.
See MCP Evaluation Result for the full analysis.
- Configurable shell preference (zsh, bash, or system default)
- Defaults to zsh for consistency with Claude Code execution
- Ensures command parsing and environment behavior matches Claude's environment
- Eliminates shell-specific edge cases and improves reliability
- Automatically detects when Claude hits output token limits
- Provides adaptive retry strategies with more concise prompts
- Sends real-time notifications via WebSocket
- UUID4 anti-hallucination: Always enabled, no configuration needed
- Pre-execution hooks: Automatically inject UUID4 requirements
- Post-execution hooks: Verify UUID4 presence in outputs
- Transparent operation: Hooks run automatically with cc_execute
- Error recovery: Built-in retry logic (3 attempts)
- Each major directory has self-assessment capabilities
- Behavioral testing (not regex-based)
- Saves raw outputs to prevent AI hallucination
- Generates comprehensive markdown reports
- UUID4 verification prevents fabricated results
- JSON-RPC 2.0 based communication
- Streaming output support with 64KB chunking for large outputs
- Bidirectional error notifications
- Session management with Redis
- Proper subprocess buffer management (8MB limit)
PYTHONUNBUFFERED=1for real-time output streaming- Async streaming prevents memory accumulation
- Chunked WebSocket transmission for large outputs
- Configurable buffer limits and timeouts
Create a .env file in the project root:
# API Keys
ANTHROPIC_API_KEY=your_key_here
# Redis Configuration
REDIS_URL=redis://localhost:6379
# CC Executor Settings
CC_EXECUTOR_PORT=8003
CC_EXECUTOR_HOST=0.0.0.0
LOG_LEVEL=INFO
# Shell Configuration (optional)
CC_EXECUTOR_SHELL=zsh # Options: zsh, bash, default
# Defaults to zsh for Claude Code consistency
# Process Configuration (optional)
PYTHONUNBUFFERED=1 # Ensures real-time output streaming
STREAM_TIMEOUT=600 # Stream timeout in seconds (default: 10 minutes)
MAX_BUFFER_SIZE=8388608 # Max buffer size in bytes (default: 8MB)# Run all tests
uv run pytest
# Run usage function assessments
cc-executor test assess core
cc-executor test assess cli
cc-executor test assess hooks
# Run stress tests
cc-executor test stress --tasks 10 --parallel 2Create a new hook file in the hooks/ directory:
from cc_executor.hooks.hook_types import HookContext, HookResult
async def my_custom_hook(context: HookContext) -> HookResult:
# Your hook logic here
return HookResult(proceed=True, message="Hook executed")
# Register the hook
HOOKS = {
"pre_execution": [my_custom_hook]
}- No API access: Claude Max uses browser auth, API keys don't work
- Broken hooks: The hook system is completely non-functional
- No SDK support: The official SDK ignores Claude Max users entirely
- Can't automate: No way to integrate into workflows despite paying premium
- The
-pflag confusion: Claude CLI uses-pnot--print, but this isn't documented - Subprocess hanging: Direct subprocess calls to Claude often hang indefinitely
- Hook execution failures: Hooks don't run reliably when called programmatically
- No real SDK: No official Python SDK for Claude Code exists
- WebSocket-based architecture: Reliable bidirectional communication
- Proper subprocess management: Process groups, timeouts, and graceful termination
- Hook integration that works: Pre/post execution hooks run consistently
- Real streaming: Output streams in real-time, not after completion
- Claude Max compatible: Works with browser-authenticated Claude sessions
- Zsh Shell Support: Now uses zsh by default for consistency with Claude Code
- Configurable Shell: Environment variable
CC_EXECUTOR_SHELLfor shell preference - Memory Optimization: Improved streaming with proper buffer management
- Better Error Detection: Enhanced token limit and rate limit detection
- Project Cleanup: Reorganized ~400+ files for better maintainability
- Subprocess execution now uses
asyncio.create_subprocess_execwith explicit shell - 8MB buffer limits prevent memory issues with large outputs
- 64KB WebSocket chunking for reliable transmission
PYTHONUNBUFFERED=1ensures real-time output visibility
- Self-Contained Directories: Each directory has all its dependencies
- Clear Responsibilities: Each component has one clear purpose
- No Cross-Cutting Dependencies: Components don't reach across directories
- Behavioral Testing: Tests verify behavior, not implementation details
- Raw Output Saving: All components save outputs to prevent hallucination
- Shell Consistency: Use the same shell as Claude Code for reliability
- Follow the existing architecture patterns
- Add usage functions to all new Python files
- Create self-assessment prompts for new directories
- Save raw outputs in
tmp/responses/ - Use behavioral testing, not regex matching
GPL-3.0-or-later