arrow-return

How To Actually Code With AI. Context Windows, MCPs, and Smarter Workflows

An image of Yuri Silva, the author of this post
10 min read

Share


Coding with AI is less about replacing developers and more about collaboration. Modern AI systems can write code, explain unfamiliar libraries (more with the power of MCPs, such as Context7), refactor messy logic, generate tests, and even reason about entire projects. But only when they’re given the right structure, context, and rules.

Context Is Everything

AI models operate within a context window: the amount of information they can “see” at one time. At a technical level, AI models like GPT or Claude make decisions based on everything in their context window. This includes:

  • Your prompt

  • Recent conversation history (if included in the context, obviously)

  • Files, code snippets, or documentation you provide

  • Information from MCPs (which can quickly fill the context window, if not handled properly)

This “window” has a limit: it’s tempting to think that a bigger context window automatically leads to better results, after all, modern models can handle hundreds of thousands or even millions of tokens. But this is not true. As Drew Breunig explains, simply dumping more information into the context can hurt performance rather than help it.

Key ways contexts can fail:

  • Context Poisoning: When an error (such as a hallucination) gets embedded in context and then gets referenced again and again, causing the agent to build on false assumptions.

  • Context Distraction: When the context becomes so expansive that the model focuses on irrelevant history instead of the task, neglecting what it learned during training.

  • Context Confusion: When extra, unnecessary information (like too many tool definitions or documents) distracts or misleads the model.

  • Context Clash: When conflicting or contradictory bits of information enter the context, confusing the model’s reasoning.

You can avoid these problems by removing irrelevant information from the context (better prompts), starting different chats for specific tasks instead of writing everything on the same chat and selecting only the minimal relevant information for the task (like not using MCPs when not necessary).

Adding more to the recipe

Rules

To improve workflows, you can rely on rules and conventions, such as those found in a AGENTS.md file, to standardize behavior. These rule files define things like expected style, error handling, security boundaries, and how agents should behave in edge cases. Establishing these rules helps the model align with human expectations and reduces ambiguity.

AGENTS.md example from AGENTS.md

# Sample AGENTS.md file
## Dev environment tips
- Use pnpm dlx turbo run where <project_name> to jump to a package instead of scanning with ls.
- Run pnpm install --filter <project_name> to add the package to your workspace so Vite, ESLint, and TypeScript can see it.
- Use pnpm create vite@latest <project_name> -- --template react-ts to spin up a new React + Vite package with TypeScript checks ready.
- Check the name field inside each package's package.json to confirm the right name—skip the top-level one.
## Testing instructions
- Find the CI plan in the .github/workflows folder.
- Run pnpm turbo run test --filter <project_name> to run every check defined for that package.
- From the package root you can just call pnpm test. The commit should pass all tests before you merge.
- To focus on one step, add the Vitest pattern: pnpm vitest run -t "<test name>".
- Fix any test or type errors until the whole suite is green.
- After moving files or changing imports, run pnpm lint --filter <project_name> to be sure ESLint and TypeScript rules still pass.
- Add or update tests for the code you change, even if nobody asked.
## PR instructions
- Title format: [<project_name>] <Title>
- Always run pnpm lint and pnpm test before committing.

Usually, you create this file at the root of the project.

Model Context Protocol (MCP)

MCPs allow an AI to interact with real tools and services instead of just imagining them or relying on what the model learned during training. However, they also increase the complexity of the context the model needs to manage.

For example, imagine you’re coding a design from Figma and sending screenshots to Claude for reference. You could significantly improve this workflow by using the Figma MCP. Rather than relying on inaccurate margins, paddings, or text details inferred from images, the model would receive precise, structured data directly from Figma.

Several tools already provide MCP support, including Figma, shadcn, Context7 (an MCP that centralizes various documentation sources), TypeScript, and many others.

Creating an MCP from scratch isn’t difficult, and it’s relatively easy to set one up to help small/medium-sized businesses improve efficiency and scale more effectively.

When Not to Use MCPs

MCPs are great, but they’re not free. Every time you turn one on, you’re stuffing more stuff into the context window. Sometimes that helps. Sometimes it just gets in the way.

The mistake is treating MCPs like a default instead of a tool.

MCPs Are Great When the Model Would Otherwise Guess

Use an MCP when you really don’t want the AI to make things up.

Good examples:

  • Pulling real spacing, colors, or text from Figma instead of screenshots

  • Using live docs for APIs that change a lot

MCPs Are Overkill for Thinking and Exploring

  • Don’t use MCPs when:

  • You’re just exploring ideas

  • You’re planning architecture

You already know the domain pretty well

  • In those cases, MCPs mostly:

  • Blow up the context window

  • Distract the model

Planning with Ralph

If you’re working with AI in great things, you can use the plan mode. It usually yields better results, and you can modify/understand better what the AI will do later. But this all happens in the same context window, and with a bigger plan, you’re limited to the context window size, leading to the problems we talked about earlier.

One of the solutions is to take this plan and prompt each task separately, avoiding the context window problem. But this will require your input after each task: “Create the components”, “Create the API endpoints”, and any other prompt.

This is where Ralph steps in. Rather than writing a prompt for each phase, you just run the same one in a loop, working with a list of tasks for the AI to code. The AI uses a plan file to track what needs to be done.

I highly recommend checking these two articles by Matt Pocock: 11 Tips for AI Coding with Ralph and Getting Started With Ralph. This is all you need to start working with this technique.

Where This Is All Going

AI is here to take some of the mental overhead off our plates.

As models get better, this stuff will matter more. Smarter systems don’t remove the need for clarity. Good inputs lead to great results. Messy inputs just produce faster chaos.

In the end, AI is just another tool. A powerful one, sure, but still a tool. It won’t replace judgment, taste, or experience. What it will do is let good developers spend more time solving real problems and less time fighting friction.

Useful links:

  • AGENTS.md: AGENTS.md is a simple, open format for guiding coding agents, used by over 60k open-source projects. Think of it as a README for agents.

  • /rams: A design engineer for your coding agent. Reviews for accessibility issues, visual inconsistencies, and UI polish—then offers to fix them. Works with Claude Code, Cursor, OpenCode, Codex, and Antigravity.

  • Cursor: The most powerful coding agent, for any model.

  • Cursor Learn: Learn how to use Cursor to build software with AI.

  • Context7: Generate context with up-to-date documentation for LLMs and AI code editors.

  • How Long Contexts Fail: Taking care of your context is the key to building successful agents. Just because there’s a 1 million token context window doesn’t mean you should fill it.

  • How to Fix Your Context: 6 tactics for fixing your context and shipping better agents. As Karpathy says, building LLM-powered apps means learning to ‘pack the context windows just right’—smartly deploying tools, managing information, and maintaining context hygiene.

  • Building Skills for Claude Code: Learn how to build custom Skills for Claude Code that teach it your team's workflows, table schemas, and business logic.

Tags

AI

Subscribe to
Our Newsletter

Join 1,000+ people and receive our weekly insights, tips, and best practices.