Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions cowork-to-code-bridge/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
name: cowork-to-code-bridge
description: Connects Claude Cowork sandboxes and AI agents to Claude Code running on your local machine, enabling cloud agents to queue tasks and receive results through a shared async RPC bridge.
---

# cowork-to-code-bridge

An async file-based RPC bridge that lets Claude Cowork sessions (and any AI agent framework) queue work to Claude Code on your local machine and receive the results back — without polling, without webhooks, without a VPS.

The local daemon watches a bind-mounted bridge directory, executes queued tasks, and returns results. The cloud agent queues work and picks up results — fully decoupled, fully async.

## When to Use This Skill

- You want a Cowork agent (or any cloud-side AI) to run code, shell commands, or tool calls on your local machine
- You need a bridge between a sandboxed AI environment and your local Claude Code instance
- You are building multi-agent pipelines where one agent orchestrates work on a developer's machine
- You want fire-and-forget task queuing with automatic retry and idempotency guarantees

## What This Skill Does

1. **Queue tasks from the cloud**: A Cowork session or agent framework calls `queue_task()` with an `idempotency_key` — the daemon picks it up and runs it locally.
2. **Block-and-wait for fast tasks**: `call_remote()` blocks until the local daemon returns a result (best for tasks under ~30s).
3. **Post messages back**: `post_message_to_cowork()` lets the local Claude Code send status updates back to the cloud session.
4. **Detect incoming messages**: `detect_messages_from_claude_code()` lets the cloud side read those updates (idempotent, safe to poll).

## Installation

### Option A — Homebrew (recommended)

```bash
brew tap abhinaykrupa/tap
brew install cowork-to-code-bridge
brew services start cowork-to-code-bridge
```

### Option B — Install script

```bash
curl -fsSL https://raw.githubusercontent.com/abhinaykrupa/cowork-to-code-bridge/main/install.sh | bash
```

Set the shared bridge root (defaults to `~/cowork-bridge`):

```bash
export BRIDGE_ROOT=~/cowork-bridge
```

## How to Use

### Basic — blocking call (fast tasks)

```python
from cowork_to_code_bridge.client import call_remote

result = call_remote("run_tests", {"suite": "unit"})
print(result)
```

### Async — queue and poll (long tasks)

```python
from cowork_to_code_bridge.client import queue_task, poll_task_result

task_id = queue_task(
"deploy_staging",
{"branch": "main"},
idempotency_key="deploy-2026-06-19",
)

# Later — poll until done
result = poll_task_result(task_id)
```

### First-connection initialization

```python
from cowork_to_code_bridge.bridge_init import (
is_first_connection,
get_initialization_message,
get_bridge_context,
mark_bridge_initialized,
)

if is_first_connection():
print(get_initialization_message())
print(get_bridge_context())
mark_bridge_initialized()
```

## Example

**Scenario**: A CrewAI agent needs to run the local test suite and report results.

**Agent side (cloud)**:
```python
task_id = queue_task("pytest", {"args": "-x tests/"}, idempotency_key="ci-run-42")
```

**Daemon (local Mac/Linux)** picks it up, runs `pytest -x tests/`, and writes the result back.

**Agent polls**:
```python
result = poll_task_result(task_id)
# {"exit_code": 0, "stdout": "5 passed in 1.2s", "stderr": ""}
```

## Compatible Frameworks

Works as an MCP server or direct Python client with:

- **CrewAI** — agent tasks that need local execution
- **AutoGen** — multi-agent conversations with local tool calls
- **LlamaIndex** — RAG pipelines that index local files
- **LiteLLM** — model-agnostic agents bridging to local tools
- **Hermes** — orchestration workflows
- **n8n** — workflow automation via MCP server mode

## Full Documentation

https://github.com/abhinaykrupa/cowork-to-code-bridge
Loading