logo

Where else can an enum prevent drift?

A recent experiment with my coding agent's instructions

Joel Clermont
Joel Clermont
2026-06-30

We reach for enums to stop magic strings from drifting through a codebase. It works great. All the values are grouped and defined in one place, and then throughout our code we can reference a single source of truth, preventing drift.

Recently I wondered if that same idea could help somewhere I had never tried it, my CLAUDE.md and Claude skills/commands.

It came up because I was refactoring some values and I noticed they existed in those Markdown files in addition to my single PHP enum. I could have just updated the values in Markdown, but isn't this the whole reason we have an enum, to prevent duplicating these values?

So as an experiment, I removed the values in Markdown and just referenced the path to the enum instead.

Here's an example for subscription types from our community:

When you need a subscription type, use the cases defined in app/Enums/SubscriptionType.php.
Read that file for the current list rather than assuming the values.

Obviously, Claude isn't parsing the enum like the PHP runtime does, but it has no trouble just reading the file when it needs to know what the values are.

This is an experiment, but so far it has gone quite well.

I exercised a few different skills, and it worked just as I hoped it would.

Here to help,

Joel

P.S. I would love to hear if you have tried any other interesting techniques with your coding agents like this. Join our community and share!

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice.