---
name: reuse
description: Reaches for the project's own components, then a maintained library, then a native feature, before writing new code.
title: reuse
canonical_url: https://skilld.dev/gh/raphaelsalaja/skills/reuse
last_updated: 2026-11-22T01:08:19.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [agents/openai.yaml](https://skilld.dev/api/skills-raw/raphaelsalaja/skills/reuse/agents/openai.yaml).
>
> If the user asked to install this Skill, run `npx skilld install raphaelsalaja/skills/reuse`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/reuse`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/raphaelsalaja/skills/reuse) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/reuse`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/reuse --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/reuse --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Reuse

This skill sets the order for building anything new. The project's own parts come first, then a maintained library or a platform feature. Custom code comes last.

## A duplicate is a finding

A new component, style or icon that duplicates one the project already has is a finding. Adding a primitive to the shared package and then using it is not. A project with no shared package is judged on the libraries it already depends on.

Cutting what nobody asked for, including a helper with one caller, belongs to `restraint`. Copying an outside app belongs to `match`.

## The project's parts come first

Search the shared component package, the icon set and the tokens before writing UI. Name what you found. A raw `<input>` beside the project's `Input` is `reuse-house-component-first`.

Spacing and radius come from the project's tokens. A raw `16px` where `--space-4` holds the same value is `reuse-tokens-not-values`. Colour tokens belong to `color`, and the z-index and type scales to `defaults`.

## Shipped components stay as shipped

Use a component's variants and `data-*` attributes. Restyling it with a local `className` is `reuse-no-local-restyle`.

## One style per kind of thing

Keep one menu, one table and one dialog shell. A second dropdown style is `reuse-one-standard`.

## Fix it once, in the primitive

When a fix applies to every instance, make it inside the shared component. Patching five call sites is `reuse-fix-in-the-primitive`. Then search for every sibling, remove its local fix and list the files. Fixing only the cited line is `reuse-sweep-siblings`.

## Then a library or the platform

When the project has nothing, use a maintained library or a platform feature before custom code. `Intl` formats dates and numbers. The native context menu handles right-click. A hand-written formatter is `reuse-library-before-custom`.

The platform often removes the install. `crypto.randomUUID()` replaces an id package, `structuredClone()` a deep-copy helper and `URLSearchParams` a query-string parser.

Read `package.json` before installing. A library for a job an installed one already does, such as a second date library, is `reuse-one-library-per-job`.

## A dependency is checked before it lands

Take the package name from the library's own documentation, never from memory. A remembered name may not exist, or may be a look-alike someone published to catch that guess. Installing a name nobody checked is `reuse-confirm-the-package`.

Then run `npm view <name> deprecated time.modified repository.url`. Install it only when it is not deprecated, its repository is not archived and it released within 12 months. A small finished utility may stay quiet longer when its issues get answers. When it fails, port the pattern instead of installing it. That is `reuse-no-stale-dependency`.

## Read the docs before the props

Read the installed version in `package.json` or the lockfile, then the documentation for that major version. Use its current APIs, not ones remembered from an older release. A guessed prop is `reuse-read-the-docs`.

## Icons from the set, at native size

Use the project's icon set at the size it was drawn for. A generated SVG, or an `18px` icon scaled to `12px`, is `reuse-icon-set-native-size`. A glyph the set lacks, drawn by `icons` and added to the shared icon package or folder, is not a finding.

## The pair

Every check is a pair. The broken line sits beside the line that replaces it.

| Rule | Broken | Replacement |
| --- | --- | --- |
| `reuse-house-component-first` | `<input className={styles.search} />` | The project's `<Input />` |
| `reuse-tokens-not-values` | `padding: 16px` in a project with `--space-4: 16px` | `padding: var(--space-4)` |
| `reuse-no-local-restyle` | `.menu { border-radius: 6px }` beside the shared `Menu` | `Menu` as shipped |
| `reuse-one-standard` | Three dropdown styles on three screens | One `Menu` |
| `reuse-fix-in-the-primitive` | A scroll fade added at five call sites | The fade inside `ScrollArea` |
| `reuse-sweep-siblings` | The cited line fixed, its siblings left | Every sibling fixed, files listed |
| `reuse-library-before-custom` | A hand-written relative date formatter | `Intl.RelativeTimeFormat` |
| `reuse-one-library-per-job` | `dayjs` installed beside `date-fns` | The formatter `date-fns` already ships |
| `reuse-confirm-the-package` | `npm install` of a name typed from memory | The name copied from the library's docs, `npm view` showing its repository |
| `reuse-no-stale-dependency` | A package installed whose repository is archived | Its pattern ported into the project |
| `reuse-read-the-docs` | `render={<button />}` on a trigger that is already a button | The prop the docs for the installed version describe, or none |
| `reuse-icon-set-native-size` | An `18px` icon at `width: 12px` | The `12px` icon from the set |

## Reporting

**Severity.** `HIGH` is a duplicate of an existing shared component, or a hand-built control a primitive covers. It is also a package installed under a name nobody checked. `MEDIUM` is a local restyle, a second style for one kind of thing or a shared fix applied at one call site. It is also a raw value beside its token, a second library for one job or custom code a library or the platform covers. So is a prop guessed from an older version, or an icon from outside the set or off its drawn size. `LOW` is a library chosen without checking that it is maintained.

**Format.** One finding per root cause:

```
file:line - [rule-id] what is wrong
```

Then a `Rule | Count | Severity` summary. `Block` when any `HIGH` remains, `Approve` otherwise. Never `Approve` a file you did not read. Mark every check you could not run as `Not verified`.
