Sets up pstack@pstack-claude in a project and keeps managed projects aligned with one pinned upstream tag and one shared overrides block. Project-only rules stay outside the block and never sync.
Layers
| Layer | Lives in | Changed by |
|---|---|---|
| Upstream | pstack@pstack-claude pinned tag in .claude/settings.json, ~/.claude/settings.json, Codex marketplace, and ~/.gemini/config/plugins/pstack |
sync --tag and user-pin. Never edit upstream pstack. |
| Shared | assets/block.md (between pstack:begin/pstack:end in AGENTS.md), assets/pstack/*.mjs -> .agents/pstack/, and assets/pstack/rules/*.md -> .agents/pstack/rules/ |
Edit in udecode/ustack, then sync |
| Project | .agents/pstack.json, .agents/playbooks/*.md, and project rules outside the block (which win over the block) |
Project edits or setup |
Commands
Run node <skill>/scripts/sync-pstack.mjs <command> from the udecode/ustack checkout when present (assets/ is the source of truth):
| Command | Effect |
|---|---|
discover <project> |
JSON facts for setup interview. Read-only. |
status [project...] |
Latest upstream tag, user pins, and per-project pin/drift/source revision. Skips linked worktrees and autoSync: false projects unless named. Read-only. |
apply <project> |
Renders block, rules, helpers, and project pin from .agents/pstack.json. Supports --tag <tag>, --dispositions <tsv>, --dry-run, --force. Refuses main checkout of a trunk project with pstack.delivery set. |
check <project> |
Exits 1 if apply would change anything. Read-only. |
verify <project> |
Checks typed-command resolution (against dropped), dead skill links, retired skill mentions, block/rule anchor notes, and check. Read-only. |
sync --tag <tag> [project...] |
Runs apply --tag across managed (non-held) projects; refuses off-branch or dirty targets unless --allow-dirty. |
playbook <project> <name> |
Prints resolved steps for .agents/playbooks/<name>.md applied onto its base pstack playbook(s). Read-only. |
smoke <project> <prompt>... |
Runs read-only routing smoke (`--runtime claude |
corpus [project...] |
Diffs installed vs local decisions-check.mjs across project ledgers and decision logs (--session <id>, --installed <dir>, --out <dir>). Read-only. |
user-pin --tag <tag> |
Updates user-scope pstack pin and prints refresh commands. |
latest |
Prints newest upstream tag. |
Anchor checks use ~/.cache/sync-pstack/ (override with SYNC_PSTACK_UPSTREAM).
Modes
| Request | Mode |
|---|---|
| Set up or install pstack in a repo | Setup |
| Sync, bump, or update pstack | Sync |
| Compare setups or list drifted projects | Compare (read-only) |
| Audit skills, playbooks, or pstack overrides | Use skill-audit |
Change which work auto-runs architect, panel, or arena |
Reviews |
| Propagate a shared workflow lesson or fix | Lesson |
| Add or edit a project playbook | Project playbooks |
A shared-source change syncs only the active project (none when working directly in ustack) unless the owner names other projects.
Setup
- Discover: Run
discover <project>and readAGENTS.mdand routed workflow rules in full. - Interview: Follow interview.md; always confirm delivery mode, recommend defaults unless evidence argues otherwise, never re-ask settled answers.
- Record: Write
.agents/pstack.jsonwithtagfromlatest. - Adapt: Follow adapt.md: delete vendored pstack copies, settle overlapping skills/rules, keep formatters off synced files, wire routing and proof skill, regenerate skills if configured.
- Apply: Run
apply <project> --dry-run, inspect diff, thenapply <project>. - Verify: Confirm
status <project>user pins match (else runuser-pin), models sheets exist (.claude/pstack-models.md,~/.codex/pstack-models.md,~/.gemini/config/pstack-models.md), run one routing smoke on a plain prompt (without naming the playbook or trigger words), runlintFix, and runverify <project>. - Deliver: Follow the project's delivery mode. For
trunk, setgit config pstack.delivery pushlocally only if direct-push was approved.
Sync
- Run
status; pin only a tag printed bylatest. - When bumping tags, read upstream
CHANGES.mdfrom~/.cache/sync-pstack/(git -C <clone> show <tag>:CHANGES.md). Judge each new/changed upstream skill or step per project:already wired,wire it in,manual only, ornowhere. Fold shared block updates through Lesson. - Run
sync --tag <tag> --dry-runon projects in scope. Write a tab-separated dispositions file (item,none|covered|noted|rewritten|dropped,reason) for every printed diff hunk and count line, then runsync --tag <tag> --dispositions <tsv>. - Resolve refusals cleanly: move generic edits to
ustack(Lesson) and project edits outside the block before--force; commit/push dirtyustackedits before syncing; rewrite broken upstream anchors. - Run
user-pin --tag <tag>and its refresh commands before smoking. - Run
verify <project>and smoke any changed playbook, gate, or rewritten/dropped disposition. Runskill-auditif upstream added/changed skills. - Deliver per project delivery mode (
trunkin a worktree vialand.mjs;pushcommits and pushes;prpushes directly to<branch>with[skip ci]if workflow filters allow;userleaves for owner).
Compare
Run status. For each unmanaged pstack project, map every override against the shared block (covered, project adaptation, policy difference, drift, unresolved), citing source paths and smallest reconciliation. Apply nothing without a request.
Reviews
.agents/pstack.json's reviews array holds { "id": "<kebab-case>", "rule": "<one sentence>" } entries naming work that auto-runs architect, interrogate, or arena.
- Inspect upstream playbook calls at the project's pin; add/update/delete rows per project.
- Cite
(reviews: <id>)on matching project playbook lines and drop uncited tool calls. - Run
apply,verify, and smoke one covered and one uncovered plain request.
Lesson
Use when a lesson or fix applies to every managed project (project-only lessons go outside the project's block).
- Fetch/fast-forward
udecode/ustackonmainand edit in place (never create branches or worktrees inustack). - Edit
assets/block.md,assets/pstack/rules/*.md, orassets/pstack/*.mjs:- Subtract before adding: remove dead rules, redundant validators, and overlapping prose first.
- Guard system boundaries only (CLI args, config, git pushes, PR creation, external APIs), never internal agent notes.
- When encoding a rule structurally (check, lint, type, hook), delete the prose rule it replaces.
- Respect hard size budgets enforced by
scripts/validate-skills(block-budget.mjs+budget-check.mjs). - Keep project-specific names/paths out (use
<!-- if key -->and optional config fields).
- Run
apply <project> --dry-run(andcorpusfor ledger helper changes) on projects in scope. - Run writing passes (
deslop/no-commentson helpers,unslopon prose),node scripts/build-workflow.mjs, andscripts/validate-skills. - Commit and push
ustack(committing any other session's remaining edits in a second commit perustack/AGENTS.md). Never amend or rebase a commit a project already synced from. - Sync each project in scope from the pushed commit, run
verify <project>, reinstall any changedustackskills, and deliver per Sync step 7.
Project playbooks
Project playbooks live in .agents/playbooks/<name>.md with extends and when frontmatter plus anchored edits (**Before**, **In**, **After**, **Replace**). Optional page-lead, page-pairs, page-require, and page-pr frontmatter lists configure which review sections plan-page.mjs --pr includes. Run playbook <project> <name> after edits to inspect resolved steps.
Template grammar
assets/block.md and assets/pstack/rules/*.md support line directives:
<!-- if key -->,<!-- if !key -->,<!-- if key=a|b -->,<!-- if key!=a --><!-- section id -->(omitted whenskipincludesid)<!-- end -->(closes innermost region; regions nest){{key}}(required config value; missing fails render)<!-- # overrides <path> "<text>" -->,<!-- # relies <path> "<text>" -->,<!-- # adds -->: anchor notes verified against upstream pstack at the pinned tag;verifyflags unnoted rules.- Indented lines continue the list item above them.