/dev-flow:promote-componentfrom dev-flow
Refactors React/React Native components up the colocation hierarchy (L0 to L1 to L2) when usage spreads across pages. Supports scan mode to identify candidates via the Rule of Three and promote mode to move files and update imports. Honors Next.js, Expo RN, and monorepo conventions.
Ships in dev-flow. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
See references/contracts.md (vendored from dev-flow). Key facts:
<project-root>/.workflow/meta.json#stack.framework (must be "next", "expo-rn", or "monorepo").meta.json#stack.route_groups (optional, helps detect the target level).<project-root>/ (or <project-root>/apps/<web|mobile>/ for monorepo).meta.json#phase. Appends to meta.json#history.Orchestrator does NOT route here automatically — invoked on demand.
composition-patterns-guide/SKILL.md — the 7 Vercel composition rules + our colocation rules.references/colocation-rules.md — the canonical Rule of Three + L0/L1/L2 spec.Next.js App Router supports _-prefixed private folders — app/<route>/_components/ is a valid non-routable convention there. Expo Router does not: every file under app/ (aside from a short reserved list) becomes a real route, so app/<route>/_components/ would create a ghost route on mobile, not a private folder. Settled upstream, not pending: the request (expo/expo#44696) was closed won't fix on 2026-06-01 — Expo Router wants components outside app/ by design. Confirmed mechanically at [email protected] (2026-10-17): no underscore rule in the route scanner. Treat mobile app/ as routes-only, permanently. See references/colocation-rules.md.
Consequently this skill uses different scan/target paths per platform — see references/colocation-rules.md for the full model and rationale. Summary:
Web (stack.framework == "next", or apps/web in a monorepo) | Mobile (stack.framework == "expo-rn", or apps/mobile in a monorepo) | |
|---|---|---|
| Candidate scan root | app/**/_components/*.tsx and components/<area>/**/*.tsx (excludes components/{ui,theme,shared,brand,logos}) | components/<feature>/*.tsx (excludes components/{ui,theme,shared}) |
| L0 target | app/<route>/_components/<Component>.tsx | components/<feature>/<Component>.tsx |
| L1 target | app/(group)/_components/<Component>.tsx | same folder as L0 (no separate L1 path on mobile — see colocation-rules.md) |
| L2 target | components/shared/<dominio>/<Component>.tsx | components/shared/<dominio>/<Component>.tsx (identical) |
Everything below is written generically ("the platform's _components/-or-components/<feature>/ root") — substitute per the table above. The scripts (scripts/scan_promotion.py, scripts/promote.py) branch on meta.json#stack.framework automatically.
scan modeRead meta.json#stack.framework:
"next" → cwd = project root, scan app/**/_components/ and components/<area>/ (excluding components/{ui,theme,shared,brand,logos}). Many web projects keep feature components in components/<area>/ and have no _components/ at all — smart-travel has 200+ there, and a scan of _components/ alone reported nothing (2026-10-12)."expo-rn" → cwd = project root, scan components/<feature>/ (excluding components/{ui,theme,shared})."monorepo" → scan apps/web/ with the web rules and apps/mobile/ with the mobile rules, separately. Print two tables.Web:
find app -type d -name "_components" -exec ls -1 {} \;
For each .tsx file in _components/, record component name, source path (e.g., app/(app)/posts/_components/PostCard.tsx), and current level (L0: under a leaf route, L1: under app/(group)/_components/).
Then, still on web, every .tsx under components/<area>/ (not ui, theme, shared, brand, logos). Count its importers by resolved path (@/components/<area>/x or a relative ./x), not by file name — two parts.tsx in different areas are different components. The pages of one route group are an area's natural consumers; it becomes an L2 candidate (components/shared/<dominio>/) when, with 3+ importers, another components/<area> imports it or two or more route groups do. scripts/scan_promotion.py prints this as a second table.
Mobile:
find components -mindepth 2 -maxdepth 2 -name "*.tsx" | grep -vE '/(ui|theme|shared)/'
For each match, record component name, source path (e.g., components/posts/PostCard.tsx), and which feature folder(s) hold a copy of that name (duplicates across feature folders are the mobile promotion signal — see Step 4).
For every component, grep the codebase for imports referencing its file path or filename (both platforms):
grep -rln "from .*['\"].*PostCard['\"]" app/ components/ --include="*.tsx" --include="*.ts"
Count distinct import sites (deduplicate by file).
Web:
| Usage count | Current level | Suggestion |
|---|---|---|
| 1 | L0 | OK — stays |
| 2 | L0 | Tolerated duplicate — wait the 3rd |
| 3+, all in same route group | L0 (in 2+ pages) | Promote to L1 (app/(group)/_components/) |
| 3+, across different route groups | L0 or L1 | Promote to L2 (components/shared/<dominio>/) |
| 2+, but on its way up | L1 → L2 | Promote to L2 |
Mobile (mobile has no separate L1 path — see colocation-rules.md):
| Copies across feature folders | Suggestion |
|---|---|
| 1 | OK — stays |
| 2 | Tolerated duplicate — wait the 3rd |
| 3+, reconcilable to one feature/domain | Merge duplicates into one components/<feature>/<Component>.tsx |
| 3+, spanning different business domains | Promote to L2 (components/shared/<dominio>/) |
Promotion candidates in apps/web/ (next):
| Component | Usages | Current level | Suggestion |
|----------------------------|--------|---------------|------------------------------------------|
| PostCard | 3 | L0 | Promote to L1 — app/(app)/_components/ |
| UserAvatar | 4 | L0 | Promote to L2 — components/shared/user/ |
| BillingSummary | 2 | L0 | Wait the 3rd use |
| PricingTable | 5 | L0 | Promote to L2 — components/shared/billing/ |
Promotion candidates in apps/mobile/ (expo-rn):
| Component | Usages | Current level | Suggestion |
|----------------------------|--------|---------------|--------------------------------------------|
| PostCard | 3 | L0 | Promote to L2 — components/shared/post/ |
| SettingsRow | 2 | L0 | Wait the 3rd use |
Ask the user: "Vuoi promuoverne alcuni? (Y/n, oppure dimmi quali)".
promote <Component> modeWeb: find the file matching <Component> under app/**/_components/.
Mobile: find the file matching <Component> under components/<feature>/ (excluding components/{ui,theme,shared}).
If multiple matches (e.g., two copies at L0):
If invoked without an explicit target, recompute from usage/copy distribution:
app/(group)/_components/<Component>.tsx. Different groups, 3+ usages → L2: components/shared/<dominio>/<Component>.tsx.components/<feature>/<Component>.tsx (no move, dedupe only). Copies spanning different business domains → L2: components/shared/<dominio>/<Component>.tsx.Ask the user for <dominio> if not obvious (either platform). If an explicit target is provided ("promote PostCard to L2 in components/shared/post/"), honor it.
Web:
# L0 → L1 (same group)
git mv app/(app)/posts/_components/PostCard.tsx app/(app)/_components/PostCard.tsx
# L0 → L2 (cross-group)
mkdir -p components/shared/post
git mv app/(app)/posts/_components/PostCard.tsx components/shared/post/PostCard.tsx
Mobile (never touches app/ — components never live there):
# Dedupe (3rd use reconciled to one feature) — keep the canonical copy in place, remove the others
rm components/profile/PostCard.tsx # duplicate removed, canonical stays at components/posts/PostCard.tsx
# L0 → L2 (cross-domain)
mkdir -p components/shared/post
git mv components/posts/PostCard.tsx components/shared/post/PostCard.tsx
If duplicates existed at L0 (the "2 copies" case), also rm them (both platforms).
Scan all .tsx / .ts files in app/ and components/, find imports referencing the OLD path or filename, rewrite to the NEW path. Applies identically on both platforms — the import-rewrite step never assumes a platform-specific path shape.
Pattern types:
from "@/app/(app)/posts/_components/PostCard" → from "@/components/shared/post/PostCard"from "@/components/posts/PostCard" → from "@/components/shared/post/PostCard"from "./PostCard" (siblings) → resolve to absolute, then rewritefrom "../PostCard" (parent) → idemUse a TypeScript-aware import rewrite (e.g., ts-morph Python equivalent via jscodeshift or simple regex with care).
npx tsc --noEmit
Must pass. If it fails:
If still failing after 2 attempts, ROLLBACK the move (git restore) and report to the user.
git add -A
git commit -m "refactor: promote <Component> from <old-level> to <new-level>"
Append to meta.json#history:
{
"skill": "promote-component",
"ran_at": "<iso>",
"inputs": {"component": "PostCard", "from": "L0 (3 sites)", "to": "L2", "domain": "post"},
"outputs": {"new_path": "components/shared/post/PostCard.tsx", "imports_updated": 3}
}
shared/common/, shared/misc/) — use the business domain.components/shared/.python3 .../dev-flow/scripts/update_meta.py <project-root> append-history \
--skill 'promote-component' --inputs '{"component": "<X>"}' --outputs '{"new_path": "<path>"}'
docs/superpowers/specs/2026-06-06-folder-structure-refactor.mdWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub lukedj78/dev-flow --plugin dev-flow57 skills in this plugin
/animated-iconsAdd a Motion-animated icon to a Next.js app from a shadcn registry instead of hand-animating an SVG. Two registries, picked from the project's icon set: **heroicons-animated** (316 icons, `shadcn add @heroicons-animated/<name>`) and **hugeicons-animated** (165 icons, `shadcn add @hugeicons-animated/<name>`, which also installs a shared `lib/use-icon-animation.ts`). Both MIT, both on the `motion` runtime, both copied into your repo as source. This skill owns the install plus the two things the raw components lack: a `prefers-reduced-motion` guard and timing aligned to the project motion tokens (`lib/motion/`). Use when the user says "animated icon", "animate this icon", "make the bell/heart/menu icon animate on hover", "aggiungi un'icona animata", or wants an icon micro-interaction. Refuses outside Next.js web — for React Native use `rn-animations-gestures`. Not for: static icons, a whole motion system (`transitions`), or installing the runtime itself (`module-add motion`)./app-securityCheck whether an app's own code can be attacked before it ships — vulnerable dependencies, secrets in the code and in git history, Next.js authorization gaps (Server Actions and route handlers without a session check, queries by id with no owner filter — IDOR), data over-exposure, secrets in public env vars, raw SQL — then read the flagged code against an OWASP checklist, with an opt-in dynamic level (Strix) that proves exploits against the app running locally. The fifth pre-deploy gate, beside compliance-audit, vercel-doctor, shadscan and launch-audit; reports and routes, never blocks. Triggers: "security review", "è sicura l'app?", "controllo di sicurezza prima del deploy", "IDOR", "secrets in the repo", "pentest". Not for: GDPR and legal (compliance-audit), UI quality (shadscan), cost (vercel-doctor), launch readiness (launch-audit), a review of one branch diff (Claude Code's /security-review), third-party registry code (registry-intake).