Skip to content

About

A change flow for OpenSpec repositories with one human gate at merge, bracketed by an explicit start and stop, plus drift checks that hold a specification to the code it claims to describe.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

openspec-steward

A Claude Code plugin for repositories using OpenSpec: a change flow with one human gate inside it, at merge, bracketed by an explicit start and stop, plus drift checks that hold a specification to the code it claims to describe.

It exists because both halves were learned the expensive way in one repository and then could not travel. The reasoning is kept, not just the rules — a rule without its reason gets "simplified" back out.

How the flow runs, why it has one gate and two brackets, and how the checker is built — with diagrams — are in docs/.

It is listed among the community projects on OpenSpec's community page.

What it insists on

Three disciplines run through every change. Each is fixed at propose, where scope is decided, rather than left to memory during apply.

  • Test first, declared per task. Every task in tasks.md states tdd: yes or tdd: no, with a reason, when it is proposed. A done tdd: yes task records the run that failed before the fix: red: <command> → <failing line>. The tdd check fails a change that leaves out either line. A test nobody saw fail proves nothing, and the red: line is where the failure is written down. See the tdd check.
  • Deferred work is a file, not a sentence. A change recommended for later is written to todo/<slug>.md and committed. A follow-up proposed only in the transcript dies with the session. /start-change matches the plan by its slug and seeds the proposal from it. /archive-on-green deletes it in the archive commit. See Deferring a change.
  • Lean build: extend before adding. A design declares the existing seam the change extends on one line: Seam: <module, file or interface>, or Seam: none — <reason>. Each new module, dependency, config key or migration names the spec scenario that needs it. A task that would duplicate existing behaviour refactors the code that owns it instead, and says so. Without this rule, "keep changes minimal" reads as "smallest local patch", and a copy beside the owner is smaller than a refactor of it. These are artifact rules that /init writes into openspec/config.yaml. The seam check fails a design with no Seam: line; it checks that the seam is declared, not that it is right. Scenario naming and reuse have no check: the reader of the proposal enforces them. See the seam check.

What's in it

Skills — the flow and the discipline:

skill covers
openspec-change-flow the sequence, why one gate inside the brackets, archive-on-verified-green, the gh pr checks --watch false green, post-archive verification, deferring a change to todo/
openspec-spec-drift what a MODIFIED delta silently deletes, both marker placement rules and why they are opposites, the doc-vs-spec asymmetry
openspec-evidence watch a check fail before trusting it; three ways a green check means nothing

Commands — the procedures:

command does
/start-change <description> describe the work; it proposes a session title and a change slug, then opens the flow (or resumes one a stop suspended): does this deserve a change, is the tree clean, is the base current, is the slug free
/archive-on-green pin the head SHA, wait, confirm each check by name, archive, verify the apply
/verify-green wait for CI on the pinned head, then: is this PR actually green, by its required checks, by name?
/init set the repository up: the steward artifact rules in openspec/config.yaml, a flow summary in AGENTS.md
/stop-change stop the flow: closed if the change reached its end, suspended with a recorded resume point if it did not; --abandon destroys it, code and all, after pinning the commits to a verified remote tag

/start-change and /stop-change bracket the flow, and the brackets nest in time rather than only once per change: a stop suspends, writing the resume point to openspec/changes/<name>/STOPPED.md, and the next /start-change consumes it and picks the work up where it was left. Merge stays the only gate inside the brackets. Why that is not a contradiction of "one gate" is argued in the openspec-change-flow skill — the metric was never the number of stops but whether a decision lives at each one, and "does this deserve a change?" was the decision the old flow left ungated.

A change proposed for later is not left in the transcript. The agent writes it to todo/<slug>.md and commits it. A later /start-change that matches it uses its slug and seeds the proposal from it, and /archive-on-green deletes it in the archive commit.

Checker — scripts/check-specs, six checks over openspec/:

check fails when
scenarios a MODIFIED delta omits a scenario the live requirement carries
duplicates one spec declares the same requirement name twice
inventories a capability that declares it enumerates code disagrees with it
strict openspec validate --specs --changes --strict does, over the main specs and every open change
tdd a task does not declare tdd: yes|no with a reason, or a done tdd: yes task records no red: run
seam a design.md does not declare one Seam: line, or Seam: none with a reason

Five are pure text comparisons over openspec/, with no knowledge of your stack. Unit tests need no fixtures on disk.

Archive-head gate: openspec-archive-head (scripts/archive-head) decides whether a pull request head may skip its test jobs. It skips only when the push since a green head changed nothing outside openspec/ and todo/, so an archive commit costs one spec-check run instead of the full suite. It fails closed. Wiring: docs/archive-head.md.

CI wait: openspec-wait-ci <pr> (scripts/ci-wait) pins the pull request's head SHA, waits until the checks on that SHA settle, and stops if the head moves. It prints each check as conclusion<TAB>name, the base branch's required checks apart from the rest, and a verdict. Exit 0 is green and nothing else is. /verify-green and /archive-on-green wait with it. It uses gh, and reads the required checks from the branch's rulesets and classic protection; with none readable, every check must pass. See What "green" means.

Archive snapshot: openspec-archive-snapshot (scripts/archive-snapshot) brackets openspec archive. --snapshot <change> records what the archive will change, in a temporary file outside the repository; --verify then fails when a requirement is not declared once, lost a scenario name, was not removed or renamed, or when a spec no delta touches changed. A missing or empty snapshot fails too. /archive-on-green runs it at steps 3 and 5. The flow: docs/change-flow.md.

Public text check: openspec-check-public (scripts/check-public) matches the text the flow publishes (pull request bodies, commit messages, change folders) against a deny-list you keep outside the repository. See Declaring a public repository.

Install

The repository is its own Claude Code marketplace. Enable the plugin for everyone who opens the consumer repository by committing this to its .claude/settings.json:

{
  "extraKnownMarketplaces": {
    "openspec-steward": {
      "source": {
        "source": "github",
        "repo": "codecicada/openspec-steward",
        "ref": "v0.11.1"
      }
    }
  },
  "enabledPlugins": {
    "openspec-steward@openspec-steward": true
  }
}

Pin ref to a tag for the same reason the checker is pinned: a moving default branch would change the flow an agent follows without a commit in the consumer. Claude Code offers to install the marketplace and the plugin the first time the repository is trusted. For one machine only, without touching the repository:

claude plugin marketplace add codecicada/openspec-steward
claude plugin install openspec-steward@openspec-steward

Then set the consumer repository up for the flow. In Claude Code, run /openspec-steward:init. Without Claude Code:

node <plugin>/scripts/init/index.mjs --root .

It adds the steward artifact rules to openspec/config.yaml, and a marked flow summary to AGENTS.md for agents that read that file rather than this plugin's skills. A second run changes nothing.

A rules: block that is already there is never rewritten. If it holds every steward rule, rules of your own beside them included, it counts as set up. Otherwise init refuses, writing nothing, and prints only the steward items it lacks: add them under their keys, next to your own, and run init again. A release that adds a steward rule does the same to a repository set up before it: no check fails, but the next init run refuses and prints only the new items.

Init also refuses when openspec/config.yaml is missing (run openspec init first), or when the block is not block style (key: lines, each once, with - item lists) and so cannot be read.

The AGENTS.md section is seven lines, plus one blank line before it: the order, where the rules live, and a link to the flow, short enough for an AGENTS.md that is a router with a line cap. It names merge on request as the flow's gate, not the repository's only one: where your own rules also require approval to apply, commit or archive, those still bind, and the section says so.

Then wire the checker into the consumer repository:

# 1. run the checks
node <plugin>/scripts/check-specs/index.mjs --root .

# 2. wire them in — as an npm script, a CI job, and a pre-push hook

openspec must be resolvable in the consumer repo for the strict check. Pin it as a devDependency — note the scope, @fission-ai/openspec; the bare openspec on npm is an unrelated package whose only published version is 0.0.0, so a pin written from the command name alone installs something else under the name your build then trusts.

The checker needs no build, no database and no credentials, so give it its own CI job rather than appending it to one that builds. It needs no git history either — check out shallow.

Migrating from openspec-flow

The plugin was called openspec-flow until 0.5.0. The name was changed because openspec-flow on npm is an unrelated package. To upgrade:

  1. In .claude/settings.json, rename the marketplace key openspec-flow to openspec-steward, set repo to codecicada/openspec-steward and ref to v0.5.0, and replace openspec-flow@openspec-flow in enabledPlugins with openspec-steward@openspec-steward.
  2. Rename openspec-flow.json to openspec-steward.json.

Step 2 can wait. Until 1.0 the checker still reads openspec-flow.json when it is the only config file, and prints a deprecation note on stderr. With both present, openspec-steward.json wins and the note names openspec-flow.json as ignored. Neither note changes the exit code.

Skill names, commands and the openspec-check-specs bin are unchanged; only the plugin namespace in front of them moves from openspec-flow: to openspec-steward:. A consumer pinned to an older tag keeps working as it is.

Declaring a public repository

In a public repository, the text the flow writes can carry private context out: internal host names, tracker ids, other sessions. Declare the repository public in openspec-steward.json:

{ "public": true }

Then write a deny-list outside the repository, one case-insensitive regular expression per line, # for comments. It names the private things, so committing it would publish them. Its location is the first of these that is set: --deny <file>, $OPENSPEC_STEWARD_DENY, $XDG_CONFIG_HOME/openspec-steward/deny, else ~/.config/openspec-steward/deny. The bin does not fall back from one to the next, and refuses a list inside the repository.

~ is the home directory Node reports, so the default is:

OS default deny-list
Linux /home/<you>/.config/openspec-steward/deny
macOS /Users/<you>/.config/openspec-steward/deny
Windows C:\Users\<you>\.config\openspec-steward\deny (%USERPROFILE%\.config\openspec-steward\deny)

On Windows, where settings usually live under %APPDATA%, point OPENSPEC_STEWARD_DENY at the file instead. In PowerShell, for the session:

$env:OPENSPEC_STEWARD_DENY = "$env:APPDATA\openspec-steward\deny"

or for every new shell: setx OPENSPEC_STEWARD_DENY "%APPDATA%\openspec-steward\deny". CI runs on Linux only, so the macOS and Windows paths are not tested there.

node <plugin>/scripts/check-public/index.mjs --stdin < pr-body.md
node <plugin>/scripts/check-public/index.mjs --log origin/main --path openspec/changes/<name>

Each hit prints <source>:<line>: matches /<pattern>/i and the run exits 1. Exit 2 means it could not run (no list, an empty list, an invalid pattern), and is not a pass. In a repository that is not declared, it exits 0 and says nothing was checked. The flow skill and /archive-on-green run it before every pull request title and body, push, archive commit and squash merge message. It scans that text, not the code diff: pass docs you want checked with --path.

The check is local. CI cannot read a list kept off the repository; a CI job would need it as a secret, written to a file outside the checkout and passed with --deny. Nothing is shipped or wired by default.

Declaring an inventory

Five of the six checks work anywhere. inventories has to derive something from your code, which is the one thing this plugin cannot know: routes come from NestJS decorators in one repository, an Express router in another, an OpenAPI document in a third.

So the derivation is yours. openspec-steward.json at the repository root:

{
  "derivers": {
    "routes": "./scripts/derive-routes.mjs"
  }
}

The module default-exports (root) => string[], and should also export normalise(item) => string:

export default function deriveRoutes(root) { /* ... */ }

// Applied to BOTH sides — your derived items and the ones the declaring
// requirement lists.
export function normalise(item) { /* ... */ }

normalise being applied to both sides is what makes the comparison symmetric. Only you know that :id and :widgetId are one route, or that a query string is not part of a path — but normalising only your own side reports every difference of spelling as drift. That was the first bug this seam produced, found by running the plugin against a real repository whose repo-local version had normalised both sides inside one function.

A capability then opts in, inside the requirement making the claim:

### Requirement: Versioned REST surface

<!-- enumerates: routes -->

The system SHALL expose the following endpoints...

Placement matters and is the opposite of the drops-scenario marker's rule — see the openspec-spec-drift skill for why.

An inventory no capability declares passes silently. Deciding that something deserves a capability is a judgement, not a defect.

The comparison reads what each unarchived change will make live, not only openspec/specs/. A change that adds a route puts it in the code and in its MODIFIED delta, and the flow archives only after CI is green, so the check cannot wait for the archive. For each change under openspec/changes/ (not archive/):

  • An ADDED or MODIFIED requirement carrying the marker replaces the live requirement's list, exactly as archive will replace its body. A finding drawn from it names the change: add-events -> rest-api: ....

  • A MODIFIED requirement that leaves out a marker the live requirement carries fails the check, naming the change, requirement and inventory. Archive replaces the body in full, so the declaration would vanish with the marker and the claim would stop being enforced. Put the marker back or, if the removal is deliberate, say so above the delta's first ##:

    <!-- drops-inventory: Versioned REST surface :: routes -->

    Either way the live list is not compared: it is about to stop existing.

  • Any other delta requirement without the marker overlays nothing; the live list stays in force until archive.

  • Two unarchived changes that both replace the same declaring requirement fail the check, and that requirement is not compared. Each replaces it in full, so whichever archives last would discard the other's items — or, if it drops the declaration, the other's whole list. Fold them into one change, or archive one and rebase the other's delta.

What it cannot do

No check here reads application code, so none can tell you whether a requirement is still true — only whether a stated claim has stopped holding. A capability can be structurally perfect, pass every check, and explain its behaviour with a reason that stopped being true months ago. That class needs a reader.

Developing this package

Read AGENTS.md first: the rules this repository is worked by, a map of its directories, and the gates to run before pushing.

npm test            # the unit tests: no dependencies, no fixtures on disk
npm run test:bin    # packs, installs and drives the bins the way a consumer gets them
npm run test:gates  # watches each /start-change and /stop-change refusal refuse
npm run test:plugin # Claude Code's own validator over the manifests, skills and commands

All four run in CI (.github/workflows/ci.yml) on every pull request and every push to master — the unit tests across Node 20, 22 and 24, the smoke test on 22, the gate refusals on git alone, and the plugin validation on 22.

test:plugin installs a pinned @anthropic-ai/claude-code and runs claude plugin validate --strict . with an empty HOME and no ANTHROPIC_API_KEY, so it needs no credentials. It also validates three broken copies of the tree — invalid plugin.json, a skill without frontmatter, unparseable command frontmatter — and expects each to fail; dropping --strict reddens the second. It does not check that the marketplace source exists or that the marketplace entry's name matches plugin.json.

The two are not redundant. Every unit test imports a module under lib/ directly and never reaches the entry point, so when the bin silently exited 0 through its npm symlink all 37 stayed green: process.argv[1] is the symlink while import.meta.url is the real file, and the entry guard compared them directly. scripts/check-specs/smoke-bin.sh covers that seam by installing the packed tarball into a throwaway project and making thirteen observations — the bin prints its usage, a missing openspec CLI fails loudly rather than passing, a seeded dropped scenario is caught and named, restoring it goes green again, a legacy openspec-flow.json passes with its deprecation note on stderr only, openspec-steward-init, which carries the same entry guard, writes its rules through its own symlink, openspec-archive-head decides through its own, an undeclared task fails tdd while an archived one is ignored, and openspec-archive-snapshot verifies a real openspec archive, then fails on an untouched spec edited after its snapshot and on an empty snapshot.

Watched failing before being trusted, per the openspec-evidence skill: reintroducing that entry guard leaves npm test at 37 passed while the smoke test reports three failures.

scripts/gates/refusal-cases.sh does the same job for the two gates, which are prose and so cannot be run. It builds each refusing state in a throwaway repository and checks that the detection command the command file names says something different there than in the adjacent permitting state — 26 observations, both directions of every boundary. A refusal whose condition no command can observe is a sentence, not a gate.

One observation is not a refusal: --abandon destroys a branch, so the harness deletes both branches and then restores the work from the verified tag in a clone that never had it. Claiming "recoverable" without recovering it once is the kind of green this repository refuses everywhere else.

Watched failing too — six mutations, each reddening exactly what reads it and nothing else: the name search narrowed to -maxdepth 1; the abandon pin checked with a local git tag -l instead of git ls-remote; the tag push skipped while the destroy runs anyway (which takes the pin check and the recovery — the rescue/full-spike-work failure reproduced on demand); the resume marker stubbed to always be present; the recorded head stubbed to always resolve; and the second-change search stopped excluding the resumed change's own name. What the harness does not cover is printed by the run itself — the "does this deserve a change?" judgement, the pull-request states, reverting code that reached the base, and whether an agent obeys a refusal it can see.

Licence

MIT — see LICENSE.

About

A change flow for OpenSpec repositories with one human gate at merge, bracketed by an explicit start and stop, plus drift checks that hold a specification to the code it claims to describe.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages