# Check what breaks before you delete code

Before you remove a function, file or setting, have Claude Code list its callers and downstream effects, and say whether removal is safe.

Paste into: **Claude Code**, started in your project folder

## Prompt template

How the builder on the page fills in this template, so you can do the same:

- `{{key}}` becomes the text entered for that field, exactly as typed. Empty text, or text that is only whitespace (spaces, tabs or line breaks), counts as empty: a required field then becomes `[fill in: <label>]` with its label, and an optional field becomes nothing.
- For a choice field, `{{key}}` becomes the text of the chosen option, or of the default when none is chosen.
- Text between `{{#key}}` and `{{/key}}` stays only when that field is not empty; a choice field always counts as filled. The markers themselves are removed, and a marker that stands alone on its line takes its line break with it.
- Each value is inserted once, as it is: `{{…}}` inside a value stays as typed.

```text
What would break if I deleted {{target}}?
{{#reason}}
Reason for deleting it: {{reason}}
{{/reason}}
{{#outside}}
It may also be used outside this repository, in: {{outside}}
{{/outside}}

Only read. Do not delete, rename or edit anything to find out. If a build or type check would reveal more callers, tell me the command instead of changing code.

Look for:
- Direct references: imports, calls and subclasses, with file path and line.
- Indirect uses: names built from strings, reflection, dependency injection, config files, scripts, docs and generated code.
- Public exposure: exported APIs, routes or packages that other projects could depend on.
- Tests that use it, and tests that would start failing.

Then give me:
1. A verdict: safe to remove now, remove only with coordinated changes, or keep for now.
2. The reason for the verdict, pointing at the references above.
3. If it is not a simple cleanup, the steps to remove it safely and in what order.
4. What you could not check, such as other repositories or deployed systems, and how I could check it.
```

## Fields

- `{{target}}` (required): What you want to delete. A function, class, file, endpoint, config key or feature flag. Include the file path if the name is common.
- `{{reason}}`: Why you want to delete it. Optional. Helps Claude judge whether a caller still needs what it provides.
- `{{outside}}`: Places outside this repository that might use it. Optional. Claude cannot see these, but it will flag what it cannot check.

This site doesn't run Claude or show model output. Results depend on your input and the model you use.

## When to use this template

- A function, file, endpoint, config key or feature flag looks unused, and before removing it you want to see who depends on it and how much other work its removal would cause.
- The name is used in ways a plain text search can miss, such as dynamic lookups, config files or generated code.
- You are cleaning up dead code in an area you do not know well and want evidence before you delete anything.

## When not to use it

- You have already decided to remove it and want the work done. Ask for a plan or the change itself, and keep the tests as the check.
- Most of its consumers live in systems Claude Code cannot see, such as other teams' repositories or a public API with outside users. Use your usage logs or ask the owners; Claude can only report what is in reach.
- You are in a plain chat without access to the project. Without the code, a list of callers would be invented.

## Why this structure

- The question opens with the exact thing to delete, so the whole answer is about one target and its dependents.
- The read-only rule includes not deleting code to see what fails. That keeps your working tree clean, and the command Claude names instead lets you run the same check yourself.
- The four kinds of use to look for go beyond direct calls. Indirect uses through strings, config and generated code are the ones a quick search tends to miss.
- The verdict comes with three fixed choices, followed by the evidence for it, so you get a decision you can act on rather than a long list of matches.
- The optional field for outside consumers, together with point 4, makes Claude say what it could not check. A clean result inside the repository does not mean nothing else depends on the target.

## Example input (fictional)

What you want to delete:

```
the retryWithBackoff helper in src/net/retry.ts
```

Why you want to delete it:

```
The HTTP client now retries failed requests on its own.
```

Places outside this repository that might use it:

```
the nightly import scripts on the batch server
```

## Follow-ups to send Claude

- Go ahead with the removal steps you listed. Run the tests after each step and stop if something fails that you did not predict.
- Mark it as deprecated first: add a warning where it is called, and list the callers I need to migrate.
- Write a short note for the teams that may depend on it, saying what is being removed, when, and what to use instead.

## Common mistakes

- Giving a name that is not unique. If several things share it, add the file path so Claude checks the right one.
- Trusting a clean result for code that is exported or exposed as an API. Other projects can use it without appearing anywhere in this repository.
- Letting Claude delete the code to see what fails. Keep the check read-only, and do the removal as a separate step once the verdict is clear.

## Related templates

- [Find where something happens in the code](https://awesomeclaudeprompts.com/prompts/find-where-code-happens/): Describe a behavior and let Claude Code find the code that does it, with file paths, the path that leads there and any duplicate implementations.
- [Plan a code change before editing](https://awesomeclaudeprompts.com/prompts/plan-code-change/): Have Claude Code read the relevant code and propose a file-by-file plan for a multi-file change, without editing anything until you approve it.
- [Migrate a pattern across a codebase](https://awesomeclaudeprompts.com/prompts/migrate-code-pattern/): Move every use of an old API, library or pattern to its replacement: Claude Code lists each place first, then changes them in checked batches.

## Sources

- [Claude Code docs: Prompt library](https://code.claude.com/docs/en/prompt-library) (Anthropic documentation)
- [Claude Code docs: Common workflows, find relevant code](https://code.claude.com/docs/en/common-workflows#find-relevant-code) (Anthropic documentation)
- [Claude Code best practices: Explore first, then plan, then code](https://code.claude.com/docs/en/best-practices#explore-first-then-plan-then-code) (Anthropic documentation)

---

Awesome Claude Prompts is an independent project. It is not affiliated with, endorsed by, or sponsored by Anthropic. Claude is a trademark of Anthropic, PBC.
