Skip to main content
Glama

xclane

Native Swift macOS (macOS 15+) Xcode build coordinator for Antigravity, Claude Code, and OpenAI Codex: warm fixed-path build slots, Xcode GUI (windowtab-*) coordination, managed simulator pooling, and a built-in stdio MCP server.

Inspired by xcslot, rebuilt from the ground up in Swift 6 with zero third-party dependencies.

How xclane coordinates parallel agents and Xcode

Features

  • Warm build slots (~/Library/Developer/xclane, override via $XCLANE_HOME): Mirrors git worktrees via clonefile(2) at fixed paths so Xcode keeps incremental builds across parallel branches and agent worktrees.

  • 3-tier fast sync, split manifest & conflict-safe write-back: Reads .git/index directly using APFS nanosecond timestamps to bypass racy same-second git status re-hashing, separates lightweight slot metadata (state.json) from the per-file mirror table (manifest.json, skipping rewrites on unchanged syncs), and mirrors diffs via clonefile(2) across three tiers: stat hit -> Git blob OID hit (zero file reads across worktrees) -> 64 KB streaming compare for dirty and non-ignored untracked files (sync.includeIgnored defaults to ["*.xcconfig"]), keeping warm wrapper overhead around ~0.11–0.15s. After a command exits cleanly, write-back copies slot-created or modified files back to the source worktree while skipping any file edited concurrently in the worktree so live edits are never clobbered.

  • Kernel flock(2) locks & machine permit cap: Zero ps polling, zero stale locks on SIGKILL, and machine-wide concurrency permits (maxConcurrent) acquired before syncing so slots stay fresh.

  • Xcode GUI (windowtab-*) & headless MCP awareness: Coordinates with Xcode's open GUI window (windowtab-* via native Xcode MCP), active gui-lock cooperative leases (managed via xclane gui-lock or installed client hooks), configured external lockfiles, and live compiler/XCBBuildService/SWBBuildService activity owned by Xcode.app or Xcode 27's headless Xcode Service.app (xcrun mcp-server). When Xcode is busy, xclane waits until it finishes (up to waitSeconds, default 3600; pass --no-wait to fail immediately or --no-yield to override).

  • Build-flavor & dirty-tree slot selection: Ranks free slots by matching worktree + build flavor (scheme, configuration, destination, action, and build/cache settings), then warm matching-flavor slots from another worktree or detached slot (preferring matching cache mode over clobbering a different mode), then same worktree (different flavor), then unused (cold) slots, then detached/other warm slots. If the best warm matching slot is busy and the best free alternative is cold or a different worktree's flavor, xclane waits briefly (up to warmSlotWaitSeconds, default 60, scaled to the busy slot's last build duration) before falling back with a warning. Automatically caps -jobs when multiple xcodebuild permits are active concurrently.

  • Shared repo caches & multi-package workspaces: Supports .xcworkspace, local & remote SwiftPM dependencies, and -testPlan; reuses the user's shared SwiftPM cache (~/Library/Caches/org.swift.swiftpm via -packageCachePath); maintains a repo-level APFS SourcePackages snapshot (and reads Xcode's existing ~/Library/Developer/Xcode/DerivedData read-only) so Cold Slot 2 bootstraps offline even while Slot 1 is held busy; skips redundant network fetches (-skipPackageUpdates -onlyUsePackageVersionsFromResolvedFile) when Package.resolved matches; supports opt-in shared LLVM CAS (--cache or "enableCompilationCache": true, 10G cap via COMPILATION_CACHE_LIMIT_SIZE) with slot-root prefix mapping (SWIFT_OTHER_PREFIX_MAPPINGS / CLANG_OTHER_PREFIX_MAPPINGS, hitting up to 100% cross-slot compile tasks); and, when product handouts are requested (--products-to, -derivedDataPath, or SYMROOT/DSTROOT/BUILD_DIR/BUILD_ROOT/CONFIGURATION_BUILD_DIR), provides UUID-cached dsymutil handouts with <App>.dSYM/Contents/Resources/<UUID>.plist DBGSourcePathRemapping.

  • Workspace hygiene: Ignores ephemeral Xcode user state (xcuserdata, .DS_Store) on untracked sync and write-back while preserving genuine generated files like Package.resolved.

  • Bounded storage & physical size reporting: Caps active per-repo slots (1..slots), expires dormant slots idle longer than slotIdleDays (default 30 days), detaches slots whose linked worktree was deleted (git worktree remove) and clears their DerivedData after 24h idle, runs lazy daily housekeeping (at most once every 24h during xclane invocations, or on demand via xclane slots prune — no background daemon) to prune stale .dSYMs, old logs, oversized CAS, and idle simulators, and reports physical APFS allocation via xclane status --sizes.

  • Zero-config fast builds (on by default in 0.5+) & --fast-agent: Automatically injects COMPILER_INDEX_STORE_ENABLE=NO (override with --index-store), shares Apple SDK MODULE_CACHE_DIR, SDK_STAT_CACHE_DIR, and SDK_EXPLICIT_MODULES_OUTPUT_PATH across all slots and repos in <root>/shared-sdk (opt out with --no-shared-sdk-caches), and scopes generic/platform=*Simulator builds on Apple Silicon to ONLY_ACTIVE_ARCH=YES ARCHS=arm64 (unless ONLY_ACTIVE_ARCH=, ARCHS=, or -arch is passed). For rapid agent iteration loops, add --fast-agent (skips dSYMs, debug dylib wrapping, stdlib tool copy, and product validation while keeping XCTest and Swift Testing file:line diagnostics intact). Automatically bypassed on archive, install, exportArchive, clean, and analyze.

  • Managed simulator pool, async pre-boot, slim clones & diff-aware/weighted testing: Lazily clones matching Shutdown baseline simulators into xclane-<Device>-<n> devices (falling back to simctl create when matching baselines are Booted) for test runs, starts background simctl boot immediately when leased to overlap simulator boot with compilation, prefers already-Booted clones on subsequent runs, locks explicit -destination id=<UDID> test runs with flock(2), and prunes idle clones. Run xclane sim slim --all (or set "simPool": { "slimClones": true }) to disable 65 non-essential background daemons while protecting com.apple.gamed. Pass --affected (or --affected-base <ref>) to walk XCBuildData/PIFCache reverse dependencies and run only impacted test targets (skipping test execution in ~0.07s when no test targets are impacted, falling back safely on manifest/config/unmapped source edits). With --shards N (or shards: N in xclane_test), xclane builds once (build-for-testing), enumerates XCTest + Swift Testing identifiers, balances suites via EMA duration-weighted LPT bin packing (test-timings.json), and fans test-without-building across up to N isolated simulator clones concurrently.

  • Background slot pre-warming (xclane slots warm): Automatically persists portable replay args (lastBuildArgs) after successful builds so idle spare slots can be pre-warmed ahead of parallel agent work (xclane slots warm --if-idle --background or MCP xclane_slots action: "warm"). Skips busy or already-warm slots at HEAD, throttles CPU/I/O with taskpolicy -c utility -d throttle (--low-priority), and stops automatically if an active build or Xcode GUI session starts.

  • Build diagnostics & SQLite forensics (xclane doctor --profile): Inspects XCBuildData/build.db (slowest tasks in the latest build iteration), detects .xcbuilddata bloat with actionable recommendations, and prunes stale .xcbuilddata bundles automatically during daily housekeeping / xclane slots prune.

  • Stall watchdog: Detects silent/flat-CPU wedged builds across descendant process trees and terminates them cleanly with build_stalled (exit code 116; default stallTimeoutSeconds: 300, 0 disables).

  • Native stdio MCP server & multi-client plugins: xclane mcp exposes xclane_build, xclane_test (with shards, affected, affectedBase, fastAgent, indexStore, noSharedSDKCaches), xclane_run (each supporting background: true for long builds), xclane_job (inspect/wait/cancel background jobs), xclane_status, xclane_slots (list, remove, prune, warm), xclane_sim (list, prune, slim), and xclane_doctor (with checkEnv, profile).

Xcode 27.3 and xclane solve different layers

Related MCP server: XCAutokit

Benchmarks (Xcode 27.2 / Apple M1 Pro)

Measured on mastodon/mastodon-ios (f3dc8d3, 1,351 compiled Swift files, MastodonSDK + remote SwiftPM packages) as well as two reproducible fixture suites: WorkApp (55-file multi-package .xcworkspace with 4 chained local SwiftPM packages, 1 remote dependency, and WorkSmoke.xctestplan) and BenchApp (63-file SwiftUI .xcodeproj + unit test target). See docs/benchmarks.md for full methodology and storage breakdown.

Cross-worktree build speedups with xclane

Workload

Result

Highlight

v0.5.0 zero-config on mastodon-ios (1,351 Swift files, generic simulator)

113.21s Cold S1 / 69.78s Cold S2 / 13.95s 1-file edit

vs 211.37s S1 / 232.96s S2 / 21.53s v0.4.0 baseline (1.87x–3.34x faster cold, -60% per-slot DerivedData)

v0.5.0 --fast-agent on mastodon-ios (1,351 Swift files)

87.91s Cold S1 / 67.72s Cold S2

2.40x–3.44x faster cold, 1.28 GB per-slot DerivedData (-63.4% disk)

--affected selective testing (multi-target BenchMulti)

6.08s leaf change / 0.07s docs-only (vs 12.83s full warm)

Scopes via PIFCache (FeatureUITests only); skips 0-impact doc diffs completely

History-weighted --shards 2 (skewed 11-test / 5-suite suite)

16.99s Run 2 (shard workers [10.07s, 10.04s])

EMA timings fix Run 1 imbalance ([8.39s, 28.92s] -> 0.03s spread, 2.87x max-shard win)

xclane sim slim (65 background daemons disabled, com.apple.gamed kept)

22.30s first-boot test vs 34.88s stock clone

1.56x faster (-36.1%) fresh simulator boot + 3.67s warm Run 2 parity

mastodon-ios fresh worktree (wt-2a / wt-2b in warm Slot 1)

14.71s / 8.43s (vs 120.11s plain cold)

0 synced, 0 compiled (8.2x–14.2x faster; 19.13s for a 1-file ShareActivityProvider.swift edit)

mastodon-ios cold Slot 2 (wt-3 with opt-in --cache CAS)

58.37s vs 110.17s no-CAS (120.11s plain cold)

1,823 / 1,823 (100%) CAS task hits via *_OTHER_PREFIX_MAPPINGS (2.06x faster than plain cold)

mastodon-ios 2 parallel worktree builds (wt-1 + wt-2a)

25.02s wall clock

Distinct slots 2 & 1 concurrently (-jobs auto-capped, 0 errors)

WorkApp .xcworkspace cross-worktree SPM edit (wt-2 in warm Slot 1)

3.94s (vs 13.63s plain cold)

2 synced files, 3 compiled Swift files (3.46x faster)

BenchApp 12-test / 6-suite sharded test run (--shards 3 vs --shards 1)

18.61s vs 28.88s (12/12 passed)

Shard execution [12.26s, 12.42s, 12.56s] (2.24x faster shard time; 1.55x faster end-to-end)

WorkApp .xcworkspace Agent 2 hitting xclane slots warm Slot 2

3.99s (vs 13.08s cold Slot 3)

Pre-warmed Slot 2 at utility QoS; 2 synced / 2 compiled (3.28x faster)

Install

Requirements: macOS 15+, Xcode, and a git repository (building from source also requires Swift 6 / swift-tools-version: 6.0).

brew install stefanoshea/tap/xclane
xclane plugin install --client all

Quick install script (prebuilt Apple Silicon binary)

curl -fsSL https://raw.githubusercontent.com/stefanoshea/xclane/main/scripts/install.sh | sh
xclane plugin install --client all

Or run both in one command: curl -fsSL https://raw.githubusercontent.com/stefanoshea/xclane/main/scripts/install.sh | sh -s -- --client all (make sure ~/.local/bin is on your PATH).

Build from source

git clone https://github.com/stefanoshea/xclane.git
cd xclane
swift build -c release
.build/release/xclane plugin install --client all

Client integrations

--client accepts antigravity (default), claude, codex, or all. The binary embeds the plugin bundle so xclane plugin install works standalone without a local checkout. For source/script installs, it installs ~/.local/bin/xclane (Homebrew installs keep /opt/homebrew/bin/xclane authoritative), registers the MCP server/skills/rules, and installs PreToolUse/PostToolUse hooks (which intercept raw xcodebuild commands to route through xclane and automatically acquire/release xclane gui-lock around native Xcode MCP build/test calls):

  • Antigravity: ~/.gemini/config/plugins/xclane (MCP server, skill, rules, lifecycle hooks)

  • Claude Code: ~/.claude.json (mcpServers.xclane), ~/.claude/skills/xclane/SKILL.md, and ~/.claude/settings.json (PreToolUse/PostToolUse hooks)

  • OpenAI Codex: ~/.codex/config.toml ([mcp_servers.xclane]), ~/.codex/skills/xclane/SKILL.md, and ~/.codex/hooks.json

Or register the MCP server manually (for Antigravity, use xclane plugin install --client antigravity):

claude mcp add -s user xclane -- xclane mcp
codex mcp add xclane -- xclane mcp

To remove installed client integrations cleanly (without touching other MCP servers or hooks), run xclane plugin uninstall --client all (pass --remove-binary if installed via script/source; Homebrew users run brew uninstall xclane).

Quick Start

xclane flags (--no-yield, --cache, --no-cache, --no-wait, --products-to <dir>, --summary, --json, etc.) go before xcodebuild arguments (xclane xcodebuild [xclane-opts] <xcodebuild-args...>):

# Build in a warm slot (auto-reuses shared SwiftPM cache + APFS SourcePackages snapshot)
xclane xcodebuild -workspace App.xcworkspace -scheme App -destination 'generic/platform=iOS Simulator' build

# Run tests on an automatically cloned & locked simulator
xclane xcodebuild -workspace App.xcworkspace -scheme App -testPlan UnitSmoke -destination 'platform=iOS Simulator,name=iPhone 18 Pro' test

# Run fast agent verification (skips dSYMs/debug dylibs/validation)
xclane xcodebuild --fast-agent -workspace App.xcworkspace -scheme App -destination 'generic/platform=iOS Simulator' build

# Run only test targets impacted by uncommitted / branch changes (via PIFCache)
xclane xcodebuild --affected -workspace App.xcworkspace -scheme App -destination 'platform=iOS Simulator,name=iPhone 18 Pro' test

# Slim managed simulator clones (disables 65 background daemons while keeping com.apple.gamed)
xclane sim slim --all

# Build once (build-for-testing) and fan tests across 3 isolated simulator clones in parallel
xclane xcodebuild --shards 3 -workspace App.xcworkspace -scheme App -destination 'platform=iOS Simulator,name=iPhone 18 Pro' test

# Pre-warm Slot 2 in the background while idle using low-priority utility QoS
xclane slots warm --if-idle --background

# Run an arbitrary command inside a synced warm slot (with write-back)
xclane run -- swift test

# Inspect permits, GUI status, slots, simulators, and physical APFS disk usage
xclane status --sizes --json

# Check toolchain, git repo, build.db profile + .xcbuilddata bloat, and sanitized env stability
xclane doctor --env --profile

Build Performance Tips

  • Zero-config v0.5.0 optimizations (automatic on build/test/build-for-testing): By default, xclane injects COMPILER_INDEX_STORE_ENABLE=NO, shares Apple SDK MODULE_CACHE_DIR / SDK_STAT_CACHE_DIR / SDK_EXPLICIT_MODULES_OUTPUT_PATH across all slots/repos under <root>/shared-sdk, and narrows generic/platform=*Simulator builds on Apple Silicon to ONLY_ACTIVE_ARCH=YES ARCHS=arm64. All optimizations are skipped automatically on archive, install, exportArchive, clean, and analyze. Override any setting individually with --index-store, --no-shared-sdk-caches, or explicit ONLY_ACTIVE_ARCH=NO / ARCHS=... / -arch ....

  • --fast-agent mode: Adds GCC_GENERATE_DEBUGGING_SYMBOLS=NO, ENABLE_DEBUG_DYLIB=NO, VALIDATE_PRODUCT=NO, and DONT_RUN_SWIFT_STDLIB_TOOL=YES, cutting Cold Slot 1 on mastodon-ios to 87.91s (2.40x faster than baseline) while preserving XCTest and Swift Testing file:line failure diagnostics.

  • Opt-in shared LLVM compilation cache (--cache / "enableCompilationCache": true): Off by default (false) because LLVM CAS adds ~14s on Slot 1 cold, ~1.8s on small incremental edits, and ~2.5 GB of disk on mastodon-ios; pass --cache (or set "enableCompilationCache": true in config) when running multi-slot builds across parallel agents (SWIFT_OTHER_PREFIX_MAPPINGS / CLANG_OTHER_PREFIX_MAPPINGS map <slotDir>=/^slot, delivering 93–100% cross-slot CAS task hits and cutting Cold Slot 2 in half). Passing --no-cache injects COMPILATION_CACHE_ENABLE_CACHING=NO and omits COMPILATION_CACHE_CAS_PATH, disabling compile caching even when enabled in .pbxproj build settings (and updating the build flavor hash so switching cache modes on the same scheme reports flavorSwitched: true).

  • Stick to one cache mode per repo (and use --slot <n> when pinning): Default mode and --cache produce distinct build flavors. Switching modes in the same slot triggers a full rebuild and keeps outputs for both modes inside that slot's DerivedData (roughly doubling per-slot disk usage). Pick one mode per repository — either keep the default or set "enableCompilationCache": true / always pass --cache — and pass --slot <n> if you explicitly want to pin a build to a separate slot.

  • Shared compilation cache cap: When CAS is enabled, xclane passes COMPILATION_CACHE_LIMIT_SIZE=10G (compilationCacheLimitMB), which Xcode enforces across builds. During xclane slots prune and daily housekeeping (when no slot in the repo is held), xclane runs llvm-cas --prune whenever the cache exceeds 1× compilationCacheLimitMB, and only resets the CAS as a safety valve if it still exceeds 2× compilationCacheLimitMB after pruning (reporting cacheReset: true in BuildSummary and printing the action in status output). On SIGINT/SIGTERM, xclane forwards the signal to xcodebuild and waits up to 5s before escalating so active compilers can finish their CAS writes.

Configuration

User config lookup order: $XCLANE_CONFIG -> $XDG_CONFIG_HOME/xclane/config.json -> ~/.config/xclane/config.json. Override the slots root directory with $XCLANE_HOME or root. Defaults:

{
  "slots": 3,
  "maxConcurrent": 3,
  "waitSeconds": 3600,
  "warmSlotWaitSeconds": 60,
  "stallTimeoutSeconds": 300,
  "enableCompilationCache": false,
  "compilationCacheLimitMB": 10240,
  "disableIndexStore": true,
  "shareSDKCaches": true,
  "singleArchSimulator": true,
  "fastAgentMode": false,
  "slotIdleDays": 30,
  "yieldToXcodeGUI": true,
  "simPool": {
    "autoLease": true,
    "maxClones": 3,
    "idleDays": 7,
    "slimClones": false
  }
}
  • slots: 3 active slots per repo

  • maxConcurrent: 3 concurrent builds machine-wide

  • warmSlotWaitSeconds: 60 max seconds to wait for a busy warm matching slot (scaled to its last commandSeconds) before falling back to a cold/other-flavor slot (0 disables waiting)

  • stallTimeoutSeconds: 300 idle seconds before build_stalled (0 disables)

  • enableCompilationCache: false (set true or pass --cache for opt-in shared LLVM CAS)

  • compilationCacheLimitMB: 10240 (10G via COMPILATION_CACHE_LIMIT_SIZE)

  • disableIndexStore: true (injects COMPILER_INDEX_STORE_ENABLE=NO; override with --index-store)

  • shareSDKCaches: true (shares MODULE_CACHE_DIR, SDK_STAT_CACHE_DIR, and SDK_EXPLICIT_MODULES_OUTPUT_PATH under <root>/shared-sdk)

  • singleArchSimulator: true (uses ONLY_ACTIVE_ARCH=YES ARCHS=arm64 on Apple Silicon generic/platform=*Simulator builds)

  • fastAgentMode: false (set true or pass --fast-agent to skip dSYMs/debug dylibs/validation/stdlib copy)

  • slotIdleDays: 30 days before dormant slots are pruned

  • simPool: autoLease leases clones on test runs; maxClones: 3 caps clones per (device, runtime) baseline; idleDays: 7; slimClones: false (true auto-slims newly created clones)

  • yieldToXcodeGUI: true (yields to both Xcode.app and headless Xcode Service.app)

Per-Repo .xclane.json

Optional .xclane.json at the repository root customizes gitignored file mirroring, cached prepare generators (pod install, xcodegen, tuist), and default simulator targets. Even without .xclane.json, sync.includeIgnored defaults to ["*.xcconfig"] and Tuist.swift / Tuist/ projects are auto-detected for prepare. prepare commands run inside the slot worktree (skipping when hashed file/directory inputs are unchanged and declared outputs exist, preserving unchanged output mtimes; newly generated or modified files follow normal write-back), and sim provides defaults when -destination omits device/OS:

{
  "sync": {
    "includeIgnored": ["*.xcconfig", "App/Secrets.plist"]
  },
  "prepare": [
    {
      "name": "xcodegen",
      "run": ["xcodegen", "generate"],
      "inputs": ["project.yml", "Specs"],
      "outputs": ["App.xcodeproj"]
    }
  ],
  "sim": {
    "deviceName": "iPhone 18 Pro",
    "osVersion": "27"
  }
}

Locked Slot Worktrees & Cleanup

Each xclane slot registers a locked detached git worktree under ~/Library/Developer/xclane/<repo>-<hash>/slots/<n>/src so git worktree prune will not erase warm build caches.

  • Inspect slots and physical APFS disk usage: xclane status --sizes

  • Cleanly remove slots (unlocks the git worktree first, deletes the slot atomically, and runs git worktree prune):

    xclane slots remove --all --yes
  • Prune orphan repos, dormant slots, stale .dSYMs, old logs, oversized CAS, and idle simulators on demand: xclane slots prune

  • If you ever delete ~/Library/Developer/xclane manually by hand, clean up any remaining locked worktree entries in your repo with:

    git worktree list
    git worktree unlock <missing-slot-path> && git worktree prune

Testing, Evals & Benchmarks

Build .build/release/xclane (swift build -c release) before running the Python eval or benchmark scripts:

swift test                                                     # Unit & integration tests
python3 scripts/run-evals.py --bin .build/release/xclane       # Fast sandboxed CLI, MCP, hook & security evals
python3 scripts/run-live-xcode-evals.py --bin .build/release/xclane  # Real Xcode + simulator integration evals
python3 scripts/run-benchmarks.py --bin .build/release/xclane  # Reproduces the benchmark table

Learnings

See docs/LEARNINGS.md for verified findings and fixes from dogfooding xclane on macOS 27 / Xcode 27 / Antigravity.

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Provides programmatic access to Xcode functionality, enabling AI assistants to create, build, test, and manage iOS/macOS projects directly.
      33
      6
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      First-party MCP server and CLI for Xcode and iOS Simulator automation. Enables control of Xcode and iOS Simulator via MCP tools for tasks like building, testing, and automation.
      9 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Connects AI coding clients like OpenCode, Codex, and Claude Code to Xcode and Apple development tools, enabling builds, tests, simulator and device management, profiling, asset handling, and more through natural language.
      78 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables multiple AI agent sessions to share a single Mac's Apple Simulator pool through one shared daemon that tracks leases and auto-dispatches freed simulators to the next waiting caller. It provides simulator UI automation, app lifecycle, profiling, live streaming, crash debugging, and HTTPS interception tools, all gated to the lease holder.
      21 npm
      MIT