# Extract a utility duplicated across three or more files

The same helper written three times, extracted once with the differences reconciled deliberately.

Category: Refactors and cleanup
Source: https://letsship.ai/use-cases/extract-a-duplicated-utility
Published: 2026-08-25

## Goal

Extract a duplicated utility into one implementation and migrate every caller.

## Acceptance criteria

- One implementation remains, with tests
- Every caller uses it
- Differences between the copies are reconciled explicitly and noted
- All touched tests pass

## What lands as proof

The deleted copies in the diff, plus tests covering every behaviour the copies had between them.

## Prompt

Copy this to an agent to open the ticket:

```text
Create a Linear issue in my team and assign it to the SHIP agent.

Title: Extract the duplicated {utility}

Description: Extract a duplicated utility into one implementation and migrate every caller.

Acceptance criteria:
- One implementation remains, with tests
- Every caller uses it
- Differences between the copies are reconciled explicitly and noted
- All touched tests pass

Before you create the issue, search this repository for near-identical helper functions and replace {utility} with the most duplicated.
```

## Questions

### What does the agent actually change?

The ticket is scoped to one outcome: extract a duplicated utility into one implementation and migrate every caller. Work that serves that outcome is in scope, and anything outside it is left for a separate ticket, so the pull request stays reviewable.

### How do I know the work is done?

The pull request carries the evidence, not only the diff. Here that means one implementation with tests, every caller migrated, so a reviewer can confirm the result without reproducing the work locally.

### How much oversight does this need?

None is required before the run starts. Every claim this ticket makes can be checked by machine, so the agent works straight through and a person reviews the finished pull request like any other.
