agentleFS
SienkLogicSienkLogic/plan-build-run/CLAUDE.md

plan-build-run

CLAUDE.md17 starsChanged 8 months agoMITView on GitHub

Plan-Build-Run is a Claude Code plugin that provides a structured development workflow. It solves context rot — quality degradation as Claude's context window fills up — through disciplined subagent delegation, file-based state, and goal-backward verification. Users invoke /pbr:* slash commands (skills) that orchestrate specialized agents via Task(). Coverage thresholds (enforced in jest.config.cjs): 55% statements, 47% branches, 58% functions, 56% lines. Dashboard (separate dependency tree): Load the plugin locally for manual testing: CI runs on Node 20/22 across Windows, macOS, and…

The file

We split this CLAUDE.md into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Hook ordering: When multiple PostToolUse hooks fire on the same event (e.g., Write|Edit), execution order is not guaranteed.

    line 105
  2. Very specific:

    Releases: Run node scripts/release.js to bump version, generate changelog (via git-cliff), tag, push, and create GitHub Release.

    line 123
  3. Very specific:

    Mutation tests: Use fs.mkdtempSync() to create temporary directories — never mutate the fixture project.

    line 179
  4. Distinctive:

    When adding a new hook script, create a corresponding test file.

    line 181

≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

What This Is

Plan-Build-Run is a Claude Code plugin that provides a structured development workflow. It solves context rot — quality degradation as Claude's context window fills up — through disciplined subagent delegation, file-based state, and goal-backward verification. Users invoke /pbr:* slash commands (skills) that orchestrate specialized agents via Task().

Critical Rules

  • NEVER add AI co-author lines to git commits or PRs. No Co-Authored-By: Claude or similar. Only add co-author lines referencing actual human contributors.
  • NEVER inline agent definitions into skill prompts. Use subagent_type: "pbr:{name}" — Claude Code auto-loads agent definitions from agents/. Reading agent .md files wastes main context.
  • Always use PBR workflow commands (/pbr:* skills) for development work, not ad-hoc manual fixes. PBR skills enforce state tracking, verification, and artifact creation that manual edits skip. When hooks don't fire (e.g., direct file edits outside Claude Code), workflow integrity degrades silently.
  • Post-work checklist — before finishing any task or session, verify: (1) npm test passes, (2) no uncommitted changes (git status is clean), (3) file paths in artifacts are correct and files exist. This catches drift that accumulates during long sessions.

Commands

npm test                    # Run all Jest tests
npm run test:coverage       # Jest with coverage enforcement
npm run test:dashboard      # Vitest dashboard tests
npm run lint                # ESLint on hooks and tests
npm run build:hooks         # Bundle hooks for distribution
npm run sync:generate       # Generate derivative plugins
npm run sync:verify         # Verify derivative consistency
npm run dashboard           # Launch dashboard UI
npm run dashboard:install   # Install dashboard dependencies

Coverage thresholds (enforced in jest.config.cjs): 55% statements, 47% branches, 58% functions, 56% lines.

Dashboard (separate dependency tree):

npm run dashboard:install                   # One-time install of dashboard deps
npm run dashboard -- --dir /path/to/project # Launch dashboard for a project

Load the plugin locally for manual testing:

claude --plugin-dir .

CI runs on Node 20/22 across Windows, macOS, and Linux. All three platforms must pass.

Architecture

Three layers:

Skills (plan-build-run/skills/{name}/SKILL.md)

Markdown files with YAML frontmatter defining slash commands (/pbr:new-project, /pbr:plan-phase, etc.). Each SKILL.md is a complete prompt that tells the orchestrator what to do. Skills read state, interact with the user, and spawn agents.

46 skills: audit, begin, build, config, continue, dashboard, debug, discuss, do, explore, health, help, import, intel, milestone, note, pause, plan, profile, quick, resume, review, scan, setup, status, statusline, test, todo, undo, and more.

Agents (agents/{name}.md)

Markdown files with YAML frontmatter defining specialized subagent prompts. Agents run in fresh Task() contexts with clean 200k token windows. Spawned via subagent_type: "pbr:{name}" — auto-loaded by Claude Code.

18 agents: audit, codebase-mapper, debugger, dev-sync, executor, general, integration-checker, intel-updater, nyquist-auditor, plan-checker, planner, researcher, roadmapper, synthesizer, ui-checker, ui-researcher, verifier.

Hook Scripts (plugins/pbr/scripts/*.js)

66 Node.js hook scripts that fire on Claude Code lifecycle events. Configured in plugins/pbr/hooks/hooks.json. All use CommonJS, must be cross-platform (path.join(), not hardcoded separators), and log via logHook() from hook-logger.js.

Dispatch pattern: Several hooks use dispatch scripts that fan out to sub-scripts based on the file being written/read:

Hook EventEntry ScriptDelegates To
SessionStartprogress-tracker.js— (injects project state)
PostToolUse (Write|Edit)post-write-dispatch.jscheck-plan-format.js, check-roadmap-sync.js, check-state-sync.js
PostToolUse (Write|Edit)context-bridge.js— (context tier tracking)
PostToolUse (Write|Edit)graph-update.js— (architecture graph)
PostToolUse (Write|Edit)architecture-guard.js— (dependency violations)
PostToolUse (Write|Edit)suggest-compact.js— (context budget warnings)
PostToolUse (Read|Glob|Grep)track-context-budget.js— (tracks reads for budget)
PostToolUse (Bash)post-bash-triage.js— (test output triage)
PostToolUse (Bash)context-bridge.js— (context tier tracking)
PostToolUse (Task)check-subagent-output.js— (validates agent output)
PostToolUse (Task)context-bridge.js— (context tier tracking)
PostToolUse (AskUserQuestion)track-user-gates.js— (gate tracking)
PostToolUseFailurelog-tool-failure.js— (logs failures)
PreToolUse (Bash)pre-bash-dispatch.jsvalidate-commit.js, check-dangerous-commands.js
PreToolUse (Write|Edit)pre-write-dispatch.jscheck-skill-workflow.js, check-summary-gate.js, check-doc-sprawl.js
PreToolUse (Task)pre-task-dispatch.js— (build/plan gates)
PreToolUse (Skill)pre-skill-dispatch.js— (context budget, args)
PreToolUse (Read)block-skill-self-read.js— (prevents SKILL.md self-read)
PreToolUse (EnterPlanMode)intercept-plan-mode.js— (blocks plan mode in PBR)
PreCompactcontext-budget-check.js— (preserves STATE.md)
PostCompactpost-compact.js— (post-compact recovery)
Stopauto-continue.js— (chains next command)
SubagentStartlog-subagent.js— (tracks lifecycle)
SubagentStoplog-subagent.js, event-handler.js— (auto-verification trigger)
TaskCreatedlog-subagent.js— (early agent signal, audit logging)
TaskCompletedtask-completed.js— (processes task completion)
InstructionsLoadedinstructions-loaded.js— (instruction reload detection)
ConfigChangecheck-config-change.js— (config change detection)
WorktreeCreateworktree-create.js— (worktree setup)
WorktreeRemoveworktree-remove.js— (worktree cleanup)
Notificationlog-notification.js— (notification logging)
UserPromptSubmitprompt-routing.js— (prompt routing)
SessionEndsession-cleanup.js— (cleanup)

Hook exit codes: 0 = success, 2 = block (PreToolUse hooks that reject a tool call).

Hook ordering: When multiple PostToolUse hooks fire on the same event (e.g., Write|Edit), execution order is not guaranteed. See references/archive/hook-ordering.md for ordering expectations, design rules, and known safe pairs.

${CLAUDE_PLUGIN_ROOT}: Used in hooks.json to reference script paths. Claude Code expands this internally — works on all platforms without shell expansion.

Supporting Directories

  • plan-build-run/bin/ — CLI tools (pbr-tools.js + lib/ modules)
  • plan-build-run/references/ — Shared reference docs loaded by skills (plan format, commit conventions, UI formatting, deviation rules)
  • plan-build-run/templates/ — EJS-style .tmpl files for generated markdown (VERIFICATION.md, SUMMARY.md, etc.)
  • plugins/pbr/commands/ — 71 command registration files (one .md per command mapping to its skill)
  • plan-build-run/skills/shared/ — 15 shared skill fragments extracted from repeated patterns across skills
  • plugins/ — Derivative plugins (codex-pbr, cursor-pbr, copilot-pbr)
  • dashboard/ — Vite + React 18 dashboard with Express backend

Key Conventions

Commit format: {type}({scope}): {description} — enforced by PreToolUse hook. Types: feat, fix, refactor, test, docs, chore, wip, revert, perf, ci, build. Scopes should be component names: hooks, skills, agents, cli, dashboard, templates, plugin, ci, config, tests, commands, refs. Also accepts quick-{NNN}, planning, or descriptive words.

Releases: Run node scripts/release.js to bump version, generate changelog (via git-cliff), tag, push, and create GitHub Release. The changelog groups entries by component (Hooks, Skills, Agents, etc.) based on commit scope and message keywords.

Skill frontmatter (SKILL.md):

---
name: skill-name
description: "What this skill does"
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Task
argument-hint: "<N> [--flag]"
---

Agent frontmatter ({name}.md):

---
name: agent-name
description: "What this agent does"
memory: none|user|project
isolation: worktree        # Run agent in isolated git worktree (optional)
color: <name|hex>          # Terminal color for agent output (optional)
permissionMode: default    # Optional: permissions for agent (optional)
tools:
  - Read
  - Write
  - Bash
---

Model selection is config-driven via config.json models map, not via agent frontmatter.

Data Flow

Skills and agents communicate through files on disk, not messages:

.planning/STATE.md      <- source of truth for current position
.planning/ROADMAP.md    <- phase structure, goals, dependencies
.planning/config.json   <- workflow settings
.planning/phases/NN-slug/
  PLAN.md               <- written by planner, read by executor
  SUMMARY.md            <- written by executor, read by orchestrator
  VERIFICATION.md       <- written by verifier, read by review skill

The orchestrator stays lean (~15% context) by delegating heavy work to agents. Each agent gets a fresh context window.

Utility library: plan-build-run/bin/pbr-tools.js is a shared Node.js library (stateLoad, configLoad, frontmatterParse, mustHavesCollect, etc.) used by multiple hook scripts. It provides CLI subcommands that agents call to avoid wasting tokens on file parsing.

Testing

Tests live in tests/ using Jest. Test files mirror script names: validate-commit.test.js tests validate-commit.js.

Dashboard tests live in dashboard/tests/ using Vitest (not Jest). Run with npm run test:dashboard.

Fixture project: tests/fixtures/fake-project/.planning/ provides read-only fixture data for tests.

Mutation tests: Use fs.mkdtempSync() to create temporary directories — never mutate the fixture project.

When adding a new hook script, create a corresponding test file. Tests must pass on Windows, macOS, and Linux.

Dashboard

The dashboard (dashboard/) is a Vite + React 18 application with a separate Express backend (dashboard/server/). It provides a web UI for browsing .planning/ state. Frontend: React 18, recharts, lucide-react. Backend: Express server with chokidar for file watching, WebSockets for live updates. CLI entry point: dashboard/bin/cli.cjs (default port 3141).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.