Skip to content
shuxueshuxuePublic

About

Computable, Git-backed spec control for the agent era.

Resources

Contributing

Security policy

Stars

331 stars

Watchers

1 watching

Forks

Repository files navigation

SpexCode — Specs govern. Agents build.

npm license: MIT Node.js 22 or newer documentation

English · 中文

SpexCode is a Git-backed spec tree and session manager for coding agents.

It is built around one problem: spec drift. Agents change code faster than anyone updates the documents that say what the code is for, and nothing tells you when a spec stopped describing the system. In SpexCode each spec names the file or function it governs. When a later commit changes that code and leaves the spec alone, SpexCode names the spec and the commit. With the hooks installed, a change inside an anchored function is blocked until someone updates the spec or records why it still holds.

Sessions run each agent in its own branch and worktree, so every change comes back with the specs it touched named in its commits.

A spec node is a spec.md under .spec/. Its code: field names the implementation:

---
title: Webhook security
code:
  - src/ingest/webhookVerifier.ts#verifyWebhook
---
Only a push signed with the configured SHA-256 secret may change a release stream.

That line is the whole binding. Versions, drift and history are computed from git on every read; nothing else is stored.

Start from the agent you already use

You can try SpexCode from Claude Code or Codex before installing the CLI. The atlas plugin reads a repository, writes an initial spec tree, checks its diagrams and hands back one page you can open.

# Claude Code
claude plugin marketplace add shuxueshuxue/spexcode-plugins
claude plugin install atlas@spexcode
# Codex
codex plugin marketplace add shuxueshuxue/spexcode-plugins
codex plugin add atlas@spexcode

Then, inside any repository, run /atlas.

The plugin uses spex init --pure for the first adoption: plain .spec/ files in git, no hooks and no agent configuration. You can add the session layer later with the CLI below.

The atlas of sindresorhus/ky: the Request pipeline node with its workflow diagram.

More repositories drawn this way: flatcode.spexcode.net. Diagrams are rendered by archify (MIT).

Computable spec drift

Each spec version is a commit that touched its spec.md; the window starts at the latest version. For every later commit, Git supplies the lines that commit changed, and SpexCode intersects them with the anchored unit's line range as it existed in that commit.

spex spec lint reports anchor-drift on src/ingest/webhookVerifier.ts#verifyWebhook since spec webhook-security v3.

An intersection is anchor-drift: an error, and with the hooks installed the candidate commit is rejected. A change elsewhere in the same file is only a drift warning. The result is a deterministic computation.

Commit cbe53ee changes line 6 of webhookVerifier.ts, inside verifyWebhook (lines 5 to 13), after spec webhook-security v3; the overlap is anchor-drift.

Everything comes from Git; SpexCode stores no drift data. There are two ways to close the window: update the spec with the code, so the new spec version closes it, or record that the contract still holds with a Spec-OK trailer or spex spec ack.

spex spec lint

With the installed hooks, an anchored hit rejects a new candidate commit. Update the spec with the code, or record why an implementation-only change still satisfies the contract:

git commit --trailer "Spec-OK: webhook-security"

For a change that is already committed:

spex spec ack webhook-security --reason "the contract still holds; this refactor preserves it"

Use it in the GUI

The SpexCode dashboard: a review session on the desktop and the webhook-security spec on a phone.

Use it in the terminal

spex session ls on the Harbor demo: sessions in review, asking and parked, each with its spec node, id, parent and prompt.

Everything the dashboard does is also a CLI verb; spex help lists them.

Git or notebook? Intuitive spec management

Specs are Markdown files in git, and the dashboard reads them as documents you can act on.

On the webhook-security spec, 1 pending change opens the word-level redline of the edit a live session made. A sentence of the webhook-security spec is selected, right-clicked, and sent to a session with a message.
A live session's edit to this spec, as a redline. A selected passage, sent to a session.

Quick start from a shell

Requires Node ≥ 22 and git.

npm i -g spexcode
cd your-repo
spex init --harness claude,codex,opencode,pi,zcode,claude-headless,opencode-headless,pi-headless,codex-headless

The example lists every built-in harness; keep the ones you use (any one id or a comma-separated subset). spex init seeds the spec tree, installs hooks and materializes workflow instructions into the files your agent already reads. Existing configuration is preserved; spex uninstall removes SpexCode's additions.

Adopt less
Command Result
spex init --pure Root spec and project config; no hooks.
spex init --harness none Spec workflow and hooks; no agent configuration.
spex init --harness … Spec workflow plus instructions for selected agents.

Add --title "Your Project" to name the root spec and dashboard.

Run isolated sessions

Session management requires tmux; on Windows use WSL2.

spex session new "[[webhook-security]] verify signatures behind a reverse proxy"
spex session ls
spex session review <session-id>
spex session merge <session-id>

Workers propose. You decide when to request the gated merge.

Open the dashboard
npm i -g @spexcode/spec-dashboard
spex serve
spex dashboard

Each project has a backend; one dashboard serves all projects on the machine. Spec, session and terminal views have shareable URLs.

Three layers

Three layers: L0 the spec-code graph in git, L1 agent sessions in isolated worktrees on top of it, L2 the dashboard reading L1.

Setup guide · Working with agents · Contributing

First introduced on LINUX DO. Licensed under MIT.

About

Computable, Git-backed spec control for the agent era.

Resources

Contributing

Security policy

Stars

331 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages