Sparehand

Docs › AI coding agents

AI coding agents

Coding agents (Claude Code and others) run tests, typechecks and linters all day, often several agents at once. Sparehand can take those runs off your computer automatically: the agent types npm test as usual, and the run happens on a free worker, with the same output and exit code.

Pick your tools

sparehand agent status              # the coding tools on this Mac, and how each is connected
sparehand agent install all         # connect every tool found here
sparehand agent install gemini      # or one: claude, codex, gemini, cursor, copilot, windsurf,
                                    #   opencode, kiro, cline
sparehand agent test gemini         # what its hook does with a heavy command and a light one
sparehand agent uninstall cursor

The Mac app does the same in Settings → AI Tools, with a switch per tool.

There are two kinds of connection:

ToolConnected byWhere
Claude Codehook~/.claude/settings.json
Gemini CLIhook, plus a note~/.gemini/settings.json, ~/.gemini/GEMINI.md
Cursorhook~/.cursor/hooks.json
Codex CLIhook that refuses and names the command, plus a note~/.codex/hooks.json, ~/.codex/AGENTS.md
GitHub Copilot CLIhook, plus a note~/.copilot/hooks/sparehand.json, ~/.copilot/copilot-instructions.md
Windsurfhook (Devin Local and Devin CLI), plus a note in Cascade's global rules~/.config/devin/config.json, ~/.codeium/windsurf/memories/global_rules.md
OpenCodehook (a plugin), plus a note~/.config/opencode/plugins/sparehand.js, ~/.config/opencode/AGENTS.md
Kirohook that refuses and names the command (CLI only), plus a steering file~/.kiro/hooks/sparehand.json, ~/.kiro/steering/sparehand.md
Clinea note only: it depends on the model following it~/Documents/Cline/Rules/sparehand.md

Three things to know:

sparehand agent status shows, per tool, whether it is on this Mac, whether it is connected by hook or by note, and the version of the tool its hook was checked against. The formats, their sources and the date of the last check are in Coding tools' hooks.

Trying a connection

sparehand agent test cursor         # or: all

This hands the installed hook two commands the way the tool would, npm test and git status, and prints what the hook answers: the first goes to a spare machine (or is refused with the command to run), the second is left alone. Nothing is run, on a worker or here. For a tool that isn't connected it shows what the hook would do; for Cline it says there is no hook to try.

Disconnecting

sparehand agent uninstall TOOL (or all) puts each file back exactly as it was, byte for byte, and removes the files and folders that were made for the connection. Sparehand keeps a copy of each file from before its first change in ~/.config/sparehand/agent-tools/ until then. If you changed a file after connecting, your changes stay and only Sparehand's part goes: its hook entry, or the lines between <!-- sparehand:start --> and <!-- sparehand:end -->.

Claude Code

sparehand agent install             # for all your projects (~/.claude/settings.json)
sparehand agent install --project   # only this project (.claude/settings.json)
sparehand agent status
sparehand agent uninstall

This adds a PreToolUse hook for the Bash tool. New sessions pick it up. The rest of this page describes that hook; the other tools' hooks follow the same rules.

What it hands over

Checks whose only result is their output and exit code, so running them elsewhere loses nothing:

A command like cd apps/api && npx jest src/orders 2>&1 | tail -20 is handed over as a whole.

What it leaves alone

How it behaves

Settings

In ~/.config/sparehand/sparehand.conf or the environment:

SettingMeaning
SPAREHAND_AGENT=offSwitch the hook off without uninstalling it
SPAREHAND_AGENT_GET=dist,coverageBring these paths back after every handed-over command; builds are handed over too
SPAREHAND_AGENT_BUILDS=1Also hand over builds (without bringing their output back)
SPAREHAND_AGENT_MATCH=regexReplace the list of commands that count as checks
SPAREHAND_AGENT_SKIP=regexExtra commands to leave alone
SPAREHAND_AGENT_CODEX=rewriteIn Codex, change the command in place instead of refusing it with the command to run. Codex takes a changed command only together with an "allow", and its documentation doesn't say whether that skips your approval

Other agents and scripts

Any tool can use sparehand run --or-local <command>: it runs on a worker when one is free and on your computer otherwise, and always returns the command's own output and exit code.