Sitemap

Context Engineering

How Scaffolding Helps Prevent AI Code Bloat

Imagine hiring a junior developer who can write code extremely fast.

Now imagine that every time you ask them to add a small feature, they ignore what already exists in your project.

Instead of reusing your components, they create new ones.

Instead of following your design system, they add their own styles.

Instead of using your existing utilities, they write another version.

They may even install new packages without checking whether the project already has something that can do the same job.

After a while, the codebase starts getting bigger, harder to understand, and more difficult to maintain.

This is one way code bloat can happen when working with AI coding assistants.

The problem is not always that the AI cannot write code.

Sometimes, it simply does not have enough context about the project it is working inside.

That is where Context Engineering comes in.

What Is Context Engineering?

In simple terms, Context Engineering is the process of giving an AI coding assistant the right information before it starts working.

Instead of explaining your entire project every time you write a prompt, you can create supporting files that explain things like:

  • how the project is structured
  • which technologies are being used
  • which components already exist
  • coding rules the AI should follow
  • things the AI should never change without permission

You can think of these files as the instructions a new developer would receive before joining a team.

The goal is simple:

Give the AI enough context so it does not have to guess.

Why AI Code Bloat Happens

When an AI coding assistant does not fully understand your project, it may make reasonable guesses.

The problem is that those guesses may not match your existing codebase.

For example, it might:

Create duplicate components

You may already have a reusable button component, but the AI creates another one instead of using it.

Add unnecessary dependencies

The AI might install a new package for something your project can already handle.

Duplicate existing logic

You may already have a utility for formatting dates, checking permissions, or handling forms, but the AI creates another version.

Add code that is never used

Unused functions, imports, and temporary workarounds can slowly build up over time.

None of these problems may seem serious on their own.

But when they happen repeatedly, the project becomes harder to maintain.

Press enter or click to view image in full size

How Scaffolding Helps

Scaffolding simply means preparing the environment the AI will work inside.

For example, imagine asking an AI assistant:

“Build a user profile card with an edit button.”

Without much context, the AI may decide everything for itself.

Get Dave Hennit’s stories in your inbox

Join Medium for free to get updates from this writer.

It could create its own styles, install a modal package, invent a new way to manage state, and build components that already exist in the project.

The feature may work, but it may not fit the rest of the application.

Now imagine the project already contains a rules file like this:

rules.md:

- Use React, TypeScript and Tailwind CSS.
- Do not install new packages without approval.
- Reuse components from `@/components/ui`.
- Follow the existing user profile data structure.
- Run linting and tests before completing the task.

Now the AI has more direction.

Instead of inventing everything from scratch, it can:

  • reuse the existing Avater, Card, and Button components
  • use the project’s existing Tailwind tokens
  • follow the current user profile structure
  • avoid adding unnecessary packages
  • check its work against the project’s existing standards

The prompt itself can stay simple.

The project context handles the rest.

Without Context vs With Context

Without Context Engineering

The AI depends heavily on guesses.

Prompts often become long because you have to keep repeating the same project information.

It may create duplicate code, introduce unnecessary packages, or use patterns that do not match the rest of the project.

With Context Engineering

The AI already has access to important project instructions.

Your prompts can focus on the task itself.

The assistant is more likely to reuse existing code, follow your architecture, and stay within the boundaries you have already defined.

Two Useful Rules

There are two ideas that make this easier to understand.

1. Separate the task from the project instructions

Your prompt should describe the thing you want the AI to do.

For example:

“Add an edit button to the user profile card.”

Your project files should explain how that work should be done.

This means you do not need to repeat your tech stack, coding style, testing requirements, and architecture in every prompt.

2. Tell the AI what it should not do

Good context is not only about telling the AI what to do.

It should also define boundaries.

For example:

  • Do not install new dependencies without approval.
  • Do not create a new component if an existing one can be reused.
  • Do not change the database schema without checking first.
  • Do not use raw colors when design tokens already exist.

These rules reduce unnecessary decisions and help keep the codebase consistent.

Prompting tells the AI what task to do.

Context Engineering helps the AI understand how that task should fit into your project.

The better the context, the less the AI has to guess.

I am a passionate product designer learning to leverage AI to build solutions, solve problems, and help emerging businesses grow.

See more from me