# Extend Not Duplicate

> Use when about to write a new script, command, or file that is near-identical to an existing one with small variations — adds a CLI flag, parameter, or config option to the existing script instead of creating a parallel copy.

- Skill: `amitkot/extend-not-duplicate` (Agent Skill)
- Install (CLI): `npx skillmds@latest add amitkot/extend-not-duplicate`
- Raw SKILL.md: https://api.skillmd.com/api/skills/amitkot/extend-not-duplicate/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: amitkot (https://skillmd.com/u/amitkot)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/amitkot/extend-not-duplicate

---


# Extend existing scripts; don't duplicate them

If you're about to write a new script that's >80% the same as an existing one with small differences (different env, different mode, different flag combo), extend the existing one with a CLI argument or config option instead of writing a parallel copy.

## Why

Two near-identical scripts diverge over time. A bug fix lands in one and not the other. A new feature gets added inconsistently. Reviewers can't tell which is canonical. The duplicated logic compounds with every change.

## How to apply

When you notice you'd be copying an existing script and changing a few values:

- Identify what's actually different — usually a flag, env var, or config field.
- Add that as a CLI arg (`--mode prod` / `--target dev`) or env knob to the existing script.
- Update callers if needed.

If the differences are structural (different control flow, different inputs, different outputs), then a separate script IS appropriate — but check first whether the structural difference can be expressed as a parameter.

