home/roleplay/skill-17

SKILL

GPTClaudeGemini··1,138 copies·updated 2026-07-14
skill-17.prompt
---
name: reuse-before-create
description: DRY discipline core. Before creating anything new, find what already exists. Every coding skill inherits this.
category: meta
version: 0.1.0
triggers: ["writing code", "adding component", "adding util", "adding type", "creating file", "new helper", "new hook"]
applies_to: [openclaw, cursor, claude-code, generic]
---

# Reuse Before Create

The single most consistent way AI coding agents degrade a codebase is by creating new
artifacts when existing ones would do. New components instead of props. New utilities
instead of imports. New types instead of references. The codebase doubles in volume,
quality halves, and every requirement change now means N edits instead of one.

This skill is the central rule for that. Every coding skill in this pack inherits it. It
is not aspirational; it is a precondition for any code-creating action.

## When to use

Always, whenever you are about to write a new component, function, hook, util, type,
constant, schema, configuration, or dependency. This is a precondition step, not an
optional review.

## The rule

**Before writing anything new, search for what already exists. Reuse first; create last.**

The order of preference is strict and non-negotiable:

1. **Reuse as-is** — existing artifact fits, import and use
2. **Extend** — add a prop, option, generic, or branch to existing artifact
3. **Compose** — combine existing artifacts into a new shape without rewriting them
4. **Extract** — pull a shared core out of two near-duplicates; both use the new core
5. **Create new** — only when none of the above apply

Each step further down costs more — both in code volume and in long-term maintenance.
Skipping straight to "create new" without proving the prior steps don't apply is the
default failure mode this skill prevents.

## Justification is not optional

When you do create something new, **a one-line justification is mandatory**, not a
nice-to-have. It belongs in the commit message, the PR description, the handoff, or as
an inline comment near the new artifact. Format:

> *"Created `formatDateTz`: no existing util handles ISO date with timezone offset; the
> project's `formatDate` strips the zone."*

This rule applies to every kind of new artifact: component, hook, util, type, constant,
schema, dependency, file, folder.

If you can't write the justification in one sentence, you haven't searched hard enough.
Go back to step 1.

## How to actually search

The most common excuse for skipping reuse is "I looked and didn't find it." That usually
means the search was shallow. Effective searches:

### By artifact type

| Looking for | Search strategy |
|---|---|
| **UI component** | grep `<ComponentName`, check `components/`, `components/ui/`, `shared/`, `design-system/` |
| **Hook** | grep `use*` prefix, check `hooks/`, `lib/hooks/` |
| **Utility** | grep verb prefix (`format*`, `parse*`, `validate*`, `is*`, `to*`), check `lib/`, `utils/`, `helpers/` |
| **Type / interface** | grep `interface ` or `type ` for the shape, check `types.ts`, `schema.ts`, `models.ts` |
| **Constant / enum** | grep the value or its semantic name, check `constants.ts`, `config.ts` |
| **Schema / validator** | grep `z.object`, `Yup.object`, `pydantic`, check `schema.ts`, `validation.ts` |
| **API endpoint / route** | grep the path, check `routes/`, `api/`, `pages/api/`, `app/api/` |
| **Data hook / query** | grep the resource name, check `api/`, `data/`, `queries/`, `hooks/` |
| **Style class / token** | grep the class string or hex value, check `theme.ts`, `tokens.ts`, `tailwind.config` |

### Concrete commands

Default tool is `rg` (ripgrep). Fall back to `grep -rn` if `rg` is unavailable. Always
run from repo root, not from a feature folder.

when to use it

Community prompt sourced from the open-source GitHub repo Ozzeron/prompt-pack (MIT). A "SKILL" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

roleplaycommunitygeneral

source

Ozzeron/prompt-pack · MIT