View .md

Offload heavy agent tests and builds from local worktrees.

Prefix any command with sx. Run test suites, Playwright browsers, typecheckers, linters, and formatters on an SSH box or scale-to-zero AWS Spot fleet—keeping your Mac cool while paying pennies per hour.

macOS $brew install daintreehq/tap/spotexec
Installs spotexec + sx alias · Linux (.deb/.rpm/.apk) & source →
~/code/my-app · wt/auth
$ sx pnpm vitest run -u src/auth.test.ts

 ✓ src/auth.test.ts (12 tests) 340ms
 ↳ 2 snapshots updated

● 4.1s on aws#3 · synced 4 files (18 KB) · pulled 2 files

$ sx pnpm prettier --write src/
src/auth.ts 42ms
src/session.ts 19ms
● 0.9s on homelab#1 · fingerprint hit (0 B) · pulled 2 files
Low Cost · 65–70% Spot Savings

Typical 2 vCPU / 4–8 GB Spot workers (t3a.large, c7a.large, m7a.large) run around $0.024–$0.038/hr—65–70% below On-Demand—and terminate to $0.00/hr when idle.

Run Far More Locally

Free your Mac from concurrent V8 heaps, TypeScript AST graphs, and headless Chromium workers. Run 4–8+ coding agents, your editor, and local dev servers side by side without swap thrashing.

Safe 3-Way Write-Back

Formatters, autofixes, and snapshot updates compare against the synced Git blob SHA-1. Edits made locally mid-run are never overwritten, and VMs hold zero AWS credentials.

01 / Why SpotExec Exists

Coding agents drove up CPU and memory—because they verify everything.

AI coding agents don't just edit text. To close the loop reliably, every Claude Code or Codex session constantly runs unit tests, end-to-end browsers, tsc --noEmit, linters, and code formatters. Running those verification loops across 4–6 parallel Git worktrees multiplies CPU spikes and multi-gigabyte memory footprints—slowing your entire machine down.

4 parallel coding agents verifying worktrees on a 32 GB MacBook Pro
Local memory & CPU pressure with and without SpotExec
Your MacBook Pro (32 GB) 3.6 / 32 GB · Cool & Instant
macOS + Editor + Browser (2.4 GB) git, rg, edits & localhost stay local (+1.2 GB)
wt/auth-refactor · Claude Code #1
rg "verifyToken" src/ → sx pnpm vitest run --coverage
180 MB
wt/checkout-e2e · Claude Code #2
edit e2e/checkout.spec.ts → sx pnpm playwright test (4x Chromium)
210 MB
wt/api-schema · Codex #1
git diff --stat → sx pnpm tsc --noEmit && pnpm eslint --fix .
165 MB
wt/worker-queue · Claude Code #3
vite dev (localhost:5173) → sx go test -race ./...
640 MB
Remote Capacity SSH ControlMaster
homelab (SSH · priority 10) 3/4 slots · $0/hr
● slot 1 · vitest --coverage wt/auth
● slot 2 · tsc && eslint wt/api
● slot 3 · go test -race wt/worker
aws/i-04a1 (c7a.2xlarge · Spot) $0.14/hr
● 4× Chromium E2E workers wt/checkout
Safe write-back: Formatted files and updated snapshots land back in each worktree via a 3-way content-ID check.
Transparent Claude Code Bash Hook

Install once with spotexec hook install --claude. Heavy verification commands rewrite to spotexec run -- '<cmd>' automatically, while git, rg, file reads, and localhost dev servers stay local.

Load-Gated Offloading (when_load_above = 0.6)

Keep single quick runs local when your laptop is quiet, and spill automatically to your SSH box or AWS Spot fleet the moment parallel agent worktrees push local CPU load above 60%.

02 / Why Spot Instances Work Here

Offload the heavy task, not the whole agent loop.

Running an entire coding agent workflow on Spot instances is fragile: if AWS reclaims the VM mid-session, your agent state and unpushed progress vanish. SpotExec flips the model. Your agents, Git worktrees, and editor stay safely on your Mac, while only the heavy individual task runs on Spot. If a VM gets reclaimed, nothing is lost—sx replays that single task on another slot and you keep the 65–70% Spot discount.

Whole Agent on Spot (Fragile)

Long-lived agent state, open shells, and in-progress edits live on a preemptible VM. A 2-minute Spot reclamation notice can interrupt an entire multi-step workflow.

Task-Level Offload with sx (Resilient)

Agents stay local on your Mac. Only stateless, repeatable checks (vitest, eslint, tsc, builds) run on 2 vCPU / 4–8 GB Spot VMs. Reclaimed mid-run? Re-dispatch on a fresh slot with zero lost work.

2 vCPU / 4–8 GB Worker Cost: On-Demand vs. Spot (us-east-1)
On-Demand AWS Spot
t3a.large 2 vCPU · 8 GB
68% off
On-Demand
$0.075/hr
Spot
~$0.024/hr
c6i.large 2 vCPU · 4 GB
67% off
On-Demand
$0.085/hr
Spot
~$0.028/hr
c7a.large 2 vCPU · 4 GB
66% off
On-Demand
$0.103/hr
Spot
~$0.035/hr
m7a.large 2 vCPU · 8 GB
67% off
On-Demand
$0.116/hr
Spot
~$0.038/hr
At ~$0.03/hr, running an entire afternoon of burst verification costs pennies—and drops to $0.00/hr after idle_timeout.
03 / Elastic Slots & Scale-to-Zero

Fill hardware you own first. Overflow to AWS Spot. Scale back to $0.00/hr.

Every sx invocation schedules cooperatively through local flock state. Static SSH boxes absorb baseline runs at zero marginal cost; Spot instances launch on overflow, pack jobs onto the oldest VMs first, and power themselves off when idle.

2 Spot VMs active Burn: $0.184/hr
~/.config/spotexec/config.toml Runner pool
version = 1
default_pool = ["homelab", "aws"]

[runners.homelab]
type = "ssh"
hosts = ["me@192.168.1.50", "me@box.ts.net"]
max_slots = 4
priority = 10        # fills first ($0/hr)

[runners.aws]
type = "aws-spot"
profile = "spotexec"
region = "us-east-2"
instance_types = ["c7a.xlarge", "c6a.xlarge"]
max_slots = 2
max_instances = 4
priority = 20        # takes overflow
idle_timeout = "10m" # self-terminates
homelab SSH · priority 10
4/4 slots active
● s1 · wt/auth: vitest
● s2 · wt/api: tsc
● s3 · wt/ui: eslint --fix
● s4 · wt/cli: go test
aws/i-04a1 (oldest) AWS Spot · c7a.xlarge
active · 0s idle
● s1 · wt/e2e: playwright #1
● s2 · wt/e2e: playwright #2
aws/i-08f2 (newest) AWS Spot · c7a.xlarge
active · 0s idle
● s1 · wt/billing: vitest
● s2 · wt/docs: build

Once all 4 homelab slots fill up, overflow demand boots two Spot instances automatically—coordinated locally via flock with zero cloud scheduler.

04 / Architecture & Failure Modes

Built for the edge cases skeptical engineers ask about first.

Click through each scenario below to inspect how spotexec handles concurrent local edits, closed laptop lids, and 2-minute AWS Spot reclamation notices.

4.1s end-to-end
Your Mac · Git Worktree

Single Go binary · Hand-signed AWS SigV4

1. .git/index SHA-1 manifest
2. Local flock pool.json & queue
6. Atomic 3-way SHA-1 write-back
Outbound RPC
SSH ControlMaster · missing-blob gzip tar
← Return Stream
Live stdout/stderr + file mutation list
Remote Runner (SSH or Spot VM)
Zero IAM credentials on VM
spotexec-helper
  • • Isolated slot process groups
  • • Reflink + S3 presigned deps
Autonomous Guards
  • • systemd idle → poweroff
  • • IMDSv2 5s Spot notice
lifecycle.lock: CoW reflink + S3 presigned cache
Git-blob delta sync → isolated slot execution → atomic 3-way write-back

Clean tracked files reuse SHA-1 blob IDs directly from .git/index without reading disk. Only blobs missing on the remote slot travel over the multiplexed SSH ControlMaster channel.

01 Your Mac (sx)

Reads .git/index SHA-1 blob IDs and hashes modified files into a manifest.

02 SSH ControlMaster

Acquires a slot lock and streams only missing blobs (0 bytes on repeat runs).

03 spotexec-helper

Hydrates node_modules / .venv via CoW reflink or S3, then runs the command.

04 3-Way Write-back

Applies formatter and snapshot updates atomically once baseline SHA-1 matches.

05 / Why Repeat Runs Feel Local

Delta sync, CoW reflinks, and baked AMIs

Instead of rsync or full container rebuilds, spotexec caches at three independent layers:

Worktree Sync (18k-file monorepo) 0 B on fingerprint hit
Repeat / clean
~12ms (.git/index SHA-1 reuse)
4 dirty files
~85ms (missing-blob tar)
Cold slot
1.8s (full gzip stream)
Dependency Hydration ([deps]) lockfile + image digest key
Same runner
<0.2s (XFS/Btrfs/APFS reflink)
New Spot VM
~3–6s (presigned S3 archive)
Lockfile miss
25–60s (runs install & caches)
AWS Spot Cold Start spotexec image bake
Warm VM slot
~15ms (SSH ControlMaster)
Baked AMI
~35–45s (bare EC2 boot)
Unbaked Ubuntu
~90–160s (boot + bootstrap)
06 / Security Boundaries

Strict isolation between untrusted repos, VMs, and your laptop

Every path, credential, and configuration key enforces a hard boundary:

1. Runner VMs hold zero AWS credentials

Spot instances launch with no IAM instance profile and enforce IMDSv2. S3 cache archives and ECR layers are accessed solely via short-lived presigned URLs generated on your workstation.

2. Cloned .spotexec.toml files cannot alter connections

Setting hosts, ssh_options, identity_file, profile, region, subnet_id, or cache_bucket inside a repo config is rejected as an error.

3. Write-back cannot escape the worktree or touch .git

Every returned path rejects symlinks, .. traversal, and any case-spelling of .git. Runners can only modify files that were in the synced manifest.

4. Per-machine IAM keys & isolated owner tags

spotexec setup creates a dedicated spotexec-<hostname> IAM user per laptop so a retired machine can be revoked cleanly without disrupting teammates.

07 / Get Started & Documentation

Up and running in three commands

Download single-file manual (/llms-full.txt) →
1. Set up your machine (once)
aws login
spotexec setup

Writes config.toml, provisions a scoped IAM key, and checks VPC & Spot vCPU quota.

2. Initialize your repository
cd ~/code/my-app
spotexec init && spotexec doctor

Detects lockfiles, [deps] caches, and test tasks; verifies end-to-end SSH & helper health.

3. Prefix with sx or hook agents
sx pnpm test
spotexec hook install --claude

Run directly from any worktree or let parallel coding agents offload heavy suites automatically.