Course contents

What context engineering means for AI coding agents

beginner4 min readUpdated
  • Cursor
  • GitHub Copilot
  • Claude Code
  • Windsurf / Devin
  • Cline
  • Codex
  • Antigravity CLI
On this page

The problem: your agent starts from zero every time

Open a new chat in Cursor, Claude Code or Codex and ask for a feature. The agent knows a lot about programming in general. It knows nothing about your project until it reads something.

That gap shows up in familiar ways:

  • It writes middleware.ts in a Next.js 16 app that already uses proxy.ts.
  • It installs packages with npm when your lockfile says pnpm.
  • It adds a test with Jest in a repo that runs Vitest.
  • It reaches for an API that was renamed after the model's training data was collected.

None of these are intelligence failures. The agent is guessing because nobody told it the facts. And because models don't remember past sessions, you end up repeating the same corrections every day.

Prompt engineering vs. context engineering

Prompt engineering is about wording one request well. It helps, but it lives in a single message and disappears when the chat ends.

Context engineering is deciding everything the model sees when it works: your instructions, the files it reads, the tools it can call, and the conversation so far. Anthropic's engineering team describes it as curating the smallest set of high-signal tokens that gets the job done (Effective context engineering for AI agents).

For coding agents, most of that work happens in plain Markdown files you commit next to your code. Every major tool now reads them automatically.

The three layers of project context

Think of project context in three layers. Each one trades reliability against cost.

LayerWhat it isWhen it loadsCost
Always-onAGENTS.md, CLAUDE.md, GEMINI.md, .github/copilot-instructions.md, always-apply rulesEvery sessionPaid on every request
ScopedRules tied to file patterns (globs), or rules the agent pulls in by descriptionWhen matching files are in play, or the agent decidesPaid only when relevant
On-demandSkills (SKILL.md folders)When the agent matches the description, or you call it by nameA short description up front, the full body only when used

The rest of this course is about putting each piece of knowledge in the right layer.

Always-on: facts the agent needs for every task

Build and test commands, the package manager, the framework version, directories that must not be edited. If the agent gets any of these wrong, every task suffers. Put them where they always load.

Scoped: guidance for one part of the codebase

Your React component conventions don't matter when the agent edits a SQL migration. A rule scoped to **/*.tsx loads only when the agent works on those files, which keeps the rest of the context clean.

On-demand: procedures for specific jobs

A code review checklist, a release process, a security audit. These are long and step-by-step, and you need them a few times a week, not on every message. That's what skills are for.

Why "more context" isn't the answer

It's tempting to paste your whole style guide into one giant file. That backfires for three reasons:

  1. Context windows are finite. Every always-on line competes with the code the agent needs to read. Codex, for example, stops reading AGENTS.md files once their combined size reaches 32 KiB by default (OpenAI Codex docs).
  2. Adherence drops as files grow. Anthropic's guidance for Claude Code is to keep each CLAUDE.md under about 200 lines, because longer files reduce how well instructions are followed (Claude Code memory docs).
  3. Generic advice is noise. "Write clean code" changes nothing. The model already knows common conventions; it needs the facts that are specific to you.

Good context is short, specific and placed where it loads at the right moment.

A quick before and after

Here's a typical first attempt at project instructions:

AGENTS.md (before)
# Instructions
- Write good, clean, maintainable code.
- Follow best practices.
- Use TypeScript.
- Be careful with security.

The agent already "knows" all of that, so nothing changes. Here's a version that actually changes behavior:

AGENTS.md (after)
# Project guide

## Commands
- Install: `pnpm install` (never npm or yarn)
- Test one file: `pnpm vitest run path/to/file.test.ts`
- Typecheck: `pnpm tsc --noEmit`

## Stack facts
- Next.js 16 App Router. Request interception lives in `proxy.ts`, not `middleware.ts`.
- Database access only through `src/db/` helpers. Don't import the client elsewhere.

## Don't
- Don't edit files under `src/generated/`. Run `pnpm codegen` instead.
- Don't upgrade dependencies unless the task asks for it.

Every line is a fact the agent couldn't reliably guess, and each one prevents a specific mistake.

Where presets fit

Writing this for every stack and every tool takes time, and each tool wants a different file in a different place. A preset is a ready-made, tested version of those files for one stack and one tool.

presets.dev ships 30 stacks for 7 tools. Each stack has a standards file (the rule layer) and a skill (the on-demand layer), so you can install both with one command:

npx presets-dev add nextjs

You'll learn exactly what that writes, and where, in Module 6.

Common mistakes

  • Treating the chat as memory. Corrections you type in chat vanish when the session ends. If you say it twice, write it down in a file.
  • Writing for humans instead of agents. Background and history are nice for a README. Agents need commands, paths, versions and boundaries.
  • Putting everything in the always-on layer. Move file-specific guidance into scoped rules and long procedures into skills.

Recap

  • Agents start every session with no knowledge of your project.
  • Context engineering means choosing what the agent sees, not just how you phrase one prompt.
  • Use three layers: always-on for universal facts, scoped rules for parts of the codebase, skills for procedures.
  • Short, specific, project-only instructions beat long generic ones.

Next step

Learn the three file types every tool uses for these layers, and when to pick each: Rules, skills and AGENTS.md.