You ask the AI to fix a bug, and it introduces three new ones. You ask it to add a feature, and it rewrites your entire tech stack. You sit there, staring at the screen, absolutely convinced your AI coding assistant has lost its mind.
But here’s the thing: the AI isn’t stupid. You’re just using it wrong.
Every time the AI starts a new session, it knows absolutely nothing about your project. It doesn’t know your tech stack, your code conventions, or why you made certain architectural decisions. The AI is a blank slate. If you make it guess, it will guess—and it will guess wrong, burning your tokens and your sanity.
You keep blaming the AI for ‘unpredictable behavior.’ The real bottleneck isn’t the model’s lack of intelligence or your lack of prompting skills. It’s context engineering.
The solution isn’t a better prompt. It’s a better onboarding document. In the world of Claude Code, it’s called a CLAUDE.md file. In Cursor, it’s an AGENTS.md. It’s essentially an onboarding manual written specifically for your AI assistant.
The AI’s ability to follow instructions doesn’t depend on how fancy your prompt is. It depends on how ruthless your project’s onboarding documentation is.
But here is the twist that trips up most developers: more context isn’t better. It’s worse.
You might think dumping 400 lines of rules into a config file makes the AI super capable. In reality, you’re just confusing it. Studies show that when a rules file stays around 50 lines, AI adherence is about 94%. But when you bloat it to 400 lines, adherence plummets to 71%. The more instructions you add, the more it ignores—all of them.
This is the Goldilocks problem. AI needs precise instructions to avoid errors, but too many instructions degrade its performance. You have to cut the fluff.
A good CLAUDE.md file isn’t a novel. It’s a sniper’s briefing. Be precise, or be ignored.
So, what should you actually write? Only what the AI cannot guess. Don’t tell it how to write clean TypeScript—it already knows that. Tell it about your specific API response format. Tell it your weird Git branch naming convention. Tell it about the hidden traps that reading the code alone won’t reveal.
And when writing those rules, stop using negative statements. If you write ‘Don’t use semicolons,’ the AI sees the word ‘semicolons’ and is more likely to output them. It’s exactly like the white bear problem in psychology. Telling an AI ‘Don’t use semicolons’ is like telling a human not to think of a white bear. It just generates more semicolons.
Instead, use positive, verifiable instructions. Don’t say ‘Properly format code,’ say ‘Use 2-space indentation.’ Don’t say ‘Test your changes,’ say ‘Run npm test before committing.’ The more specific you are, the easier it is for the AI to judge whether it’s complying.
For large projects, don’t try to cram everything into the root config file. Use path-specific rules so the context only loads when the AI is actually editing files in that directory. Use @import for progressive disclosure—tell the AI where to find information rather than force-feeding it all at once.
The ultimate goal is to treat this config file as a living document. Every time the AI screws up, don’t just fix the error. Have it write the correction into the CLAUDE.md. Over time, you’ll build a customized knowledge base that turns a generic language model into an elite team member who knows your project inside out.
We used to write README.md for humans. Now we write CLAUDE.md for AI. If you haven’t written one for your project yet, you’re actively wasting your own time. Start with a simple 20-line file, and you’ll feel the relief immediately.
FAQ
Q: Isn't AI supposed to be smart enough to just read my code and figure it out?
A: No. AI starts every session as a blank slate. While it can analyze code, doing so for every single session wastes context and tokens. Explicitly stating your rules saves it from guessing and prevents massive rework.
Q: What's the practical implication of the 50-line rule?
A: Stop treating your config file like a documentation dump. If a rule doesn't directly prevent the AI from making a specific mistake, delete it. Less context means higher adherence.
Q: Is prompt engineering dead then?
A: It's evolving. Prompt engineering is about asking for what you want in the moment. Context engineering is about building a persistent environment where the AI inherently knows what to do. The latter scales much better.