consolidate-patterns
Skill316 starsChanged 5 months agoMITView on GitHub
Use as a checkpoint after building several page-builder components, to remove duplication — e.g. "consolidate patterns", "extract reusable", "dedupe components", "review components for shared patterns". Extracts JSX/Tailwind repeated across 2+ components into shared elementary components. React-only — never touches Strapi schemas.
In this repository25 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-content-typeSkill
- add-localeSkill
- add-ui-componentSkill
- copy-componentSkill
- create-content-componentSkill
- find-componentSkill
- find-skillsSkill
- frontend-designSkill
- make-prSkill
- next-best-practicesSkill
- remove-azure-monitorSkill
- remove-cache-revalidationSkill
- remove-cdn-purgeSkill
- remove-sentrySkill
- resolve-review-suggestionsSkill
- review-prSkill
- seed-contentSkill
- start-workSkill
- strapi-schema-checkSkill
- validate-branch-refsSkill
- vercel-react-best-practicesSkill
- write-testsSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
If still none, report "nothing to review" and stop.
- Distinctive: line 44
Never extract a one-off — a pattern must repeat to justify a shared component.
- Distinctive: line 45
Never modify Strapi schemas — this is React refactoring only.
- Distinctive: line 47
Don't over-abstract — no speculative props or variants the call sites don't use.
- Distinctive: line 48
Leave the commit to the user (don't auto-commit).
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Consolidate Patterns
Review recently built page-builder components, find JSX/Tailwind patterns repeated across 2+ of them, extract each into a shared elementary component, and update the call sites. React-only — never modify Strapi schemas.
Inputs
- Component names or paths, or none.
min_occurrences— a pattern must appear in at least this many components (default2).
Resolve names to apps/ui/src/components/page-builder/components/**/Strapi*.tsx. If no components are given, fall back to recent git history:
git log --oneline --diff-filter=A --name-only -20 -- 'apps/ui/src/components/page-builder/components/**/Strapi*.tsx'If still none, report "nothing to review" and stop.
Steps
- Read each component in full.
- Detect repeats of three kinds: identical JSX structures (same element hierarchy, differing only in content/className), repeated Tailwind class groups on structurally similar elements, and repeated sub-component compositions. For each, record which components contain it, the fragment, the occurrence count, and a proposed component name.
- Filter out anything below
min_occurrences. If nothing remains, report "no consolidation needed" and stop. - Extract each remaining pattern into
apps/ui/src/components/elementary/<Name>.tsx, matching local conventions (seeadd-ui-component):cn()from@/lib/styles,readonly-typed props, a named export, design tokens frompackages/design-system(no raw hex). Keep the extraction concrete — a direct lift of the repeated JSX, not a generalized framework. Update every source component to import and use it; the rendered HTML must be byte-for-byte identical. - Showcase (optional) — if a dev page fits (under
apps/ui/src/app/[locale]/dev/), add a usage example. Skip silently if none applies. Quality gates:
pnpm --filter @repo/ui exec tsc --noEmit pnpm --filter @repo/ui lintFix any failures before reporting done.
- Report patterns found (with counts), elementary components created (with paths), call sites updated, and patterns skipped (below threshold).
Constraints
- Never extract a one-off — a pattern must repeat to justify a shared component.
- Never modify Strapi schemas — this is React refactoring only.
- Rendered output must be identical before and after.
- Don't over-abstract — no speculative props or variants the call sites don't use.
- Leave the commit to the user (don't auto-commit).
See also
add-ui-component— elementary component conventions and templates.create-content-component— the skill that builds the page-builder components this one reviews.apps/docs/docs/page-builder/introduction.md— component architecture.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

