◆ Vibe EngineeringSMIT · AI Agentic Engineering Urdu
Class 11 · 11.2

Foundations recap: how the machine really works

The most valuable day of week one was the “heavy theory” day — because once you understand what the model is actually doing, every trick that follows stops being magic. Here is that foundation, distilled.

🎯 Goal: refresh the theory⏱ Read: 15 min🧠 Type: revision

Weeks of tooling all rest on a handful of ideas about the model underneath. If any of these feel shaky, this is the page to slow down on — everything in the finale assumes them.

01What an LLM really does

Strip away the hype and a large language model is a next-token predictor. It reads the text so far, breaks it into tokens (chunks of characters), and predicts the most plausible next token — over and over. That is it. Everything clever it appears to do emerges from doing that spectacularly well.

Vibeengineeringistheartof ? predict next token your text, split into tokens
No memory, no plan — just the next most-likely token, given everything in front of it right now.
The illusion of memory

The model does not remember your last message. Each turn, the entire conversation is fed back in as input. What feels like memory is really re-reading the whole transcript every time. That single fact explains context windows, compacting, and why agents.md matters so much.

02The four tricks that make an agent

A raw model just predicts text. Four additions turn that autocomplete into an agent that can do work in the world:

1 · Reasoning

Think before answering

Let the model write out its thinking first — it dramatically improves multi-step results.

2 · Tools

Call out to the world

Give it functions it can invoke — read a file, run a command, search the web. This is the seed MCP grows from.

3 · The loop

Act, observe, repeat

Run a tool, feed the result back, decide the next move — looping until the task is done.

4 · Autonomy

Own the goal

Hand it an objective, not a script, and let it choose the steps. That is the leap from tool to agent.

A precise definition

An agent is an LLM running in a loop, with tools, working toward a goal you set. Claude Code is exactly this: reasoning + a toolbox (read/write files, run shell, search) + a loop + a goal. Sub-agents and swarms — the finale — are just more of these loops, arranged cleverly.

03Context engineering

Because the model re-reads everything each turn, the context window (its working memory) is your most precious resource. Managing what goes into it is context engineering, and it is the skill that separates frustrating sessions from smooth ones.

LeverWhat it isWhen to use it
system promptThe standing instructions the agent always sees.Set the ground rules once.
/contextSee how full the window is right now.When answers get vague or slow.
/compactSummarise the history to reclaim space.Mid-task, when the window fills up.
/clearWipe the slate for a fresh task.Switching to unrelated work.
Why this echoes in the finale

Sub-agents exist largely to protect the main context window: they go do a noisy job in their own separate context and hand back only the answer. If context engineering makes sense to you, sub-agents will feel obvious in Class 12.4.

04agents.md & CLAUDE.md

The single highest-leverage file in this whole course. An agents.md (or CLAUDE.md for Claude Code) is a plain-markdown brief that is loaded into context automatically — your project’s standing orders.

CLAUDE.md
# Project: Pre-Legal SaaS
## Stack
Next.js (frontend) · FastAPI (backend) · SQLite (db)

## Conventions
- Use uv run, never bare python
- All docs live in planning/
- Keep changes small; one feature per PR

## How to run
docker compose up  # opens on localhost:3000
Keep it lean

A CLAUDE.md that tries to say everything ends up saying nothing — it just burns context. Short, specific, and true beats long and aspirational. We saw this with the lean global CLAUDE.md in Class 10.1.

05Being the boss — the five principles

From Class 5, the habits that make vibe coding actually work — still true at every scale:

Spec it first

Say clearly what you want before it writes a line. Vague in, vague out.

Start simple

Get the smallest version working, then grow it. Resist the mega-prompt.

Iterate in small steps

Build, look, correct. Short loops catch mistakes while they are cheap.

Challenge it

Ask “could this be simpler?” It will happily over-engineer if you let it.

Handle frustration

When stuck, reset context, rewind, or restate the goal — don’t argue in circles.

✓ Key takeaways

  • An LLM is a next-token predictor; “memory” is just re-reading the whole transcript each turn.
  • An agent = model + reasoning + tools + a loop + a goal. Everything in week 3 is more of these loops.
  • Context is finite: use /context, /compact, /clear — and sub-agents exist to protect it.
  • A lean CLAUDE.md is your highest-leverage file. Short and true wins.
  • Be the boss: spec, start simple, iterate, challenge, and handle frustration calmly.