buildanything 1.8.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +9 -3
- package/CHANGELOG.md +57 -0
- package/README.md +2 -2
- package/agents/a11y-architect.md +166 -0
- package/agents/business-model.md +80 -29
- package/agents/code-architect.md +75 -0
- package/agents/code-reviewer.md +255 -0
- package/agents/code-simplifier.md +64 -0
- package/agents/design-brand-guardian.md +293 -53
- package/agents/design-critic.md +139 -0
- package/agents/design-inclusive-visuals-specialist.md +6 -19
- package/agents/design-ui-designer.md +335 -56
- package/agents/design-ux-architect.md +403 -55
- package/agents/design-ux-researcher.md +264 -49
- package/agents/engineering-ai-engineer.md +26 -36
- package/agents/engineering-backend-architect.md +185 -36
- package/agents/engineering-data-engineer.md +225 -43
- package/agents/engineering-devops-automator.md +227 -74
- package/agents/engineering-frontend-developer.md +210 -34
- package/agents/engineering-mobile-app-builder.md +6 -1
- package/agents/engineering-rapid-prototyper.md +30 -9
- package/agents/engineering-security-engineer.md +263 -61
- package/agents/engineering-senior-developer.md +128 -19
- package/agents/engineering-sre.md +84 -0
- package/agents/engineering-technical-writer.md +285 -41
- package/agents/feature-intel.md +110 -0
- package/agents/ios-app-review-guardian.md +19 -2
- package/agents/ios-foundation-models-specialist.md +20 -2
- package/agents/ios-storekit-specialist.md +9 -2
- package/agents/ios-swift-architect.md +28 -1
- package/agents/ios-swift-search.md +8 -1
- package/agents/ios-swift-ui-design.md +33 -1
- package/agents/marketing-app-store-optimizer.md +246 -64
- package/agents/planner.md +216 -0
- package/agents/pr-test-analyzer.md +63 -0
- package/agents/product-feedback-synthesizer.md +8 -2
- package/agents/refactor-cleaner.md +102 -0
- package/agents/security-reviewer.md +128 -0
- package/agents/silent-failure-hunter.md +54 -0
- package/agents/swift-build-resolver.md +119 -0
- package/agents/swift-reviewer.md +112 -0
- package/agents/tech-feasibility.md +21 -1
- package/agents/testing-api-tester.md +236 -59
- package/agents/testing-evidence-collector.md +26 -1
- package/agents/testing-performance-benchmarker.md +21 -1
- package/agents/testing-reality-checker.md +6 -1
- package/agents/visual-research.md +116 -0
- package/bin/adapters/cycle-counter-tool.ts +155 -0
- package/bin/adapters/scribe-tool.ts +71 -0
- package/bin/adapters/state-save-tool.ts +130 -0
- package/bin/adapters/write-lease-tool.ts +127 -0
- package/bin/buildanything-runtime.js +15 -0
- package/bin/buildanything-runtime.ts +328 -0
- package/bin/setup.js +83 -8
- package/commands/add-feature.md +2 -0
- package/commands/build.md +782 -266
- package/commands/fix.md +1 -1
- package/commands/self-check.md +121 -0
- package/commands/setup.md +50 -9
- package/commands/ux-review.md +2 -2
- package/commands/verify.md +6 -9
- package/docs/migration/agents.yaml +729 -0
- package/docs/migration/phase-graph.yaml +1088 -0
- package/docs/migration/sdk-host-compat.md +18 -0
- package/hooks/compile-writer-owner-cache.ts +171 -0
- package/hooks/hooks.json +36 -0
- package/hooks/pre-tool-use +19 -0
- package/hooks/pre-tool-use.ts +776 -0
- package/hooks/record-mode-transitions.ts +178 -0
- package/hooks/session-start +71 -1
- package/hooks/subagent-start +17 -0
- package/hooks/subagent-start.ts +471 -0
- package/hooks/subagent-stop +17 -0
- package/hooks/subagent-stop.ts +153 -0
- package/package.json +24 -4
- package/protocols/architecture-schema.md +171 -0
- package/protocols/decision-log.md +131 -0
- package/protocols/ios-context.md +10 -11
- package/protocols/ios-phase-branches.md +208 -33
- package/protocols/launch-readiness.md +258 -0
- package/protocols/metric-loop.md +62 -2
- package/protocols/smoke-test.md +9 -1
- package/protocols/state-schema.json +388 -0
- package/protocols/state-schema.md +172 -0
- package/protocols/verify.md +62 -2
- package/protocols/visual-dna.md +185 -0
- package/protocols/web-phase-branches.md +222 -72
- package/skills/ios/_VENDORED.md +2 -0
- package/skills/ios/app-store-connect-metadata/SKILL.md +148 -0
- package/skills/ios/asc-privacy-manifest/SKILL.md +350 -0
- package/skills/ios/hig-components-content/SKILL.md +86 -0
- package/skills/ios/hig-components-content/references/activity-views.md +79 -0
- package/skills/ios/hig-components-content/references/charts.md +180 -0
- package/skills/ios/hig-components-content/references/collections.md +48 -0
- package/skills/ios/hig-components-content/references/color-wells.md +42 -0
- package/skills/ios/hig-components-content/references/image-views.md +82 -0
- package/skills/ios/hig-components-content/references/image-wells.md +34 -0
- package/skills/ios/hig-components-content/references/lockups.md +78 -0
- package/skills/ios/hig-components-content/references/web-views.md +36 -0
- package/skills/ios/hig-components-controls/SKILL.md +88 -0
- package/skills/ios/hig-components-controls/references/combo-boxes.md +40 -0
- package/skills/ios/hig-components-controls/references/controls.md +112 -0
- package/skills/ios/hig-components-controls/references/gauges.md +74 -0
- package/skills/ios/hig-components-controls/references/labels.md +92 -0
- package/skills/ios/hig-components-controls/references/pickers.md +128 -0
- package/skills/ios/hig-components-controls/references/rating-indicators.md +38 -0
- package/skills/ios/hig-components-controls/references/segmented-controls.md +94 -0
- package/skills/ios/hig-components-controls/references/sliders.md +92 -0
- package/skills/ios/hig-components-controls/references/steppers.md +40 -0
- package/skills/ios/hig-components-controls/references/text-fields.md +88 -0
- package/skills/ios/hig-components-controls/references/text-views.md +56 -0
- package/skills/ios/hig-components-controls/references/toggles.md +127 -0
- package/skills/ios/hig-components-controls/references/token-fields.md +48 -0
- package/skills/ios/hig-components-controls/references/virtual-keyboards.md +156 -0
- package/skills/ios/hig-components-dialogs/SKILL.md +76 -0
- package/skills/ios/hig-components-dialogs/references/action-sheets.md +74 -0
- package/skills/ios/hig-components-dialogs/references/alerts.md +158 -0
- package/skills/ios/hig-components-dialogs/references/digit-entry-views.md +32 -0
- package/skills/ios/hig-components-dialogs/references/popovers.md +81 -0
- package/skills/ios/hig-components-dialogs/references/sheets.md +157 -0
- package/skills/ios/hig-components-layout/SKILL.md +99 -0
- package/skills/ios/hig-components-layout/references/boxes.md +48 -0
- package/skills/ios/hig-components-layout/references/column-views.md +44 -0
- package/skills/ios/hig-components-layout/references/lists-and-tables.md +99 -0
- package/skills/ios/hig-components-layout/references/ornaments.md +56 -0
- package/skills/ios/hig-components-layout/references/outline-views.md +64 -0
- package/skills/ios/hig-components-layout/references/panels.md +75 -0
- package/skills/ios/hig-components-layout/references/scroll-views.md +123 -0
- package/skills/ios/hig-components-layout/references/sidebars.md +109 -0
- package/skills/ios/hig-components-layout/references/split-views.md +110 -0
- package/skills/ios/hig-components-layout/references/tab-bars.md +173 -0
- package/skills/ios/hig-components-layout/references/tab-views.md +68 -0
- package/skills/ios/hig-components-layout/references/windows.md +188 -0
- package/skills/ios/hig-components-menus/SKILL.md +81 -0
- package/skills/ios/hig-components-menus/references/action-button.md +61 -0
- package/skills/ios/hig-components-menus/references/buttons.md +261 -0
- package/skills/ios/hig-components-menus/references/context-menus.md +105 -0
- package/skills/ios/hig-components-menus/references/disclosure-controls.md +84 -0
- package/skills/ios/hig-components-menus/references/dock-menus.md +40 -0
- package/skills/ios/hig-components-menus/references/edit-menus.md +88 -0
- package/skills/ios/hig-components-menus/references/menus.md +171 -0
- package/skills/ios/hig-components-menus/references/pop-up-buttons.md +70 -0
- package/skills/ios/hig-components-menus/references/pull-down-buttons.md +77 -0
- package/skills/ios/hig-components-menus/references/the-menu-bar.md +303 -0
- package/skills/ios/hig-components-menus/references/toolbars.md +256 -0
- package/skills/ios/hig-components-search/SKILL.md +68 -0
- package/skills/ios/hig-components-search/references/page-controls.md +120 -0
- package/skills/ios/hig-components-search/references/path-controls.md +40 -0
- package/skills/ios/hig-components-search/references/search-fields.md +189 -0
- package/skills/ios/hig-components-status/SKILL.md +80 -0
- package/skills/ios/hig-components-status/references/activity-rings.md +105 -0
- package/skills/ios/hig-components-status/references/progress-indicators.md +116 -0
- package/skills/ios/hig-components-status/references/status-bars.md +38 -0
- package/skills/ios/hig-components-system/SKILL.md +88 -0
- package/skills/ios/hig-components-system/references/app-clips.md +387 -0
- package/skills/ios/hig-components-system/references/app-shortcuts.md +114 -0
- package/skills/ios/hig-components-system/references/complications.md +425 -0
- package/skills/ios/hig-components-system/references/home-screen-quick-actions.md +42 -0
- package/skills/ios/hig-components-system/references/live-activities.md +442 -0
- package/skills/ios/hig-components-system/references/notifications.md +153 -0
- package/skills/ios/hig-components-system/references/top-shelf.md +135 -0
- package/skills/ios/hig-components-system/references/watch-faces.md +40 -0
- package/skills/ios/hig-components-system/references/widgets.md +517 -0
- package/skills/ios/hig-foundations/SKILL.md +98 -0
- package/skills/ios/hig-foundations/references/accessibility.md +291 -0
- package/skills/ios/hig-foundations/references/app-icons.md +210 -0
- package/skills/ios/hig-foundations/references/branding.md +44 -0
- package/skills/ios/hig-foundations/references/color.md +274 -0
- package/skills/ios/hig-foundations/references/dark-mode.md +116 -0
- package/skills/ios/hig-foundations/references/icons.md +263 -0
- package/skills/ios/hig-foundations/references/images.md +176 -0
- package/skills/ios/hig-foundations/references/immersive-experiences.md +174 -0
- package/skills/ios/hig-foundations/references/inclusion.md +189 -0
- package/skills/ios/hig-foundations/references/layout.md +425 -0
- package/skills/ios/hig-foundations/references/materials.md +238 -0
- package/skills/ios/hig-foundations/references/motion.md +103 -0
- package/skills/ios/hig-foundations/references/privacy.md +231 -0
- package/skills/ios/hig-foundations/references/right-to-left.md +206 -0
- package/skills/ios/hig-foundations/references/sf-symbols.md +310 -0
- package/skills/ios/hig-foundations/references/spatial-layout.md +142 -0
- package/skills/ios/hig-foundations/references/typography.md +1146 -0
- package/skills/ios/hig-foundations/references/writing.md +91 -0
- package/skills/ios/hig-inputs/SKILL.md +94 -0
- package/skills/ios/hig-inputs/references/apple-pencil-and-scribble.md +148 -0
- package/skills/ios/hig-inputs/references/camera-control.md +107 -0
- package/skills/ios/hig-inputs/references/digital-crown.md +83 -0
- package/skills/ios/hig-inputs/references/eyes.md +120 -0
- package/skills/ios/hig-inputs/references/focus-and-selection.md +120 -0
- package/skills/ios/hig-inputs/references/game-controls.md +156 -0
- package/skills/ios/hig-inputs/references/gestures.md +208 -0
- package/skills/ios/hig-inputs/references/gyro-and-accelerometer.md +40 -0
- package/skills/ios/hig-inputs/references/keyboards.md +234 -0
- package/skills/ios/hig-inputs/references/nearby-interactions.md +70 -0
- package/skills/ios/hig-inputs/references/pointing-devices.md +237 -0
- package/skills/ios/hig-inputs/references/remotes.md +67 -0
- package/skills/ios/hig-inputs/references/spatial-interactions.md +70 -0
- package/skills/ios/hig-patterns/SKILL.md +104 -0
- package/skills/ios/hig-patterns/references/charting-data.md +81 -0
- package/skills/ios/hig-patterns/references/collaboration-and-sharing.md +86 -0
- package/skills/ios/hig-patterns/references/drag-and-drop.md +134 -0
- package/skills/ios/hig-patterns/references/entering-data.md +69 -0
- package/skills/ios/hig-patterns/references/feedback.md +67 -0
- package/skills/ios/hig-patterns/references/file-management.md +135 -0
- package/skills/ios/hig-patterns/references/going-full-screen.md +79 -0
- package/skills/ios/hig-patterns/references/launching.md +81 -0
- package/skills/ios/hig-patterns/references/live-viewing-apps.md +79 -0
- package/skills/ios/hig-patterns/references/loading.md +59 -0
- package/skills/ios/hig-patterns/references/managing-accounts.md +107 -0
- package/skills/ios/hig-patterns/references/managing-notifications.md +99 -0
- package/skills/ios/hig-patterns/references/modality.md +82 -0
- package/skills/ios/hig-patterns/references/multitasking.md +131 -0
- package/skills/ios/hig-patterns/references/offering-help.md +117 -0
- package/skills/ios/hig-patterns/references/onboarding.md +69 -0
- package/skills/ios/hig-patterns/references/playing-audio.md +124 -0
- package/skills/ios/hig-patterns/references/playing-haptics.md +280 -0
- package/skills/ios/hig-patterns/references/playing-video.md +180 -0
- package/skills/ios/hig-patterns/references/printing.md +50 -0
- package/skills/ios/hig-patterns/references/ratings-and-reviews.md +48 -0
- package/skills/ios/hig-patterns/references/searching.md +70 -0
- package/skills/ios/hig-patterns/references/settings.md +84 -0
- package/skills/ios/hig-patterns/references/undo-and-redo.md +58 -0
- package/skills/ios/hig-patterns/references/workouts.md +76 -0
- package/skills/ios/hig-platforms/SKILL.md +84 -0
- package/skills/ios/hig-platforms/references/designing-for-games.md +159 -0
- package/skills/ios/hig-platforms/references/designing-for-ios.md +66 -0
- package/skills/ios/hig-platforms/references/designing-for-ipados.md +64 -0
- package/skills/ios/hig-platforms/references/designing-for-macos.md +70 -0
- package/skills/ios/hig-platforms/references/designing-for-tvos.md +68 -0
- package/skills/ios/hig-platforms/references/designing-for-visionos.md +85 -0
- package/skills/ios/hig-platforms/references/designing-for-watchos.md +74 -0
- package/skills/ios/hig-project-context/SKILL.md +133 -0
- package/skills/ios/hig-technologies/SKILL.md +107 -0
- package/skills/ios/hig-technologies/references/airplay.md +125 -0
- package/skills/ios/hig-technologies/references/always-on.md +62 -0
- package/skills/ios/hig-technologies/references/apple-pay.md +441 -0
- package/skills/ios/hig-technologies/references/augmented-reality.md +247 -0
- package/skills/ios/hig-technologies/references/carekit.md +224 -0
- package/skills/ios/hig-technologies/references/carplay.md +119 -0
- package/skills/ios/hig-technologies/references/game-center.md +343 -0
- package/skills/ios/hig-technologies/references/generative-ai.md +110 -0
- package/skills/ios/hig-technologies/references/healthkit.md +120 -0
- package/skills/ios/hig-technologies/references/homekit.md +343 -0
- package/skills/ios/hig-technologies/references/icloud.md +52 -0
- package/skills/ios/hig-technologies/references/id-verifier.md +73 -0
- package/skills/ios/hig-technologies/references/imessage-apps-and-stickers.md +105 -0
- package/skills/ios/hig-technologies/references/in-app-purchase.md +263 -0
- package/skills/ios/hig-technologies/references/live-photos.md +54 -0
- package/skills/ios/hig-technologies/references/mac-catalyst.md +216 -0
- package/skills/ios/hig-technologies/references/machine-learning.md +394 -0
- package/skills/ios/hig-technologies/references/maps.md +221 -0
- package/skills/ios/hig-technologies/references/nfc.md +51 -0
- package/skills/ios/hig-technologies/references/photo-editing.md +40 -0
- package/skills/ios/hig-technologies/references/researchkit.md +134 -0
- package/skills/ios/hig-technologies/references/shareplay.md +142 -0
- package/skills/ios/hig-technologies/references/shazamkit.md +47 -0
- package/skills/ios/hig-technologies/references/sign-in-with-apple.md +288 -0
- package/skills/ios/hig-technologies/references/siri.md +523 -0
- package/skills/ios/hig-technologies/references/tap-to-pay-on-iphone.md +208 -0
- package/skills/ios/hig-technologies/references/voiceover.md +90 -0
- package/skills/ios/hig-technologies/references/wallet.md +420 -0
- package/skills/ios/ios-bootstrap/SKILL.md +16 -7
- package/skills/ios/swift-actor-persistence/SKILL.md +143 -0
- package/skills/ios/swift-concurrency-6-2/SKILL.md +216 -0
- package/skills/ios/swift-protocol-di-testing/SKILL.md +190 -0
- package/skills/ios/swiftui-design-tokens/SKILL.md +475 -0
- package/skills/ios/writing-for-interfaces/SKILL.md +75 -0
- package/skills/web/accessibility/SKILL.md +146 -0
- package/skills/web/aceternity-ui/SKILL.md +719 -0
- package/skills/web/aceternity-ui/metadata.json +10 -0
- package/skills/web/api-design/SKILL.md +523 -0
- package/skills/web/chart-accessibility/SKILL.md +332 -0
- package/skills/web/composition-patterns/AGENTS.md +946 -0
- package/skills/web/composition-patterns/README.md +60 -0
- package/skills/web/composition-patterns/SKILL.md +89 -0
- package/skills/web/composition-patterns/metadata.json +11 -0
- package/skills/web/composition-patterns/rules/_sections.md +29 -0
- package/skills/web/composition-patterns/rules/_template.md +24 -0
- package/skills/web/composition-patterns/rules/architecture-avoid-boolean-props.md +100 -0
- package/skills/web/composition-patterns/rules/architecture-compound-components.md +112 -0
- package/skills/web/composition-patterns/rules/patterns-children-over-render-props.md +87 -0
- package/skills/web/composition-patterns/rules/patterns-explicit-variants.md +100 -0
- package/skills/web/composition-patterns/rules/react19-no-forwardref.md +42 -0
- package/skills/web/composition-patterns/rules/state-context-interface.md +191 -0
- package/skills/web/composition-patterns/rules/state-decouple-implementation.md +113 -0
- package/skills/web/composition-patterns/rules/state-lift-state.md +125 -0
- package/skills/web/cost-aware-llm-pipeline/SKILL.md +183 -0
- package/skills/web/database-migrations/SKILL.md +429 -0
- package/skills/web/deployment-patterns/SKILL.md +427 -0
- package/skills/web/docker-patterns/SKILL.md +364 -0
- package/skills/web/e2e-testing/SKILL.md +326 -0
- package/skills/web/lighthouse-ci/SKILL.md +361 -0
- package/skills/web/mcp-server-patterns/SKILL.md +69 -0
- package/skills/web/next-best-practices/SKILL.md +153 -0
- package/skills/web/next-best-practices/async-patterns.md +87 -0
- package/skills/web/next-best-practices/bundling.md +180 -0
- package/skills/web/next-best-practices/data-patterns.md +297 -0
- package/skills/web/next-best-practices/debug-tricks.md +105 -0
- package/skills/web/next-best-practices/directives.md +73 -0
- package/skills/web/next-best-practices/error-handling.md +227 -0
- package/skills/web/next-best-practices/file-conventions.md +140 -0
- package/skills/web/next-best-practices/font.md +245 -0
- package/skills/web/next-best-practices/functions.md +108 -0
- package/skills/web/next-best-practices/hydration-error.md +91 -0
- package/skills/web/next-best-practices/image.md +173 -0
- package/skills/web/next-best-practices/metadata.md +301 -0
- package/skills/web/next-best-practices/parallel-routes.md +287 -0
- package/skills/web/next-best-practices/route-handlers.md +146 -0
- package/skills/web/next-best-practices/rsc-boundaries.md +159 -0
- package/skills/web/next-best-practices/runtime-selection.md +39 -0
- package/skills/web/next-best-practices/scripts.md +141 -0
- package/skills/web/next-best-practices/self-hosting.md +371 -0
- package/skills/web/next-best-practices/suspense-boundaries.md +67 -0
- package/skills/web/next-cache-components/SKILL.md +411 -0
- package/skills/web/postgres-best-practices/SKILL.md +14 -0
- package/skills/web/postgres-best-practices/references/schema-design.md +9 -0
- package/skills/web/react-best-practices/AGENTS.md +3810 -0
- package/skills/web/react-best-practices/README.md +123 -0
- package/skills/web/react-best-practices/SKILL.md +149 -0
- package/skills/web/react-best-practices/metadata.json +15 -0
- package/skills/web/react-best-practices/rules/_sections.md +46 -0
- package/skills/web/react-best-practices/rules/_template.md +28 -0
- package/skills/web/react-best-practices/rules/advanced-effect-event-deps.md +56 -0
- package/skills/web/react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/skills/web/react-best-practices/rules/advanced-init-once.md +42 -0
- package/skills/web/react-best-practices/rules/advanced-use-latest.md +39 -0
- package/skills/web/react-best-practices/rules/async-api-routes.md +38 -0
- package/skills/web/react-best-practices/rules/async-cheap-condition-before-await.md +37 -0
- package/skills/web/react-best-practices/rules/async-defer-await.md +82 -0
- package/skills/web/react-best-practices/rules/async-dependencies.md +51 -0
- package/skills/web/react-best-practices/rules/async-parallel.md +28 -0
- package/skills/web/react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/skills/web/react-best-practices/rules/bundle-analyzable-paths.md +63 -0
- package/skills/web/react-best-practices/rules/bundle-barrel-imports.md +60 -0
- package/skills/web/react-best-practices/rules/bundle-conditional.md +31 -0
- package/skills/web/react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/skills/web/react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/skills/web/react-best-practices/rules/bundle-preload.md +50 -0
- package/skills/web/react-best-practices/rules/client-event-listeners.md +74 -0
- package/skills/web/react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/skills/web/react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/skills/web/react-best-practices/rules/client-swr-dedup.md +56 -0
- package/skills/web/react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/skills/web/react-best-practices/rules/js-cache-function-results.md +80 -0
- package/skills/web/react-best-practices/rules/js-cache-property-access.md +28 -0
- package/skills/web/react-best-practices/rules/js-cache-storage.md +70 -0
- package/skills/web/react-best-practices/rules/js-combine-iterations.md +32 -0
- package/skills/web/react-best-practices/rules/js-early-exit.md +50 -0
- package/skills/web/react-best-practices/rules/js-flatmap-filter.md +60 -0
- package/skills/web/react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/skills/web/react-best-practices/rules/js-index-maps.md +37 -0
- package/skills/web/react-best-practices/rules/js-length-check-first.md +49 -0
- package/skills/web/react-best-practices/rules/js-min-max-loop.md +82 -0
- package/skills/web/react-best-practices/rules/js-request-idle-callback.md +105 -0
- package/skills/web/react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/skills/web/react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/skills/web/react-best-practices/rules/rendering-activity.md +26 -0
- package/skills/web/react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/skills/web/react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/skills/web/react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/skills/web/react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/skills/web/react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/skills/web/react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/skills/web/react-best-practices/rules/rendering-resource-hints.md +85 -0
- package/skills/web/react-best-practices/rules/rendering-script-defer-async.md +68 -0
- package/skills/web/react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/skills/web/react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/skills/web/react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/skills/web/react-best-practices/rules/rerender-dependencies.md +45 -0
- package/skills/web/react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/skills/web/react-best-practices/rules/rerender-derived-state.md +29 -0
- package/skills/web/react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/skills/web/react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/skills/web/react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/skills/web/react-best-practices/rules/rerender-memo.md +44 -0
- package/skills/web/react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/skills/web/react-best-practices/rules/rerender-no-inline-components.md +82 -0
- package/skills/web/react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/skills/web/react-best-practices/rules/rerender-split-combined-hooks.md +64 -0
- package/skills/web/react-best-practices/rules/rerender-transitions.md +40 -0
- package/skills/web/react-best-practices/rules/rerender-use-deferred-value.md +59 -0
- package/skills/web/react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/skills/web/react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/skills/web/react-best-practices/rules/server-auth-actions.md +96 -0
- package/skills/web/react-best-practices/rules/server-cache-lru.md +41 -0
- package/skills/web/react-best-practices/rules/server-cache-react.md +76 -0
- package/skills/web/react-best-practices/rules/server-dedup-props.md +65 -0
- package/skills/web/react-best-practices/rules/server-hoist-static-io.md +149 -0
- package/skills/web/react-best-practices/rules/server-no-shared-module-state.md +50 -0
- package/skills/web/react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/skills/web/react-best-practices/rules/server-parallel-nested-fetching.md +34 -0
- package/skills/web/react-best-practices/rules/server-serialization.md +38 -0
- package/skills/web/seo/SKILL.md +154 -0
- package/skills/web/web-design-guidelines/SKILL.md +39 -0
- package/skills/web/zap-scan-config/SKILL.md +444 -0
- package/skills/web/zap-scan-config/assets/.gitkeep +9 -0
- package/skills/web/zap-scan-config/assets/github_action.yml +207 -0
- package/skills/web/zap-scan-config/assets/gitlab_ci.yml +226 -0
- package/skills/web/zap-scan-config/assets/zap_automation.yaml +196 -0
- package/skills/web/zap-scan-config/assets/zap_context.xml +192 -0
- package/skills/web/zap-scan-config/references/EXAMPLE.md +40 -0
- package/skills/web/zap-scan-config/references/api_testing_guide.md +475 -0
- package/skills/web/zap-scan-config/references/authentication_guide.md +431 -0
- package/skills/web/zap-scan-config/references/false_positive_handling.md +427 -0
- package/skills/web/zap-scan-config/references/owasp_mapping.md +255 -0
- package/src/lrr/aggregator.ts +80 -0
- package/src/orchestrator/hooks/context-header.ts +95 -0
- package/src/orchestrator/hooks/token-accounting-emitter.ts +77 -0
- package/src/orchestrator/hooks/token-accounting.ts +101 -0
- package/src/orchestrator/mcp/cycle-counter.ts +129 -0
- package/src/orchestrator/mcp/scribe.ts +283 -0
- package/src/orchestrator/mcp/state-save.ts +149 -0
- package/src/orchestrator/mcp/write-lease.ts +167 -0
- package/src/orchestrator/phase4-shared-context.ts +41 -0
- package/src/orchestrator/schemas/backward-edge.ts +46 -0
- package/agents/agentic-identity-trust.md +0 -121
- package/agents/data-consolidation-agent.md +0 -39
- package/agents/design-image-prompt-engineer.md +0 -105
- package/agents/design-visual-storyteller.md +0 -147
- package/agents/design-whimsy-injector.md +0 -89
- package/agents/engineering-autonomous-optimization-architect.md +0 -105
- package/agents/market-intel.md +0 -35
- package/agents/marketing-instagram-curator.md +0 -111
- package/agents/marketing-reddit-community-builder.md +0 -121
- package/agents/marketing-social-media-strategist.md +0 -74
- package/agents/marketing-tiktok-strategist.md +0 -123
- package/agents/marketing-twitter-engager.md +0 -124
- package/agents/marketing-wechat-official-account.md +0 -143
- package/agents/marketing-xiaohongshu-specialist.md +0 -136
- package/agents/marketing-zhihu-strategist.md +0 -160
- package/agents/product-behavioral-nudge-engine.md +0 -78
- package/agents/project-management-experiment-tracker.md +0 -102
- package/agents/report-distribution-agent.md +0 -43
- package/agents/risk-analysis.md +0 -45
- package/agents/sales-data-extraction-agent.md +0 -46
- package/agents/specialized-cultural-intelligence-strategist.md +0 -65
- package/agents/specialized-developer-advocate.md +0 -146
- package/agents/support-analytics-reporter.md +0 -133
- package/agents/support-executive-summary-generator.md +0 -64
- package/agents/support-finance-tracker.md +0 -145
- package/agents/support-legal-compliance-checker.md +0 -129
- package/agents/support-support-responder.md +0 -91
- package/agents/testing-accessibility-auditor.md +0 -110
- package/agents/testing-test-results-analyzer.md +0 -97
- package/agents/testing-tool-evaluator.md +0 -76
- package/agents/testing-workflow-optimizer.md +0 -99
- package/agents/user-research.md +0 -40
- package/protocols/brainstorm.md +0 -99
- package/protocols/design.md +0 -269
- package/protocols/planning.md +0 -87
- package/skills/ios/ios-hig/SKILL.md +0 -41
- package/skills/ios/ios-hig/references/accessibility.md +0 -81
- package/skills/ios/ios-hig/references/content.md +0 -142
- package/skills/ios/ios-hig/references/feedback.md +0 -123
- package/skills/ios/ios-hig/references/interaction.md +0 -199
- package/skills/ios/ios-hig/references/performance-platform.md +0 -129
- package/skills/ios/ios-hig/references/privacy-permissions.md +0 -181
- package/skills/ios/ios-hig/references/visual-design.md +0 -84
package/commands/build.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Full product build pipeline — orchestrates specialist agents through brainstorming, research, architecture, implementation,
|
|
2
|
+
description: "Full product build pipeline — orchestrates specialist agents through brainstorming, research, architecture, design, implementation, audit, launch review, and ship"
|
|
3
3
|
argument-hint: "Describe what to build, or path to a design doc. --autonomous for unattended mode. --resume to continue a previous build."
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -13,45 +13,105 @@ Every step below tells you to call the Agent tool. DO IT. Do not role-play as th
|
|
|
13
13
|
For implementation agents, set mode: "bypassPermissions".
|
|
14
14
|
For parallel work, put multiple Agent tool calls in ONE message.
|
|
15
15
|
|
|
16
|
-
Exception: Brainstorming
|
|
16
|
+
Exception: Brainstorming in Phase 1 Step 1.0 and Step 1.3 uses an INTERNAL Brainstorm Facilitator role — the orchestrator relays between the facilitator sub-agent and the user, never role-plays the agent itself.
|
|
17
17
|
</HARD-GATE>
|
|
18
18
|
|
|
19
|
+
<HARD-GATE>
|
|
20
|
+
SUBAGENT_TYPE REQUIRED.
|
|
21
|
+
|
|
22
|
+
Every Agent tool call MUST include a `subagent_type` field unless the dispatch is explicitly marked INTERNAL (inline role-string). INTERNAL dispatches are listed in `docs/plans/agent-dispatch-audit.md` — they are orchestrator helpers (Brainstorm Facilitator, Research Synthesizer, Design Doc Writer, Prereq Collector, Task DAG Validator, Refs Indexer, Briefing Officer, Dogfood runner, Fake-Data Detector, PM chapter, LRR Aggregator, Completion Report, Verify scaffolding dispatcher).
|
|
23
|
+
|
|
24
|
+
Missing `subagent_type` on a non-INTERNAL dispatch is a HARD-GATE violation. The orchestrator rejects dispatches that don't name a specific agent. If you catch yourself typing `description: "..."` without a `subagent_type:` line alongside it, STOP and look up the right agent from the dispatch audit.
|
|
25
|
+
</HARD-GATE>
|
|
26
|
+
|
|
27
|
+
<HARD-GATE>
|
|
28
|
+
ARTIFACT WRITER-OWNER RULE.
|
|
29
|
+
|
|
30
|
+
Every shared artifact has ONE concurrent writer at any instant. The writer-owner table in `docs/plans/orchestration-proposed-state.md` §6 defines which phase writes which file. Before any file write, the orchestrator verifies the current phase is the rightful writer. Non-owning phase writes are a HARD-GATE violation. For parallel-batch phases (e.g., Phase 4), intra-phase dispatches MUST NOT race on the same file — writes either target disjoint per-dispatch filenames OR route through an orchestrator-scribe handler (see `decisions.jsonl` handling below).
|
|
31
|
+
|
|
32
|
+
Live downstream docs (read across Phase 3+):
|
|
33
|
+
- `CLAUDE.md` — P1 writer (then auto-loaded into every subagent)
|
|
34
|
+
- `design-doc.md` (PRD) — P1 writer
|
|
35
|
+
- `architecture.md` — P2 writer
|
|
36
|
+
- `sprint-tasks.md` — P2 writer
|
|
37
|
+
- `quality-targets.json` — P2 writer
|
|
38
|
+
- `visual-design-spec.md` — P3 writer (web) / `ios-design-board.md` P3 writer (iOS)
|
|
39
|
+
- `refs.json` — P2 writer + P3 writer (P3 extends after visual spec lands)
|
|
40
|
+
- `decisions.jsonl` — orchestrator-scribe ONLY via `scribe_decision` MCP tool (subagents return `deviation_row` objects; the orchestrator forwards each row through the MCP, which owns ID allocation and atomic append)
|
|
41
|
+
- `learnings.jsonl` — P5, P7 writers
|
|
42
|
+
- `evidence/*.json` — P5 writer (P4 contributes per-task, P6/P7 readers)
|
|
43
|
+
- `lrr/*.json` — P6 writer (1 per chapter + Aggregator)
|
|
44
|
+
- `lrr-aggregate.json` — P6 writer (Aggregator only)
|
|
45
|
+
|
|
46
|
+
Phase-internal scaffolding (lives in `docs/plans/phase1-scratch/` after Gate 1, never read by P3+):
|
|
47
|
+
- `idea-draft.md`, `feature-intel.md`, `tech-feasibility.md`, `ux-research.md`, `business-model.md`, `findings-digest.md`, `suggested-questions.md`, `user-decisions.md`, `prereqs.json`
|
|
48
|
+
|
|
49
|
+
Phase 4 implementers never reference Phase 1 raw research files. They are SPENT after Phase 2 dispatch.
|
|
50
|
+
</HARD-GATE>
|
|
51
|
+
|
|
52
|
+
> **Default-deny (Stage 2+):** Once Stage 2 of the SDK migration activates, any `Write|Edit` tool call targeting a path absent from this table will be denied by the `PreToolUse` hook with message `"path not in writer-owner table — please add to phase-graph.yaml or route through scribe MCP"`. This is a pre-announcement; actual hook wiring ships in Task 2.1.3.
|
|
53
|
+
|
|
54
|
+
<HARD-GATE>
|
|
55
|
+
CONTEXT HEADER — RENDER ONCE, HOIST AS STABLE PREFIX.
|
|
56
|
+
|
|
57
|
+
Every phase uses a CONTEXT header prepended to dispatch prompts. The orchestrator MUST render this header ONCE at the start of each phase by reading `.build-state.json` (and `visual-dna.md` for web, Phase 4+) and resolving all values into concrete strings. The rendered header is then reused verbatim for every dispatch in that phase.
|
|
58
|
+
|
|
59
|
+
DO NOT paste `{read from .build-state.json}` placeholders into dispatch prompts. DO NOT re-read state files per dispatch. The values do not change within a phase.
|
|
60
|
+
|
|
61
|
+
**Canonical template** (orchestrator resolves before first dispatch of each phase):
|
|
62
|
+
```
|
|
63
|
+
CONTEXT:
|
|
64
|
+
project_type: <resolved value>
|
|
65
|
+
phase: <current phase number>
|
|
66
|
+
dna: <resolved from docs/plans/visual-dna.md — INCLUDE only if project_type=web AND phase >= 4>
|
|
67
|
+
ios_features: <resolved from .build-state.json — INCLUDE only if project_type=ios>
|
|
68
|
+
|
|
69
|
+
TASK:
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Rendering procedure** (run once per phase boundary):
|
|
73
|
+
1. Read `docs/plans/.build-state.json`. Extract `project_type`, `ios_features`.
|
|
74
|
+
2. If `project_type=web` AND phase >= 4: read `docs/plans/visual-dna.md` and extract the DNA summary (first 5 lines or the `## Summary` section). Otherwise omit the `dna` field.
|
|
75
|
+
3. If `project_type=ios`: include `ios_features`. Otherwise omit.
|
|
76
|
+
4. Substitute all values into the template above. Store the result as `rendered_context_header`.
|
|
77
|
+
5. For every dispatch in this phase, prepend `rendered_context_header` — do NOT re-read or re-interpolate.
|
|
78
|
+
|
|
79
|
+
This keeps the prefix stable across parallel batches (enabling KV-cache reuse) and eliminates redundant state-file reads (~300K–1M tokens saved per build).
|
|
80
|
+
</HARD-GATE>
|
|
81
|
+
|
|
82
|
+
## SSOT Rule (machine-readable form is authoritative)
|
|
83
|
+
|
|
84
|
+
For every HARD-GATE promoted to code in Stages 2–5, the machine-readable form (`phase-graph.yaml`, `decisions.schema.json`, `state-schema.md`) is AUTHORITATIVE at runtime. Prose in `commands/build.md` and `protocols/*.md` is a narrative view of the machine-readable form. Prose edits without corresponding machine-readable edits are build-breaking PRs enforced by `eval/lint_phase_graph.py` in CI.
|
|
85
|
+
|
|
19
86
|
### Orchestrator Discipline
|
|
20
87
|
|
|
21
88
|
Your context window is precious. Protect it.
|
|
22
89
|
|
|
23
|
-
**You are a DISPATCHER, not a DOER.** Your job is: read state → decide next step → compose agent prompt → dispatch → process
|
|
90
|
+
**You are a DISPATCHER, not a DOER.** Your job is: read state → decide next step → compose agent prompt → dispatch → process compact return → decide next step.
|
|
24
91
|
|
|
25
92
|
**Two types of agents — handle their results differently:**
|
|
26
93
|
|
|
27
94
|
| Agent Type | Examples | What you keep |
|
|
28
95
|
|-----------|----------|---------------|
|
|
29
|
-
| **Research/analysis** |
|
|
30
|
-
| **Implementation** | Code writing, fixes, cleanup, verification, scaffolding | **Summary only** — their work product lives in the codebase. Keep: what was done, files changed, test results, pass/fail. Discard: code snippets, full build logs
|
|
31
|
-
|
|
32
|
-
**After implementation agents return:**
|
|
33
|
-
1. Extract: what was built, files changed, test pass/fail, any blockers
|
|
34
|
-
2. Record in `docs/plans/.build-state.md` under the current phase
|
|
35
|
-
3. The code is in the repo — you don't need it in your context
|
|
36
|
-
|
|
37
|
-
**After research/analysis agents return:**
|
|
38
|
-
1. Read and use the full output — this is your decision-making input
|
|
39
|
-
2. Save the output to the appropriate file in `docs/plans/` (research brief, architecture doc, etc.)
|
|
40
|
-
3. Once saved to disk, you can reference the file later instead of holding it all in context
|
|
96
|
+
| **Research/analysis** | Architecture design, audits, measurement, chapter verdicts | **Compact return only** — save full output to `docs/plans/`, keep the filename + headline verdict in context. Phase 1 research goes through the Research Synthesizer — the orchestrator never reads raw research. |
|
|
97
|
+
| **Implementation** | Code writing, fixes, cleanup, verification, scaffolding | **Summary only** — their work product lives in the codebase. Keep: what was done, files changed, test results, pass/fail. Discard: code snippets, full build logs. |
|
|
41
98
|
|
|
42
99
|
**Never do these yourself:**
|
|
43
|
-
- Read source code files to understand implementation details — spawn an
|
|
100
|
+
- Read source code files to understand implementation details — spawn an INTERNAL inline exploration agent (see Step 2.1)
|
|
44
101
|
- Write or edit code — spawn an implementation agent
|
|
45
102
|
- Debug failures — spawn a fix agent with the error message
|
|
103
|
+
- Read raw Phase 1 research files — the Research Synthesizer (Step 1.2) reads them; you only read the digest
|
|
46
104
|
|
|
47
105
|
If you catch yourself typing code or reading source files: STOP. You are wasting context. Spawn an agent.
|
|
48
106
|
|
|
49
|
-
**Dispatch Counter:** Track agent dispatches in `docs/plans/.build-state.
|
|
50
|
-
- `
|
|
51
|
-
- `
|
|
52
|
-
Increment after each agent returns (parallel dispatch of
|
|
107
|
+
**Dispatch Counter:** Track agent dispatches in `docs/plans/.build-state.json` (source of truth) under the `dispatch_count` and `last_save_phase` fields:
|
|
108
|
+
- `dispatch_count: [N]`
|
|
109
|
+
- `last_save_phase: [Phase.Step]`
|
|
110
|
+
Increment after each agent returns (parallel dispatch of 6 agents = +6). Reset to 0 after each compaction save. The rendered markdown view (`.build-state.md`) is regenerated from the JSON on every update — never edit the markdown directly.
|
|
53
111
|
|
|
54
|
-
**Compaction checkpoint format:** At every phase boundary, check `
|
|
112
|
+
**Compaction checkpoint format:** At every phase boundary, check `dispatch_count` in `docs/plans/.build-state.json`. If >= 8: save ALL state (current phase, task statuses, metric loop scores, decisions) to `docs/plans/.build-state.json` and regenerate `.build-state.md` as the rendered view. Reset `dispatch_count` to 0. TodoWrite does NOT survive compaction — rebuild it from the JSON state file on resume. See `protocols/state-schema.md` for the full schema and rendering contract.
|
|
113
|
+
|
|
114
|
+
**Cumulative-cost banner at phase boundaries:** When announcing a phase transition (e.g. "Phase N complete — proceeding to Phase N+1"), prefix the message with `[Cost so far: $X.XX • Y tokens]`. Source the values from the last-appended entry in `docs/plans/build-log.md`'s token-accounting lines (fields `cumulative_usd=...` plus the sum of `input_tokens=...` + `output_tokens=...`), written by `src/orchestrator/hooks/token-accounting.ts` (see module for exact schema). If the build-log has no token-accounting entries yet, omit the prefix rather than guessing.
|
|
55
115
|
|
|
56
116
|
Input: $ARGUMENTS
|
|
57
117
|
|
|
@@ -59,41 +119,52 @@ Input: $ARGUMENTS
|
|
|
59
119
|
|
|
60
120
|
If the input contains `--autonomous` or `--auto`, this build runs **unattended**. The user will not be present to approve quality gates. In autonomous mode:
|
|
61
121
|
- Quality gates auto-approve. Do NOT pause and wait for user input.
|
|
62
|
-
- Brainstorming runs in autonomous mode (
|
|
122
|
+
- Brainstorming runs in autonomous mode (Brainstorm Facilitator synthesizes directly from build request + available context).
|
|
63
123
|
- Metric loops that stall accept at >= 60% of target, skip below that.
|
|
64
|
-
- Log every decision to `docs/plans/build-log.md` so the user can review later.
|
|
65
124
|
|
|
66
125
|
If `--autonomous` is NOT present, all quality gates require user approval as described below.
|
|
67
126
|
|
|
68
127
|
When combining `--resume` with `--autonomous`: the current invocation's flags take precedence over saved state. If you resume a previously interactive build with `--autonomous`, it continues in autonomous mode.
|
|
69
128
|
|
|
70
|
-
###
|
|
129
|
+
### Always-On Build Log
|
|
130
|
+
|
|
131
|
+
`docs/plans/build-log.md` is written in **BOTH interactive and autonomous mode**. Every phase transition writes a one-line entry with the shape: `{timestamp, phase, step, action, outcome}`. Append to this file at EVERY phase boundary, EVERY LRR chapter dispatch, EVERY metric-loop iteration, and EVERY quality gate decision. In autonomous mode, ALSO log every auto-approval decision here so the user can review later.
|
|
71
132
|
|
|
72
|
-
|
|
133
|
+
### Metric Loop (callable service)
|
|
73
134
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
135
|
+
Every phase can invoke the **metric-driven iteration loop** as a service to drive quality. Read the full protocol at `protocols/metric-loop.md`. Called by Phase 3 (Design Critic loop), Phase 4 (per-task quality), Phase 5 (metric fix loop on failing audits), Phase 7 (documentation quality). Critical rules (survive compaction):
|
|
136
|
+
|
|
137
|
+
1. YOU define a metric for this phase based on context. The metric is NOT predefined.
|
|
138
|
+
2. Spawn a **measurement/critic agent** to score the artifact 0-100. Read its compact return.
|
|
139
|
+
3. Pick the ONE highest-impact issue. Spawn a separate **fix/generator agent** with ONLY that issue + file paths.
|
|
77
140
|
4. Re-measure. Repeat until: target met, stalled (2 consecutive delta <= 0), or max iterations.
|
|
78
|
-
5. Track all scores in `docs/plans/.build-state.
|
|
141
|
+
5. Track all scores in `docs/plans/.build-state.json` — this is your lifeline across compaction.
|
|
79
142
|
|
|
80
143
|
<HARD-GATE>
|
|
81
144
|
METRIC LOOP NON-NEGOTIABLES:
|
|
82
|
-
- Measurement agent and fix agent are SEPARATE Agent tool calls — never share context (author-bias elimination).
|
|
145
|
+
- Measurement/critic agent and fix/generator agent are SEPARATE Agent tool calls — never share context (author-bias elimination).
|
|
83
146
|
- Fix agent gets ONLY the top issue + file paths + acceptance criteria. NOT the full measurement findings.
|
|
84
147
|
- One fix per iteration. Measure impact before fixing the next thing.
|
|
85
148
|
- Each measurement is fresh — don't accumulate findings across iterations.
|
|
86
149
|
</HARD-GATE>
|
|
87
150
|
|
|
88
|
-
###
|
|
151
|
+
### Verify Protocol (callable service)
|
|
152
|
+
|
|
153
|
+
The 7-check verification gate is called by Phase 2 (architecture check), Phase 4 (per task), Phase 5 (audit), and Phase 7 (pre-ship). Full protocol at `protocols/verify.md`. Phase-internal — dispatched as INTERNAL inline role-string "Verify scaffolding" with agent running 7 checks sequentially: Build → Type-Check → Lint → Test → Security → Diff Review → Artifacts.
|
|
154
|
+
|
|
155
|
+
### Decision Log (callable service)
|
|
89
156
|
|
|
90
|
-
|
|
157
|
+
`docs/plans/decisions.jsonl` — append-only, ORCHESTRATOR-SCRIBE ONLY via the `scribe_decision` MCP tool. Subagents return `deviation_row` objects in their structured result; the orchestrator forwards each row through `scribe_decision`, which allocates `D-{phase}-<seq>` IDs and atomically appends. The orchestrator MUST NOT Write or Edit this file directly. Row-producing phases: Phase 1 synthesis (3 rows), Phase 2 architecture synthesis (4 rows), Phase 4 implementers (only on deviation). Readers: Phase 0 resume handler, Phase 5 Reality Checker, Phase 6 LRR Aggregator (the ⭐⭐ backward-routing read). Schema at `protocols/decision-log.md`. Dispatch flow: see Phase 4 "Orchestrator-scribe dispatch" section.
|
|
91
158
|
|
|
92
|
-
|
|
93
|
-
2. **Previous agent's output** — what the upstream agent produced (if any)
|
|
94
|
-
3. **Acceptance criteria** — what "done" looks like for THIS agent
|
|
159
|
+
### Learnings (callable service)
|
|
95
160
|
|
|
96
|
-
|
|
161
|
+
`docs/plans/learnings.jsonl` — append-only cross-run learnings store. Writers: Phase 5 reality sweep, Phase 7. Readers: Phase 0 Learnings Loader (Step 0.1d) and Phase 5 reality sweep.
|
|
162
|
+
|
|
163
|
+
### Refs-Not-Pastes Rule
|
|
164
|
+
|
|
165
|
+
For Phase 3+ agents, the orchestrator passes REFS to live downstream docs (`design-doc.md`, `architecture.md`, `visual-design-spec.md`, `sprint-tasks.md`, `quality-targets.json`, `decisions.jsonl`) — NOT pasted content. The orchestrator reads `docs/plans/refs.json` (produced by the Phase 2 Refs Indexer), resolves the task topic against the flat anchor index, and passes a short ref list to the agent. The agent uses the Read tool to pull refs it needs. This keeps orchestrator context lean and lets the agent widen its view on demand. Phase 1-2 agents still receive full documents because the architecture anchors don't exist yet.
|
|
166
|
+
|
|
167
|
+
**refs.json mutation invalidates sprint-context hash (Stage 6 / task 6.3.2).** Any orchestrator update to `docs/plans/refs.json` (Phase 2 Refs Indexer initial write, Phase 3 extension after `visual-design-spec.md` lands, or any subsequent correction) MUST be IMMEDIATELY followed by a `state_save` call that sets `.build-state.json.current_sprint_context_hash = null`. This invalidates the cached Phase 4 sprint-scoped shared-context block so the next subagent dispatch re-renders with fresh references. See `src/orchestrator/phase4-shared-context.ts#shouldInvalidate` for how the hash is consulted at render time. Skipping this invalidation causes Phase 4 implementers to read stale anchor indices — a silent correctness failure.
|
|
97
168
|
|
|
98
169
|
### Complexity Routing (Advisory)
|
|
99
170
|
|
|
@@ -101,39 +172,66 @@ Tag agent prompts with `[COMPLEXITY: S/M/L]` based on task size from `docs/plans
|
|
|
101
172
|
|
|
102
173
|
### Mode-Specific Tool Stacks
|
|
103
174
|
|
|
104
|
-
Mode-specific tool stacks, per-phase branches, and persona rules
|
|
175
|
+
Mode-specific tool stacks, per-phase branches, and persona rules live in separate files. Load ONE based on `project_type`:
|
|
105
176
|
- iOS: `protocols/ios-phase-branches.md` (includes iOS Mode Tool Stack)
|
|
106
177
|
- Web: `protocols/web-phase-branches.md` (web defaults)
|
|
107
178
|
|
|
179
|
+
### Backward Edges — Routing Fix
|
|
180
|
+
|
|
181
|
+
When a later phase finds a problem whose root cause lives earlier, control flows BACKWARD to the authoring phase. The orchestrator codifies these edges so problems are fixed where they were introduced, not patched locally.
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
PROBLEM FOUND AT ROUTES BACK TO
|
|
185
|
+
─────────────────────────────────────────────────────────────────
|
|
186
|
+
Gate 1 (human says "no") → Phase 1 Step 1.0 with feedback
|
|
187
|
+
Gate 2 (human says "no") → Phase 2 with feedback
|
|
188
|
+
Phase 5 Audit (code issue) → Phase 4 target task
|
|
189
|
+
Phase 5 Audit (design issue) → Phase 3 target step
|
|
190
|
+
Phase 5 Audit (spec issue) → Phase 2 re-architect
|
|
191
|
+
Phase 6 LRR BLOCK (⭐⭐) → Aggregator reads decisions.jsonl
|
|
192
|
+
by related_decision_id →
|
|
193
|
+
authoring phase → re-open
|
|
194
|
+
Phase 6 LRR NEEDS_WORK (code) → Phase 4 target task
|
|
195
|
+
Phase 6 LRR NEEDS_WORK (struct) → Phase 2 or Phase 3
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
The ⭐⭐ star rule: when the LRR Aggregator receives a BLOCK verdict, it reads the `related_decision_id` on the blocker, looks up that row in `decisions.jsonl`, finds which phase authored the decision (the `decided_by` field), and re-opens that phase with the finding as input. Infrastructure already exists (decision IDs, author tracking) — wired here.
|
|
199
|
+
|
|
200
|
+
**Re-entry halt rule (Stage 4 A7).** Before dispatching any backward routing (LRR BLOCK → Phase N re-open, Reality Checker BLOCK → Phase M re-entry, Gate "no" → Phase 1/2 re-entry, etc.), check `.build-state.json.backward_routing_count` AND the per-target-phase variant `.build-state.json.backward_routing_count_by_target_phase[<N>]`. If the new (post-increment) value of EITHER counter for the target phase would exceed `max_cycles` (currently 2, from `phase-graph.yaml:routing.max_cycles`) — i.e., on the attempted third backward iteration — the orchestrator MUST halt and escalate to the user instead of dispatching. The Stage 4 `cycle_counter_check` MCP is the authoritative enforcer at runtime — it increments atomically and returns `escalate_to_user` once the new value exceeds `max_cycles`. This prose documents the behavior for the markdown-mode rollback path and for human readers.
|
|
201
|
+
|
|
202
|
+
**Phase-entry `in_flight_backward_edge` clear (Stage 4 A3 / task 4.3.3).** On the FIRST `state_save` after any phase entry — whether forward progression or backward-edge re-entry — the orchestrator MUST explicitly set `.build-state.json.in_flight_backward_edge = null`. This is the "successful landing" signal that closes the atomic crash-seam opened by `cycle_counter_check` (which writes `in_flight_backward_edge` in the same atomic state_save that increments the counter). If the runtime crashes between edge dispatch and landing, `--resume` in `bin/buildanything-runtime.ts` observes a stale `in_flight_backward_edge` (age > 60s) and decrements the counter (see task 4.3.4). See `src/orchestrator/mcp/cycle-counter.ts#clearInFlightEdge` for the runtime primitive.
|
|
203
|
+
|
|
108
204
|
---
|
|
109
205
|
|
|
110
|
-
## Phase 0:
|
|
206
|
+
## Phase 0: Pre-flight (state read only)
|
|
207
|
+
|
|
208
|
+
Phase 0 is thin. No agent dispatch. No human input. Instant. The orchestrator reads state files and applies universal checks.
|
|
111
209
|
|
|
112
210
|
**Resuming?** If the input contains `--resume` OR if context was just compacted (SessionStart hook fired with active state):
|
|
113
|
-
1. Read `docs/plans/.build-state.
|
|
114
|
-
If
|
|
211
|
+
1. Read `docs/plans/.build-state.json` (source of truth) — verify it exists and has a `resume_point` field. Fall back to reading `docs/plans/.build-state.md` (rendered view) if the JSON file is missing but the markdown exists (graceful migration path from pre-W1-2 builds).
|
|
212
|
+
If neither exists, OR neither has a Resume Point, warn the user: 'No previous build state found. Starting fresh.' Then proceed to Step 0.1 as a new build.
|
|
115
213
|
2. Re-read this file and all protocol files in `protocols/`.
|
|
116
|
-
3. Re-read `docs/plans/sprint-tasks.md`, `docs/plans/architecture.md`,
|
|
117
|
-
4.
|
|
118
|
-
5.
|
|
119
|
-
6.
|
|
214
|
+
3. Re-read live downstream docs: `docs/plans/sprint-tasks.md`, `docs/plans/architecture.md`, `docs/plans/design-doc.md`, `docs/plans/visual-design-spec.md` (if exists), `CLAUDE.md`.
|
|
215
|
+
4. Read `docs/plans/decisions.jsonl` if it exists (top 5 most recent rows, filtered to the current phase and upstream phases). Pass short row fields + `ref` anchors into Phase 0 rehydration context — not the full row prose. See `protocols/decision-log.md`.
|
|
216
|
+
5. Rebuild TodoWrite from the state file (TodoWrite does NOT survive compaction or session breaks).
|
|
217
|
+
6. Reset `dispatches_since_save` to 0 (fresh context window).
|
|
218
|
+
7. Resume from the saved phase and step. Skip Phase 0.
|
|
120
219
|
|
|
121
220
|
### Step 0.1 — Read the Room
|
|
122
221
|
|
|
123
|
-
|
|
222
|
+
Scan for existing context:
|
|
124
223
|
|
|
125
224
|
- Check if the input is a file path (e.g., `docs/plans/brainstorm.md`). If so, read it.
|
|
126
225
|
- Check if `docs/plans/` or `docs/briefs/` exist with prior brainstorming, design docs, decision briefs, or research. Read them.
|
|
127
226
|
- Check if there's existing code in the project. If so, this is an enhancement, not greenfield.
|
|
128
227
|
- Check the conversation history — has the user been discussing this idea already?
|
|
129
|
-
- Check if `docs/plans/learnings.md` exists from a previous build. If so, read it. Apply relevant PATTERNS to agent prompt design, avoid listed PITFALLs, use HEURISTICS when applicable.
|
|
130
228
|
|
|
131
229
|
**Classify what you found:**
|
|
132
230
|
|
|
133
231
|
| Context Level | What You Have | What Happens |
|
|
134
232
|
|---|---|---|
|
|
135
233
|
| **Full design** | Design doc with decisions, scope, tech stack, data models | Skip Phase 1. Feed design into Phase 2. |
|
|
136
|
-
| **Decision brief** | An idea-sweep brief with verdicts and MVP definition | Phase 1 skips research (
|
|
234
|
+
| **Decision brief** | An idea-sweep brief with verdicts and MVP definition | Phase 1 skips Step 1.1 research (already done). Brainstorming refines the brief into a design. |
|
|
137
235
|
| **Partial context** | Some notes, conversation, rough sketch | Phase 1 runs fully. Feed context into brainstorming + research. |
|
|
138
236
|
| **Raw idea** | One-line build request, no prior work | Phase 1 runs fully from scratch. |
|
|
139
237
|
|
|
@@ -141,430 +239,848 @@ Before doing anything, scan for existing context:
|
|
|
141
239
|
|
|
142
240
|
Scan the build request AND any context from Step 0.1 for iOS signals. Keywords: **iOS, iPhone, iPad, SwiftUI, Swift, App Store, TestFlight, Xcode, Apple, Liquid Glass, watchOS, visionOS, SwiftData, HIG**.
|
|
143
241
|
|
|
144
|
-
**Classification logic:**
|
|
145
|
-
|
|
146
242
|
| Signal | Action |
|
|
147
243
|
|---|---|
|
|
148
244
|
| iOS keywords present in prompt | Confirm with user: "This looks like an iOS app — confirm? [y/n]" |
|
|
149
|
-
| User confirms OR says iOS during brainstorming | Set `project_type: ios` in `docs/plans/.build-state.
|
|
245
|
+
| User confirms OR says iOS during brainstorming | Set `project_type: ios` in `docs/plans/.build-state.json` (regenerate markdown view) |
|
|
150
246
|
| `.xcodeproj` / `Package.swift` / `*.swift` files in existing codebase | Set `project_type: ios` automatically |
|
|
151
|
-
| No iOS signals, no Swift files | Default `project_type: web`
|
|
247
|
+
| No iOS signals, no Swift files | Default `project_type: web` |
|
|
152
248
|
|
|
153
249
|
**Autonomous mode:** skip the confirmation prompt. If iOS keywords are present, set `project_type: ios` and log the inference to `docs/plans/build-log.md`.
|
|
154
250
|
|
|
155
251
|
**Conditional branch-file load:**
|
|
156
|
-
-
|
|
157
|
-
-
|
|
158
|
-
- Load only ONE branch file.
|
|
252
|
+
- `project_type=ios`: load `protocols/ios-phase-branches.md` AND `protocols/ios-context.md`. Reference `protocols/ios-frameworks-map.md` by path only.
|
|
253
|
+
- `project_type=web`: load `protocols/web-phase-branches.md`.
|
|
254
|
+
- Load only ONE branch file.
|
|
159
255
|
|
|
160
|
-
Record the classification in `docs/plans/.build-state.
|
|
256
|
+
Record the classification in `docs/plans/.build-state.json` as the top-level `project_type` field. Regenerate `.build-state.md` after the write. This field survives compaction and gates every branching block below.
|
|
161
257
|
|
|
162
|
-
**Mode-specific additions to Phase 0:** See `protocols/ios-phase-branches.md` §Phase 0 additions (iOS only).
|
|
258
|
+
**Mode-specific additions to Phase 0:** See `protocols/ios-phase-branches.md` §Phase 0 additions (iOS only).
|
|
163
259
|
|
|
164
|
-
### Step 0.
|
|
260
|
+
### Step 0.1d — Learnings Loader (PITFALL replay)
|
|
165
261
|
|
|
166
|
-
|
|
262
|
+
Read `docs/plans/learnings.jsonl` (cross-run learnings store). If the project-local file does not exist, fall back to `~/.claude/buildanything/learnings.jsonl`. If neither exists, proceed with an empty active-learnings file and skip the rest of this step.
|
|
167
263
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
-
|
|
264
|
+
If a learnings file exists:
|
|
265
|
+
1. Parse each line as a JSON row with the schema written at Phase 5 reality sweep: `{run_id, timestamp, project_type, phase_where_learning_surfaced, metric, top_issue, fix_applied, score_delta, pattern_type}`.
|
|
266
|
+
2. Filter entries where `project_type` matches the current build's classification.
|
|
267
|
+
3. Rank the filtered entries by composite score: prefer entries matching expected `pattern_type` (PITFALL > PATTERN > HEURISTIC), then by `phase_where_learning_surfaced` (earlier phases first), then by `score_delta` magnitude.
|
|
268
|
+
4. Select the top 3 most relevant entries.
|
|
269
|
+
5. Write them to `docs/plans/.active-learnings.md` as a short markdown section downstream agents inject into their prompts. Format:
|
|
174
270
|
|
|
175
|
-
|
|
271
|
+
```markdown
|
|
272
|
+
## Prior Learnings (top 3 relevant)
|
|
176
273
|
|
|
274
|
+
- **PITFALL (phase 4.x, iOS):** [top_issue] — fix: [fix_applied]
|
|
275
|
+
- **PATTERN (phase 5.x, web):** [top_issue] — fix: [fix_applied]
|
|
276
|
+
- **HEURISTIC (phase 4.x, iOS):** [top_issue] — fix: [fix_applied]
|
|
177
277
|
```
|
|
178
|
-
BEFORE I GO HEADS-DOWN, please set up:
|
|
179
278
|
|
|
180
|
-
|
|
181
|
-
[ ] [Database] → add connection URL to .env
|
|
182
|
-
[ ] GitHub repo → share the URL
|
|
183
|
-
[ ] [Deployment service] connected (optional)
|
|
279
|
+
Phase 4 implementer dispatch reads `.active-learnings.md` and injects its contents into every implementer prompt under a `## Prior Learnings` section. This is how learnings from build N flow into build N+1.
|
|
184
280
|
|
|
185
|
-
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
<HARD-GATE>
|
|
189
|
-
Interactive mode: DO NOT proceed until the user confirms prerequisites (or says to skip).
|
|
190
|
-
Autonomous mode: Log checklist to `docs/plans/build-log.md`. Create `.env.example` with required keys. Proceed — log missing keys as blockers if hit during build.
|
|
191
|
-
</HARD-GATE>
|
|
192
|
-
|
|
193
|
-
### Step 0.3 — Initialize
|
|
281
|
+
### Step 0.2 — Initialize
|
|
194
282
|
|
|
195
283
|
0. Create `docs/plans/` directory if it doesn't exist (greenfield projects won't have it).
|
|
196
284
|
1. Create a TodoWrite checklist with Phases 0-7.
|
|
197
|
-
2.
|
|
285
|
+
2. Write `docs/plans/.build-state.json` per the schema in `protocols/state-schema.md`. Required top-level fields: `project_type`, `phase`, `step`, `input`, `context_level`, `prerequisites`, `dispatch_count`, `last_save_phase`, `autonomous`, `session_id`, `session_started`, `completed_tasks[]`, `metric_loop_scores[]`, `decisions_next_id` (object keyed by phase number — see Phase 4 orchestrator-scribe handler), `resume_point { phase, step, completed_tasks, git_branch }`. Then regenerate `docs/plans/.build-state.md` from the JSON as a **read-only rendered view**.
|
|
198
286
|
3. Go to Phase 1 (or Phase 2 if context level is "Full design").
|
|
199
287
|
|
|
288
|
+
**NO prereq collection in Phase 0.** Stack isn't decided yet. Prereqs move to Step 1.5, after Gate 1. Asking for creds before the stack is picked means asking for wrong creds or re-asking on rejection.
|
|
289
|
+
|
|
290
|
+
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
291
|
+
|
|
200
292
|
---
|
|
201
293
|
|
|
202
294
|
## Phase -1: iOS Bootstrap (iOS-only, greenfield only)
|
|
203
295
|
|
|
204
|
-
**If `project_type=ios` AND no `.xcodeproj` exists:** follow `protocols/ios-phase-branches.md` §Phase -1 — iOS Bootstrap. Otherwise skip entirely
|
|
296
|
+
**If `project_type=ios` AND no `.xcodeproj` exists:** follow `protocols/ios-phase-branches.md` §Phase -1 — iOS Bootstrap. Otherwise skip entirely.
|
|
297
|
+
|
|
298
|
+
iOS structural changes are out of scope for this orchestrator migration (per proposed-state §7).
|
|
205
299
|
|
|
206
|
-
**Compaction checkpoint.** Update
|
|
300
|
+
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
207
301
|
|
|
208
302
|
---
|
|
209
303
|
|
|
210
|
-
## Phase 1:
|
|
304
|
+
## Phase 1: Discover — BRAINSTORM ↔ RESEARCH loop
|
|
211
305
|
|
|
212
|
-
**Goal**: Turn the raw idea into a validated Design Document grounded in research. This ensures Phase 2 architects receive a
|
|
306
|
+
**Goal**: Turn the raw idea into a validated Design Document (the PRD) grounded in research. This ensures Phase 2 architects receive a PRD, not a guess.
|
|
213
307
|
|
|
214
308
|
**Skip if** Step 0.1 classified context as "Full design" — go straight to Phase 2.
|
|
215
309
|
|
|
310
|
+
**Orchestrator discipline in Phase 1**: Dispatch → wait → read compact return → dispatch next. No synthesis. No reasoning. No raw artifact reads. Keep it thin. The Research Synthesizer (Step 1.2) is the only agent that reads raw research files.
|
|
311
|
+
|
|
216
312
|
**Mode-specific branch:**
|
|
217
|
-
-
|
|
218
|
-
-
|
|
313
|
+
- `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 1 (iOS skill bundle, ios-swift-architect, App Store/TestFlight/iOS 26 research angles).
|
|
314
|
+
- `project_type=web`: no additional branch instructions.
|
|
219
315
|
|
|
220
|
-
### Step 1.
|
|
316
|
+
### Step 1.0 — INITIAL BRAINSTORM
|
|
221
317
|
|
|
222
|
-
|
|
318
|
+
Dispatch the Brainstorm Facilitator as an INTERNAL inline role-string — NO `subagent_type`. The facilitator drives a conversation to capture the raw idea: what it is, who it's for, what problem it solves, hard constraints.
|
|
223
319
|
|
|
224
|
-
|
|
320
|
+
Call the Agent tool — description: "Initial brainstorm" — INTERNAL inline role-string — prompt: "You are the Brainstorm Facilitator (round 1). Your job is to drive a conversation with the user to capture the raw idea. Ask questions one at a time in plain language. Topics to cover: WHAT is being built (product/feature), WHO it's for (persona), WHAT problem it solves, HARD CONSTRAINTS (budget, timeline, platform, integrations). Keep it to 4-8 questions. Write the raw idea to `docs/plans/phase1-scratch/idea-draft.md` with a header and a section per topic. Orchestrator relays your questions to the user and relays the user's answers back to you."
|
|
225
321
|
|
|
226
|
-
|
|
322
|
+
**Autonomous mode:** facilitator synthesizes directly from build request + available context without asking questions. Logs rationale to `docs/plans/build-log.md`.
|
|
227
323
|
|
|
228
|
-
|
|
324
|
+
**Returns:** `docs/plans/phase1-scratch/idea-draft.md`
|
|
325
|
+
|
|
326
|
+
### Step 1.1 — RESEARCH (TEAM of 4 parallel agents, ONE message)
|
|
229
327
|
|
|
230
328
|
Skip if context level is "Decision brief" (research already done).
|
|
231
329
|
|
|
232
|
-
Call the Agent tool
|
|
330
|
+
Call the Agent tool 4 times in a single message. Each gets the build request + `docs/plans/phase1-scratch/idea-draft.md`. Each writes its own output file. Raw files are NOT read by the orchestrator in Step 1.2 — a separate Research Synthesizer reads them. They ARE routed by domain to Phase 2 architects (hybrid routing — see Phase 2 Step 2.2).
|
|
233
331
|
|
|
234
|
-
|
|
332
|
+
**CONTEXT header:** Render `rendered_context_header` for phase 1 per the canonical template (see CONTEXT HEADER HARD-GATE above). Prepend to every Phase 1 research prompt below.
|
|
235
333
|
|
|
236
|
-
|
|
334
|
+
1. Description: "Feature intel" — subagent_type: `feature-intel` — Prompt: "[CONTEXT header above] Extract competitor feature matrix for: [build request]. Idea draft: read docs/plans/phase1-scratch/idea-draft.md with your Read tool. Walk 5-10 rivals. Return must-haves (features present in >=80% of rivals — table stakes) + stand-outs (features unique to individual rivals — differentiation opportunities), sorted by competitor. Save to `docs/plans/phase1-scratch/feature-intel.md`."
|
|
237
335
|
|
|
238
|
-
|
|
336
|
+
2. Description: "Tech feasibility" — subagent_type: `tech-feasibility` — Prompt: "[CONTEXT header above] Evaluate hard technical problems (Solved/Hard/Unsolved), build-vs-buy decisions, MVP scope, stack validation for: [build request]. Idea draft: read docs/plans/phase1-scratch/idea-draft.md with your Read tool. Verify APIs and libraries from the draft exist and are maintained. Save to `docs/plans/phase1-scratch/tech-feasibility.md`. Report with a Technical Verdict."
|
|
239
337
|
|
|
240
|
-
|
|
338
|
+
3. Description: "UX research" — subagent_type: `design-ux-researcher` — Prompt: "[CONTEXT header above] Analyze target persona, jobs-to-be-done, current alternatives, and behavioral barriers for: [build request]. Idea draft: read docs/plans/phase1-scratch/idea-draft.md with your Read tool. Save to `docs/plans/phase1-scratch/ux-research.md`. Report with a User Verdict."
|
|
241
339
|
|
|
242
|
-
|
|
340
|
+
4. Description: "Business model" — subagent_type: `business-model` — Prompt: "[CONTEXT header above] Light-touch revenue/channels/unit-economics analysis for: [build request]. Idea draft: read docs/plans/phase1-scratch/idea-draft.md with your Read tool. Surface product-impact conclusions only — which features the business model requires, which channels gate the feature set. Do not write full financial modeling. Save to `docs/plans/phase1-scratch/business-model.md`."
|
|
243
341
|
|
|
244
|
-
|
|
342
|
+
### Step 1.2 — RESEARCH DIGEST (context protection)
|
|
245
343
|
|
|
246
|
-
|
|
344
|
+
Dispatch the Research Synthesizer as an INTERNAL inline role-string — NO `subagent_type`. The synthesizer reads all 4 raw research files IN ITS OWN context, synthesizes, and returns a compact digest + dynamic questions. The orchestrator never loads the raw files. Saves ~3-5K tokens of orchestrator context per build.
|
|
247
345
|
|
|
248
|
-
|
|
346
|
+
Call the Agent tool — description: "Research digest" — INTERNAL inline role-string — prompt: "You are the Research Synthesizer. Read these 4 raw research files with your own Read tool:
|
|
347
|
+
- `docs/plans/phase1-scratch/feature-intel.md`
|
|
348
|
+
- `docs/plans/phase1-scratch/tech-feasibility.md`
|
|
349
|
+
- `docs/plans/phase1-scratch/ux-research.md`
|
|
350
|
+
- `docs/plans/phase1-scratch/business-model.md`
|
|
249
351
|
|
|
250
|
-
|
|
251
|
-
-
|
|
252
|
-
-
|
|
253
|
-
-
|
|
352
|
+
Synthesize a compact findings digest (~500 words, no padding) covering:
|
|
353
|
+
- Feature landscape summary (must-haves, stand-outs, gaps)
|
|
354
|
+
- Technical verdict with hard-problem callouts
|
|
355
|
+
- Persona + JTBD highlights
|
|
356
|
+
- Business-model implications for product scope
|
|
254
357
|
|
|
255
|
-
|
|
358
|
+
Then generate a DYNAMIC list of 4-8 brainstorm questions tuned to what actually surfaced — not a fixed script. Example: if tech-feasibility found an unsolved problem, surface a scope question. If UX research says persona is time-poor, surface a flow-simplification question.
|
|
256
359
|
|
|
257
|
-
|
|
360
|
+
Write:
|
|
361
|
+
1. `docs/plans/phase1-scratch/findings-digest.md` (~500 words)
|
|
362
|
+
2. `docs/plans/phase1-scratch/suggested-questions.md` (4-8 dynamic questions)
|
|
258
363
|
|
|
259
|
-
|
|
364
|
+
Return a compact summary to the orchestrator. The orchestrator does NOT read the raw files."
|
|
260
365
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
366
|
+
### Step 1.3 — INFORMED BRAINSTORM
|
|
367
|
+
|
|
368
|
+
Dispatch the Brainstorm Facilitator (round 2) as an INTERNAL inline role-string. This is a dynamic conversation — questions adapt to what research surfaced, not a fixed script. User makes product decisions WITH research in hand.
|
|
369
|
+
|
|
370
|
+
Call the Agent tool — description: "Informed brainstorm" — INTERNAL inline role-string — prompt: "You are the Brainstorm Facilitator (round 2). Read `docs/plans/phase1-scratch/findings-digest.md` + `docs/plans/phase1-scratch/suggested-questions.md` via the Read tool. Drive a DYNAMIC conversation with the user using those questions — adapt based on answers, don't run a fixed script. Topics to cover (wording is dynamic, tuned to what surfaced):
|
|
371
|
+
- Which must-have features to include vs. cut
|
|
372
|
+
- Which stand-out features for differentiation
|
|
373
|
+
- Any persona / JTBD adjustments
|
|
374
|
+
- Does business model suggest specific features (e.g., freemium needs a free tier UI)
|
|
375
|
+
|
|
376
|
+
Orchestrator relays your questions to the user and relays answers back. Write decisions to `docs/plans/phase1-scratch/user-decisions.md`."
|
|
377
|
+
|
|
378
|
+
**Autonomous mode:** facilitator picks pragmatic defaults from the digest without asking questions. Logs rationale to `docs/plans/build-log.md`.
|
|
264
379
|
|
|
265
|
-
|
|
380
|
+
### Step 1.4 — DESIGN DOC + CLAUDE.md
|
|
381
|
+
|
|
382
|
+
Dispatch the Design Doc Writer as an INTERNAL inline role-string. Writes TWO outputs. The design doc is explicitly named **THE PRD** — the authoritative product document read by every Phase 2-7 agent via `refs.json` anchors, no full pastes.
|
|
383
|
+
|
|
384
|
+
Call the Agent tool — description: "Design doc and CLAUDE.md" — INTERNAL inline role-string — prompt: "You are the Design Doc Writer. Read with your own Read tool:
|
|
385
|
+
- `docs/plans/phase1-scratch/idea-draft.md`
|
|
386
|
+
- `docs/plans/phase1-scratch/findings-digest.md`
|
|
387
|
+
- `docs/plans/phase1-scratch/user-decisions.md`
|
|
388
|
+
|
|
389
|
+
Write TWO outputs.
|
|
390
|
+
|
|
391
|
+
OUTPUT 1 — `docs/plans/design-doc.md` — **THE PRD** (authoritative product document). Header MUST begin with `# [Product Name] — PRD`. Structure:
|
|
392
|
+
- Product — what it is, core value prop, success criteria
|
|
393
|
+
- User — persona, JTBD, hard constraints
|
|
394
|
+
- Scope — MVP features (must-haves + chosen stand-outs), explicit Out-of-Scope boundary
|
|
395
|
+
- Tech Stack — chosen stack with 1-line rationale
|
|
396
|
+
- Data Model — shape of core entities
|
|
397
|
+
- Decisions — links to `decisions.jsonl` rows
|
|
398
|
+
|
|
399
|
+
This doc is read by all Phase 2-7 agents via `refs.json` anchors. Section headers should be stable (don't rename them later) so anchors survive.
|
|
400
|
+
|
|
401
|
+
OUTPUT 2 — `CLAUDE.md` (project root, NOT `docs/plans/`). <200-line product brain, auto-loaded into every spawned subagent context by Claude Code. The orchestrator NEVER pastes it. Structure:
|
|
266
402
|
|
|
267
403
|
```
|
|
268
404
|
## Product
|
|
269
405
|
[1-3 sentences: what this is, core value prop, what success looks like]
|
|
270
406
|
|
|
271
407
|
## User
|
|
272
|
-
[Primary persona: who they are, what they care about, pain points,
|
|
273
|
-
technical sophistication. This drives every UX decision.]
|
|
408
|
+
[Primary persona: who they are, what they care about, pain points, technical sophistication]
|
|
274
409
|
|
|
275
410
|
## Tech Stack
|
|
276
|
-
[Stack choices with 1-line rationale for each
|
|
277
|
-
key libraries, deployment target.]
|
|
411
|
+
[Stack choices with 1-line rationale for each]
|
|
278
412
|
|
|
279
413
|
## Scope
|
|
280
|
-
[What's in MVP vs. deferred. Hard boundaries.
|
|
281
|
-
from building features that aren't scoped.]
|
|
414
|
+
[What's in MVP vs. deferred. Hard boundaries.]
|
|
282
415
|
|
|
283
416
|
## Rules
|
|
284
|
-
[Project-specific hard rules derived from the product and user context.
|
|
285
|
-
Examples: "All data must be real-time — no simulated/fake data",
|
|
286
|
-
"User must be able to pause/stop any automated process at any time",
|
|
287
|
-
"Every interactive element must have visible feedback within 200ms".
|
|
288
|
-
Only include rules this specific project needs — not generic best practices.]
|
|
417
|
+
[Project-specific hard rules derived from the product and user context.]
|
|
289
418
|
```
|
|
290
419
|
|
|
291
|
-
|
|
420
|
+
<HARD-GATE>
|
|
421
|
+
CLAUDE.md must be under 200 lines. Not a wiki, not a conventions doc, not a dump of everything. Minimum context an agent needs to make correct decisions about this specific product.
|
|
422
|
+
</HARD-GATE>
|
|
423
|
+
|
|
424
|
+
Return 3 decision rows in your structured result under a `phase_1_decisions` field — one each for tech stack, data model, and scope boundary. Each row shape: `{phase: 1, author: \"architect\", type: \"tech-stack\" | \"data-model\" | \"scope-boundary\", summary, rationale, related_files: [\"docs/plans/design-doc.md\"]}`. The orchestrator forwards each row through the `scribe_decision` MCP tool (see Phase 4 "Orchestrator-scribe dispatch"). DO NOT write `decisions.jsonl` directly."
|
|
425
|
+
|
|
426
|
+
**Writes:** `docs/plans/design-doc.md` (PRD), `CLAUDE.md`. Decision rows flow through the orchestrator's `scribe_decision` MCP calls.
|
|
427
|
+
|
|
428
|
+
**Post-Step 1.4 — CLAUDE.md size enforcement (mechanical check):**
|
|
429
|
+
After the Design Doc Writer returns, run `wc -l < CLAUDE.md` and capture the line count. If the count exceeds 200 lines:
|
|
430
|
+
1. FAIL the step. Log to `docs/plans/build-log.md`: `"CLAUDE.md size violation: {count} lines (limit: 200)"`.
|
|
431
|
+
2. Re-dispatch the Design Doc Writer with this additional instruction prepended: `"CLAUDE.md EXCEEDED 200 LINES ({count} lines). Rewrite CLAUDE.md to ≤200 lines. Cut aggressively — keep only what a subagent needs to make correct product decisions. No conventions, no wiki content, no boilerplate."`.
|
|
432
|
+
3. Max 2 retries. If still over 200 after 2 retries, HARD-FAIL and surface to user: `"CLAUDE.md is {count} lines after 2 rewrites. Please manually trim to ≤200 lines before proceeding — this file is auto-loaded into every subagent and bloat here multiplies across all Phases 2-7 dispatches."`.
|
|
292
433
|
|
|
293
434
|
### Quality Gate 1
|
|
294
435
|
|
|
295
|
-
**
|
|
436
|
+
**Interactive:** Present Design Doc summary + Research Digest findings to user. Ask: "Approve this design, or adjust?"
|
|
437
|
+
|
|
438
|
+
<HARD-GATE>
|
|
439
|
+
Gate 1 rejection path is codified:
|
|
440
|
+
- On NO → loop back to Phase 1 Step 1.0 with user feedback passed back to Brainstorm Facilitator (round 1 re-invocation).
|
|
441
|
+
- On YES → proceed to Step 1.5.
|
|
442
|
+
- DO NOT PROCEED without user approval in interactive mode.
|
|
443
|
+
</HARD-GATE>
|
|
444
|
+
|
|
445
|
+
**Autonomous:** Log design-doc path + digest path to `docs/plans/build-log.md`. Auto-approve. Proceed.
|
|
296
446
|
|
|
297
|
-
|
|
447
|
+
Update TodoWrite and `.build-state.json`.
|
|
298
448
|
|
|
299
|
-
|
|
449
|
+
### Step 1.5 — PREREQ COLLECTOR (post-Gate 1)
|
|
300
450
|
|
|
301
|
-
|
|
451
|
+
Dispatch the Prereq Collector as an INTERNAL inline role-string. Reads `design-doc.md` to determine which credentials are actually needed for the chosen stack. Asks the user ONLY for stack-specific creds.
|
|
452
|
+
|
|
453
|
+
Call the Agent tool — description: "Prereq collection" — INTERNAL inline role-string — prompt: "You are the Prereq Collector. Read `docs/plans/design-doc.md` with your own Read tool — focus on the Tech Stack section. Determine which credentials the chosen stack actually needs (do NOT ask for a generic laundry list — ask ONLY for what this stack uses).
|
|
454
|
+
|
|
455
|
+
Example: 'You chose Next.js + Supabase + Vercel — I need your Supabase URL, Supabase anon key, and Vercel auth token.' Skip anything the stack doesn't use.
|
|
456
|
+
|
|
457
|
+
Output: `docs/plans/phase1-scratch/prereqs.json` with shape `{supabase_url, supabase_anon_key, ...}`. Ask the user once. If they don't have a credential, mark it as `null` and note in the JSON that Phase 4 will surface it as a blocker if hit."
|
|
458
|
+
|
|
459
|
+
**Autonomous mode:** Create `.env.example` with required keys. Proceed. Log missing keys as blockers if hit during build.
|
|
460
|
+
|
|
461
|
+
**Why here:** at Phase 0 we don't yet know the stack (it's decided in Step 1.3). Asking for creds before Gate 1 means asking for wrong creds or re-asking on rejection.
|
|
462
|
+
|
|
463
|
+
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
302
464
|
|
|
303
465
|
---
|
|
304
466
|
|
|
305
|
-
## Phase 2:
|
|
467
|
+
## Phase 2: Plan / Architect — TEAM of 6 + sequence
|
|
306
468
|
|
|
307
|
-
**Goal**: Convert the
|
|
469
|
+
**Goal**: Convert the PRD into a concrete architecture and ordered task list with explicit dependencies. Every architect receives the PRD (design-doc.md) + the Research Digest + its domain's raw research file (hybrid routing).
|
|
308
470
|
|
|
309
471
|
**Mode-specific branch:**
|
|
310
|
-
-
|
|
311
|
-
-
|
|
472
|
+
- `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 2 (replaces Backend/Frontend dispatch with SwiftUI/SwiftData/Concurrency/iOS security; adds Feature Flag Resolution at end of phase).
|
|
473
|
+
- `project_type=web`: no additional branch instructions.
|
|
312
474
|
|
|
313
|
-
### Step 2.1 — Explore
|
|
475
|
+
### Step 2.1 — Explore existing codebase (only if existing code)
|
|
314
476
|
|
|
315
|
-
If existing code, call the Agent tool — description: "Explore codebase" — prompt: "Explore
|
|
477
|
+
If existing code, call the Agent tool — description: "Explore codebase" — INTERNAL inline role-string — prompt: "Explore existing codebase. Map architecture layers, file conventions, testing patterns, existing features, integration points. Return a compact summary suitable for architects to consume — not a full dump."
|
|
316
478
|
|
|
317
479
|
If greenfield, skip to Step 2.2.
|
|
318
480
|
|
|
319
|
-
### Step 2.2 — Architecture Design (
|
|
481
|
+
### Step 2.2 — Architecture Design (TEAM of 6 architects coordinating via SendMessage)
|
|
482
|
+
|
|
483
|
+
The 6 architects design as a TEAM — not 6 isolated subagents. Cross-domain contract boundaries (Backend↔Frontend on API shape, Security↔Backend on auth, A11y↔Frontend on component patterns, Performance↔Backend+Data on query shapes) are caught at design time via peer SendMessage, not absorbed silently by a downstream stitcher.
|
|
484
|
+
|
|
485
|
+
**On re-entry from LRR backward routing:** If Phase 2 is being re-opened via the re-entry dispatch template (Step 6.3), skip team creation if the original `phase-2-architects` team is still live from this build; otherwise recreate it. Pass the re-entry payload (`{blocking_finding, prior_output: "docs/plans/architecture.md", decision_row}`) into the dispatch prompt of the architect(s) whose domain matches `decision_row.author` — only those architects re-run, not all 6. The re-dispatched architect revises its `docs/plans/phase-2-contracts/<name>.md` in place, SendMessages peers on any contract boundary it now changes, and the synthesizer re-runs once to re-stitch `architecture.md`. Do NOT redo unaffected domains.
|
|
486
|
+
|
|
487
|
+
**Step 2.2a — Create the team.**
|
|
488
|
+
|
|
489
|
+
Call `TeamCreate` with `team_name: "phase-2-architects"`. This team scopes the SendMessage channel for the 6 architects below. Capture the team id in `.build-state.json` for teardown.
|
|
490
|
+
|
|
491
|
+
**Step 2.2b — Dispatch 6 architects as teammates (ONE message).**
|
|
492
|
+
|
|
493
|
+
Call the Agent tool 6 times in a single message. Each call passes `team_name: "phase-2-architects"` and a unique `name` (listed below). Each architect receives: `docs/plans/design-doc.md` (PRD) + `docs/plans/phase1-scratch/findings-digest.md` + ITS DOMAIN'S RAW RESEARCH FILE (hybrid routing) + the team roster + cross-check pairings + the per-architect output file path.
|
|
494
|
+
|
|
495
|
+
Shared brief appended to every architect prompt:
|
|
496
|
+
|
|
497
|
+
```
|
|
498
|
+
TEAM: phase-2-architects
|
|
499
|
+
ROSTER:
|
|
500
|
+
- backend-architect (owns services, API contracts, DB schema)
|
|
501
|
+
- frontend-architect (owns component hierarchy, state mgmt, routing)
|
|
502
|
+
- data-engineer (owns ETL/ELT, schema versioning, query patterns)
|
|
503
|
+
- security-engineer (owns auth model, input validation, threat model)
|
|
504
|
+
- accessibility-auditor (owns WCAG 2.2 AA constraints on component/nav choice)
|
|
505
|
+
- performance-benchmarker (owns quality-targets.json, bundle + latency budgets)
|
|
506
|
+
|
|
507
|
+
CROSS-CHECK PAIRINGS (mandatory — if your design touches one of these boundaries, SendMessage the peer before you finalize):
|
|
508
|
+
- Backend ↔ Frontend on API contract shape (REST vs GraphQL, request/response schemas, error envelope)
|
|
509
|
+
- Security ↔ Backend on auth flow (token storage, refresh, session model, authz gates)
|
|
510
|
+
- Accessibility ↔ Frontend on component patterns (primitives, focus management, landmark structure)
|
|
511
|
+
- Performance ↔ Backend+Data on query shapes (N+1 risk, indexing strategy, bundle impact of data layer choices)
|
|
512
|
+
|
|
513
|
+
COORDINATION RULES:
|
|
514
|
+
- Plain text in your output file is INVISIBLE to teammates. If a contract boundary intersects another architect's domain, you MUST `SendMessage` to that peer using the exact `name` from the roster above. Do not assume they will read your file.
|
|
515
|
+
- If a peer SendMessage challenges a decision you have written, revise your output file and SendMessage back with the resolution — do not silently ignore.
|
|
516
|
+
- Idle (exit) only after: (1) your initial read + draft is complete, AND (2) all cross-check pairings touching your domain have either been resolved via SendMessage or confirmed non-intersecting.
|
|
517
|
+
|
|
518
|
+
OUTPUT:
|
|
519
|
+
Write your findings to `docs/plans/phase-2-contracts/<your-name>.md` (e.g., `docs/plans/phase-2-contracts/backend-architect.md`). This file is the authoritative record of your post-debate position — include both your initial decisions AND any revisions driven by peer SendMessage.
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
Per-architect dispatches:
|
|
523
|
+
|
|
524
|
+
**CONTEXT header:** Render `rendered_context_header` for phase 2 per the canonical template (see CONTEXT HEADER HARD-GATE above). Prepend to every Phase 2 architect prompt below.
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
1. Description: "Backend architecture" — subagent_type: `engineering-backend-architect` — team_name: `phase-2-architects` — name: `backend-architect` — Prompt: "[CONTEXT header above] Design system architecture. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/tech-feasibility.md`, `docs/plans/phase1-scratch/feature-intel.md`\nInclude services, data models, API contracts, database schema, integration points. Respect stack choices from PRD.\n\n[paste shared team brief above]"
|
|
528
|
+
|
|
529
|
+
2. Description: "Frontend architecture" — subagent_type: `engineering-frontend-developer` — team_name: `phase-2-architects` — name: `frontend-architect` — Prompt: "[CONTEXT header above] Design frontend architecture. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/ux-research.md`, `docs/plans/phase1-scratch/feature-intel.md`\nInclude component hierarchy, layout strategy, responsive approach, state management, routing. Align UX with the persona from research.\n\n[paste shared team brief above]"
|
|
530
|
+
|
|
531
|
+
3. Description: "Data engineering" — subagent_type: `engineering-data-engineer` — team_name: `phase-2-architects` — name: `data-engineer` — Prompt: "[CONTEXT header above] Design data architecture. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/tech-feasibility.md`\nInclude ETL/ELT patterns, schema versioning, query patterns, indexing strategy, data lineage, migration plan.\n\n[paste shared team brief above]"
|
|
320
532
|
|
|
321
|
-
Read
|
|
533
|
+
4. Description: "Security architecture" — subagent_type: `engineering-security-engineer` — team_name: `phase-2-architects` — name: `security-engineer` — Prompt: "[CONTEXT header above] Security review. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\nCover auth model, input validation, secrets management, threat model, dependency hygiene. Note: no raw research file routed — digest only (security architecture is a cross-cutting concern).\n\n[paste shared team brief above]"
|
|
322
534
|
|
|
323
|
-
|
|
535
|
+
5. Description: "A11y constraints" — subagent_type: `a11y-architect` — team_name: `phase-2-architects` — name: `accessibility-auditor` — Prompt: "[CONTEXT header above] Accessibility-driven architecture constraints. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/ux-research.md`\nIdentify WCAG 2.2 AA requirements that affect component choice, navigation structure, form patterns, focus management, landmark regions.\n\n[paste shared team brief above]"
|
|
324
536
|
|
|
325
|
-
|
|
537
|
+
6. Description: "Performance constraints" — subagent_type: `testing-performance-benchmarker` — team_name: `phase-2-architects` — name: `performance-benchmarker` — Prompt: "[CONTEXT header above] Define quality targets for this build. Read these files via your Read tool before starting — do NOT expect pasted content:\n - PRD: `docs/plans/design-doc.md`\n - DIGEST: `docs/plans/phase1-scratch/findings-digest.md`\n - YOUR DOMAIN RAW: `docs/plans/phase1-scratch/tech-feasibility.md`\nWrite `docs/plans/quality-targets.json` covering bundle budget, LCP, TTI, API p95, Lighthouse scores. Use per-Scope budgets from `orchestration-proposed-state.md` §11: Marketing 500KB / Product 300KB / Dashboard 400KB / Internal 200KB gzipped.\n\n[paste shared team brief above]"
|
|
326
538
|
|
|
327
|
-
2.
|
|
539
|
+
**Step 2.2c — Wait for all 6 teammates to idle**, then proceed to synthesis. The `docs/plans/phase-2-contracts/*.md` files now contain post-debate positions (initial draft plus any SendMessage-driven revisions). The orchestrator does NOT read these files — the synthesizer below does.
|
|
328
540
|
|
|
329
|
-
|
|
541
|
+
After all 6 teammates are idle, the 4 raw research files are **SPENT**. They sit on disk for audit but no downstream phase reads them — they are NOT in the `refs.json` index. The orchestrator MOVES them to `docs/plans/phase1-scratch/` if not already there, to make the distinction physically obvious.
|
|
330
542
|
|
|
331
|
-
|
|
543
|
+
**Step 2.2d — Team teardown.** After the synthesizer dispatch at Step 2.3 returns, call `TeamDelete` on `phase-2-architects` to clean up the team channel.
|
|
332
544
|
|
|
333
|
-
|
|
545
|
+
### Step 2.3 — Sequence: Implementation Blueprint → Sprint Breakdown → DAG Validator → Refs Indexer
|
|
334
546
|
|
|
335
|
-
|
|
547
|
+
Four sequential dispatches.
|
|
336
548
|
|
|
337
|
-
|
|
549
|
+
**CONTEXT header:** Reuse `rendered_context_header` from phase 2 (already rendered above). Prepend to Step 2.3 synthesizer + sprint-breakdown prompts.
|
|
338
550
|
|
|
339
|
-
|
|
551
|
+
1. Description: "Implementation blueprint" — subagent_type: `code-architect` — Prompt: "[CONTEXT header above] Implementation blueprint. Read the PRD via your Read tool: `docs/plans/design-doc.md`. Read all 6 post-debate architect positions via your own Read tool from `docs/plans/phase-2-contracts/`:\n - `backend-architect.md`\n - `frontend-architect.md`\n - `data-engineer.md`\n - `security-engineer.md`\n - `accessibility-auditor.md`\n - `performance-benchmarker.md`\n\nThese files are the authoritative team positions AFTER any SendMessage-driven revisions — the architects already cross-checked each other's contract boundaries, so you can stitch without re-debating. Your job is to assemble, not adjudicate. Include specific files to create/modify, build sequence, dependency order. Write `docs/plans/architecture.md` with stable section anchors per `protocols/architecture-schema.md`. Required top-level sections: Overview, Frontend, Backend, Data Model, Security, Infrastructure, MVP Scope, Out of Scope. Scope to MVP boundary from the PRD."
|
|
340
552
|
|
|
341
|
-
|
|
553
|
+
2. Description: "Sprint breakdown" — subagent_type: `planner` — Prompt: "[CONTEXT header above] Break this architecture into ordered, atomic tasks. Each task needs: description, acceptance criteria, **dependencies** (list of task IDs this depends on), size (S/M/L), **Behavioral Test** field for every UI task (concrete interaction: 'Navigate to [page], click [element], verify [outcome]') or curl-based acceptance test for API tasks. Read these files via your Read tool before starting:\n - ARCHITECTURE: `docs/plans/architecture.md`\n - PRD: `docs/plans/design-doc.md`\nScope to MVP only. Save to `docs/plans/sprint-tasks.md`. Dependencies field is load-bearing — Phase 4 uses it to batch independent tasks in parallel."
|
|
342
554
|
|
|
343
|
-
|
|
555
|
+
3. Description: "Task DAG validator" — INTERNAL inline role-string — Prompt: "You are the Task DAG Validator. Read `docs/plans/sprint-tasks.md`. Validate for DAG correctness:
|
|
556
|
+
- No circular dependencies
|
|
557
|
+
- All referenced task IDs in the Dependencies field exist
|
|
558
|
+
- Sizing is consistent (S/M/L)
|
|
559
|
+
- Dependencies match the architecture document (don't depend on a task that builds a component you don't need)
|
|
560
|
+
- Every UI task has a Behavioral Test field; every API task has a curl-based test
|
|
561
|
+
Report any violations. If clean, return PASS. If violations, return a list of fix requests — Sprint Breakdown re-dispatches once with the fix list."
|
|
344
562
|
|
|
345
|
-
|
|
563
|
+
4. Description: "Refs indexer" — INTERNAL inline role-string — Prompt: "You are the Refs Indexer. Generate `docs/plans/refs.json` covering ALL live downstream docs:
|
|
564
|
+
- `docs/plans/design-doc.md` (PRD)
|
|
565
|
+
- `docs/plans/architecture.md`
|
|
566
|
+
- `docs/plans/sprint-tasks.md`
|
|
567
|
+
- `docs/plans/quality-targets.json`
|
|
568
|
+
- `docs/plans/visual-design-spec.md` (if it exists yet — Phase 3 extends refs.json after it writes this file)
|
|
346
569
|
|
|
347
|
-
|
|
570
|
+
For each doc, extract section anchors into a flat index. Schema: `[{\"anchor\": \"design-doc.md#persona\", \"topic\": \"user persona\", \"file_path\": \"docs/plans/design-doc.md\"}, ...]`. This index is consumed by the Phase 4 Briefing Officer for per-task context maps. Do NOT include Phase 1 scratch files — they are SPENT."
|
|
571
|
+
|
|
572
|
+
**Architecture Metric Loop (callable service):** Run the Metric Loop Protocol (`protocols/metric-loop.md`) on `architecture.md`. Define a metric: coverage of PRD requirements, specificity, consistency across the 6 architects, and **simplicity** — is this the simplest architecture that meets the requirements? Could any service, abstraction, or dependency be eliminated? Penalize over-engineering. Max 3 iterations.
|
|
573
|
+
|
|
574
|
+
**Architecture decisions:** The Implementation Blueprint synthesizer returns 4 `deviation_row` objects (or a `phase_2_decisions` array of row objects) in its structured result — one per cross-cutting Phase 2 decision (API contract, persistence layer, auth model, framework choice). The orchestrator forwards each row through the `scribe_decision` MCP tool (see Phase 4 "Orchestrator-scribe dispatch"); the MCP allocates `D-2-<seq>` IDs and atomically appends to `docs/plans/decisions.jsonl`. Author = `architect`. Each row carries a `ref` anchor pointing into `architecture.md` per `protocols/decision-log.md`. Total: 4 rows.
|
|
575
|
+
|
|
576
|
+
**Writes:** `docs/plans/architecture.md`, `docs/plans/sprint-tasks.md`, `docs/plans/quality-targets.json`, `docs/plans/refs.json`. Decision rows (4) flow through the orchestrator's `scribe_decision` MCP calls.
|
|
348
577
|
|
|
349
578
|
### Quality Gate 2
|
|
350
579
|
|
|
351
|
-
**
|
|
580
|
+
**Interactive:** Present Architecture + Sprint Task List (with dependency graph). Ask: "Approve to start designing + building, or flag changes?"
|
|
352
581
|
|
|
353
|
-
|
|
582
|
+
<HARD-GATE>
|
|
583
|
+
Gate 2 rejection path is codified:
|
|
584
|
+
- On NO → loop back to Phase 2 with user feedback.
|
|
585
|
+
- On YES → proceed to Phase 3.
|
|
586
|
+
- DO NOT PROCEED without user approval in interactive mode.
|
|
587
|
+
- Also codifies the LRR BLOCK backward edge: `LRR BLOCK authoring=Phase 2 → back to Phase 2`. The ⭐⭐ star rule routes BLOCK findings via Aggregator decisions.jsonl `decided_by` lookup; if `decided_by == architect`, the build re-opens Phase 2 with the finding as input.
|
|
588
|
+
</HARD-GATE>
|
|
589
|
+
|
|
590
|
+
**Autonomous:** Log to `docs/plans/build-log.md`. Auto-approve. Proceed.
|
|
354
591
|
|
|
355
|
-
Update TodoWrite and
|
|
592
|
+
Update TodoWrite and `.build-state.json`.
|
|
356
593
|
|
|
357
594
|
**iOS feature flag resolution:** if `project_type=ios`, resolve `ios_features` before leaving Phase 2 per `protocols/ios-phase-branches.md` §Phase 2 → Feature Flag Resolution.
|
|
358
595
|
|
|
359
|
-
**Compaction checkpoint.** Update
|
|
596
|
+
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
360
597
|
|
|
361
598
|
---
|
|
362
599
|
|
|
363
|
-
## Phase 3: Design
|
|
600
|
+
## Phase 3: Design (DNA-first SEQUENCE)
|
|
601
|
+
|
|
602
|
+
**Goal**: Lock Visual DNA first, then research against it, then compose from library, then spec, then implement, then critique, then a11y.
|
|
364
603
|
|
|
365
|
-
**
|
|
604
|
+
**NOTE:** Runs AFTER Phase 2. Cannot parallelize — design decisions depend on architecture outcomes.
|
|
366
605
|
|
|
367
606
|
**Skip if** the project has no user-facing frontend (CLI tools, pure APIs, backend services).
|
|
368
607
|
|
|
369
608
|
<HARD-GATE>
|
|
370
|
-
UI/UX IS THE PRODUCT. This phase is a full peer to Architecture and Build — not a footnote, not an afterthought
|
|
609
|
+
UI/UX IS THE PRODUCT. This phase is a full peer to Architecture and Build — not a footnote, not an afterthought. Do NOT skip, compress, or rush this phase for any reason.
|
|
371
610
|
|
|
372
|
-
Phase 4
|
|
611
|
+
Phase 4 WILL NOT START without `docs/plans/visual-design-spec.md` (web) or `docs/plans/ios-design-board.md` (iOS). If the artifact does not exist, return here.
|
|
373
612
|
</HARD-GATE>
|
|
374
613
|
|
|
375
|
-
**Mode-specific branch:**
|
|
376
|
-
-
|
|
377
|
-
-
|
|
614
|
+
**Mode-specific branch files drive Phase 3 in detail:**
|
|
615
|
+
- `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 3 (HIG + App Store + screenlane harvest → iOS Design Board, SwiftUI Preview QA loop).
|
|
616
|
+
- `project_type=web`: follow `protocols/web-phase-branches.md` §Phase 3 — this file contains the NEW structure with steps 3.0-3.7 covering Visual DNA Selection (Brand Guardian as DNA owner at 3.0), Visual Research, Component Library Mapping, UX Architecture, Visual Design Spec, Inclusive Visuals Check, Style Guide Implementation (wrapped in Design Critic metric loop), and A11y Design Review. See `orchestration-proposed-state.md` §11 for the component library strategy.
|
|
617
|
+
|
|
618
|
+
**Phase 3 write discipline:** Phase 3 is the writer for `docs/plans/visual-design-spec.md` (web) and extends `docs/plans/refs.json` to cover the visual spec anchors once it lands. Phase 3 does NOT write to `architecture.md` or `sprint-tasks.md` — those are Phase 2's.
|
|
378
619
|
|
|
379
|
-
|
|
620
|
+
<HARD-GATE>
|
|
621
|
+
LRR BLOCK backward edge: `LRR BLOCK authoring=Phase 3 → back to Phase 3`. The ⭐⭐ star rule routes BLOCK findings via Aggregator decisions.jsonl `decided_by` lookup; if `decided_by == design-brand-guardian` or any Phase 3 writer, the build re-opens Phase 3 with the finding as input.
|
|
622
|
+
</HARD-GATE>
|
|
623
|
+
|
|
624
|
+
**On re-entry from LRR backward routing:** When Phase 3 is re-opened via the re-entry dispatch template (Step 6.3), the orchestrator passes the re-entry payload (`{blocking_finding, prior_output: "docs/plans/visual-design-spec.md" or "docs/plans/visual-dna.md", decision_row}`) into the specific Phase 3 step named by `decision_row.author`. That step revises the prior output to address `blocking_finding` only — DNA lock, component manifest, or visual spec — and emits a new decision_row. Unaffected steps are NOT re-run. Mode-specific branch files (`protocols/web-phase-branches.md` / `protocols/ios-phase-branches.md`) define which step owns which `decided_by` value.
|
|
625
|
+
|
|
626
|
+
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
380
627
|
|
|
381
628
|
---
|
|
382
629
|
|
|
383
|
-
## Phase 4:
|
|
630
|
+
## Phase 4: Build — PARALLEL BATCHES by task dependencies
|
|
384
631
|
|
|
385
632
|
<HARD-GATE>
|
|
386
|
-
Before starting Phase 4: Phase 2 must be approved
|
|
387
|
-
- Web: `docs/plans/visual-design-spec.md` must exist.
|
|
388
|
-
- iOS: `docs/plans/ios-design-board.md` must exist.
|
|
389
|
-
If the artifact does not exist, DO NOT PROCEED. Return to Phase 3.
|
|
390
|
-
Step 4.2 (Design System) MUST implement from the design artifact — not generic architecture tokens.
|
|
633
|
+
Before starting Phase 4: Phase 2 must be approved, Phase 3 must have produced the design artifact for this mode (`visual-design-spec.md` web / `ios-design-board.md` iOS). You MUST call the Agent tool for EVERY task. No exceptions.
|
|
391
634
|
</HARD-GATE>
|
|
392
635
|
|
|
393
|
-
**
|
|
394
|
-
|
|
395
|
-
-
|
|
636
|
+
**Goal**: Scaffold project + execute sprint tasks in dependency-ordered batches. Independent sibling tasks run in parallel (~30-50% wall-clock saving on typical sprint).
|
|
637
|
+
|
|
638
|
+
**Mode-specific branch:**
|
|
639
|
+
- `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 4 (entitlements generator + Info.plist hardening, XcodeBuildMCP folder structure, SwiftUI design tokens, Maestro flow stubs).
|
|
640
|
+
- `project_type=web`: follow `protocols/web-phase-branches.md` §Phase 4 (web project scaffolding, CSS design system tokens, Playwright acceptance test stubs).
|
|
641
|
+
|
|
642
|
+
### Step 4.0 — Scaffold (old Phase 4 Foundation merged here)
|
|
643
|
+
|
|
644
|
+
Scaffolding is project skeleton + design system + acceptance test stubs. Three sequential dispatches (full details in the mode-specific branch file):
|
|
645
|
+
|
|
646
|
+
**CONTEXT header:** Render `rendered_context_header` for phase 4 per the canonical template (see CONTEXT HEADER HARD-GATE above). Includes `dna` field for web projects. Prepend to every Phase 4 scaffold prompt below; branch files do the same for per-task flow.
|
|
396
647
|
|
|
397
|
-
|
|
648
|
+
1. Description: "Project scaffolding" — subagent_type: `engineering-rapid-prototyper` — mode: "bypassPermissions" — prompt per branch file (web: Next.js/Vite/etc; iOS: Xcode project from bootstrap). Prepend CONTEXT header above. [COMPLEXITY: M]
|
|
398
649
|
|
|
399
|
-
|
|
650
|
+
2. Description: "Design system setup" — subagent_type: `engineering-frontend-developer` — mode: "bypassPermissions" — prompt per branch file. Prepend CONTEXT header above. Implements design tokens from `visual-design-spec.md` or `ios-design-board.md`. The living style guide from Phase 3 is the reference implementation — components must match. [COMPLEXITY: M]
|
|
400
651
|
|
|
401
|
-
|
|
652
|
+
3. Description: "Scaffold acceptance tests" — INTERNAL inline role-string — mode: "bypassPermissions" — prompt: "[CONTEXT header above] Scaffold acceptance tests from sprint-tasks.md. Use Page Object Model. Read `docs/plans/sprint-tasks.md`. For every task with a Behavioral Test field, create a Playwright test stub (web) or Maestro flow stub (iOS). Each stub: navigate → interact → assert. Stubs must FAIL right now (features aren't built yet) — that's correct. Commit: 'test: scaffold acceptance tests from sprint tasks'."
|
|
402
653
|
|
|
403
|
-
Run the
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
654
|
+
**Scaffold verification:** Run the Verify Protocol (INTERNAL inline — "Verify scaffolding") — 7 checks sequentially, stop on first FAIL. Do not proceed to Step 4.1 until PASS.
|
|
655
|
+
|
|
656
|
+
### Step 4.1+ — Task execution in dependency-ordered batches
|
|
657
|
+
|
|
658
|
+
Expand TodoWrite with each sprint task.
|
|
408
659
|
|
|
409
|
-
|
|
660
|
+
Build a DAG from `sprint-tasks.md` Dependencies fields. Execute in batches: the next batch is the set of all tasks whose dependencies are all complete. Dispatch each batch as parallel Agent tool calls in ONE message.
|
|
410
661
|
|
|
411
|
-
|
|
662
|
+
**Per-task flow (runs for every task in every batch):**
|
|
412
663
|
|
|
413
|
-
|
|
664
|
+
#### Briefing Officer (INTERNAL inline)
|
|
414
665
|
|
|
415
|
-
|
|
666
|
+
Dispatch before every implementer. Assembles a compact <40-line context map that tells the implementer EXACTLY where to look for each kind of context. Refs not pastes.
|
|
667
|
+
|
|
668
|
+
Call the Agent tool — description: "Briefing for [task name]" — INTERNAL inline role-string — prompt: "You are the Briefing Officer. Read `docs/plans/refs.json` and the task row for [task-id] from `docs/plans/sprint-tasks.md`. Build a compact context map (~40 lines max) in this exact shape:
|
|
669
|
+
|
|
670
|
+
```
|
|
671
|
+
CONTEXT MAP — [task-id] [task name]
|
|
672
|
+
persona / JTBD → design-doc.md#persona
|
|
673
|
+
product scope → design-doc.md#scope
|
|
674
|
+
visual tokens → visual-design-spec.md#tokens
|
|
675
|
+
component variants → component-manifest.md#[category]
|
|
676
|
+
auth model → architecture.md#auth
|
|
677
|
+
data schema → architecture.md#data-model
|
|
678
|
+
sibling task deps → sprint-tasks.md#[dep-id-1], #[dep-id-2]
|
|
679
|
+
prior decisions → decisions.jsonl rows [row-id-1], [row-id-2]
|
|
680
|
+
quality targets → quality-targets.json (full file)
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
CLAUDE.md is NOT in the map — it auto-loads into every subagent. Raw Phase 1 research is NOT in the map — it is SPENT. The implementer reads refs on-demand using the Read tool; no full pastes."
|
|
684
|
+
|
|
685
|
+
The Briefing Officer's output is the handoff payload for the implementer — not for the orchestrator to re-paste.
|
|
686
|
+
|
|
687
|
+
#### Implementer dispatch (subagent_type by task type)
|
|
688
|
+
|
|
689
|
+
Dispatch by task type and complexity:
|
|
690
|
+
- UI tasks: `subagent_type: engineering-frontend-developer` (S/M) or `subagent_type: engineering-senior-developer` (L)
|
|
691
|
+
- Backend tasks: `subagent_type: engineering-backend-architect` (L) or `subagent_type: engineering-senior-developer` (M)
|
|
692
|
+
- Hard / complex / cross-cutting tasks: `subagent_type: engineering-senior-developer`
|
|
693
|
+
|
|
694
|
+
Call the Agent tool — description: "[task-id] [task name]" — subagent_type per above — mode: "bypassPermissions" — prompt: "[CONTEXT header above] [COMPLEXITY: S/M/L from sprint-tasks.md]. TASK: [task description + acceptance criteria from sprint-tasks.md]. Sprint context is prepended; focus on this task.
|
|
695
|
+
|
|
696
|
+
## Prior Learnings
|
|
697
|
+
[paste contents of `docs/plans/.active-learnings.md` if it exists, otherwise omit this section]
|
|
698
|
+
|
|
699
|
+
## Deviation Reporting
|
|
700
|
+
If your implementation deviates from the planned architecture, return a `deviation_row` object per the schema in `protocols/decision-log.md`. If no deviation, return `deviation_row: null`. Do NOT write `decisions.jsonl` directly.
|
|
701
|
+
|
|
702
|
+
Implement fully with real code and tests. Commit: 'feat: [task]'. Report what you built, files changed, and test results.
|
|
703
|
+
|
|
704
|
+
## On Re-entry (from LRR backward routing)
|
|
705
|
+
**[ORCHESTRATOR: Include the "On Re-entry" section below ONLY when this is a re-entry dispatch from LRR backward routing. For normal Phase 4 execution, OMIT it.]**
|
|
706
|
+
|
|
707
|
+
If this dispatch is a re-entry (the orchestrator passes `blocking_finding`, `prior_output`, and `decision_row` in the prompt), DO NOT treat this as a fresh task. Read `prior_output` (the path to your previous task artifact under `.task-outputs/[task-id].json` + changed files) and `decision_row` (the original deviation rationale from decisions.jsonl). Revise ONLY what `blocking_finding` requires — do not redo unaffected code, do not re-run acceptance tests that already passed, do not touch files outside the blast radius of the finding. Return a fresh `deviation_row` in your result payload documenting the revision rationale (author=this task-id, type and summary describing the revision)."
|
|
708
|
+
|
|
709
|
+
#### Per-task security review (auth/PII tasks only)
|
|
710
|
+
|
|
711
|
+
FOR tasks touching auth, PII, secrets, or payment flows — add a per-task security review BEFORE Senior Dev cleanup:
|
|
712
|
+
|
|
713
|
+
Call the Agent tool — description: "Security review for [task-id]" — subagent_type: `security-reviewer` — prompt: "[CONTEXT header above] Review changed files from [task-id] for security issues. Scope: auth logic, input validation, secrets handling, dependency hygiene, OWASP Top 10 for web (or iOS Keychain / ATS / data protection for iOS). Return blocking findings only — 80%+ confidence threshold. Files to review: [list from implementer's changeset]."
|
|
714
|
+
|
|
715
|
+
#### Senior Dev cleanup (simplifier + refactor-cleaner if TS)
|
|
716
|
+
|
|
717
|
+
Two-pass cleanup. Scope is sacred: ONLY files from the implementation changeset. Zero exceptions.
|
|
718
|
+
|
|
719
|
+
1. Call the Agent tool — description: "Simplify [task-id]" — subagent_type: `code-simplifier` — mode: "bypassPermissions" — prompt: "[CONTEXT header above] Simplify changed files from [task-id]. Remove dead code, unused imports, redundant abstractions. Do NOT add features. Do NOT change architecture. Do NOT touch files outside the changeset. If simplification breaks acceptance criteria, revert and skip. Files: [list]."
|
|
720
|
+
|
|
721
|
+
2. If TS/JS task: Call the Agent tool — description: "Refactor [task-id]" — subagent_type: `refactor-cleaner` — mode: "bypassPermissions" — prompt: "[CONTEXT header above] Run knip/depcheck/ts-prune on changed files from [task-id]. Remove orphaned exports, unused deps, dead files. Same scope rules as simplifier — changeset only. Files: [list]."
|
|
722
|
+
|
|
723
|
+
Skip cleanup if trivial (< 20 lines, single file).
|
|
724
|
+
|
|
725
|
+
#### Per-task code review (parallel pair)
|
|
726
|
+
|
|
727
|
+
Call the Agent tool 2 times in one message after Senior Dev cleanup:
|
|
728
|
+
|
|
729
|
+
1. Description: "Code review for [task-id]" — subagent_type: `code-reviewer` — Prompt: "[CONTEXT header above] Review changed files from [task-id]. Report findings with 80%+ confidence threshold only — skip low-confidence nitpicks. Scope: changeset only. Acceptance criteria: [paste from task]. Files: [list]."
|
|
730
|
+
|
|
731
|
+
2. Description: "Silent failure hunt for [task-id]" — subagent_type: `silent-failure-hunter` — Prompt: "[CONTEXT header above] Hunt silent failures in changed files from [task-id]. Targets: empty catch blocks, try/catch returning null, swallowed errors, unhandled promise rejections, assertions disabled in production. Files: [list]. Report blocking findings only."
|
|
732
|
+
|
|
733
|
+
#### Metric Loop (generator/critic) — authoritative behavioral check
|
|
734
|
+
|
|
735
|
+
Run the Metric Loop Protocol (callable service) on the task implementation. Define a metric based on the task's acceptance criteria. For UI-facing tasks, include behavioral verification per the mode-specific branch file (web: agent-browser; iOS: SwiftUI Preview captures). Max 5 iterations.
|
|
736
|
+
|
|
737
|
+
The metric loop's final measurement IS the authoritative behavioral verification for this task — no separate smoke-test dispatch. The critic's final score + pass/fail is what downstream steps consume.
|
|
738
|
+
|
|
739
|
+
Generator: same implementer agent re-invoked. Critic: measurement agent dispatched fresh. Never share context.
|
|
740
|
+
|
|
741
|
+
On target met: mark task complete. On stall: accept if score >= 60% of target (autonomous) or present to user (interactive).
|
|
742
|
+
|
|
743
|
+
#### Verify Service (static checks only)
|
|
744
|
+
|
|
745
|
+
Run the Verify Protocol (INTERNAL inline — "Verify scaffolding") after the metric loop exits. Verify now covers STATIC checks only: type-check, lint, build. Behavioral verification has already happened in the metric loop above — verify consumes the metric loop's final pass/fail + score from `.build-state.json.metric_loop_scores[]` rather than re-running behavioral checks. If any static check FAILS, dispatch a fix agent with the error, re-verify. Max 3 fix attempts.
|
|
746
|
+
|
|
747
|
+
#### After each task completes
|
|
748
|
+
|
|
749
|
+
Update TodoWrite and `.build-state.json`. Write a compact summary to `docs/plans/.task-outputs/[task-id].json` with {files-changed, tests-passing, verify-status}.
|
|
750
|
+
|
|
751
|
+
**Writes:** source code, `docs/plans/.task-outputs/`. Deviation rows flow through the orchestrator's `scribe_decision` MCP calls below — implementers do NOT touch `decisions.jsonl`.
|
|
752
|
+
|
|
753
|
+
<HARD-GATE>
|
|
754
|
+
DECISIONS.JSONL — ORCHESTRATOR-SCRIBE ONLY via `scribe_decision` MCP. Only the orchestrator may cause appends to `docs/plans/decisions.jsonl`, and it does so exclusively by invoking the `scribe_decision` MCP tool. Any dispatch prompt asking a subagent to write this file is a bug. The orchestrator itself MUST NOT Write or Edit the file directly. Subagents return `deviation_row` objects in their structured result; the orchestrator forwards them through the MCP, which owns ID allocation and atomic append.
|
|
755
|
+
</HARD-GATE>
|
|
756
|
+
|
|
757
|
+
#### Orchestrator-scribe dispatch (route deviation rows through `scribe_decision` MCP)
|
|
758
|
+
|
|
759
|
+
Runs after every Phase 4 parallel batch returns (and anywhere else a subagent returns a `deviation_row`, including Phase 1 synthesis and Phase 2 architecture synthesis). The scribe MCP is the single writer for `docs/plans/decisions.jsonl`; the orchestrator is the single caller of the MCP.
|
|
760
|
+
|
|
761
|
+
1. Walk `batch_results`. Collect every non-null `deviation_row` from each subagent return.
|
|
762
|
+
2. For each row, invoke the `scribe_decision` MCP tool with the row's fields (`phase`, `category`/`type`, `summary`, `decided_by`/`author`, `impact_level`, `rationale`, `related_files`) per the MCP's documented schema. One MCP call per row.
|
|
763
|
+
3. The MCP allocates the `decision_id` (`D-{N}-<seq>`), stamps `timestamp` (ISO-8601) and `status: "open"`, validates against `decisions.schema.json`, and atomically appends the line. The orchestrator MUST NOT Write or Edit `docs/plans/decisions.jsonl` directly, MUST NOT pre-compute decision IDs, and MUST NOT read or allocate `.build-state.json.decisions_next_id.P{N}` — ID allocation is the MCP's responsibility.
|
|
764
|
+
4. Regenerate `.build-state.md` after the batch completes so the rendered view reflects the newly appended rows.
|
|
765
|
+
|
|
766
|
+
**On resume:** the scribe MCP reconstructs its ID allocator internally on first invocation by scanning `docs/plans/decisions.jsonl` (for each phase `N`, `max(seq)+1` across rows whose `decision_id` matches `D-{N}-<seq>`). The orchestrator no longer maintains `decisions_next_id` in `.build-state.json`; the field is effectively deprecated under Stage 2 (scribe owns ID allocation end-to-end) and is scheduled for formal removal in Stage 4 schema bump A7 (see Task 4.5.1 in `docs/migration/sdk-hybrid/TASK-BREAKDOWN.md`). TODO(stage-4-A7): drop `decisions_next_id` from the state schema.
|
|
767
|
+
|
|
768
|
+
<HARD-GATE>
|
|
769
|
+
LRR NEEDS_WORK backward edge: `LRR NEEDS_WORK (code-level) → back to Phase 4 target task`. The Aggregator classifies the finding and routes to the specific task via `related_decision_id` lookup; Phase 4 re-opens that task with the finding as input.
|
|
770
|
+
</HARD-GATE>
|
|
771
|
+
|
|
772
|
+
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
416
773
|
|
|
417
774
|
---
|
|
418
775
|
|
|
419
|
-
## Phase 5:
|
|
776
|
+
## Phase 5: Audit — TEAM of 6 + eval harness + 3 parallel + feedback synth
|
|
420
777
|
|
|
421
778
|
<HARD-GATE>
|
|
422
|
-
Before starting
|
|
779
|
+
Before starting Phase 5: run the Verify Protocol (7 checks) one more time. All checks must pass before expensive audit agents fire.
|
|
423
780
|
</HARD-GATE>
|
|
424
781
|
|
|
425
|
-
**
|
|
426
|
-
- If `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 5 (iOS skill bundle, feature-flag-gated skill loading, iOS implement prompt, SwiftUI Preview metric loop, Maestro smoke tests)
|
|
427
|
-
- If `project_type=web`: follow `protocols/web-phase-branches.md` §Phase 5 (web implement prompt, agent-browser metric loop, localhost smoke tests)
|
|
782
|
+
**Goal**: Surface quality issues before Launch Review. Split from old Phase 6 — old 6.1-6.3 (5-agent audit, eval harness, E2E + dogfood + fake-data) live here. Old 6.4-6.5 (Reality Check + LRR) move to Phase 6.
|
|
428
783
|
|
|
429
|
-
|
|
784
|
+
**Mode-specific branch:**
|
|
785
|
+
- `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 5 (iOS twin commands: `/buildanything:verify` → `/buildanything:ux-review` → `/buildanything:fix` in sequence; Maestro smoke tests). Skip the web TEAM below and jump to Step 5.4 Feedback Synthesizer with iOS evidence.
|
|
786
|
+
- `project_type=web`: continue below.
|
|
430
787
|
|
|
431
|
-
|
|
788
|
+
### Step 5.1 — TEAM of 6 parallel auditors (ONE message)
|
|
432
789
|
|
|
433
|
-
|
|
790
|
+
Read the NFRs from `docs/plans/quality-targets.json`. Pass the relevant targets to each audit agent so they have concrete thresholds, not generic checks.
|
|
434
791
|
|
|
435
|
-
|
|
792
|
+
**CONTEXT header:** Render `rendered_context_header` for phase 5 per the canonical template (see CONTEXT HEADER HARD-GATE above). Prepend to every Phase 5 prompt below.
|
|
436
793
|
|
|
437
|
-
|
|
794
|
+
Call the Agent tool 6 times in one message:
|
|
438
795
|
|
|
439
|
-
|
|
440
|
-
[COMPLEXITY: S]
|
|
441
|
-
- Skip if trivial (< 20 lines, single file).
|
|
442
|
-
- Cleanup agent is a SEPARATE agent from the implementer — no cleaning your own mess.
|
|
443
|
-
- Scope is sacred: ONLY files from the implementation changeset. Zero exceptions.
|
|
444
|
-
- Cleanup fixes: naming, dead code, unused imports, style, DRY. Does NOT: add features, change architecture, touch other files.
|
|
445
|
-
- If cleanup breaks acceptance criteria, revert and skip. Never block the metric loop on cleanup failure.
|
|
796
|
+
1. Description: "API testing" — subagent_type: `testing-api-tester` — Prompt: "[CONTEXT header above] Comprehensive API validation: all endpoints, edge cases, error responses, auth flows. NFR targets: Read `docs/plans/quality-targets.json` via your Read tool for performance and reliability thresholds. Report findings with severity counts."
|
|
446
797
|
|
|
447
|
-
|
|
798
|
+
2. Description: "Performance audit" — subagent_type: `testing-performance-benchmarker` — Prompt: "[CONTEXT header above] Measure response times, identify bottlenecks, flag performance issues. NFR targets: Read `docs/plans/quality-targets.json` via your Read tool for performance thresholds. Bundle size per-Scope budgets apply (Marketing 500KB / Product 300KB / Dashboard 400KB / Internal 200KB gzipped). Report benchmarks AGAINST these targets, not generic metrics."
|
|
448
799
|
|
|
449
|
-
|
|
800
|
+
3. Description: "A11y audit" — subagent_type: `a11y-architect` — Prompt: "[CONTEXT header above] WCAG 2.2 AA runtime compliance audit on all interfaces. Check screen reader, keyboard nav, contrast, focus order, touch targets (>=44px), reduced-motion variants. Report issues with severity (Critical/Serious/Moderate/Minor)."
|
|
450
801
|
|
|
451
|
-
|
|
802
|
+
4. Description: "Security audit" — subagent_type: `engineering-security-engineer` — Prompt: "[CONTEXT header above] Security review at app level: auth, input validation, data exposure, dependency vulnerabilities. NFR targets: Read `docs/plans/quality-targets.json` via your Read tool for security thresholds. Report findings with severity."
|
|
452
803
|
|
|
453
|
-
|
|
804
|
+
5. Description: "UX quality audit" — subagent_type: `design-ux-researcher` — Prompt: "[CONTEXT header above] UX quality review of every user-facing page. First, screenshot the living style guide at /design-system (web) as your reference. Then review every product page: loading states (every async action shows a loading indicator), error states (every form and API call shows user-friendly feedback), empty states (lists/tables handle zero items), mobile responsiveness (test at 375px — touch targets >= 44px, no horizontal scroll), form validation (inline feedback, not alert()), transition smoothness, visual consistency vs style guide (buttons, inputs, cards, colors, spacing should match). Report issues with page, severity, and screenshot."
|
|
454
805
|
|
|
455
|
-
|
|
806
|
+
6. Description: "Brand Guardian drift check" — subagent_type: `design-brand-guardian` — Prompt: "[CONTEXT header above] You are the Phase 5 drift check. Read docs/plans/visual-dna.md (the DNA card locked at Phase 3.0) + the actually-built pages via Playwright screenshots under docs/plans/evidence/. Score whether Phase 4 implementers stayed true to the DNA or drifted away from it. Specifically check: does the built Character axis match the DNA? Does Density match? Is Material consistent? Is Motion aligned? Report drift count and specific elements. Save findings to docs/plans/evidence/brand-drift.md. Note: this is a drift check only — the Phase 6 LRR Brand Guardian chapter does the verdict. You do NOT issue a pass/fail here, only surface findings."
|
|
456
807
|
|
|
457
|
-
|
|
458
|
-
- **Interactive:** present score history + top remaining issue to user.
|
|
459
|
-
- **Autonomous:** accept if score >= 60% of target, skip otherwise. Log to `docs/plans/build-log.md`.
|
|
808
|
+
### Step 5.2 — Sequence: Eval Harness → Metric Loop
|
|
460
809
|
|
|
461
|
-
|
|
810
|
+
Run the Eval Harness Protocol (`protocols/eval-harness.md`). Define 8-15 concrete, executable eval cases from the audit findings and architecture doc. Run the eval agent. Record baseline pass rate. CRITICAL and HIGH failures feed into the Metric Loop as specific issues to fix.
|
|
462
811
|
|
|
463
|
-
|
|
812
|
+
Run the Metric Loop Protocol (callable service) on the full codebase using audit findings as initial input. Define a composite metric based on what this project needs. Max 4 iterations. When fixing, dispatch to the RIGHT specialist — security → `security-reviewer`, a11y → `engineering-frontend-developer`, perf → `testing-performance-benchmarker`. Don't send everything to one agent.
|
|
464
813
|
|
|
465
|
-
|
|
814
|
+
Re-run the Eval Harness after the metric loop exits. All CRITICAL eval cases must now pass. If any CRITICAL case still fails, include it as evidence for Phase 6.
|
|
466
815
|
|
|
467
|
-
|
|
816
|
+
### Step 5.3 — TEAM of 3 parallel (ONE message)
|
|
468
817
|
|
|
469
|
-
|
|
818
|
+
Call the Agent tool 3 times in one message:
|
|
470
819
|
|
|
471
|
-
|
|
820
|
+
1. Description: "E2E runner" — INTERNAL inline role-string — mode: "bypassPermissions" — Prompt: "Run Playwright E2E test generation, execution, and stability check per `protocols/web-phase-branches.md` Phase 5 E2E steps (generate and run E2E tests for User Journeys, 3 mandatory iterations for flakiness detection). Report results + artifact paths. Records results to `docs/plans/evidence/e2e/iter-3-results.json`."
|
|
472
821
|
|
|
473
|
-
|
|
822
|
+
2. Description: "Dogfood the app" — INTERNAL inline role-string + agent-browser skill — mode: "bypassPermissions" — Prompt: "You are the Dogfood runner. Run the agent-browser dogfood skill against the running app at http://localhost:[port]. Explore every reachable page. Click every button. Fill every form. Check console for errors. Report a structured list of issues with severity ratings, screenshots, repro steps. Write findings to `docs/plans/evidence/dogfood/findings.md`. Do NOT classify or route findings — that's the Feedback Synthesizer's job at Step 5.4."
|
|
474
823
|
|
|
475
|
-
Run the
|
|
824
|
+
3. Description: "Fake-data detector" — INTERNAL inline role-string — mode: "bypassPermissions" — Prompt: "Run the Fake Data Detector Protocol (`protocols/fake-data-detector.md`). Static analysis: grep for Math.random() in business data paths, hardcoded API responses, setTimeout faking async, placeholder text. Dynamic analysis: inspect HAR files from `docs/plans/evidence/` for missing real API calls, static responses, absent WebSocket traffic. Write findings to `docs/plans/evidence/fake-data-audit.md` with file:line refs and severity."
|
|
476
825
|
|
|
477
|
-
|
|
826
|
+
### Step 5.4 — Feedback Synthesizer
|
|
478
827
|
|
|
479
|
-
|
|
828
|
+
The Dogfood findings used to dead-end. Now route them to fix loops.
|
|
829
|
+
|
|
830
|
+
Call the Agent tool — description: "Synthesize dogfood findings" — subagent_type: `product-feedback-synthesizer` — Prompt: "[CONTEXT header above] Interpret Dogfood output. Input: `docs/plans/evidence/dogfood/findings.md`. For each finding, classify it and assign a target phase for the fix:
|
|
831
|
+
- Code-level bug (broken feature, failing logic, fake data) → `target_phase: 4`, assign to the specific task that owns the affected file
|
|
832
|
+
- Visual/design issue (styling drift, missing state, a11y gap) → `target_phase: 3`, assign to the Phase 3 step that owns the relevant artifact
|
|
833
|
+
- Structural/architecture issue (missing feature, wrong data flow, API mismatch) → `target_phase: 2`, assign to the architecture section
|
|
480
834
|
|
|
481
|
-
|
|
835
|
+
Output: `docs/plans/evidence/dogfood/classified-findings.json` with shape `[{finding_id, severity, target_phase, target_task_or_step, description, evidence_ref}, ...]`. This file is read by the Phase 5 fix loop and by the Phase 6 LRR Aggregator for backward routing."
|
|
482
836
|
|
|
483
|
-
|
|
837
|
+
**Phase 5 fix loop:** For each CRITICAL/HIGH classified finding, dispatch the appropriate fix agent based on `target_phase`. Max 2 fix cycles.
|
|
484
838
|
|
|
485
|
-
|
|
839
|
+
**Writes:** `docs/plans/evidence/*.json`, `docs/plans/evidence/fake-data-audit.md`, `docs/plans/evidence/dogfood/classified-findings.json`, `docs/plans/learnings.jsonl` (reality sweep writes PITFALL/PATTERN rows — see `protocols/decision-log.md` for the Dissent Log Revisit Pass path).
|
|
486
840
|
|
|
487
|
-
**
|
|
488
|
-
- If `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 6 — dispatch iOS twin commands (`/buildanything:verify` → `/buildanything:ux-review` → `/buildanything:fix`) in sequence. Skip Steps 6.1, 6.1b, 6.2, 6.2b, 6.2c, 6.2d, 6.2e. Then run Step 6.4 Reality Check below with iOS evidence.
|
|
489
|
-
- If `project_type=web`: follow `protocols/web-phase-branches.md` §Phase 6 — run Steps 6.1 (5-agent audit), 6.1b (eval harness), 6.2 (metric loop), 6.2b (eval re-run), 6.2c (Playwright E2E, 3 mandatory iterations), 6.2d (agent-browser dogfood), 6.2e (fake data detector). Then run Step 6.4 Reality Check below.
|
|
841
|
+
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
490
842
|
|
|
491
|
-
|
|
843
|
+
---
|
|
492
844
|
|
|
493
|
-
|
|
845
|
+
## Phase 6: Launch Readiness Review
|
|
494
846
|
|
|
495
|
-
|
|
847
|
+
**Goal**: 5 independent chapter judges + mechanical aggregator with file-completeness checkpoint + author-aware backward routing on BLOCK.
|
|
496
848
|
|
|
497
|
-
|
|
849
|
+
Split from old Phase 6. Old 6.4 (Reality Check) and 6.5 (LRR) merged and restructured. Reality Checker keeps its evidence sweep role only — the combined verdict authority moved to the LRR Aggregator.
|
|
498
850
|
|
|
499
|
-
|
|
851
|
+
### Step 6.0 — Reality Check (evidence sweep + dissent log revisit pass)
|
|
500
852
|
|
|
501
|
-
|
|
502
|
-
- **Code bug** (broken feature, failing test, fake data) → spawn implementation fix agent with the finding + affected files.
|
|
503
|
-
- **Structural issue** (missing feature, wrong architecture, data flow problem) → spawn architect agent to produce a fix plan, then implementation agent to execute it. This is a mini Phase 5 loop for the specific issue.
|
|
504
|
-
- **Blocker** (missing API key, no backend, needs human action) → log to `docs/plans/build-log.md` and present to user. Cannot be auto-fixed.
|
|
505
|
-
2. After fixes, re-run verification (7 checks) + the specific failing gate (E2E, dogfood, or fake data — whichever surfaced the issue).
|
|
506
|
-
3. Re-run the Reality Checker with updated evidence.
|
|
853
|
+
Reality Checker runs its existing evidence sweep per `commands/build.md` precondition list. Writes the manifest to `docs/plans/evidence/reality-check-manifest.json`. Does NOT issue a combined verdict.
|
|
507
854
|
|
|
508
855
|
<HARD-GATE>
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
856
|
+
PRECONDITION (orchestrator-side, BEFORE dispatching Reality Checker):
|
|
857
|
+
|
|
858
|
+
REQUIRED EVIDENCE FOR ALL PROJECTS:
|
|
859
|
+
- `docs/plans/.build-state.json` exists, contains current build session id, contains a recent `VERIFY: PASS` line from this session.
|
|
860
|
+
|
|
861
|
+
REQUIRED EVIDENCE FOR `project_type=web`:
|
|
862
|
+
- `docs/plans/evidence/eval-harness/baseline.json` (non-empty)
|
|
863
|
+
- `docs/plans/evidence/eval-harness/final.json` (non-empty)
|
|
864
|
+
- `docs/plans/evidence/e2e/iter-3-results.json` (non-empty)
|
|
865
|
+
- `docs/plans/evidence/dogfood/findings.md` (non-empty)
|
|
866
|
+
- `docs/plans/evidence/dogfood/classified-findings.json` (non-empty)
|
|
867
|
+
- `docs/plans/evidence/fake-data-audit.md` (non-empty)
|
|
868
|
+
- `docs/plans/evidence/manifest.json`
|
|
869
|
+
|
|
870
|
+
REQUIRED EVIDENCE FOR `project_type=ios`:
|
|
871
|
+
- `docs/plans/ios-verify-report.md` (non-empty)
|
|
872
|
+
- `docs/plans/ios-ux-review-report.md` (non-empty)
|
|
873
|
+
- At least one `*.yaml` file in `maestro/`
|
|
874
|
+
- At least one `*.png` screenshot in `docs/plans/evidence/maestro-runs/` from this build session
|
|
875
|
+
- `docs/plans/evidence/manifest.json`
|
|
876
|
+
|
|
877
|
+
If any required file does not exist or is empty, do NOT dispatch Reality Checker. Log "REALITY CHECK BLOCKED" with missing-file list. Interactive: present blocker to user. Autonomous: return to the failing step and re-dispatch once; if still missing, abort.
|
|
513
878
|
</HARD-GATE>
|
|
514
879
|
|
|
515
|
-
**
|
|
880
|
+
**CONTEXT header:** Render `rendered_context_header` for phase 6 per the canonical template (see CONTEXT HEADER HARD-GATE above). Prepend to every Phase 6 prompt below (Reality Checker + the 5 LRR chapters).
|
|
516
881
|
|
|
517
|
-
|
|
882
|
+
Call the Agent tool — description: "Evidence sweep" — subagent_type: `testing-reality-checker` — Prompt: "[CONTEXT header above] You are the Reality Checker — evidence-sweep role only. Default verdict: NONE. You receive evidence by FILE PATH only — never by paste. Use Read and Glob tools to verify each file exists, is non-empty, was modified within this build session, contains no placeholder strings ('TODO', 'PLACEHOLDER', 'TBD', 'FIXME', 'XXX').
|
|
518
883
|
|
|
519
|
-
|
|
884
|
+
Evidence paths to verify: [orchestrator pastes the precondition list per project_type].
|
|
885
|
+
|
|
886
|
+
For every Behavioral Test field in `docs/plans/sprint-tasks.md`, verify a corresponding evidence file exists in `docs/plans/evidence/[task-slug]/` AND that the test-stub-detector (per `protocols/verify.md` Step 2) does not flag the corresponding test file as a stub.
|
|
887
|
+
|
|
888
|
+
For every architecture MUST in `docs/plans/architecture.md`, verify the implementation file exists via Glob AND contains the named symbol via Grep.
|
|
889
|
+
|
|
890
|
+
**Dissent Log Revisit Pass:** Read `docs/plans/decisions.jsonl`. For every row where `status == \"open\"` and `revisit_criterion` is non-empty, semantically evaluate the criterion against current evidence. If triggered:
|
|
891
|
+
1. Emit a structural finding in the manifest: `revisit-criterion-triggered: D-N-M — [criterion]`
|
|
892
|
+
2. Append a PITFALL row to `docs/plans/learnings.jsonl` with `{pattern_type: \"PITFALL\", top_issue: \"[decision] — [criterion]\", fix_applied: \"[what build did instead]\", provenance: {decision_id: \"D-N-M\"}}`
|
|
893
|
+
3. Flag the triggered decision — this feeds LRR as a potential cross-chapter concern
|
|
520
894
|
|
|
521
|
-
|
|
522
|
-
- If `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 7 — ship pipeline is optional (simulator-only is a valid end-state). If shipping, run asc-* agents + fastlane. Skip web Step 7.1 below.
|
|
523
|
-
- If `project_type=web`: follow `protocols/web-phase-branches.md` §Phase 7 (Step 7.1 documentation + deploy notes).
|
|
895
|
+
Write the evidence manifest to `docs/plans/evidence/reality-check-manifest.json` with fields `{file_path, sha256, byte_count, modified_time, verdict_contribution}` per file. Emit any structural findings surfaced during the sweep. DO NOT issue a combined verdict — that authority moved to the LRR Aggregator at Step 6.1 below."
|
|
524
896
|
|
|
525
|
-
### Step
|
|
897
|
+
### Step 6.1 — LRR: 5 chapter judges in parallel (ONE message)
|
|
526
898
|
|
|
527
|
-
|
|
899
|
+
Follow the Launch Readiness Review Protocol (`protocols/launch-readiness.md`). The net-5 panel: Eng-Quality (merged Eng+QA with PM chapter folded in), Security, SRE (includes Performance), A11y (NEW SEAT), Brand Guardian (REPLACES old Design mechanical check).
|
|
528
900
|
|
|
529
|
-
|
|
901
|
+
Dispatch 5 chapter judges in parallel. Each receives fresh context, its own evidence slice, and the chapter verdict schema from `protocols/launch-readiness.md`.
|
|
530
902
|
|
|
531
|
-
Call the Agent tool
|
|
903
|
+
Call the Agent tool 5 times in ONE message. Note: the Eng-Quality chapter dispatches `code-reviewer` as primary, with a parallel `pr-test-analyzer` sub-dispatch for test-coverage adequacy evidence that feeds into the Eng-Quality verdict file.
|
|
532
904
|
|
|
533
|
-
|
|
534
|
-
|-------------|------|------|----------|--------|
|
|
905
|
+
1. Description: "LRR Eng-Quality chapter" — subagent_type: `code-reviewer` — Prompt: "[CONTEXT header above] You are the Eng-Quality chapter of the Launch Readiness Review. Your natural tendency is to be encouraging. Fight it. Default verdict: NEEDS WORK.
|
|
535
906
|
|
|
536
|
-
|
|
907
|
+
Read: `docs/plans/architecture.md`, `docs/plans/design-doc.md` (PRD — needed for requirements coverage evaluation), `docs/plans/sprint-tasks.md`, `docs/plans/.task-outputs/`, `protocols/verify.md` check outputs from `.build-state.json`, test results from Phase 4 and 5, eval-harness results from `docs/plans/evidence/eval-harness/`. Also read `docs/plans/decisions.jsonl` for cross-chapter context.
|
|
537
908
|
|
|
538
|
-
|
|
909
|
+
Requirements coverage is folded into this chapter — not a separate dispatch. For EVERY feature listed in the MVP scope of `design-doc.md`, evaluate: (1) does it have a corresponding implemented task in sprint-tasks.md, (2) does it have a passing test or behavioral verification in evidence, (3) is it reachable and functional per the task-outputs. Emit a `requirements_coverage` field in your verdict JSON with shape `[{feature: \"<name>\", status: \"COVERED\" | \"PARTIAL\" | \"MISSING\"}, ...]`. Any MISSING feature is a BLOCK finding. Any PARTIAL feature is a CONCERNS finding at minimum.
|
|
539
910
|
|
|
540
|
-
|
|
911
|
+
Before writing the final verdict, spawn a parallel subagent dispatch: description: 'LRR test coverage adequacy' — subagent_type: `pr-test-analyzer` — prompt: 'You are a test-coverage auditor for the Eng-Quality LRR chapter. Read the test files under tests/, task-outputs/, and behavioral-test stub detector output. Evaluate: (1) do declared behavioral tests have non-stub bodies, (2) does coverage match the PR diff scope, (3) are edge cases covered, (4) are any tests flaky markers set. Return a JSON summary with test_coverage_score (0-100), stub_flagged_count, edge_case_gap_count, recommendations[]. Save to docs/plans/evidence/lrr/eng-quality-coverage.json.' Read the resulting eng-quality-coverage.json and fold its findings into your verdict.
|
|
541
912
|
|
|
542
|
-
|
|
913
|
+
Evaluate code quality + test coverage adequacy + architecture conformance + requirements coverage TOGETHER (single coherent view — merged from old Eng + QA chapters). Check: do declared behavioral tests actually exercise the features? Are there stub-flagged tests? Do tests match task acceptance criteria? Does the built code match architecture MUSTs? Are MVP features all COVERED?
|
|
543
914
|
|
|
544
|
-
|
|
915
|
+
Write verdict to `docs/plans/evidence/lrr/eng-quality.json` per `protocols/launch-readiness.md` schema. Fields: `chapter=eng-quality`, `verdict` (PASS|CONCERNS|BLOCK), `override_blocks_launch` (false unless BLOCK), `evidence_files_read` (non-empty, MUST include eng-quality-coverage.json), `findings[]` (each with `severity`, `description`, `evidence_ref`, `related_decision_id` if blocker ties to a decisions.jsonl row), `requirements_coverage[]` (one entry per MVP feature with `{feature, status}`), `follow_up_spawned=false`, `follow_up_findings=null`. Eng-Quality CANNOT spawn follow-ups."
|
|
545
916
|
|
|
546
|
-
|
|
917
|
+
2. Description: "LRR Security chapter" — subagent_type: `security-reviewer` — Prompt: "[CONTEXT header above] You are the Security chapter of the LRR. Read: `docs/plans/evidence/fake-data-audit.md`, Phase 5 security audit output (from Step 5.1), eval-harness security cases. Also read `docs/plans/decisions.jsonl` for context.
|
|
547
918
|
|
|
548
|
-
|
|
919
|
+
Evaluate auth model, input validation, secrets management, dependency vulnerabilities. Write verdict to `docs/plans/evidence/lrr/security.json` per schema. Fields: `chapter=security`, `verdict`, `override_blocks_launch`, `evidence_files_read` (non-empty), `findings[]` (with `related_decision_id` when applicable), `follow_up_spawned` (boolean), `follow_up_findings` (null or typed object).
|
|
549
920
|
|
|
550
|
-
|
|
921
|
+
Security MAY spawn ONE read-only follow-up investigation, but ONLY if verdict would be BLOCK — NOT on suspicion. This is tightened from current behavior. Follow-up: read-only, Read/Grep/Glob only, max 15 tool calls, self-report tool_calls_used. See `protocols/launch-readiness.md` for follow-up flow."
|
|
551
922
|
|
|
552
|
-
-
|
|
553
|
-
- **PITFALL:** [what failed, caused waste, or required excessive iterations]
|
|
554
|
-
- **HEURISTIC:** [project-specific tuning discovered during this build]
|
|
923
|
+
3. Description: "LRR SRE chapter" — subagent_type: `engineering-sre` — Prompt: "[CONTEXT header above] You are the SRE chapter of the LRR. Read: performance-audit outputs from Phase 5 (Step 5.1 performance auditor + Step 5.2 eval-harness perf cases), Performance Benchmarker evidence, NFRs from `docs/plans/quality-targets.json` and `docs/plans/sprint-tasks.md`, reliability checks. Also read `docs/plans/decisions.jsonl` for context.
|
|
555
924
|
|
|
556
|
-
|
|
925
|
+
Evaluate whether the build meets NFR targets (response time, load handling, error rates) and is production-ready under load. Bundle-size budget violations (>25% over Scope budget) auto-block. Write verdict to `docs/plans/evidence/lrr/sre.json` per schema.
|
|
557
926
|
|
|
558
|
-
|
|
927
|
+
SRE MAY spawn ONE read-only follow-up investigation, but ONLY if verdict would be BLOCK. Same caps as Security."
|
|
559
928
|
|
|
560
|
-
|
|
929
|
+
4. Description: "LRR A11y chapter" — subagent_type: `a11y-architect` — Prompt: "[CONTEXT header above] You are the A11y chapter of the LRR (NEW SEAT in this panel — closes the biggest coverage gap). Read: Phase 5 a11y audit output (from Step 5.1), WCAG 2.2 AA runtime check, per-page accessibility findings, `docs/plans/quality-targets.json` a11y section.
|
|
930
|
+
|
|
931
|
+
Scoring rules:
|
|
932
|
+
- PASS if zero Serious + zero Critical findings
|
|
933
|
+
- CONCERNS if 1-3 Serious + 0 Critical
|
|
934
|
+
- BLOCK if any Critical OR >3 Serious
|
|
935
|
+
|
|
936
|
+
Write verdict to `docs/plans/evidence/lrr/a11y.json` per schema. A11y CANNOT spawn follow-ups."
|
|
937
|
+
|
|
938
|
+
5. Description: "LRR Brand Guardian chapter" — subagent_type: `design-brand-guardian` — Prompt: "[CONTEXT header above] You are the Brand Guardian chapter of the LRR (REPLACES the old Design mechanical check — real taste judgment, not a 15-line mechanical gate). Your natural tendency is to be encouraging. Fight it. Default verdict: NEEDS WORK.
|
|
939
|
+
|
|
940
|
+
Read: `docs/plans/visual-design-spec.md`, `docs/plans/visual-dna.md` (the 6-axis DNA card locked at Phase 3.0), `docs/plans/design-references.md`, Playwright screenshots under `docs/plans/evidence/` matching production pages, Phase 3.6 Design Critic final score from `.build-state.json`.
|
|
941
|
+
|
|
942
|
+
Evaluate DRIFT: did the built product stay true to the DNA card locked at Phase 3.0? Score the gap on 6 DNA axes (Scope, Density, Character, Material, Motion, Type) + 5 craft dimensions (whitespace rhythm, visual hierarchy, motion coherence, color harmony, typographic refinement). Cite specific elements ('the hero padding at landing.tsx:42 is 32px but DNA calls for Airy density — should be 48px+') — never vague ('needs polish').
|
|
943
|
+
|
|
944
|
+
Write verdict to `docs/plans/evidence/lrr/brand-guardian.json` per schema. Fields per protocol. Brand Guardian CANNOT spawn follow-ups."
|
|
945
|
+
|
|
946
|
+
**Security/SRE BLOCK-only follow-up dispatch — SDK-gated (Stage 5 / task 5.3.1).** The read-only follow-up investigations spawned by the Security and SRE chapters (BLOCK-only trigger per `protocols/launch-readiness.md`) are dispatched via a TS switch: when the SDK flag is active (default), the orchestrator dispatches the follow-up through `claude-agent-sdk` with `maxTurns: 15` — a hard safety rail that prevents runaway remediation loops. When the SDK is disabled (`BUILDANYTHING_SDK=off`), fall back to the standard Agent tool dispatch with the same 15 tool-call cap self-reported via `tool_calls_used` (the markdown-mode cap documented in `protocols/launch-readiness.md`). If a follow-up exceeds 15 turns under SDK mode, the orchestrator flags to the user (interactive) or logs a warning and treats the parent chapter as BLOCK confirmed (autonomous) — do NOT let the subagent churn indefinitely.
|
|
947
|
+
|
|
948
|
+
### Step 6.1a — PM coverage fold-in
|
|
949
|
+
|
|
950
|
+
PM coverage is a sub-input of the Eng-Quality chapter — evaluated inline within the Eng-Quality dispatch at Step 6.1 above against `design-doc.md` MVP scope and emitted as a `requirements_coverage[]` field on `eng-quality.json`. The LRR Aggregator runs exactly once. Chapter count stays 5.
|
|
951
|
+
|
|
952
|
+
### Step 6.2 — LRR Aggregator (sequential, after all 5 chapter files exist)
|
|
953
|
+
|
|
954
|
+
Call the Agent tool — description: "LRR Aggregator" — INTERNAL inline role-string — Prompt: "You are the LRR Aggregator. You mechanically apply the 6 aggregation rules from `protocols/launch-readiness.md`. You may NOT self-approve — you cite the triggering rule number on every verdict.
|
|
955
|
+
|
|
956
|
+
**STEP 1 — FILE-COMPLETENESS CHECKPOINT:** Before applying any aggregation rule, use Glob to list `docs/plans/evidence/lrr/*.json` and verify ALL 5 expected chapter files exist and parse as valid JSON:
|
|
957
|
+
- `eng-quality.json`
|
|
958
|
+
- `security.json`
|
|
959
|
+
- `sre.json`
|
|
960
|
+
- `a11y.json`
|
|
961
|
+
- `brand-guardian.json`
|
|
962
|
+
|
|
963
|
+
If any are missing or malformed, log 'LRR INCOMPLETE' with the missing file list, write a partial status to `docs/plans/evidence/lrr-incomplete.json`, and STOP — do not emit a combined verdict. This is the file-completeness checkpoint that closes the partial-glob race the current Aggregator is vulnerable to.
|
|
964
|
+
|
|
965
|
+
**STEP 2 — APPLY 6 RULES per `protocols/launch-readiness.md`:**
|
|
966
|
+
1. ANY `override_blocks_launch: true` → combined_verdict = BLOCKED
|
|
967
|
+
2. ALL verdicts PASS AND zero follow-ups spawned → combined_verdict = PRODUCTION READY
|
|
968
|
+
3. ANY verdict BLOCK (with override_blocks_launch: false) → combined_verdict = NEEDS WORK + findings routed to fix loop
|
|
969
|
+
4. ANY verdict CONCERNS → combined_verdict = NEEDS WORK, concerns logged
|
|
970
|
+
5. Follow-up spawned AND follow_up.confirmed: true → treat parent chapter verdict as if BLOCK
|
|
971
|
+
6. Contradictions between chapters on typed fields → combined_verdict = BLOCKED with cross-chapter contradiction finding
|
|
972
|
+
|
|
973
|
+
**STEP 3 — ON BLOCK VERDICT (the ⭐⭐ star rule — backward routing):** For each BLOCK finding in any chapter, read the `related_decision_id` field. Look up that row in `docs/plans/decisions.jsonl`. Find the `decided_by` field (author of the decision — per the `decided_by` free-form role-string convention in `protocols/decision-log.md`. The Aggregator matches on the string value directly. Common values: `architect` (Phase 2 architecture decisions), `design-brand-guardian` (Phase 3 Visual DNA lock), `implementer` (Phase 4 deviation rows), `human` (Gate 1/2 user decisions)). Route BACKWARD to the authoring phase with the finding as input. This replaces the current 'stop and wait' BLOCK behavior with author-aware re-entry.
|
|
974
|
+
|
|
975
|
+
**BLOCK sequentialization (Stage 4 A6 / task 4.4.3).** When multiple chapters return BLOCK in the same LRR round, the aggregator MUST process the BLOCK findings one-at-a-time in chapter declaration order (Eng-Quality → Security → SRE → A11y → Brand Guardian). DO NOT dispatch backward-routing re-entries or Security/SRE follow-up investigations in parallel — sequentialize to preserve deterministic commit ordering, avoid writer-owner lease contention on shared artifacts (`decisions.jsonl`, `lrr-routing.json`), and make the per-target-phase cycle-counter increments monotonic. Parallel BLOCK dispatch is a hard error.
|
|
976
|
+
|
|
977
|
+
Write routing decisions to `docs/plans/evidence/lrr-routing.json` with shape `[{finding_id, chapter, related_decision_id, authoring_phase, action: \"re-open\"}, ...]`.
|
|
978
|
+
|
|
979
|
+
**STEP 4 — ON NEEDS_WORK:** Classify findings & route to Phase 4 (code-level — single-task fix) or Phase 2 (structural — re-architect) or Phase 3 (visual — re-design). Same routing file.
|
|
980
|
+
|
|
981
|
+
**STEP 5 — ON READY:** Write `docs/plans/evidence/lrr-aggregate.json` with shape:
|
|
982
|
+
|
|
983
|
+
```json
|
|
984
|
+
{
|
|
985
|
+
\"combined_verdict\": \"PRODUCTION READY | NEEDS WORK | BLOCKED\",
|
|
986
|
+
\"chapter_verdicts\": {\"eng-quality\": \"PASS|CONCERNS|BLOCK\", \"security\": \"...\", \"sre\": \"...\", \"a11y\": \"...\", \"brand-guardian\": \"...\"},
|
|
987
|
+
\"triggered_rule\": <1-6>,
|
|
988
|
+
\"findings\": [...aggregated from all chapters...],
|
|
989
|
+
\"follow_ups_spawned\": [list of chapters that spawned follow-ups],
|
|
990
|
+
\"backward_routing\": [...from lrr-routing.json if any...],
|
|
991
|
+
\"timestamp\": \"ISO-8601\"
|
|
992
|
+
}
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
Forward to Phase 7.
|
|
996
|
+
|
|
997
|
+
Cite triggering rule number in output. No verdict is valid without citing the rule."
|
|
998
|
+
|
|
999
|
+
### Step 6.3 — Verdict resolution
|
|
1000
|
+
|
|
1001
|
+
The LRR Aggregator's `combined_verdict` is the authoritative verdict. Resolution rules:
|
|
1002
|
+
|
|
1003
|
+
- **PRODUCTION READY** → log aggregate path to `.build-state.json` and `build-log.md`. Proceed to Phase 7.
|
|
1004
|
+
- **NEEDS WORK** → apply backward routing from `lrr-routing.json` per the re-entry template below. Max 2 NEEDS_WORK cycles before presenting to user (interactive) or proceeding with warning (autonomous).
|
|
1005
|
+
- **BLOCKED** → apply backward routing (⭐⭐ star rule) per the re-entry template below. NEVER proceed to Phase 7 with BLOCKED.
|
|
1006
|
+
|
|
1007
|
+
**Re-entry dispatch template (used by backward routing from LRR BLOCK / NEEDS_WORK, and by the Phase 5 → Phase 4 fix loop):**
|
|
1008
|
+
|
|
1009
|
+
```
|
|
1010
|
+
On re-entry from LRR BLOCK:
|
|
1011
|
+
INPUT passed to the re-opened phase:
|
|
1012
|
+
blocking_finding: {chapter, finding_id, severity, description, related_decision_id, related_files}
|
|
1013
|
+
prior_output: path to the phase's previous artifact
|
|
1014
|
+
decision_row: the row from decisions.jsonl containing original reasoning + authorship
|
|
1015
|
+
TASK for the re-opened phase:
|
|
1016
|
+
Revise prior_output to address blocking_finding. Do NOT redo unaffected work. Emit a new decision_row documenting the revision rationale.
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
The orchestrator assembles this payload from `lrr-routing.json` + `decisions.jsonl` + the prior artifact path, then invokes the target phase's "on re-entry" branch (see Phase 2 Step 2.2, Phase 3, and Phase 4 implementer dispatches).
|
|
1020
|
+
|
|
1021
|
+
<HARD-GATE>
|
|
1022
|
+
The LRR Aggregator is the ONLY agent that may emit `combined_verdict`. No other agent — not the orchestrator, not Reality Checker, not individual chapters — may self-issue a combined verdict. This is the non-negotiable independence guarantee.
|
|
1023
|
+
|
|
1024
|
+
Max 2 NEEDS_WORK cycles. If LRR returns NEEDS_WORK a third time:
|
|
1025
|
+
- Interactive: present all remaining issues. Ask for direction.
|
|
1026
|
+
- Autonomous: log remaining issues. Proceed to Phase 7 with a warning in the Completion Report.
|
|
1027
|
+
Do not loop forever.
|
|
1028
|
+
</HARD-GATE>
|
|
1029
|
+
|
|
1030
|
+
**Writes:** `docs/plans/evidence/lrr/*.json`, `docs/plans/evidence/lrr-aggregate.json`, `docs/plans/evidence/lrr-routing.json`.
|
|
1031
|
+
|
|
1032
|
+
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|
|
1033
|
+
|
|
1034
|
+
---
|
|
1035
|
+
|
|
1036
|
+
## Phase 7: Ship
|
|
1037
|
+
|
|
1038
|
+
**Pre-ship Verify gate:** Run the Verify Protocol (INTERNAL inline — "Verify scaffolding") before any Step 7.1 dispatch. All 7 checks (Build → Type-Check → Lint → Test → Security → Diff Review → Artifacts) must pass. If any check FAILS, dispatch a fix agent with the error, re-verify. Max 2 fix attempts. Do not proceed to Step 7.1 until PASS.
|
|
1039
|
+
|
|
1040
|
+
**Mode-specific branch:**
|
|
1041
|
+
- `project_type=ios`: follow `protocols/ios-phase-branches.md` §Phase 7 — ship pipeline is optional (simulator-only is a valid end-state). If shipping, run asc-* agents + fastlane.
|
|
1042
|
+
- `project_type=web`: follow `protocols/web-phase-branches.md` §Phase 7 (Step 7.1 documentation + deploy notes).
|
|
1043
|
+
|
|
1044
|
+
### Step 7.1 — Sequence: Documentation → Doc Metric Loop → ASO (iOS) → Deploy → Completion Report
|
|
1045
|
+
|
|
1046
|
+
**CONTEXT header:** Render `rendered_context_header` for phase 7 per the canonical template (see CONTEXT HEADER HARD-GATE above). Prepend to every Phase 7 prompt below.
|
|
1047
|
+
|
|
1048
|
+
1. Description: "Technical Writer" — subagent_type: `engineering-technical-writer` — mode: "bypassPermissions" — Prompt: "[CONTEXT header above] Write project docs: README with setup/architecture/usage, API docs if applicable, deployment notes. The README is the first thing a new developer reads — optimize for that reader. Commit: 'docs: project documentation'. Deployment target per the PRD (Vercel/Netlify/Railway/Fly.io/etc.) — include the deploy flow specific to that target in the README."
|
|
1049
|
+
|
|
1050
|
+
2. Documentation Metric Loop: Run the Metric Loop Protocol (callable service) on documentation. Define a metric based on completeness and whether a new developer could follow the README end-to-end. Max 3 iterations.
|
|
1051
|
+
|
|
1052
|
+
3. Description: "App Store Optimizer" (iOS only, conditional on ship) — subagent_type: `marketing-app-store-optimizer` — Prompt per `protocols/ios-phase-branches.md` §Phase 7 (asc-* flow — app name, subtitle, keywords, description, screenshots, privacy labels). Prepend CONTEXT header above. Skip entirely for web.
|
|
1053
|
+
|
|
1054
|
+
4. Description: "Deploy" — subagent_type: `engineering-devops-automator` — mode: "bypassPermissions" — Prompt: "[CONTEXT header above] Deploy the app to the target from the PRD (`docs/plans/design-doc.md#tech-stack`). Run pre-deploy checks: build, env vars, secrets. Execute deploy. Verify the deployed URL returns 200 and serves the built app (not the placeholder). Report deploy URL and any smoke-test findings."
|
|
1055
|
+
|
|
1056
|
+
5. Description: "Completion Report" — INTERNAL inline role-string — Prompt: "[CONTEXT header above] You are the Completion Report writer. Draw verification surface from the LRR Aggregator's structured output (`docs/plans/evidence/lrr-aggregate.json`) and the Reality Checker evidence manifest (`docs/plans/evidence/reality-check-manifest.json`) — NOT from orchestrator summary prose. Present:
|
|
561
1057
|
|
|
562
1058
|
```
|
|
563
1059
|
BUILD COMPLETE
|
|
564
1060
|
Project: [name] | Tasks: [done]/[total] | Tests: [count] passing
|
|
565
|
-
Agents used: [list] | Verdict: [
|
|
1061
|
+
Agents used: [list distinct subagent_types] | Verdict: [combined_verdict from lrr-aggregate.json]
|
|
566
1062
|
Metric loops run: [count] | Avg iterations: [N]
|
|
567
|
-
Remaining: [any NEEDS WORK items]
|
|
1063
|
+
Remaining: [any NEEDS WORK items from lrr-routing.json]
|
|
568
1064
|
```
|
|
569
1065
|
|
|
570
|
-
|
|
1066
|
+
**Verification table (MANDATORY — pulled from LRR aggregator output):**
|
|
1067
|
+
|
|
1068
|
+
| Metric | Count | Status |
|
|
1069
|
+
|--------|-------|--------|
|
|
1070
|
+
| Behavioral Tests declared in spec | from sprint-tasks.md | — |
|
|
1071
|
+
| Behavioral Tests with non-stub bodies | from Eng-Quality findings | PASS if equal |
|
|
1072
|
+
| Behavioral evidence files written | count from manifest | — |
|
|
1073
|
+
| Maestro flows present (iOS) | count of maestro/*.yaml | — |
|
|
1074
|
+
| Test-stub detector flagged files | from Eng-Quality findings | PASS if 0 |
|
|
1075
|
+
| Combined verdict | from lrr-aggregate.json | — |
|
|
1076
|
+
| LRR chapter verdicts | list of chapter:verdict pairs | — |
|
|
1077
|
+
| LRR follow-ups spawned | count | — |
|
|
1078
|
+
| LRR triggered rule | rule number 1-6 | — |
|
|
1079
|
+
|
|
1080
|
+
If there's a Verification Gap (declared != passing, or stub-flagged > 0), surface a top-level 'Verification Gap' section BEFORE writing the report to disk. Ask user: 'Write Completion Report with this verification gap surfaced? [YES/NO]'. In autonomous mode: write but flag prominently.
|
|
1081
|
+
|
|
1082
|
+
Create final commit. Mark all TodoWrite items complete. Update `.build-state.json`: 'Phase: 7 COMPLETE'."
|
|
1083
|
+
|
|
1084
|
+
**Writes:** `docs/plans/learnings.jsonl` (late learnings only — doc friction, deploy blockers, late-surfacing gaps). If no late learnings surfaced, skip. Row schema: `{run_id, timestamp, project_type, phase_where_learning_surfaced: \"7.x\", metric, top_issue, fix_applied, score_delta, pattern_type}`.
|
|
1085
|
+
|
|
1086
|
+
**Compaction checkpoint.** Update `.build-state.json` per the format above.
|