Skip to content

feat: corpus-back react pattern loader + 4 foundational patterns#87

Merged
KailasMahavarkar merged 4 commits intomainfrom
feat/corpus-react-patterns
Apr 21, 2026
Merged

feat: corpus-back react pattern loader + 4 foundational patterns#87
KailasMahavarkar merged 4 commits intomainfrom
feat/corpus-react-patterns

Conversation

@KailasMahavarkar
Copy link
Copy Markdown
Collaborator

Summary

  • Adds corpus support to src/plugins/react/tools/get-pattern.ts with a generic per-pattern loader (validates name/category/description/when/code) that falls back to the in-file PATTERNS registry when the slice is missing
  • Creates the frontend.react corpus namespace
  • Adds 4 corpus-backed pattern slices: rsc-default, zustand-store, state-hierarchy, suspense-boundary
  • Registers frontend.react in corpus/index.yaml
  • New tests/react-pattern-corpus-backed-tools-behaviour.test.ts asserts corpus source for every migrated pattern

Test plan

  • bun test tests/react-pattern-corpus-backed-tools-behaviour.test.ts - 5 pass
  • bun run build - typecheck exit 0

KailasMahavarkar and others added 4 commits April 22, 2026 02:33
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>
@KailasMahavarkar KailasMahavarkar force-pushed the feat/corpus-react-patterns branch from 7fa9825 to 88f8ae0 Compare April 21, 2026 21:03
@KailasMahavarkar KailasMahavarkar merged commit 2b16beb into main Apr 21, 2026
4 checks passed
@KailasMahavarkar KailasMahavarkar deleted the feat/corpus-react-patterns branch April 21, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant