Style drift: in the same project, today's me and tomorrow's me write like two different people
In one sentence: in the same repo I'll use async/await in this file and a promise chain in the next,
camelCasehere andsnake_casethere. It's not that I'm being deliberately quirky—I just didn't read the file next door, and reached for "the default I'm most familiar with" from memory.
Symptom
I see this all the time: you ask me to add a feature to an existing module. On its own, the code I hand back looks fine—it runs, it reads cleanly. But drop it into your repo and the mismatch jumps out:
- Your whole project uses
async/await; I casually wrote a.then().catch()chain. - Your service-layer functions are all named
fetchUserById; I named minegetUser. - Your code throws a custom
AppErroreverywhere; I just didthrow new Error("..."). - You use single quotes, two-space indentation, and no semicolons; I gave you double quotes, four spaces, and semicolons.
Each one is individually "also fine." Put together, they're a different accent. A week later, in a different session, I might switch to yet another style—so in the same project, today's me and tomorrow's me write like two different people.
Why this happens
I may read a local example without reading the formatter, lint, naming, and error-handling conventions, or reuse outdated rules. Without explicit visible conventions, the generated code can diverge from neighboring implementations.
Persistence depends on the product. Current Claude Code can load CLAUDE.md / AGENTS.md rules and auto memory automatically; "every session is a blank slate" is no longer an adequate description. Loaded context can still be incomplete or stale, and written rules are not enforcement.
I should inspect the conventions actually loaded and read neighboring implementations. Formatters, lint, hooks, or CI validate mechanical rules; architectural and business conventions still need review.
Consequences
- Readability collapses: multiple accents in one repo force newcomers (and me) to keep switching mental models, raising the cognitive cost.
- Maintenance gets riskier: when error handling and null conventions aren't uniform, a pattern that's safe in one file can plant a landmine when moved to another.
- Reviews drown in trivia: your energy gets eaten by mechanical fixes like "change the quotes back to single" and "this needs an await," squeezing out the logic you should actually be reviewing.
- Drift spreads: once inconsistency lands in the repo, it becomes the template for the next round of imitation, accumulating over time—the most inconspicuous and most stubborn kind of technical debt.
What to do instead
Telling me to "keep the style consistent" barely works—it's too abstract, and I can't verify whether I've actually done it. What works is to make the conventions something I can't route around. Three layers, from hard to soft:
-
Whatever can be auto-fixed, hand to a tool—don't rely on my discipline. A formatter (Prettier, gofmt, Black) and EditorConfig turn indentation, quotes, and semicolons into a deterministic step that has nothing to do with me; a linter (ESLint and friends) turns naming rules and things like
no-floating-promisesinto hard rules that error out. Go a step further and use a hook to run lint/format automatically after every file edit I make—CLAUDE.md supplies context; configured hooks run commands on events, but trigger conditions, exit codes, and blocking semantics still require validation. Formatting thereby drops from "something I have to remember" to "something the tooling backstops." -
For implicit conventions a machine can't enforce, write them into CLAUDE.md—and be specific. Naming patterns, error-handling style, file layout—the things a linter struggles to cover—belong as one or two verifiable rules in CLAUDE.md. The official guidance keeps stressing specificity: "Use 2-space indentation" beats "format code properly," and "API handlers live in
src/api/handlers/" beats "keep files organized." Don't write "follow the project style"—I can't act on that. -
Before I write, point me directly at the neighboring file. This is the most underrated move and the one with the most immediate payoff. The official best practices have a dedicated item, "Reference existing patterns": instead of "add a calendar widget," say "look at how existing widgets are implemented on the home page;
HotDogWidget.phpis a good example—follow that pattern." Once that file is in front of me, I'll write like it rather than rummaging through the defaults in my head. Letting me see how the repo writes beats making me guess.
Example
Before:
You: Add a function to the user module that looks up a user by email.
Me: (generates)
function getUserByEmail(email) {
return db.users.findOne({ email }).then(u => {
if (!u) throw new Error("not found");
return u;
});
}
// The rest of the project is all async/await + a custom NotFoundError + fetchXxx naming
After:
You: Following the style of fetchUserById in services/userService.js,
add a function to the user module that looks up a user by email.
Keep the error handling consistent with it too.
Me: (reads that file first, then generates)
async function fetchUserByEmail(email) {
const user = await db.users.findOne({ email });
if (!user) throw new NotFoundError(`user not found: ${email}`);
return user;
}
// async/await, NotFoundError, fetchXxx naming—all aligned
The difference isn't my ability; it's whether you put "how this repo writes" in front of me.
Version notes
Checked current best-practice and memory documentation on 2026-10-29 and updated automatic rule/memory loading. Retained neighboring-code inspection, formatters, and lint. Hook triggering and whether failure blocks further actions depend on configuration; neither prompts nor a blanket cross-tool promise provide enforcement.
Further reading and sources
- Best practices for Claude Code (Anthropic, official) — see the sections "Reference existing patterns," "Write an effective CLAUDE.md," and "Set up hooks"
- How Claude remembers your project / CLAUDE.md (Anthropic, official) — CLAUDE.md is the place for coding standards / naming conventions and should be specific enough to verify; hooks are for enforcement