git-span
git-span records the relationships in a codebase that no schema, type system,
test, or build step enforces. A span connects exact line ranges or whole files,
stores the reason they must stay aligned, and reports when any anchor moves,
changes, or disappears.
Span declarations are ordinary tracked files under .span/, so they travel
with the code through branches, reviews, merges, and CI. The CLI is complete on
its own, and integrations for Claude Code, OpenAI Codex, OpenCode, and
Antigravity surface relevant spans while an agent works.
Install
npm install -g git-span
git span --version
The npm package selects the native binary for Linux, macOS, or Windows. Agent
plugins call git span from PATH; install the CLI anywhere an agent session
runs before installing its plugin.
Full agent setup is documented at git-span.com:
- Claude Code installs from the
goodfoot-io/git-span marketplace.
- Codex installs from the same repository marketplace and requires hook review through
/hooks.
- OpenCode loads the
opencode-git-span npm plugin and uses its installer for skills and the expert agent.
- Antigravity installs
plugins-antigravity/git-span with agy plugin install.
Quick start
git span add checkout-request-flow \
src/client.ts#L10-L40 \
src/server.ts#L20-L64
git span why checkout-request-flow \
"The server contract is authoritative for the request fields the client sends."
git add .span
git commit -m "Record checkout request coupling"
git span drift
Use git span list and git span show <name> to inspect declarations,
git span tree to explore their blast radius, and git span history <name>
to review provenance. git span drift --fix repairs safe positional movement;
meaning-changing drift remains visible for review. See
git-span.com for the complete CLI reference.
VS Code
The goodfoot.git-span extension uses the independently installed git span
binary from PATH. It provides:
- a custom editor for files under
.span/, including anchor diffs and source navigation;
- Git Span: Show CLI Version;
- Git Span: Open Terminal.
See git-span.com for usage and troubleshooting. Repository-specific extension notes live in packages/extension/README.md.
Development
During local development, run commands from packages/git-span:
cd packages/git-span
yarn build:local
build:local compiles the release binary into the shared Cargo target root,
installs it to ~/.local/bin, and regenerates the man page; the bare
yarn build only regenerates the man page.
Common command shape:
git span doctor
git span add checkout-request-flow src/client.ts#L10-L40 src/server.ts#L20-L64
git span why checkout-request-flow "The browser initiates the charge request that the Stripe-backed server validates; the server contract is authoritative for accepted fields."
git span config checkout-request-flow copy_detection any-file-in-repo # set one resolver knob; bare `git span config <name>` reads all three
git add .span && git commit -m "Record checkout-request-flow span"
git span drift checkout-request-flow
git span replace checkout-request-flow src/client.ts#L10-L40 src/client.ts#L12-L42 # atomic swap: retire the old anchor, install the new, or nothing
git add .span && git commit -m "Move checkout-request-flow anchor after the handler rename"
Exit codes
git-span follows the POSIX convention used by git and cargo:
- 0 — success.
- 1 — operational failure: the command was well-formed, but
the environment or repository state prevents completion.
Example:
git span show nope when nope is not a known span.
- 2 — usage error: the command itself is malformed (unknown
flag, missing required argument). Example:
git span show --bogus.
git span drift overlays its own §10.4 contract on top of this:
exit 1 when drift is found, exit 0 with --no-exit-code. There is no
pre-commit subcommand; span coverage is instead created by the
.githooks/pre-commit.wiki.sh hook, which runs wiki check --fix as an
advisory best-effort pass (it never aborts the commit) and never stages
files that were already dirty before the hook ran.
Monorepo Layout