A gated engineering method for Claude Code, built for working without reading every diff yourself. The agent routes each task to a playbook with evidence gates, proves behaviour on the running app, gets an independent verdict bound to the exact head SHA, and can only merge when the checks are green and that verdict exists. Hooks enforce what prose cannot hold.
Before the build, a planning layer turns ideas and bug reports into GitHub issues with acceptance criteria, so work survives between sessions and machines and an agent can take the next ticket without asking.
It is a distillation of pstack and of the planning skills in mattpocock/skills, in its own words, rewritten for Claude Code without the Cursor-only machinery. See NOTICE.
In a shell, on each machine:
claude plugin marketplace add bfcarrasco/bstack
claude plugin install bstack@bstackThen, in a Claude Code session, run /bstack:setup, in every Claude config dir you use (~/.claude and any other set through CLAUDE_CONFIG_DIR). It turns on auto-update for this marketplace (off by default for third-party marketplaces, so an install without it stays on the commit it was installed at), turns off AI attribution, and checks node, git and gh. Updates then arrive on their own after each merge to main. The plugin has no version on purpose, so installs track commits.
To see whether a machine is current, run node <plugin dir>/scripts/install-status.mjs <config dir>.... It prints the installed commit against main, whether auto-update is on, and the command that updates a profile that is behind.
Requirements: Node 18+ on PATH (the hooks are Node scripts), git, and the GitHub CLI (gh) logged in for the repos you work on.
| Part | What it does |
|---|---|
Session rules (rules/) |
Injected at every session and subagent start by a hook, so they hold without anyone loading a skill. |
bstack:mode |
Router: goal, smallest change, playbook and risk tier. Playbooks: investigate, bug-fix, feature, refactor, migration, ticket, ship, autonomous-run. |
bstack:plan |
Sizes the work, grills you where intent is unclear, and writes a spec with ticket sub-issues, or a map of decision tickets for foggy work. Keeps GLOSSARY.md and ADRs. |
bstack:orchestrator |
One T3 Code thread for all repos: takes a goal, starts one lane (a child thread in its own worktree) per ticket on the model scripts/model.mjs lane names, answers the lanes' technical questions and asks you only what is yours to decide. See Orchestrator. |
bstack:triage |
Sorts incoming issues: checks the claim, finds duplicates and work already done, writes acceptance criteria, labels the state. |
bstack:audit |
Review and clean up a whole repo: map, find, prove, present once, fix through small gated PRs. |
bstack:vibecoding |
Prototype an idea fast when you ask for it: no plan, tests, PR or review before it runs. Then discard it, or harden it into a ticket that ships through the full gate. |
bstack:verify |
Run the app safely on test data and prove behaviour on the real surface. |
bstack:frontend |
UI rules for web apps: container-query-first layout, tokens with Automatic.css 4 names, component boundaries, basic accessibility. Ships a starter token sheet. |
bstack:comments |
Comment cleanup judged by a critic agent, not the author. See Comments. |
bstack:correct |
Turn repeated mistakes into checks (weekly or after a revert). |
bstack:judge agent |
One judge per code PR in its own worktree: breaks the change with reproductions and proves or breaks every acceptance criterion. The guard starts it on Opus for tier 2 and risk paths, on Sonnet otherwise (the table in scripts/lib/models.mjs, the decision on #226), and starts a bstack:worker on Sonnet for an expected tier 0-1 ticket in an internal repo, unless the call names a model. A judge status records the tier it judged (PASS tier=2), so the gate knows it broke a tier 2 change. It replaced the reviewer and adversary agents (#254); their old statuses and comments still count. |
bstack:comment-critic agent |
Classifies each comment and suppression with proof; has only Read, Grep and Glob. |
bstack:worker agent |
Its own context for one scoped change, and for the fix rounds on it. |
scripts/checks.mjs |
Runs the repo's check commands on the builder's machine and posts the result on the PR head. See Checks. |
idea or bug report -> bstack:triage or bstack:plan -> tickets (issues) -> ticket playbook -> PR -> checks + judge verdict -> merge -> deploy (your OK)
- One PR, clear: no plan, straight to a playbook.
- Several PRs, clear goal: a grilling session, then a spec issue (
plan:spec) with one sub-issue per PR, ordered with GitHub's native blocking. - Foggy: a map issue (
plan:map) with decision tickets (plan:research,plan:prototype,plan:grill,plan:task), one decision per session, until the way is clear and a spec can be written. - Build: "take the next ticket" picks the first open, unblocked, unclaimed ticket (
scripts/tracker.mjs next), builds it as one PR withCloses #<n>, and the judge judges it against the ticket's acceptance criteria. - Issues are kept by the agent, never by hand. Specs are temporary: once merged, the code and tests are the truth.
scripts/tracker.mjs labelscreates the labels a repo lacks and changes nothing else. It needsgh2.94 or newer.scripts/tracker.mjs board -R owner/repo [-R owner/repo ...]rebuilds what is in flight from GitHub alone: open specs and maps with progress, claimed tickets with their PRs, open PRs with checks, latest verdict and blocking rounds, tickets waiting for a person, andnext. It only reads, and prints no issue bodies, comments or diffs.
Start a new thread in T3 Code, in any project, on your usual model at medium effort, and write /bstack:orchestrator followed by the goal, for example /bstack:orchestrator byg #42 i owner/repo. Leave the thread open; T3 wakes it when a lane finishes or asks.
- Each ticket becomes a lane: a child thread started with
delegate_taskin a worktree from the default branch, with a brief of Goal, Done when, Constraints and Result form (scripts/lane.mjs brief). The lane is a full bstack session: it builds, starts its own judge and merges. - A lane answers with JSON that matches
skills/orchestrator/lane-result.schema.json(scripts/lane.mjs resultchecks it). The orchestrator reads no diff, log or transcript. - It answers technical questions itself and records them on the ticket. Questions on the stop list, and about goal, scope or priority, come to you together, each with a recommended answer, while the other lanes go on.
The guard runs before every Bash and PowerShell command (Windows routes shell commands through PowerShell, so a Bash-only hook would never fire there), every file write and every MCP tool call. It fails closed.
- No direct push to
mainormaster, no--allor--mirrorpushes. - No
--no-verify. No plain force-push (only--force-with-lease). No rebase of a branch that is already pushed. gh pr mergeonly as--squash, never--autoor--admin, and only when the risk tier, computed byrisk-tier.mjsfrom the PR diff, is 0 (docs only: no check on the head is needed), or when:- the checks are green on the head SHA (no checks, or only skipped checks, is not green), and
- a judge verdict exists for that exact SHA (or carries to it, see below) and is not FAIL, and for tier 2 the result described under risk tiers.
- No merging or moving
mainthrough side doors:gh apimerge and ref endpoints, the contents API on the default branch, GraphQL merge mutations, MCP merge or push tools. - No commit status or check run written by an agent through
gh api, an inline GraphQL mutation or a GitHub MCP tool: the merge gate reads them as green CI. Rerun a workflow withgh run rerun. - Verdicts are posted by a
SubagentStophook when the judge agent finishes, after it checks that the SHA is still the PR head: a commit status on the judged head, which the merge gate reads, and a comment with the report, which it does not. The user-OK line counts only as a whole comment of its own, never quoted among other text; the guard refuses aghcomment, review, issue or API write whose command line (heredocs and piped commands included) or readable body file holds it. The gate does not check who wrote that comment (#109). - No second judge on a judged head: starting
bstack:judgewith a prompt that names one PR (PR <n> in owner/repo) is refused when that PR's head already has a judge result status, or a blocking result of any judge. A new judge needs a new head. On any doubt (no PR named, a PR that cannot be read, any other agent type) the agent starts.
A new commit changes the head SHA, so an old verdict no longer counts, with one exception. A verdict judged on an older head carries to the current head when:
- every commit after the judged head is a merge of the base branch,
- the PR's own diff is the same on both heads (code files line for line, ignoring only index lines and hunk headers; docs files such as
CHANGELOG.md, unless.github/risk-paths.txtlists them, by their added and removed lines), - the checks are green and the risk tier is not higher on the current head, and
- at tier 2, the base branch changed none of the code files the PR changes.
The guard then posts a comment with both heads, the merge commits and the diff fingerprint they share. What it cannot see is a semantic conflict: the base branch changing code the PR depends on in another file. The checks on the merged head are the only guard against that.
A repo can make GitHub itself refuse a merge without the checks and the judge, with a ruleset that requires the bstack/judge status. Every head the gate lets through carries a passing one:
- a judged head: the hook's status;
- a carried result: the gate writes
bstack/judgeon the current head besidebstack/verdict, withcarried-from=<sha>; - a docs-only (tier 0) head: the gate writes
docs only (tier 0), no judge needed; - a head merged on the owner's OK line (judge UNPROVEN, or after three blocking rounds): the gate writes
owner-ok judge=<the judge's result>, linked to the judge's comment, once per head. GitHub keeps only the newest status per context, so the gate and the rounds reader read this one back as the judge result it replaced, never as a PASS.
The gate runs from the installed plugin, never from the PR, so a PR cannot change what it posts. Carried and docs-only statuses do not count as a judge result when the gate reads them back.
.github/ruleset-main.json requires this repo's CI jobs and bstack/judge on the default branch. Create it once, from the repo root:
gh api -X POST repos/{owner}/{repo}/rulesets --input .github/ruleset-main.jsonCreate it only after every machine that merges in the repo runs a plugin version with this gate; an older gate posts no bstack/judge for docs-only or owner-ok heads, so GitHub refuses those merges. A head whose only PASS is a legacy bstack/verdict from before the judge has no bstack/judge either and needs a fresh bstack:judge.
Another repo copies the file and lists its own CI job names. The ruleset has no bypass actors: agents use the owner's account, so an admin bypass would let every agent past it. bstack/judge has no integration_id, since the gate posts it with the user's token, so any token with statuses: write can satisfy it on GitHub; the guard's merge gate still holds for agents.
What gates a PR runs on the builder's machine, once per head, instead of in a workflow run per push.
.github/bstack-checks.txtlists the commands, one per line (format, lint, types, tests). Blank lines and lines that start with#are ignored.node <plugin dir>/scripts/checks.mjs [--pr <n>] [-R owner/repo]runs every command from the repo root, also after one fails, and, when the PR's base branch orHEADhas.github/comment-baseline.json, the comment ratchet (see Comments) on the PR's diff from the PR's base sha. It exits 0 when all passed, 1 when one failed and 2 when there is neither a command nor a baseline. With no PR it says the comment check was not run; a base missing from the clone fails it with the fetch to run. For a PR the commands getBSTACK_PR,BSTACK_PR_TITLE,BSTACK_HEAD_SHAandBSTACK_BASE_SHA.- It posts the commit status
bstack/checks(success, orfailurenaming the first failing command) only when an open PR exists,HEADis that PR's head, and the tree is clean, before and after the commands ran. Otherwise it printsnot posted: <reason>. The merge gate reads the status like any other check. nightly.ymlis the workflow template a repo copies: once a night on the default branch, skipped when the branch has not moved, it runs the same commands on a clean machine, then what changes with time rather than with the diff (a release build, advisories), and opens an issue when it fails.- A repo without the checks file is gated by whatever its workflows post. When the base branch has a comment baseline, the merge gate also needs
bstack/checkssuccess on the head. bstack itself keeps its pull-request workflow: the repo is public, and the guard must be proven on Windows before it reaches every session.
- 0: docs only. Nothing: it merges without a check on its head. Docs are a strict list: a path ending in
.md,.rstor.adoc, or a file named exactlyLICENSE,NOTICE,CHANGELOGorREADME, with no extension or one of those three or.txt. Not docs: anything underskills/,agents/,rules/,commands/,.claude/or.cursor/, and agent instruction files (AGENTS.md,CLAUDE.md,GEMINI.mdand their variants such asCLAUDE.local.md,copilot-instructions.md,*.instructions.md,*.prompt.md). A renamed or copied file is docs only when both its paths are. An entry the diff does not show as plain text is tier 1: a binary file, a file mode other than 100644 (executable, symlink, submodule), an entry without a changed line, or a diff header the parser cannot read. A PR diff that names no file blocks the merge. - 1: code, config, CI, agent instructions, and weakened checks: a skipped or removed test, a deleted test file or one renamed out of the suite, fewer assertions, a new lint or type suppression, a CI step removed, changed or allowed to fail, a removed line in
.github/bstack-checks.txt. Green checks and a judge verdict.risk-tier.mjsprints each weakened check as a reason that starts withweakened check:, and the judge fails it unless the PR body says why. These reasons are never cut from the list; the other reasons stop at twelve. - 2: the judge also breaks the change. SQL that writes or deletes data or changes schema, code that removes files, calls that delete (
.delete(on an HTTP client or session, theDELETEmethod), outbound calls with side effects, mail and webhooks, concurrency, auth and importer code,n8n/code. Adds the user's OK when a revert cannot undo it. A runnable test file is never auth or importer code by its name.
Tier 2 takes one judge run per PR. The guard walks the head's first parents through the PR's commits and takes the tier 2 result on the latest commit that has one (the newest, when that commit has several); a later result on an older commit never overrides it. With blocking findings, a commit that is not a merge-in of the base branch must follow it, and the head's verdict must be newer: the fix goes through the bug-fix playbook and a fresh judge re-runs each reproduction on the new head. Two kinds of PR keep rounds until clean instead, which means a result without blocking findings for the head itself, and the user's OK line after three blocking rounds: a PR that changes a path listed in .github/risk-paths.txt, and a PR that changes a policy file (risk-paths.txt or bstack-exposure.txt), which always needs the user's OK line for the head.
In prose files (.md, .rst, .txt, .adoc, not CMakeLists.txt), a skipped test or || true counts only where Claude Code may execute it: inside a ```! block, on a line that contains !` anywhere (also with $ARGUMENTS or another argument placeholder between them) and on to the next backtick after it, in a file's leading YAML frontmatter (where skill and agent hooks: live), or anywhere in a file under commands/. The guard reads such a file at the PR head to see that; when it cannot, the line counts as a weakened check.
A repo can raise paths to tier 2 with globs in .github/risk-paths.txt. A file renamed out of a listed path is still listed. The guard and risk-tier.mjs --pr read it from the PR's base branch through gh, never from the checkout; without --pr, risk-tier.mjs reads it from --base (default origin/HEAD). A missing file means no extra paths; any other read failure blocks the merge. A PR that changes the file is tier 2.
.github/bstack-exposure.txt on the base branch decides what is tier 2: exactly internal, else external. External: every tier 2 reason above. Internal: only a schema or migration file, a SQL schema statement, SQL that deletes data (DELETE FROM, TRUNCATE), code that removes files, calls that delete, the policy files, and paths listed in risk-paths.txt; the other reasons are tier 1 and keep their reason text. The guard reads the file like risk-paths.txt, and only for a PR that is tier 2 as external: a missing file is external, any other read failure blocks the merge.
The guard catches mistakes. For every agent, judges included, it holds four things:
- no merge without green checks and a verdict status for the merged head,
- no push to the default branch,
- no rewrite of shared history,
- only the hook writes verdict statuses (and an agent does not post the owner's OK line).
Judges run what builders run: there is no command list for them.
It is not a security boundary. A determined agent with the same token can go around it, by design: the threat model is mistakes, not cheating.
The goal is fewer comments: what a comment says becomes a better name, a check, an ADR or nothing.
bstack:commentsspawns the critic on a diff or paths, checks its report, and acts per class: deletes tautologies and stale comments, fixes excuses and suppressions that hide bugs, encodes constraints as checks, writes ADRs, opens issues for the rest. Only external facts with proof stay, asexternal: <fact> (<proof>).scripts/comments.mjs countestimates comment lines and suppressions per file. The skill's first run in a repo writes.github/comment-baseline.jsonwithcomments.mjs baselineafter the cleanup; later runs rewrite it when counts fell.- The ratchet: in a repo with the baseline,
checks.mjsalso failsbstack/checkswhen a file in the PR diff has more comment lines than both its baseline and its version at the PR base, with the files and the fix.bstack:auditsends its comment findings tobstack:comments.
Open one Claude Code session per repo, each in its own worktree, and ask for an audit:
/bstack:audit
The agent maps the repo, runs the existing and the stricter checks, proves each finding, presents them once ranked, then lands checks first and fixes after, as small PRs through the merge gate.
- The gate stops forgetting, stale verdicts and side doors. It does not stop an agent determined to cheat (for example by obfuscating the user-OK line). On a free GitHub plan, a private repo cannot enforce required status checks server-side, so this is its enforcement layer; a public repo adds them with a ruleset.
risk-tier.mjsis a heuristic. It errs towards higher tiers. You may treat a change as riskier, never as safer.- Weekly quota: the judge runs Opus for tier 2 and risk paths and Sonnet otherwise, only where the tier calls for it.
node --test "tests/*.test.mjs"
node tools/check-plugin.mjs
claude plugin validate .Changes go through pull requests like anything else. Changes to rules and playbooks change every session, so they need the owner's OK.