agentleFS
ChariereFiedlerChariereFiedler/ronce-racine/skills/refactoring-shared-component-api/SKILL.md

refactoring-shared-component-api

Skill9 starsChanged 23 days agoMITView on GitHub

Use when changing the public API (props, emits, slots, events, exported signatures) of a UI component or module consumed in 2+ places - renaming a prop, removing a parameter, changing a contract - "change this shared component's API", "change l'API de ce composant partagé", "rename this prop", "renomme cette prop". Also use when a typecheck passes but the change touches a shared contract.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    This skill: when: changing the public API (props/emits/slots/events/exported signature) of a component or module consumed in 2+ places

    line 16
  2. Distinctive:

    frontend-spec-call-site-audit: instead if: specifying a new feature, not changing an existing contract

    line 17
  3. Very specific:

    If the compiler checks templates strictly (e.g.

    line 44
  4. Distinctive:

    Every wrapper/adapter touched gets its own mount test (the event bubbles up, the prop drives the render) - these bugs are invisible until a …

    line 47
  5. Very specific:

    Test procedure: scripts/sweep-call-sites.test.ts - deterministic behavioral test of the script (positive + negative fixture).

    line 76

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

Refactoring a shared component's API

If the current repo has a dedicated skill or conventions for this case, they win.

This skill vs. others

  • This skill when: changing the public API (props/emits/slots/events/exported signature) of a component or module consumed in 2+ places
  • frontend-spec-call-site-audit instead if: specifying a new feature, not changing an existing contract
  • writing-robust-tests alongside: to write the integration-point tests in step 4

Principle

A shared-API refactor is not done when the typecheck passes: it is done when every grepped call site is migrated or justified. Many frameworks (Vue fallthrough attrs, dynamic JS, untyped templates) silently accept an unknown prop/argument - no compile, typecheck, or runtime signal.

Context to gather (before acting)

  • Does the compiler check templates strictly (strictTemplates, typed JSX)? If not, the silent-contract check in step 3 is manual and mandatory
  • Typecheck + test commands: read package.json / Cargo.toml / CI
  • Locate existing compatibility wrappers around the component - these are the most often forgotten consumers

Checklist (mandatory order, no step is optional)

1. Exhaustive sweep BEFORE touching the component - scripts/sweep-call-sites.ts

  • Grep every call site - all casings (<MyBadge, <my-badge), dynamic usages (:is=, factories), object spreads (v-bind="obj", {...props})
  • Compatibility wrappers are first-class call sites - the wrapper whose only job is to preserve the old interface is the most often forgotten consumer
  • Include: stories/fixtures/mocks, docstrings that reference the old API
  • List every call site; that is the migration checklist

2. Migration

  • Migrate each listed call site, ticking them off as you go
  • For each removed or renamed prop/parameter: grepping the old name must return 0 occurrences among consumers

3. Silent-contract check

  • For each migrated call site: open the consumed component and verify that every prop/argument passed is declared in its interface
  • If the compiler checks templates strictly (e.g. strictTemplates), the typecheck is enough; otherwise this check is manual and mandatory

4. Integration-point tests

  • Every wrapper/adapter touched gets its own mount test (the event bubbles up, the prop drives the render) - these bugs are invisible until a human exercises the feature

5. Validation

  • Unit tests + typecheck; verify the existing tests actually exercise the prop name (a test on a CSS class passes even if the rename is incomplete)

Templates

  • templates/migration-checklist.md - migration checklist to paste into the MR (call sites + status)

Traps & rationalizations

ExcuseReality
"The typecheck passes, it's done"Fallthrough attrs, dynamic JS, and untyped templates accept an unknown prop without complaint. The call-site sweep is authoritative.
"The compat wrapper isn't really a call site"It's the most often forgotten consumer, and its only job is to carry the old interface. Sweep mandatory.
"A global sed on variant will be faster"A generic name touches unrelated components. Migrate file by file.
"The existing tests pass"A test on a CSS class passes even if the rename is incomplete. Verify they exercise the prop name.

Exit condition

  • Exhaustive sweep run (scripts/sweep-call-sites.ts), all call sites listed
  • Each call site migrated or justified (not affected); grep of the old name = 0 occurrences among consumers
  • Silent-contract check done (every prop passed is declared in the component's interface)
  • Mount test on each wrapper/adapter touched
  • Tests + typecheck run, output pasted - never "it should pass"
  • Deliverable: list of call sites + status (migrated / removed / not affected, justified)

Tooling

  • Test procedure: scripts/sweep-call-sites.test.ts - deterministic behavioral test of the script (positive + negative fixture). Run npx tsx scripts/sweep-call-sites.test.ts from the canonical repo after any change to the script (also picked up by npm test). Not distributed to target repos.
  • scripts/sweep-call-sites.ts <ComponentName> [rootDir] - automatic sweep (casings, dynamic usages, spreads, suspicious wrappers highlighted, stories/mocks), output = markdown checklist

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.