
xclane
io.github.stefanoshea/xclane
Warm Xcode build lanes, shared LLVM CAS, and managed simulator pooling for AI agents
Documentation
xclane
Native Swift macOS (macOS 15+) Xcode build coordinator for Antigravity, Claude Code, and OpenAI Codex: warm fixed-path build lanes, 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.

Features
- Warm build lanes (
~/Library/Developer/xclane, override via$XCLANE_HOME): Mirrors git worktrees viaclonefile(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/indexdirectly using APFS nanosecond timestamps to bypass racy same-secondgit statusre-hashing, separates lightweight lane metadata (state.json) from the per-file mirror table (manifest.json, skipping rewrites on unchanged syncs), and mirrors diffs viaclonefile(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.includeIgnoreddefaults to["*.xcconfig"]), keeping warm wrapper overhead around~0.11–0.15s. After a command exits cleanly, write-back copies lane-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: Zeropspolling, zero stale locks onSIGKILL, and machine-wide concurrency permits (maxConcurrent) acquired before syncing so lanes stay fresh. - Xcode GUI (
windowtab-*) & headless MCP awareness: Coordinates with Xcode's open GUI window (windowtab-*via native Xcode MCP), activegui-lockcooperative leases (managed viaxclane gui-lockor installed client hooks), configured external lockfiles, and live compiler/XCBBuildService/SWBBuildServiceactivity owned byXcode.appor Xcode 27's headlessXcode Service.app(xcrun mcp-server). When Xcode is busy,xclanewaits until it finishes (up towaitSeconds, default3600; pass--no-waitto fail immediately or--no-yieldto override). - Build-flavor & dirty-tree lane selection: Ranks free lanes by matching worktree + build flavor (scheme, configuration, destination, action, and build/cache settings), then warm matching-flavor lanes from another worktree or detached lane (preferring matching cache mode over clobbering a different mode), then same worktree (different flavor), then unused (
cold) lanes, then detached/other warm lanes. If the best warm matching lane is busy and the best free alternative is cold or a different worktree's flavor,xclanewaits briefly (up towarmLaneWaitSeconds, default60, scaled to the busy lane's last build duration) before falling back with a warning. Automatically caps-jobswhen multiplexcodebuildpermits 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.swiftpmvia-packageCachePath); maintains a repo-level APFSSourcePackagessnapshot (and reads Xcode's existing~/Library/Developer/Xcode/DerivedDataread-only) so Cold Lane 2 bootstraps offline even while Lane 1 is held busy; skips redundant network fetches (-skipPackageUpdates -onlyUsePackageVersionsFromResolvedFile) whenPackage.resolvedmatches; supports opt-in shared LLVM CAS (--cacheor"enableCompilationCache": true,10Gcap viaCOMPILATION_CACHE_LIMIT_SIZE) with lane-root prefix mapping (SWIFT_OTHER_PREFIX_MAPPINGS/CLANG_OTHER_PREFIX_MAPPINGS, hitting up to 100% cross-lane compile tasks); and, when product handouts are requested (--products-to,-derivedDataPath, orSYMROOT/DSTROOT/BUILD_DIR/BUILD_ROOT/CONFIGURATION_BUILD_DIR), provides UUID-cacheddsymutilhandouts with<App>.dSYM/Contents/Resources/<UUID>.plistDBGSourcePathRemapping. - Workspace hygiene: Ignores ephemeral Xcode user state (
xcuserdata,.DS_Store) on untracked sync and write-back while preserving genuine generated files likePackage.resolved. - Bounded storage & physical size reporting: Caps active per-repo lanes (
1..lanes), expires dormant lanes idle longer thanlaneIdleDays(default30days), detaches lanes whose linked worktree was deleted (git worktree remove) and clears theirDerivedDataafter 24h idle, runs lazy daily housekeeping (at most once every 24h duringxclaneinvocations, or on demand viaxclane lanes prune— no background daemon) to prune stale.dSYMs, old logs, oversized CAS, and idle simulators, and reports physical APFS allocation viaxclane status --sizes. - Zero-config fast builds (on by default in
0.5+) &--fast-agent: Automatically injectsCOMPILER_INDEX_STORE_ENABLE=NO(override with--index-store), shares Apple SDKMODULE_CACHE_DIR,SDK_STAT_CACHE_DIR, andSDK_EXPLICIT_MODULES_OUTPUT_PATHacross all lanes and repos in<root>/shared-sdk(opt out with--no-shared-sdk-caches), and scopesgeneric/platform=*Simulatorbuilds on Apple Silicon toONLY_ACTIVE_ARCH=YES ARCHS=arm64(unlessONLY_ACTIVE_ARCH=,ARCHS=, or-archis 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 Testingfile:linediagnostics intact). Automatically bypassed onarchive,install,exportArchive,clean, andanalyze. - Managed simulator pool, async pre-boot, slim clones & diff-aware/weighted testing: Lazily clones matching
Shutdownbaseline simulators intoxclane-<Device>-<n>devices (falling back tosimctl createwhen matching baselines areBooted) for test runs, starts backgroundsimctl bootimmediately when leased to overlap simulator boot with compilation, prefers already-Bootedclones on subsequent runs, locks explicit-destination id=<UDID>test runs withflock(2), and prunes idle clones. Runxclane sim slim --all(or set"simPool": { "slimClones": true }) to disable 65 non-essential background daemons while protectingcom.apple.gamed. Pass--affected(or--affected-base <ref>) to walkXCBuildData/PIFCachereverse dependencies and run only impacted test targets (skipping test execution in~0.07swhen no test targets are impacted, falling back safely on manifest/config/unmapped source edits). With--shards N(orshards: Ninxclane_test),xclanebuilds once (build-for-testing), enumerates XCTest + Swift Testing identifiers, balances suites via EMA duration-weighted LPT bin packing (test-timings.json), and fanstest-without-buildingacross up toNisolated simulator clones concurrently. - Background lane pre-warming (
xclane lanes warm): Automatically persists portable replay args (lastBuildArgs) after successful builds so idle spare lanes can be pre-warmed ahead of parallel agent work (xclane lanes warm --if-idle --backgroundor MCPxclane_lanesaction: "warm"). Skips busy or already-warm lanes atHEAD, throttles CPU/I/O withtaskpolicy -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): InspectsXCBuildData/build.db(slowest tasks in the latest build iteration), detects.xcbuilddatabloat with actionable recommendations, and prunes stale.xcbuilddatabundles automatically during daily housekeeping /xclane lanes prune. - Stall watchdog: Detects silent/flat-CPU wedged builds across descendant process trees and terminates them cleanly with
build_stalled(exit code 116; defaultstallTimeoutSeconds: 300,0disables). - Native stdio MCP server & multi-client plugins:
xclane mcpexposesxclane_build,xclane_test(withshards,affected,affectedBase,fastAgent,indexStore,noSharedSDKCaches),xclane_run(each supportingbackground: truefor long builds),xclane_job(inspect/wait/cancel background jobs),xclane_status,xclane_lanes(list,remove,prune,warm),xclane_sim(list,prune,slim), andxclane_doctor(withcheckEnv,profile).

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.

| Workload | Result | Highlight |
|---|---|---|
v0.5.0+ zero-config on mastodon-ios (1,351 Swift files, generic simulator) | 113.21s Cold L1 / 69.78s Cold L2 / 13.95s 1-file edit | vs 211.37s L1 / 232.96s L2 / 21.53s v0.4.0 baseline (1.87x–3.34x faster cold, -60% per-lane DerivedData) |
v0.5.0+ --fast-agent on mastodon-ios (1,351 Swift files) | 87.91s Cold L1 / 67.72s Cold L2 | 2.40x–3.44x faster cold, 1.28 GB per-lane 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 Lane 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 Lane 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 lanes 2 & 1 concurrently (-jobs auto-capped, 0 errors) |
WorkApp .xcworkspace cross-worktree SPM edit (wt-2 in warm Lane 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 lanes warm Lane 2 | 3.99s (vs 13.08s cold Lane 3) | Pre-warmed Lane 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).
Homebrew (recommended)
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/PostToolUsehooks) - 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 lane (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 Lane 2 in the background while idle using low-priority utility QoS
xclane lanes warm --if-idle --background
# Run an arbitrary command inside a synced warm lane (with write-back)
xclane run -- swift test
# Inspect permits, GUI status, lanes, 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 onbuild/test/build-for-testing): By default,xclaneinjectsCOMPILER_INDEX_STORE_ENABLE=NO, shares Apple SDKMODULE_CACHE_DIR/SDK_STAT_CACHE_DIR/SDK_EXPLICIT_MODULES_OUTPUT_PATHacross all lanes/repos under<root>/shared-sdk, and narrowsgeneric/platform=*Simulatorbuilds on Apple Silicon toONLY_ACTIVE_ARCH=YES ARCHS=arm64. All optimizations are skipped automatically onarchive,install,exportArchive,clean, andanalyze. Override any setting individually with--index-store,--no-shared-sdk-caches, or explicitONLY_ACTIVE_ARCH=NO/ARCHS=.../-arch .... --fast-agentmode: AddsGCC_GENERATE_DEBUGGING_SYMBOLS=NO,ENABLE_DEBUG_DYLIB=NO,VALIDATE_PRODUCT=NO, andDONT_RUN_SWIFT_STDLIB_TOOL=YES, cutting Cold Lane 1 onmastodon-iosto 87.91s (2.40x faster than baseline) while preserving XCTest and Swift Testingfile:linefailure diagnostics.- Opt-in shared LLVM compilation cache (
--cache/"enableCompilationCache": true): Off by default (false) because LLVM CAS adds ~14s on Lane 1 cold, ~1.8s on small incremental edits, and ~2.5 GB of disk onmastodon-ios; pass--cache(or set"enableCompilationCache": truein config) when running multi-lane builds across parallel agents (SWIFT_OTHER_PREFIX_MAPPINGS/CLANG_OTHER_PREFIX_MAPPINGSmap<laneDir>=/^slot, delivering 93–100% cross-lane CAS task hits and cutting Cold Lane 2 in half). Passing--no-cacheinjectsCOMPILATION_CACHE_ENABLE_CACHING=NOand omitsCOMPILATION_CACHE_CAS_PATH, disabling compile caching even when enabled in.pbxprojbuild settings (and updating the build flavor hash so switching cache modes on the same scheme reportsflavorSwitched: true). - Stick to one cache mode per repo (and use
--lane <n>when pinning): Default mode and--cacheproduce distinct build flavors. Switching modes in the same lane triggers a full rebuild and keeps outputs for both modes inside that lane'sDerivedData(roughly doubling per-lane disk usage). Pick one mode per repository — either keep the default or set"enableCompilationCache": true/ always pass--cache— and pass--lane <n>if you explicitly want to pin a build to a separate lane. - Shared compilation cache cap: When CAS is enabled,
xclanepassesCOMPILATION_CACHE_LIMIT_SIZE=10G(compilationCacheLimitMB), which Xcode enforces across builds. Duringxclane lanes pruneand daily housekeeping (when no lane in the repo is held),xclanerunsllvm-cas --prunewhenever the cache exceeds1×compilationCacheLimitMB, and only resets the CAS as a safety valve if it still exceeds2×compilationCacheLimitMBafter pruning (reportingcacheReset: trueinBuildSummaryand printing the action in status output). OnSIGINT/SIGTERM,xclaneforwards the signal toxcodebuildand 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 storage root directory with $XCLANE_HOME or root. Defaults:
{
"lanes": 3,
"maxConcurrent": 3,
"waitSeconds": 3600,
"warmLaneWaitSeconds": 60,
"stallTimeoutSeconds": 300,
"enableCompilationCache": false,
"compilationCacheLimitMB": 10240,
"disableIndexStore": true,
"shareSDKCaches": true,
"singleArchSimulator": true,
"fastAgentMode": false,
"laneIdleDays": 30,
"yieldToXcodeGUI": true,
"simPool": {
"autoLease": true,
"maxClones": 3,
"idleDays": 7,
"slimClones": false
}
}
lanes:3active lanes per repo (slotsstill accepted as a legacy key)maxConcurrent:3concurrent builds machine-widewarmLaneWaitSeconds:60max seconds to wait for a busy warm matching lane (scaled to its lastcommandSeconds) before falling back to a cold/other-flavor lane (0disables waiting)stallTimeoutSeconds:300idle seconds beforebuild_stalled(0disables)enableCompilationCache:false(settrueor pass--cachefor opt-in shared LLVM CAS)compilationCacheLimitMB:10240(10GviaCOMPILATION_CACHE_LIMIT_SIZE)disableIndexStore:true(injectsCOMPILER_INDEX_STORE_ENABLE=NO; override with--index-store)shareSDKCaches:true(sharesMODULE_CACHE_DIR,SDK_STAT_CACHE_DIR, andSDK_EXPLICIT_MODULES_OUTPUT_PATHunder<root>/shared-sdk)singleArchSimulator:true(usesONLY_ACTIVE_ARCH=YES ARCHS=arm64on Apple Silicongeneric/platform=*Simulatorbuilds)fastAgentMode:false(settrueor pass--fast-agentto skip dSYMs/debug dylibs/validation/stdlib copy)laneIdleDays:30days before dormant lanes are prunedsimPool:autoLeaseleases clones on test runs;maxClones: 3caps clones per(device, runtime)baseline;idleDays: 7;slimClones: false(trueauto-slims newly created clones)yieldToXcodeGUI:true(yields to bothXcode.appand headlessXcode 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 lane 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 Lane Worktrees & Cleanup
Each xclane lane 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 lanes and physical APFS disk usage:
xclane status --sizes - Cleanly remove lanes (unlocks the git worktree first, deletes the lane atomically, and runs
git worktree prune):xclane lanes remove --all --yes - Prune orphan repos, dormant lanes, stale
.dSYMs, old logs, oversized CAS, and idle simulators on demand:xclane lanes prune - If you ever delete
~/Library/Developer/xclanemanually by hand, clean up any remaining locked worktree entries in your repo with:git worktree list git worktree unlock <missing-lane-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.
https://github.com/stefanoshea/xclane/releases/download/v0.6.0/xclane-v0.6.0-macos-arm64.mcpb# mcpb: https://github.com/stefanoshea/xclane/releases/download/v0.6.0/xclane-v0.6.0-macos-arm64.mcpb