design-creative
Reuse-First: Make Your Agent Stop Duplicating Code
Scenario-driven guide to the reuse-first agent skill: search before writing helpers to keep your codebase lean.
Where this fits
You're mid-refactor and the agent starts adding another isActive() helper. You already have one in lib/status.ts, but the agent didn't look. Now you have two implementations drifting apart. The reuse-first skill solves this by forcing agents to search before writing any new helper, util, type guard, mapper, or small generic function. It makes the reuse decision explicit so your codebase doesn't accumulate near-identical logic.
Why agents benefit
- Searches before writing – the agent runs a codebase search first and must prove it did in one line, reducing duplicate helpers.
- Prefers import, then extract, then write – it chooses the least-code option instead of jumping straight to a new function.
- Owns only the reuse decision – it stops after placing the helper correctly, so it won't wander into feature implementation or load other skills.
- Handles repeated inline patterns – when the same guard like
if (object.isCancelled || object.isRefunded)appears twice, it extracts instead of copy-pasting. - Respects hard gates – no new package or helper without search, making agent behavior predictable and reviewable.
Practical scenarios
Adding a mapper for an API response
The agent needs to convert BackendUser to User. Instead of writing a new mapUser function, reuse-first searches and finds an existing mapper in selectors/user.ts. It imports that instead, keeping the mapping logic in one place.
Refactoring two functions that share a guard
While updating payment flows, the agent sees if (order.isCancelled || order.isRefunded) in both refund.ts and cancel.ts. The skill triggers, extracts the condition into isRefundableOrder, and places it in utils/order.ts so both call sites use it.
Adding a small generic type guard
When the agent is about to write Array.isArray(x) && x.every(...) to check a list of IDs, it first searches. It finds isIdList already in types/guards.ts and reuses it instead of creating a near-duplicate.
Add it to your agent workflow
Install the skill with one command:
npx skills add AlemTuzlak/skills --skill reuse-first
Then let it load when your agent is about to add a helper. For example, during a feature implementation, the agent will search first and report: "Found existing formatDate in utils/date.ts, importing instead of creating a new helper." That's the whole workflow: search, prove, reuse, stop.
Compare before adopting
Before adding it, compare with your current workflow: Does your agent already search for existing helpers? Does it have a clear rule for when to extract vs. write new? Check maintenance freshness – this skill is concise, but verify it aligns with your codebase's naming conventions and file structure. Also consider alternatives like enforcing reuse via lint rules or custom prompts. The skill shines when you need consistent, enforced behavior across many agent sessions.
Why it is worth tracking
With 39 stars and a clear, focused README, it's an early but well-scoped skill. The hard gates and narrow ownership make it easy to evaluate without ceremony. Track it if you're tired of deleting duplicate helpers after agent-driven changes. For the full context and future updates, see the reuse-first skill page.
Featured Skill
reuse-first
Skill by AlemTuzlak