| 1 | --- |
| 2 | name: plan-update |
| 3 | description: Use when you need to update a plan document with deep research across all compiler passes. Launches parallel subagents to analyze how a topic affects every compiler phase, then consolidates findings into the plan doc. |
| 4 | --- |
| 5 | |
| 6 | # Plan Update |
| 7 | |
| 8 | Deep-research a topic across all compiler passes and update a plan document. |
| 9 | |
| 10 | Arguments: |
| 11 | - $ARGUMENTS: `<plan-doc-path> <topic/question>` |
| 12 | - Example: `compiler/docs/rust-port/rust-port-0001-babel-ast.md scope resolution strategy` |
| 13 | - Example: `compiler/docs/rust-port/rust-port-architecture.md error handling patterns` |
| 14 | |
| 15 | ## Instructions |
| 16 | |
| 17 | ### Step 1: Read context |
| 18 | |
| 19 | Read these files to understand the current state: |
| 20 | - The plan doc specified in $ARGUMENTS |
| 21 | - `compiler/docs/rust-port/rust-port-architecture.md` (architecture guide and port conventions) |
| 22 | - `compiler/packages/babel-plugin-react-compiler/docs/passes/README.md` (pass overview) |
| 23 | |
| 24 | ### Step 2: Launch parallel analysis agents |
| 25 | |
| 26 | Launch **8 parallel Agent tool calls** using the `analyze-pass-impact` agent. Each agent analyzes one phase group. Pass each agent the topic from $ARGUMENTS and the list of pass doc files for its phase. |
| 27 | |
| 28 | **Phase groups and their pass docs:** |
| 29 | |
| 30 | 1. **Lowering & SSA** (passes 01-03): |
| 31 | `01-lower.md`, `02-enterSSA.md`, `03-eliminateRedundantPhi.md` |
| 32 | |
| 33 | 2. **Optimization & Types** (passes 04-06): |
| 34 | `04-constantPropagation.md`, `05-deadCodeElimination.md`, `06-inferTypes.md` |
| 35 | |
| 36 | 3. **Function & Effect Analysis** (passes 07-09): |
| 37 | `07-analyseFunctions.md`, `08-inferMutationAliasingEffects.md`, `09-inferMutationAliasingRanges.md` |
| 38 | |
| 39 | 4. **Reactivity & Scope Variables** (passes 10-14): |
| 40 | `10-inferReactivePlaces.md`, `11-inferReactiveScopeVariables.md`, `12-rewriteInstructionKindsBasedOnReassignment.md`, `13-alignMethodCallScopes.md`, `14-alignObjectMethodScopes.md` |
| 41 | |
| 42 | 5. **Scope Alignment & Terminals** (passes 15-20): |
| 43 | `15-alignReactiveScopesToBlockScopesHIR.md`, `16-mergeOverlappingReactiveScopesHIR.md`, `17-buildReactiveScopeTerminalsHIR.md`, `18-flattenReactiveLoopsHIR.md`, `19-flattenScopesWithHooksOrUseHIR.md`, `20-propagateScopeDependenciesHIR.md` |
| 44 | |
| 45 | 6. **Reactive Function & Transforms** (passes 21-30): |
| 46 | `21-buildReactiveFunction.md`, `22-pruneUnusedLabels.md`, `23-pruneNonEscapingScopes.md`, `24-pruneNonReactiveDependencies.md`, `25-pruneUnusedScopes.md`, `26-mergeReactiveScopesThatInvalidateTogether.md`, `27-pruneAlwaysInvalidatingScopes.md`, `28-propagateEarlyReturns.md`, `29-promoteUsedTemporaries.md`, `30-renameVariables.md` |
| 47 | |
| 48 | 7. **Codegen & Optimization** (passes 31, 34-38): |
| 49 | `31-codegenReactiveFunction.md`, `34-optimizePropsMethodCalls.md`, `35-optimizeForSSR.md`, `36-outlineJSX.md`, `37-outlineFunctions.md`, `38-memoizeFbtAndMacroOperandsInSameScope.md` |
| 50 | |
| 51 | 8. **Validation Passes** (passes 39-55): |
| 52 | `39-validateContextVariableLValues.md`, `40-validateUseMemo.md`, `41-validateHooksUsage.md`, `42-validateNoCapitalizedCalls.md`, `43-validateLocalsNotReassignedAfterRender.md`, `44-validateNoSetStateInRender.md`, `45-validateNoDerivedComputationsInEffects.md`, `46-validateNoSetStateInEffects.md`, `47-validateNoJSXInTryStatement.md`, `48-validateNoImpureValuesInRender.md`, `49-validateNoRefAccessInRender.md`, `50-validateNoFreezingKnownMutableFunctions.md`, `51-validateExhaustiveDependencies.md`, `53-validatePreservedManualMemoization.md`, `54-validateStaticComponents.md`, `55-validateSourceLocations.md` |
| 53 | |
| 54 | Each agent prompt should be: |
| 55 | ``` |
| 56 | Analyze how the topic "<topic>" affects the following compiler passes. |
| 57 | |
| 58 | Read each pass's documentation in compiler/packages/babel-plugin-react-compiler/docs/passes/ and its implementation source. Also read compiler/docs/rust-port/rust-port-architecture.md for port conventions. |
| 59 | |
| 60 | Pass docs to analyze: <list of pass doc filenames> |
| 61 | |
| 62 | For each pass, report: |
| 63 | - Pass name and purpose (1 line) |
| 64 | - Impact: "none", "minor" (mechanical changes only), "moderate" (logic changes), or "significant" (redesign needed) |
| 65 | - If impact is not "none": specific details of what changes are needed |
| 66 | - Key code locations in the implementation (file:line references) |
| 67 | |
| 68 | Be thorough but concise. Focus on concrete impacts, not speculation. |
| 69 | ``` |
| 70 | |
| 71 | ### Step 3: Consolidate and update |
| 72 | |
| 73 | After all agents complete: |
| 74 | 1. Merge their findings into a coherent analysis |
| 75 | 2. Group by impact level (significant > moderate > minor > none) |
| 76 | 3. Update the plan document. The final state should reflect the latest findings and understanding: |
| 77 | - Update the plan document in-place to remove outdated content and describe the latest understanding. |
| 78 | - KEEP any existing content that is still relevant |
| 79 | - REMOVE outdated or now-irrelevant content |
| 80 | - Per-pass impact summary table (updated in place, ie update each section based on new findings) |
| 81 | - Detailed notes for passes with moderate+ impact |
| 82 | - Updated "Current status" or "Remaining Work" section if applicable |
| 83 | |
| 84 | ### Step 4: Show summary |
| 85 | |
| 86 | Show the user a brief summary of findings: how many passes are affected at each level, and the key insights. |