agentleFS
notum-cznotum-cz/strapi-next-monorepo-starter/.claude/skills/consolidate-patterns/SKILL.md

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.

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
  1. Distinctive:

    If still none, report "nothing to review" and stop.

    line 22
  2. Distinctive:

    Never extract a one-off — a pattern must repeat to justify a shared component.

    line 44
  3. Distinctive:

    Never modify Strapi schemas — this is React refactoring only.

    line 45
  4. Distinctive:

    Don't over-abstract — no speculative props or variants the call sites don't use.

    line 47
  5. Distinctive:

    Leave the commit to the user (don't auto-commit).

    line 48

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 (default 2).

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

  1. Read each component in full.
  2. 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.
  3. Filter out anything below min_occurrences. If nothing remains, report "no consolidation needed" and stop.
  4. Extract each remaining pattern into apps/ui/src/components/elementary/<Name>.tsx, matching local conventions (see add-ui-component): cn() from @/lib/styles, readonly-typed props, a named export, design tokens from packages/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.
  5. Showcase (optional) — if a dev page fits (under apps/ui/src/app/[locale]/dev/), add a usage example. Skip silently if none applies.
  6. Quality gates:

    pnpm --filter @repo/ui exec tsc --noEmit
    pnpm --filter @repo/ui lint

    Fix any failures before reporting done.

  7. 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.