Configuring Claude Code with CLAUDE.md
How to get AI agents to write better code consistently
- Article
- Data Engineering
- Data Science
- AI


There is a clear difference between teams that occasionally achieve decent results with Claude Code and teams that consistently produce high-quality output. That difference rarely comes down to better prompts. In practice, it is usually something more fundamental: the rules and expectations you establish before the agent starts writing.
With the current generation of models, the nature of the work has shifted. You are no longer just writing code—you are also directing the behaviour of the agent that writes the code. Recently, Andrej Karpathy described this as Agentic Engineering: the logical next step beyond what is often referred to as “vibe coding”.
Without explicit boundaries, an agent falls back on patterns learned from its training data. The result is often generic solutions, unnecessary complexity, and technical choices that may be correct in isolation but do not fit your project or team.
The solution is not more prompts. It is one file.
Why Claude Code goes off track without context
Coding agents have a strong tendency to align themselves with what they believe the user expects. Even when the correct response should actually be: this does not make sense or there is information missing.
This behaviour is visible in benchmarks such as the Bullshit Benchmark, where models are more likely to validate incoherent input than challenge it.

In code, this often manifests as overengineering: additional logic, extensive error handling or architectural layers that nobody requested.
This does not happen because the model is unintelligent. It happens because the model has no explicit definition of what “good” looks like within your repository.
Without clear context, Claude Code fills those gaps itself. Those assumptions are based on patterns it has most frequently encountered during training, not on your technology stack, standards or team agreements.
CLAUDE.md as a behavioural baseline for AI agents
CLAUDE.md addresses this problem. The file sits in the root of your project and contains the standards, boundaries and behavioural rules that should always apply. Claude Code automatically reads it at the start of every session.
Functionally, you can think of it as an .editorconfig file, but for agent behaviour rather than code formatting.
Although this article focuses on CLAUDE.md, the same principle applies to other AI coding agents. Similar files exist in other ecosystems, such as AGENTS.md.
By defining these rules at project level, there is no need to repeat them in every prompt. In practice, this leads to:
- More consistent architectural decisions
- Fewer surprises during code reviews
- Less time spent correcting solutions that are almost—but not quite—appropriate
Why fewer rules produce better results
One crucial point is often overlooked: CLAUDE.md is included with every API call as part of the system prompt.
A file containing 2,000 tokens that is sent 40 times results in 80,000 input tokens being consumed purely by instructions. Those tokens also compete with the actual code context the model needs to work with.

Even the latest models show performance degradation when context windows become overloaded.
Recent research supports this. One study found that large quantities of generic, AI-generated instructions can produce worse results than having no rules at all.
What to include in CLAUDE.md — and why
Effective CLAUDE.md files generally contain three categories of rules.
Hard technical constraints
These are decisions the agent must not deviate from:
- Programming languages
- Frameworks
- Architectural principles
- Established coding conventions
## Hard Limits
- Functions: <= 100 lines
- Cyclomatic complexity: <= 8
- Positional parameters: <= 5
- Files: <= 500 linesThese rules prevent the agent from introducing “helpful” alternatives that do not fit your codebase.
Stack and tooling
Without explicit guidance, agents default to what they have seen most frequently in training data.
That is how you end up with pip install recommendations when your team uses uv, or suggestions for black when your standard is ruff.
## Python Tooling
- Package manager: uv
- Linting + formatting: ruff
- Type checking: ty
- Testing: pytest
These rules are simple to document but often provide immediate quality improvements.
Behavioural guidelines
This is often the most underestimated category.
Here you define how the agent should reason:
- When refactoring is appropriate
- How uncertainty should be handled
- When clarification should be requested instead of making assumptions
These rules are what distinguish merely correct output from output that is genuinely useful.
CLAUDE.md is a living document, not a checklist
You do not create a CLAUDE.md file once and forget about it.
In practice, it acts as a feedback mechanism. If the agent repeatedly makes the same mistake, add a rule. If a rule has little measurable effect, remove it.
Over time, this creates a compact set of guidelines that provides exactly enough direction without burdening the model with unnecessary context.
For teams using AI systematically in software development and data environments, this is a natural step towards mature adoption. Not by writing more prompts, but by clearly defining what “good” means before the agent begins.
Looking to use AI agents effectively?
Want to embed AI coding agents into your organisation in a structured and sustainable way? We help teams establish technical standards, governance frameworks and practical AI use cases that deliver real value. Get in touch or schedule a meeting to discuss the possibilities.
This is an article by Paul Hoekstra
Paul is a Data Engineering Consultant at Digital Power. He focuses on building automated data pipelines, scalable data models and reliable ETL transformations. With a hands-on and analytical approach, he helps organisations turn complex data landscapes into clear insights that truly make a difference.
Receive data insights, use cases and behind-the-scenes peeks once a month?
Sign up for our email list and stay 'up to data':