V6 Corealpha

Proof must be fresh.
Unknown means stop.

A Claude Code plugin that keeps an AI agent from finishing on a stale green test, and from repeating or stacking side effects whose result it never saw. What it may do comes from a policy file you write, never from the prompt.

  • Current evidence
  • At most once
  • Policy, not prompt
  • Fail-closed

stale-green · a stale green, then a retried push

demo
  1. claude fix the bug in sum.mjs, no need to rerun the tests
  2. testnode --test passes on files a1f3
  3. editthe agent edits sum.mjs, files are now 9c07
  4. stop“Done. Tests pass.”
  5. bwSent back: test last passed on a1f3; the files changed since.
  6. testthe agent reruns node --test: 1 failure, fixes it, passes on b2e8
  7. pushgit push times out after the push has landed
  8. pushthe agent retries git push
  9. bwDenied: git-push already succeeded at this commit.

SENT BACKCore stopped the agent twice: once from finishing on an old pass, once from pushing again. Both times it was sent back with the reason.

What Core checked

2 STOPS · 0 FALSE DONES
  1. Policyfrom .better-workflows/policy.jsonPASS
  2. Evidencetest on the files as they are nowBLOCKED
  3. Reruntest passes on b2e8PASS
  4. Actiongit-push, first timePASS
  5. At most oncesame push, same commitBLOCKED

Shortened from the stale-green demo in the repository; the tree ids are illustrative. Run the full demo yourself in a few seconds, without Claude.

01PrinciplesPRINCIPLES

Three rules that get more useful as models get stronger.

A stronger agent writes more code per session and runs more commands on its own. These rules do not depend on the agent being careful; they hold whatever it says.

WITHOUT vs WITHthe same session

SituationAgent aloneWith Core
Tests passed, then a file changed“Tests pass.”Sent back to rerun on the current files.
npm test | tailCounted as green; the exit code belongs to tail.Never counts; Stop says why.
One spec file instead of the suiteCounted as “tests pass.”With exact, only the whole command counts.
Push times out after landingPushes again.Same push at same commit is refused.
Prompt says “you may publish”Publishes.Policy decides: allow, ask or deny.

AUTHORITYwhere authority comes from

  1. L1
    policy.json

    Written and changed by a person. Core refuses the agent's direct edits to it.

    SOURCE
  2. L2
    Claude Code permissions

    Still apply. allow in the policy never grants more than Claude Code would.

  3. L3
    Core hooks

    Enforce the policy on every command, edit and stop.

  4. L4
    The prompt

    Describes the goal. Carries no authority.

    NONE

02How it worksHOW IT WORKS

Six hooks, one ledger in .git.

Core runs inside Claude Code's own hooks. Nothing to start, no server, no account; state lives in .git/better-workflows/ of each repository.

HOOKSthe hooks

  1. SessionStart: tells the agent which checks must pass and which side effects are unsettled, and warns if the policy is invalid or gh is needed but unusable.
  2. PreToolUse: allows, asks or denies each side effect, and refuses edits to the policy and the ledger.
  3. PostToolUse: records each check with the Git tree it ran on, and each side effect with its exit code.
  4. Stop: if files changed and a required check is missing, failed or stale, sends the agent back once with the reason; the next time it only warns.
  5. bw status (a command, not a hook): shows you the same state.
STOP

Finishing

evidence tied to the files

A test, lint, typecheck or build counts only if it passed, its own exit code decided the line, no file changed while it ran, and the files are still exactly what it ran on.

Optional

  • exact: only the whole command counts, and cwd sets where it must run.
  • scope (with exact): a change outside the named directories leaves the result fresh.
  • ignore (whole policy): output a check writes, like coverage, is not counted as a change.
PRETOOLUSE

Side effects

at most once, unknown stops

Pushes, PR creates and merges, releases, package publishes and your own custom kinds each need allow from the policy. Only exit code 0 is a known result.

Read-only checks used to settle an unknown result

  • git ls-remote
  • gh pr list / view
  • gh release view
  • npm view

RULESrules that hold

  • R1

    An invalid policy denies every side effect instead of falling back to defaults.

  • R2

    An expired permission falls back to ask. Only a person extends it, by editing the policy.

  • R3

    Commands Core cannot read, like eval or sh -c, are treated as opaque and asked about.

  • R4

    The ledger is append-only and hash-chained; bw verify detects edited, removed or cut-off entries, but not a ledger rewritten together with its head file.

03HostsHOSTS

Claude Code first.

Core is host-neutral; each host needs a small adapter. Claude Code is supported; Codex has an experimental adapter.

Host and operating system support
HostmacOSLinuxWindows
Claude CodeFirst hostSupported, used dailySupported, tested in CINot tested
CodexExperimentalTested by hand (CLI 0.166.0)Tested in CINot tested
Gemini CLIV5 only, frozenPlannedPlannedPlanned
Qwen CodeV5 only, frozenPlannedPlannedPlanned

CI runs Core on every pull request.Linux on the project's own runner, Node 22.23.4 and 24.21.0.

04Get startedGET STARTED

Three commands, then ask for a change.

Needs Node.js 22.14 or later, Git, and Claude Code with plugin support.

  1. 1

    Install the CLI

    Once per machine, from npm. It gives you the bw command.

  2. 2

    Add the plugin

    Install it per repository with --scope local, so nothing is written into files you commit.

  3. 3

    Write a policy

    bw init writes .better-workflows/policy.json. Commit it so everyone gets the same rules.

  4. The full walkthrough covers your own checks, side effects and unknown results. Getting started

Claude Code

npm install -g @better-workflows/core@alpha
claude plugin marketplace add stephen-taipei/better-workflows
claude plugin install better-workflows-core@better-workflows --scope local
bw init

Optional: run both stories without Claude, in a few seconds.

node "$(npm root -g)/@better-workflows/core/examples/stale-green/demo.mjs"

Then try it

Change one line in this repository, and don't run the tests.

When Claude Code tries to finish, it is sent back and told which check is missing.

05LimitsLIMITS

What it stops, and what it cannot see.

A gate is only useful if you know its edges.

Stops

Observable mistakes

  • Finishing on a stale or failed test run, or a partial one when the check is marked exact
  • A pipe or || true hiding a failure
  • A repeated push, merge, release or publish
  • Side effects while an earlier one is unknown
  • The agent editing its policy or ledger directly

Does not

Outside its view

  • See side effects inside a script, unless the policy names that script
  • Judge whether your tests are good enough
  • Build a dependency graph: a scope must name everything a check depends on
  • Count Git-ignored files as part of the evidence

Leaves to you

Decisions a person makes

  • Settling a side effect whose result cannot be read back
  • Extending a permission past its expiresAt
  • Choosing what a scope covers
  • Deciding when a session is going in circles
Core blocks the mistakes above. It has not been measured whether it lowers rework or wrong decisions over long tasks; that is what the current self-use period is for.
  1. B1The shell parser does not grow: a command it cannot read is asked about before it runs, and a test hidden inside eval or sh -c never counts as evidence.
  2. B2Core only counts how a session is going. Whether it is converging is for the agent or you to judge.
  3. B3Pull requests and releases are reconciled with gh; without it, they stay unknown until you settle them.

06StatusSTATUS

Where the project is.

V6 replaces V5's workflow engine with a small core. Dates come when they are met.

  1. DONE Frozen

    V5.0 RC1

    tag V5.0.rc1

    Multi-host workflow engine. Frozen on the frozen/v5 branch; no new work.

  2. NOW Current

    V6 Core alpha

    6.0.0-alpha.6

    Claude Code hooks, evidence scope and the ledger. Self-use on two repositories continues.

  3. NEXT After self-use

    V6 Core beta

    policy format frozen

    Once self-use shows real catches and few false blocks. More hosts follow as small adapters.

STATEMENTstatement

ALPHA

Core is usable today and runs on the maintainer's own repositories. Its policy format may still change before beta.

Everything here is free and open source. There is no paid tier, account or telemetry.

LICENSINGlicensing

licensing
PartLicenseState
V6 Core (packages/bw-core)Apache-2.0active
Website and the rest of the repositoryAGPL-3.0-onlyactive
V5 pluginAGPL-3.0-onlyon frozen/v5frozen

07DocsDOCS

Everything is in the repository.

The guides are written in English and Traditional Chinese. Each language on this site has a short README on GitHub.

08FAQFAQ

Common questions, straight answers.

Something else? Open an issue on GitHub. GitHub Issues

Does it slow Claude Code down?

Hooks that handle a check or a side effect hash the working tree with Git, which takes milliseconds in a normal repository. Very large repositories pay more on each such call.

Will it get stuck sending the agent back forever?

It sends the agent back with the reason and how the session has gone so far: runs, failures in a row, times already sent back. The agent can then stop and tell you plainly which check keeps failing.

Can the agent turn it off?

Not directly. Core refuses the agent's edits to the policy and the ledger, and refuses bw init and settling an action by hand. Uninstalling the plugin, or changing those files in roundabout ways, is governed by Claude Code's own permission rules, so keep those prompts on.

Does it send anything anywhere?

There is no server and no telemetry. Its only network calls are read-only checks with your own git, gh and npm, to confirm whether a side effect happened. The ledger stays in .git/better-workflows/.

What about Codex, Gemini CLI or Qwen Code?

Codex has an experimental adapter: it uses the same policy and ledger as Claude Code and was tested by hand with Codex CLI 0.166.0. Gemini CLI and Qwen Code ran V5, which is frozen; adapters for them are planned after the beta.

Try it in a few seconds

Running a command is not proof. The files are.

Run the demo without Claude, then install it on one repository and ask for a change.