claude-hashline
Replaces str_replace-style editing in Claude Code with hashline: a
line-anchored patch language. Instead of reproducing exact old text (and hitting
"String to replace not found" retry loops), the model reads a file tagged with a
whole-file content hash and edits by line number.
[src/app.ts#9A46] [src/app.ts#9A46]
1:export function hello() { PUT 2.=2:
2: return "world"; + return "hashline";
3:}
The patch engine is the MIT-licensed
@oh-my-pi/hashline (see NOTICE). This
plugin is the Claude Code integration: an MCP server exposing read/search/edit,
plus a hook that blocks the built-in editors so the model uses hashline.
Background on why line-anchored editing beats string replacement:
The Harness Problem.
How it works
- MCP server (
src/server.ts, run under Bun) exposes three tools:
read — tags output and snapshots the file by absolute path.
search — regex across the workspace, returning tagged hits you can edit
straight off (no whole-file read first). Respects .gitignore; skips
node_modules, dot-dirs, and oversized files.
edit — adds three gates over the engine: path containment (can't escape the
workspace), read-before-edit, and file creation (a tagless [path] header
creates a file). Stale tags are rejected/recovered by the engine.
- PreToolUse hook (
hooks/) denies built-in Edit/Write and redirects to
hashline. NotebookEdit stays available — hashline has no notebook support,
and line-editing raw .ipynb JSON is worse than the built-in. A SessionStart hook nudges the model up front so
it doesn't waste a turn on a blocked built-in.
Install
Requires Bun ≥ 1.3.14 on PATH. Inside Claude Code, add the marketplace
from GitHub and install:
/plugin marketplace add 0x7067/claude-hashline
/plugin install claude-hashline@hashline-dev
Restart when prompted. Bun auto-installs the server's deps on first launch, so
there's nothing else to run. Verify the MCP server is up with /mcp (look for
hashline) and that the built-in editors are blocked — Edit/Write should be
denied with a redirect to hashline__edit.
The MCP server and hooks are declared in .claude-plugin/plugin.json and
hooks/hooks.json. Safe to enable globally.
Reduce permission prompts
Replacing the built-in editors with MCP tools has a hidden cost: Claude Code's
acceptEdits mode auto-accepts built-in Edit/Write but never MCP tools,
so every hashline call prompts until you allowlist it. Without this, the plugin
trades one kind of friction for another. Add to your settings.json (user or
project scope):
{
"permissions": {
"allow": [
"mcp__plugin_claude-hashline_hashline__read",
"mcp__plugin_claude-hashline_hashline__search",
"mcp__plugin_claude-hashline_hashline__edit"
]
}
}
read/search are read-only and always safe to allow. Allowing edit gives
the equivalent of a permanent acceptEdits for hashline (edits are confined to
the workspace jail); leave it off the list if you want to review each edit.
Opting out
Enforcement is on by default and blocks editing everywhere, so any repo relying
on the built-in editors must opt out via any of:
.hashline-off marker at the repo root or any ancestor — committable, so a
team can exclude a repo by checking it in.
HASHLINE_DISABLED=1 in the environment — the recovery valve when the
hashline edit tool itself is broken (the agent can't remove a marker while
Write is blocked).
~/.hashline-off — a HOME-trusted sentinel with the same recovery role.
The block is a workflow nudge, not a security boundary — a .hashline-off can be
shipped in a cloned repo or dropped by a prompt-injected agent. The jailed MCP
filesystem is the real boundary. For an opt-out repo contents can't spoof, use
~/.hashline-off or HASHLINE_DISABLED.
Jail carve-outs
The jail confines read/edit/search to the workspace root (cwd or
HASHLINE_ROOT). Four opt-in flags widen it (all default-on in the plugin):