Quickstart¶
You've set up your agent by hand: a harness, a model, a few MCP servers, some skills, an
instructions file. It works on your laptop. This walkthrough pins all of it into a
harness.lock, versions it in git, keeps it current as you add to your setup, brings it
back on another machine, and starts sessions from it. It takes about five minutes.
The examples use Claude Code. The same commands work with Codex, Pi, OpenCode, Cursor, Gemini CLI, and the other supported harnesses.
1. Pin your setup¶
Run hlock pin --user in the repository where you want to keep the lock. --user pins
the setup in your home directory (~/.claude), which is where a setup made by hand lives.
Without it, pin records only the project's own skills, MCP servers and config (see
Project and user scope).
$ hlock pin --user
โ pinned claude-code 2.1.0 โ harness.lock (the only installed harness)
โญโ ๐ harness.lock ยท pinned โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ harness claude-code 2.1.0 โ
โ scope project + user โ
โ llm ยท default anthropic:opus โ
โ mcp github (stdio) โ
โ skills 1 (1 local) โ
โ instructions {root}/CLAUDE.md โ
โ config {root}/settings.json, ~/.claude.json /mcpServers โ
โ secrets 1 redacted (supplied as HLOCK_SECRET_* when syncing) โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
vendored 4 files into .hlock/vendor/claude-code/ ยท review before committing
next โ hlock check ยท hlock sync
pin found the installed harness and recorded its version and install source, the model,
every MCP server and the package it launches, skills, plugins, instruction files, and the
config files they came from, each with a digest.
Secrets never reach the lock. The GitHub token in the MCP server's config became a placeholder:
Things another machine can't download, like a skill you wrote yourself, your
CLAUDE.md, and your config files, are copied (with secrets redacted) into
.hlock/vendor/. See Pinning your setup for everything pin records.
2. Commit it¶
Like uv.lock or Cargo.lock, harness.lock belongs in version control.
3. Add to your setup, and lock what's new¶
Setups grow by hand: you install a skill, connect another MCP server, edit a setting.
hlock check re-captures your setup and shows what changed since the pin:
$ hlock check
โ drift: your claude-code setup changed since harness.lock was pinned
+ mcp linear
+ skill write-tests (user)
~ config ~/.claude.json: ad825f266f โ b33482f12e
hint: re-pin with hlock pin --user, or restore it with hlock sync --in-place
Run hlock pin --user again to lock the new pieces. It prints the same diff, and the
change becomes a reviewable diff of harness.lock in git:
$ hlock pin --user
โ pinned claude-code 2.1.0 โ harness.lock (the only installed harness)
โญโ ๐ harness.lock ยท pinned โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ harness claude-code 2.1.0 โ
โ scope project + user โ
โ llm ยท default anthropic:opus โ
โ mcp github (stdio), linear (http) โ
โ skills 2 (2 local) โ
โ instructions {root}/CLAUDE.md โ
โ config {root}/settings.json, ~/.claude.json /mcpServers โ
โ secrets 1 redacted (supplied as HLOCK_SECRET_* when syncing) โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
vendored 5 files into .hlock/vendor/claude-code/ ยท review before committing
changes since the last pin
+ mcp linear
+ skill write-tests (user)
~ config ~/.claude.json: ad825f266f โ b33482f12e
next โ hlock check ยท hlock sync
If the change wasn't intended, hlock sync --in-place restores the locked setup into your
config instead.
4. Rehydrate it elsewhere¶
On a new laptop, a VM, or a teammate's machine, clone the repository, set the secrets the
lock asks for (as variables, as here, or once in your keychain with
hlock secret set), approve what the lock runs on this machine, and
run hlock sync:
$ export HLOCK_SECRET_GITHUB_GITHUB_TOKEN=ghp_โฆ
$ hlock trust --yes
kind name runs digest status
โ mcp github npx -y @modelcontextprotocol/server-github bd687d330ce4 not yet trusted
โ approved 1 (recorded in ~/.hlock/trust.toml)
next โ hlock sync
$ hlock sync --yes
Sync plan for Claude Code 2.1.0 โ .hlock/env/claude-code/config
โ harness Claude Code 2.1.0
โ mcp `npx` for MCP servers: github
โ secret HLOCK_SECRET_GITHUB_GITHUB_TOKEN (mcp github GITHUB_TOKEN)
โ config Write .hlock/env/claude-code/config/settings.json
โ config Write .hlock/env/claude-code/config/.claude.json /mcpServers
โ skill Copy skill review-pr โ .hlock/env/claude-code/config/skills/review-pr
โ skill Copy skill write-tests โ .hlock/env/claude-code/config/skills/write-tests
โ instructions Write .hlock/env/claude-code/config/CLAUDE.md
โ Write .hlock/env/claude-code/config/settings.json
โ Write .hlock/env/claude-code/config/.claude.json /mcpServers
โ Copy skill review-pr โ .hlock/env/claude-code/config/skills/review-pr
โ Copy skill write-tests โ .hlock/env/claude-code/config/skills/write-tests
โ Write .hlock/env/claude-code/config/CLAUDE.md
โ in sync at .hlock/env/claude-code/config your own config wasn't touched
use it: CLAUDE_CONFIG_DIR=.hlock/env/claude-code/config claude
to restore into your own config instead: hlock sync --in-place
$ hlock check --prefix .hlock/env
โ the claude-code setup in .hlock/env matches harness.lock
An MCP server starts a program, so hlock installs it only once you've
approved it on this machine, by its command and digest; on a
terminal, sync asks you itself. sync builds a plan: โ steps are already true, โ steps
hlock does for you, and โ steps need you, with the exact command to run. It writes into an isolated config root in
.hlock/env/, so the setup on that machine stays as it was. Pass --in-place to restore
into ~/.claude itself; sync keeps a backup of any file it replaces.
Pass --install to let it install missing harnesses and packages, and --pull to
download local model weights. Without --yes, it shows the plan and asks first.
hlock sync --docker writes a Docker image with the same setup instead.
5. Launch sessions and run prompts¶
hlock launch starts the harness on the locked setup, in an isolated config directory
under .hlock/env/, the way uv run uses a virtual environment. Your own ~/.claude
isn't touched, and nothing you haven't locked leaks in:
$ hlock launch
โ Write .hlock/env/claude-code/config/settings.json
โ Write .hlock/env/claude-code/config/.claude.json /mcpServers
โ Copy skill review-pr โ .hlock/env/claude-code/config/skills/review-pr
โ Copy skill write-tests โ .hlock/env/claude-code/config/skills/write-tests
โ Write .hlock/env/claude-code/config/CLAUDE.md
โถ Claude Code CLAUDE_CONFIG_DIR=.hlock/env/claude-code/config โฆ/bin/claude
hlock run sends one prompt through the same environment, using the harness's own
non-interactive mode (claude -p, codex exec, opencode run, โฆ), and exits 0 or 1
with the harness. The environment is only rebuilt when the lock changes:
$ hlock run "summarize README.md"
โถ Claude Code CLAUDE_CONFIG_DIR=.hlock/env/claude-code/config โฆ/bin/claude -p summarize README.md
โฆ
โ success harness Claude Code latency โฆ
Between the โถ line and the result is the harness's own output. hlock run --json
captures it, with the exit code and latency, for scripts.
You can also launch the lock in a different harness: hlock launch opencode carries the
MCP servers, skills, and instructions over. See Launching a locked harness.
Where to next¶
Already using APM?
Keep apm.yml: hlock reads it. See Coming from APM.
Your setup is pinned, versioned, and portable. From here, two paths, and a helper for both:
Optimize your harness. Measure your setup against your own tasks and let hlock find a better one:
- Draft an eval pack from the requests you've already made to
your agent:
hlock evals init --from-tracesreads the sessions Claude Code, Codex, and Pi logged for this project. It writes an Agent Skill too, so your agent can help you review the drafts. - List the models, decision models, and harnesses to try in a
harness.toml, and resolve the best combination. - Go below the stack with
hlock tune: prompts, hyperparameters, and fine-tuned small models.
Switch harnesses. hlock migrate --to codex writes your lock
onto another harness, with your skills, MCP servers, and instructions moved to where it
reads them.
Go local. hlock localize turns your lock into an equivalent
that runs entirely on your machine, with an open-source harness and local models. Give it
an eval pack, and it measures the local candidates against your tasks and records the
evidence next to your original lock's.
Let an agent do the busywork. On a new machine, hlock sync lists the steps it can't
do itself, like installing a harness at the pinned version. hlock meta init sets up
hlock's built-in agent with your API key or a local model, and hlock meta run install
has it do those steps, then checks that the machine matches the lock. The same agent can
fill in an eval pack (hlock meta run bootstrap-evals). See
Delegating to the meta harness.