feat: corpus-back react pattern loader + 4 foundational patterns#87
Merged
KailasMahavarkar merged 4 commits intomainfrom Apr 21, 2026
Merged
feat: corpus-back react pattern loader + 4 foundational patterns#87KailasMahavarkar merged 4 commits intomainfrom
KailasMahavarkar merged 4 commits intomainfrom
Conversation
Adds corpus support to `src/plugins/react/tools/get-pattern.ts`. Tool now reads per-pattern slices from `corpus/frontend/react/<name>.yaml`, validates required fields (category, description, when, code), and falls back to the in-file PATTERNS registry when the corpus entry is missing or invalid. Creates the react corpus namespace: - `corpus/frontend/react/index.yaml` registers the `frontend.react` namespace and pattern files - `corpus/frontend/react/rsc-default.yaml` captures the RSC-by-default pattern (server-component body, use-client counter, anti-pattern data-only client component, SEO/interactivity tips) - `corpus/index.yaml` registers the new namespace New `tests/react-pattern-corpus-backed-tools-behaviour.test.ts` asserts corpus source for rsc-default and fallback for zustand-store. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds corpus/frontend/react/zustand-store.yaml with auth-store template, persist middleware, slice-selector usage guidance. Registers zustand-store in namespace index. Test asserts corpus source for zustand-store; fallback check moves to state-hierarchy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds corpus/frontend/react/state-hierarchy.yaml with the URL → server → local → Zustand → Context ladder and the Context-for-reactive-state anti-pattern. Registers state-hierarchy in namespace index. Test asserts corpus source for state-hierarchy; fallback check moves to suspense-boundary. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds corpus/frontend/react/suspense-boundary.yaml with ErrorBoundary + Suspense composition for async RSC children. Registers suspense-boundary in namespace index. Test asserts corpus source for suspense-boundary; fallback check moves to composition-pattern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
7fa9825 to
88f8ae0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/plugins/react/tools/get-pattern.tswith a generic per-pattern loader (validates name/category/description/when/code) that falls back to the in-file PATTERNS registry when the slice is missingfrontend.reactcorpus namespacefrontend.reactincorpus/index.yamltests/react-pattern-corpus-backed-tools-behaviour.test.tsasserts corpus source for every migrated patternTest plan