agentsclimarketplace

Poo fix

Skill keysjoao/poo-skills/poo-fix

Refactors duplicate code into shared components/utilities. Use after /poo audit finds duplicates. Trigger when: "fix duplicates", "consolidate components", "merge duplicates", "extract shared", "poo fix", "refactor to shared".From its SKILL.md

Install
npx -y skills add keysjoao/poo-skills --skill poo-fix

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
  • runs commandsInstructs the agent to run 1 command, including `npx tsc --noEmit`.

SKILL.md

3.7 KB, 846 tokens by cl100k_base, as published. Nobody here has run it

POO Fix — Consolidate Duplicates

Refactors identified duplicate code into shared, reusable components following OOP/SOLID principles.

Input

Either:

  • Results from /poo audit (list of duplicate pairs)
  • User pointing at specific files ("esses dois componentes fazem a mesma coisa")
  • A file path to analyze

Workflow

Step 1: Analyze the Duplicates

For each duplicate pair:

  1. Read BOTH files completely
  2. Identify:
    • Shared logic (identical or near-identical code)
    • Differences (props, styling, edge cases)
    • Dependencies (what each imports)

Step 2: Design the Shared Abstraction

Choose the right pattern:

PatternWhen to UseExample
Shared ComponentSame UI, minor prop differences<DownloadButton variant="primary">
CompositionSame structure, different content<Card><CardHeader/><CardBody/></Card>
Custom HookSame logic, different UIuseDownload() returns {download, loading, error}
Utility FunctionSame operation, no UIformatCurrency(value, locale)
Base Class/InterfaceSame contract, different implementationsinterface DataExporter { export(): void }
Higher-Order ComponentSame wrapper behaviorwithAuth(Component)
Render Props / SlotsSame logic, totally different UI<DataFetcher render={data => ...}/>

Step 3: Determine Location

1. Check if shared directory exists:
   Glob: **/components/shared/** OR **/components/ui/** OR **/components/common/**

2. If not, check project conventions:
   - Next.js: components/ at root or src/components/
   - React: src/components/shared/
   - Vue: src/components/common/

3. For utilities: utils/ or lib/
4. For hooks: hooks/ or composables/ (Vue)
5. For types: types/ or interfaces/

Step 4: Build the Shared Code

  1. Create the shared component/utility with ALL variants:

    • Use props/params to handle differences
    • Add TypeScript types for all variants
    • Export from a clean index file
  2. Update ALL consumers:

    • Replace duplicate imports with shared import
    • Pass appropriate props/params
    • Delete the old duplicate files
  3. Verify nothing breaks:

    • Check all imports resolve
    • Check TypeScript compiles
    • Run existing tests if available

Step 5: Report Changes

## POO Fix Report

### Created
- `components/shared/DownloadButton.tsx` — unified download button

### Updated (now using shared component)
- `pages/reports/index.tsx` — was: local DownloadBtn, now: shared DownloadButton
- `pages/exports/index.tsx` — was: local ExportDownload, now: shared DownloadButton

### Deleted (duplicates removed)
- `pages/reports/components/DownloadBtn.tsx`
- `pages/exports/components/ExportDownload.tsx`

### Props/Variants Added
- `variant`: "primary" | "secondary" | "icon-only"
- `format`: "csv" | "xlsx" | "pdf"

### Lines Saved: ~120 lines (2 files → 1 shared)

Refactoring Rules

  1. Never break existing functionality — the refactored code must work identically
  2. Preserve all edge cases — if one version handles an edge case, the shared version must too
  3. Use TypeScript generics when the types differ between consumers
  4. Add JSDoc comments explaining props/params that exist to support specific consumers
  5. Run type check afternpx tsc --noEmit to verify
  6. Update barrel exports — if the project uses index.ts re-exports

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.