Find deprecated model IDs in your code: a free grep method
When a provider announces a retirement, the first question is “where do we use it?”. You can answer most of that in ten minutes with ripgrep (rg) and a list of names. This guide shows the method, the places it usually misses, and how to keep it running in CI. No product required.
Step 1: build the list from the provider's page
Copy model names and IDs from the provider's own deprecation page, not from a blog post or memory. For Anthropic that is Anthropic model deprecations; for OpenAI, OpenAI deprecations. Note the retirement date next to each one; you will need it to decide what to fix first.
As an example, these Anthropic models were retired or scheduled for retirement between October 2025 and November 2026 (from Anthropic's page, last verified 6 October 2026):
| Model | Retired or retiring |
|---|---|
| Claude Sonnet 3.5 (two IDs) | October 2025 |
| Claude Opus 3 | January 2026 |
| Claude Sonnet 3.7, Claude Haiku 3.5 | February 2026 |
| Claude Haiku 3 | April 2026 |
| Claude Sonnet 4, Claude Opus 4 | June 2026 |
| Claude Opus 4.1 | August 2026 |
| Claude Sonnet 4.5 | 30 November 2026 |
Step 2: turn names into tolerant patterns
The same model appears in code with different separators and cases: dashes in API IDs, dots in comments, spaces in docs. Write one pattern per model that tolerates them. For Claude Sonnet 4.5:
sonnet[-_. ]?4[-_.]5Combine patterns into one search, case-insensitive, with line numbers:
rg -n -i \
-e "sonnet[-_. ]?4[-_.]5" \
-e "opus[-_. ]?4[-_.]1" \
-e "haiku[-_. ]?3[-_.]5" \
--glob '!node_modules' --glob '!vendor' --glob '!dist' --glob '!*.lock'Be careful with short patterns. A pattern for “Opus 4” also matches “Opus 4.1” and newer 4.x versions, so anchor it: opus[-_. ]?4(?![-_.]?\d) needs rg -P for the look-ahead.
Step 3: include the file types grep users forget
By default, ripgrep respects .gitignore and skips hidden files. Model IDs often live outside the main source tree:
- Infrastructure:
.tf,.tfvars, Helm values, deployment YAML. - Environment templates:
.env.examplefiles (search with--hidden). - Notebooks:
.ipynbfiles are JSON, so a text search works, but the hit is inside a long line. Add--max-columns 200to keep output readable. - Prompt and eval configs: YAML or JSON files that pair a prompt with a model.
Run the search across every repository the team owns, not just the main one. A simple loop over a folder of clones is enough for a one-off audit.
Step 4: run it in CI so IDs don't come back
A one-off search fixes today. A CI step stops new references to retired IDs. A minimal version fails the build if any pattern matches:
# .github/workflows/model-ids.yml (one step)
- name: Block retired model IDs
run: |
if rg -n -i -f .retired-model-patterns.txt --glob '!*.md' .; then
echo "Retired model ID found. See the provider's deprecation page."
exit 1
fiKeep the patterns in .retired-model-patterns.txt, one per line. Ripgrep treats every line in that file as a pattern, so don't put comments in it; record the source URL and date for each pattern in a separate README next to it.
Where grep falls short
- Runtime-built IDs. If code assembles the model name from parts, no text search will find it. Anthropic's usage export (what you actually called) covers some of this gap.
- Keeping the list current. The pattern file is only as good as the last time someone updated it. Notices in 2026 gave about 60 days, so a quarterly review is too slow.
- Platform dates. The same model can retire on different dates on Bedrock or Vertex. See why dates differ.
- Parameters. Some breaks are not the model ID but a request parameter, such as sampling parameters on Claude 4.7+.
If the grep method covers your needs, keep using it. If you want the list maintained and the results posted as a GitHub issue with dates and sources, that is what SunsetLint does. To prevent the problem at the source, see keeping model IDs in one place.