Skip to main content
Glama

CortexHands

Let frontier AI models think & review. Let cheap CLI & API agents do the hands-on coding — safely inside isolated Git worktrees.

CI License: MIT Node.js MCP

English | 简体中文 | Architecture & Interview Guide | WorkBuddy Setup | Launch Posts


Why CortexHands?

Frontier reasoning models (Google Antigravity, Claude Code, Codex, Cursor) are expensive and rate-limited — burning their quota on boilerplate edits, test-fix loops, and multi-file exploration hurts. On the other hand, cheap or free coding workers (Tencent WorkBuddy / CodeBuddy, DeepSeek, Ollama, OpenCode, Aider) have generous quota, but left unsupervised they can edit unrelated files, break tests, or pollute your working branch.

CortexHands is a cross-platform Planner-Executor-Reviewer MCP Orchestrator (v0.2.0) that combines the best of both worlds:

  • Git Worktree Sandbox: Every delegated task runs in .cortex-hands/worktrees/<taskId> on its own branch — your main branch is never touched until you approve. Supports squash / merge / patch-only delivery and one-click rollback (abort_task).

  • Parallel Multi-Worktree Batching (dispatch_batch): Run 2–5 disjoint subtasks concurrently in separate isolated worktrees with bounded concurrency and pre-flight scope-overlap warnings.

  • Scope Guard + Auto-Detect Quality Gate: Enforce allowedPaths glob whitelists (with !exclusions), block sensitive files (.env, *.key, *.pem) by default, auto-detect project test/typecheck commands (Node / Go / Rust / Python), and return a token-compressed Review Packet instead of noisy raw logs.

  • Same-Session Rework + Circuit Breaker: Rejections via request_rework resume the worker's existing session (--resume <sessionId>) in the same worktree, capped by maxRounds to stop infinite retry loops.

  • First-Class Windows & macOS WorkBuddy 5.11.3 Support: Auto-discovers WorkBuddy via Windows Registry / common drives / macOS app bundles, handles WorkBuddy 5.11.3 codebuddy-lite-wb.mjs routing (CODEBUDDY_FORCE_LITE_WB_BUNDLE=1), and kills Windows process trees cleanly (taskkill /T /F) so zero zombie locks remain.

  • Built-in Sandboxed OpenAI-Compatible Worker (openai-api): Works out-of-the-box with DeepSeek, Ollama, SiliconFlow, OpenRouter, or any /v1/chat/completions endpoint — with worktree path-traversal protection and multi-round session memory.

  • Zero-Dependency Local Observability Dashboard: Run cortex-hands dashboard to inspect live tasks, Scope Guard alerts, color-highlighted diffs, and token savings in your browser (127.0.0.1:3847).

  • Native Antigravity Plugin + Standard MCP: Ships both a ready-to-install Antigravity plugin (MCP + workflow SKILL.md + rules/AGENTS.md) and standard stdio MCP configs for Claude Code, Cursor, and Codex.


Related MCP server: cheap-agent-codex

Architecture

flowchart LR
    Planner["Frontier Planner & Reviewer\n(Antigravity / Claude Code / Codex)"]
    MCP["CortexHands MCP Server\n(9 tools over stdio)"]
    Core["Orchestrator State Machine\n• Parallel Git Worktree Sandbox\n• Scope Guard & Auto-Detect Gate\n• Diff Compressor & Circuit Breaker\n• Live Dashboard & Telemetry"]
    Worker["Pluggable Cheap Workers\n• WorkBuddy CLI (Win/macOS)\n• OpenAI-API (DeepSeek/Ollama)\n• Generic CLI (OpenCode/Aider)"]

    Planner -->|"1. dispatch_task / dispatch_batch"| MCP
    MCP --> Core
    Core -->|"2. isolated worktree(s)"| Worker
    Worker -->|"3. edits + self-test"| Core
    Core -->|"4. compressed Review Packet"| Planner
    Planner -->|"5a. request_rework (--resume)"| MCP
    Planner -->|"5b. approve_and_merge / abort_task"| MCP

Quick Start (60 Seconds)

1. Try the Zero-Cost End-to-End Demo & Live Dashboard

No API key or quota required — watches a full Round 1 scope violation + failing test -> automated interception -> Round 2 rework fix -> squash merge -> telemetry report in 3 seconds:

git clone https://github.com/DuskstarXiao/cortex-hands.git
cd cortex-hands
npm install && npm run build
node dist/index.js demo --persist
node dist/index.js dashboard

2. Run Environment Doctor

Checks Node.js, Git, WorkBuddy CLI auto-discovery, OpenAI/Generic workers, and Antigravity plugin status:

node dist/index.js doctor

If WorkBuddy headless CLI reports Authentication required, sign in once interactively:

node dist/index.js login-workbuddy
# Inside the prompt, run /login once, then /exit

3. Install into Antigravity (One Command)

node dist/index.js init --target antigravity

This installs the complete Antigravity Plugin (MCP server + cortex-hands-workflow skill + rules) into ~/.gemini/config/plugins/cortex-hands/.

For other MCP clients:

node dist/index.js init --target claude   # Claude Code
node dist/index.js init --target cursor   # Cursor
node dist/index.js init --target codex    # OpenAI Codex CLI

MCP Tools Reference (9 High-Cohesion Tools)

Tool

Role

Purpose

dispatch_task

Planner

Creates an isolated Git worktree, injects the execution contract, runs the worker, and executes automated gates

dispatch_batch

Planner

Executes 1–5 independent subtasks concurrently across separate Git worktrees with scope-overlap warnings

get_task_status

Planner

Polls live status, round number, and recent worker events (for async: true runs)

get_review_packet

Reviewer

Returns Scope Guard findings, compressed gate test summaries, diff stat, and bounded unified diff

request_rework

Reviewer

Rejects output and sends targeted comments back to the same worktree & worker session (--resume), guarded by maxRounds circuit breaker

approve_and_merge

Reviewer

Blocks merge if gate failed (unless forced), cleanly merges via squash / merge / patch-only, and cleans up the worktree

abort_task

Reviewer

Terminates the worker process tree safely and removes the temporary worktree & branch

list_tasks

Utility

Lists recent tasks and available worker adapters

get_telemetry_report

Analytics

Reports first-pass approval rate, avg rounds, context compression ratio, and estimated planner tokens saved


Pluggable Workers & .cortex-hands.json

Option A: Tencent WorkBuddy (Default, Zero API Key)

Auto-discovered on Windows (5.11.3+) and macOS. See docs/WORKBUDDY_SETUP.md.

Option B: Built-in Sandboxed OpenAI-Compatible API (worker: "openai-api")

Works with DeepSeek, local Ollama, SiliconFlow, OpenRouter, Moonshot/Kimi, Zhipu, etc.:

export CORTEX_HANDS_OPENAI_BASE_URL="https://api.deepseek.com/v1"   # or http://127.0.0.1:11434/v1
export CORTEX_HANDS_OPENAI_MODEL="deepseek-chat"                    # or qwen2.5-coder:14b
export CORTEX_HANDS_OPENAI_API_KEY="sk-..."                         # optional for Ollama

Option C: Any Local CLI (worker: "generic-cli")

export CORTEX_HANDS_GENERIC_CLI_CMD="opencode run {prompt}"

Optional Repo Defaults (.cortex-hands.json)

{
  "defaultWorker": "workbuddy",
  "maxRounds": 3,
  "autoDetectGates": true,
  "allowedPaths": ["src/**", "tests/**"],
  "mergeStrategy": "squash"
}

Development & Verification

npm run typecheck   # Strict TypeScript checking
npm run build       # Bundle single-file ESM CLI via tsup
npm test            # 17 unit + real Git worktree + dashboard + MCP JSON-RPC tests

Compliance Notice

CortexHands strictly invokes official user-installed CLIs, user-supplied standard APIs, and open protocols (MCP / Git). It does not reverse-engineer private APIs, extract browser cookies, bypass rate limits, or automate multi-account farming.

License

MIT

Available Tools

9 tools
abort_taskA

Cancel a running or pending task, terminate its worker process tree safely, and remove its isolated Git worktree without touching the main branch.

Inputs: taskId (required), reason.

approve_and_mergeA

Approve the reviewed worktree changes, merge them cleanly into the repository (or export a patch), and clean up the temporary Git worktree.

Inputs: taskId (required), commitMessage, mergeStrategy, forceWithoutGatePass.

dispatch_batchA

Dispatch multiple independent subtasks concurrently across separate isolated Git worktrees (bounded concurrency pool + pre-flight scope overlap warnings). Ideal for parallelizing disjoint modules or tests.

Inputs: tasks (required), repoPath (required), defaultModel, defaultWorker, +1 more.

dispatch_taskA

Dispatch a bounded coding task to a cheap/local execution worker (e.g. WorkBuddy) inside an isolated Git worktree. Automatically runs Scope Guard and gate commands before returning a compressed Review Packet to save planner tokens.

Inputs: title (required), prompt (required), repoPath (required), acceptanceCriteria (required), +9 more.

get_review_packetA

Fetch the token-compressed Review Packet (Scope Guard results, gate test summaries, diff stat, and bounded git diff) for planner review.

Inputs: taskId (required), maxDiffLines.

get_task_statusA

Inspect the live status, round progress, and recent events of a dispatched task.

Inputs: taskId (required).

get_telemetry_reportB

Generate a Markdown cost-savings and quality-gate report showing context compression ratio, estimated planner tokens saved, first-pass approval rate, and caught violations.

Inputs: range.

list_tasksB

List recent CortexHands tasks and available workers so the planner can resume pending reviews or check active runs.

Inputs: limit.

request_reworkA

Reject the worker output and send targeted review comments back to the SAME worktree and worker session (--resume). Automatically enforces the maxRounds circuit breaker.

Inputs: taskId (required), reviewComments (required), async, focusFiles, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 9 tools

    Disambiguation4/5

    Each tool maps to a distinct lifecycle step (dispatch, status, review, rework, merge, abort, telemetry), so the core set is easy to tell apart. The only real overlaps are dispatch_task vs dispatch_batch and list_tasks vs get_task_status, which descriptions do resolve but still require reading.

    Naming Consistency4/5

    All names are snake_case and verb-first (get_, list_, dispatch_, abort_, request_, approve_), giving a predictable pattern. approve_and_merge is the one compound outlier, and the get_ prefix is used for three different resource types, but overall it reads consistently.

    Tool Count5/5

    Nine tools is well within the ideal band and every tool corresponds to a meaningful workflow step: orchestration, monitoring, review, remediation, cleanup, and reporting. Nothing feels padded or missing in count terms.

    Completeness4/5

    The dispatch-to-merge lifecycle is fully closed: single and batch dispatch, status polling, review packet retrieval, rework with a round circuit breaker, approval/merge, and abort with cleanup, plus telemetry. Minor gaps remain, such as standalone worker management or deeper raw log retrieval for failed runs, but core workflows have no dead ends.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables multiple AI coding CLIs (Claude Code, Gemini/Antigravity, Codex, and OpenCode) to collaborate as a coordinated team by routing cross-agent prompts, sharing messages and review tickets, tracking tasks on a shared store, and isolating each agent in its own Git worktree with turn-budget safeguards—all inspectable and steerable from a local web dashboard.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to spawn, parallelize, and synchronize multi-agent programming swarms through a stdio MCP interface. Provides tools for DAG-scheduled task dispatch, isolated Git worktree execution, atomic file locking, shared blackboard memory, and clean merging of completed agent work back to the main repository.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables an orchestrating agent to delegate tasks to Codex, Claude, or Gemini worker CLIs running in isolated git worktrees, then wait on jobs, inspect per-file diffs, and merge or discard the resulting changes before anything touches the working tree.
      1
      MIT