Index of every page on this site: llms.txt
All skills
amanktyr avatar

/reuse-first

@5711aad
by Aman Ktyramanktyr/tailor6 stars
Run it yourself

Enforces reuse-first software engineering. Prevents duplicate components, utilities, hooks, functions, CSS classes, and abstractions by searching existing workspace code first.

Use this Skill: https://skilld.dev/gh/amanktyr/tailor/reuse-first

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈47 tokens for metadata: the name and description. ≈1.2k when used: this file.

Description uses 2.4% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈190 characters, or 2.4%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Reuse-First Engineering Skill

Activate this skill before creating any new component, utility function, hook, service, database helper, or CSS class.

Operational Directive: Never build from scratch what already exists in the codebase.


1. Automated AST Catalog Search

Before writing new code, query the workspace symbol catalog or execute the duplicate finder:

# Search for matching components, hooks, or functions in workspace
node skills/reuse-first/scripts/find-duplicates.js modal
node skills/reuse-first/scripts/find-duplicates.js user
node skills/reuse-first/scripts/find-duplicates.js fetch

2. Semantic Synonym Lookup Matrix

Inspect concept synonyms rather than searching for exact names only:

Requested Concept Potential Matches & Synonyms to Inspect First
Modal / Dialog Dialog, Popup, Sheet, Drawer, Modal, AlertModal, ConfirmBox
Toast / Notification Notification, Snackbar, Banner, Toast, Message, Alert
Data Fetcher / API getUser, fetchUser, loadUser, findUser, queryUser, userService, apiClient
Date Formatting formatDate, formatTimestamp, parseDate, dateUtils, timeAgo, Intl.DateTimeFormat
Button / CTA Button, IconButton, ActionButton, SubmitBtn, LinkButton
Dropdown / Picker Select, Combobox, MenuSelect, DropdownMenu, Autocomplete
Form Inputs Input, TextField, FormField, Checkbox, RadioGroup, Switch
Table / Grid DataTable, Table, DataGrid, VirtualList, Pagination

3. Decision Framework: Parameterize vs Create New

When a matching component or utility is identified:

┌────────────────────────────────────────────────────────┐
│ Is semantic similarity >= 70%?                         │
└───────────────────────────┬────────────────────────────┘
                            │
            ┌───────────────┴───────────────┐
           YES                              NO
            │                               │
┌───────────▼────────────┐      ┌───────────▼────────────┐
│ Can it be extended with │      │ Are domain boundaries  │
│ optional props/params  │      │ completely distinct?   │
│ without breaking       │      └───────────┬────────────┘
│ existing callers?      │                  │
└───────────┬────────────┘                 YES
            │                               │
     ┌──────┴──────┐            ┌───────────▼────────────┐
    YES            NO           │ Implement new focused  │
     │             │            │ abstraction. Document  │
┌────▼───────┐ ┌───▼──────────┐ │ in .ai/ architecture.  │
│ EXTEND &   │ │ EXTRACT      │ └────────────────────────┘
│ REUSE      │ │ shared base  │
└────────────┘ │ & specialize │
               └──────────────┘

Bad Pattern (Blind Duplication)

Creating DeleteConfirmModal.tsx with 150 lines of duplicate backdrop, CSS transitions, and keyboard event handlers when Dialog.tsx already exists.

Good Pattern (Clean Parameterization)

import { Dialog } from '@/components/ui/Dialog';

export function DeleteConfirmModal({ isOpen, onClose, onConfirm, itemName }: Props) {
  return (
    <Dialog
      isOpen={isOpen}
      onClose={onClose}
      title={`Delete ${itemName}?`}
      variant="destructive"
      onConfirm={onConfirm}
    >
      <p>This action cannot be undone.</p>
    </Dialog>
  );
}

4. When NOT to Reuse (Engineering Judgment)

Do NOT force reuse if:

  1. Security Risk: The existing code has known vulnerabilities, insecure deserialization, or lacks authorization checks.
  2. Obsolete / Deprecated Code: The existing component is marked @deprecated or scheduled for retirement in an ADR.
  3. Unwanted Coupling: Reusing it would couple two independent bounded domains (e.g., coupling Billing internals with Marketing).
  4. Brittle Complexity: Reusing it requires more than 3 boolean flags, fragile nested conditionals, or CSS !important overrides.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts3mo3 checks · Risk SAFE
  • Gen Agent Trust Hub3mo

    This skill provides a local search utility to help identify and reuse existing code components and functions within a project workspace, operating entirely offline without dangerous system calls.

  • Socket3mo

    No alerts

  • Snyk3mo

    Risk: LOW · No issues

Signed by skilld at 5711aad. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 3 months ago

README badge

README badge for amanktyr/tailor/reuse-first