# Replace magic numbers and repeated string literals with named constants

Unexplained numbers and repeated literals given names, so the next reader does not have to guess.

Category: Refactors and cleanup
Source: https://letsship.ai/use-cases/replace-magic-numbers-with-constants
Published: 2026-08-25

## Goal

Replace magic numbers and repeated string literals in one module with named constants.

## Acceptance criteria

- Each value is named for what it means rather than what it is
- The constant is used at every site that had the literal
- Behaviour is unchanged
- Values that differ only by coincidence are not merged

## What lands as proof

An unchanged test suite plus a diff where each literal became a name, not a shared name for unrelated values.

## 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: Name the magic values in {module}

Description: Replace magic numbers and repeated string literals in one module with named constants.

Acceptance criteria:
- Each value is named for what it means rather than what it is
- The constant is used at every site that had the literal
- Behaviour is unchanged
- Values that differ only by coincidence are not merged

Before you create the issue, find a module in this repository with repeated unexplained literals and replace {module}.
```

## Questions

### What does the agent actually change?

The ticket is scoped to one outcome: replace magic numbers and repeated string literals in one module with named constants. 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 behaviour unchanged, the constant used at every site, 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.
