Agentic Software Engineering: Foundations — slides
Speed without
discipline
is not engineering.
A practical foundation for working with AI coding agents — the engineering discipline, Claude Code, reusable skills, and the systems knowledge behind tokens and caching.
Speed without discipline is not engineering.
AI coding agents make development 10× faster. Without process, that speed produces broken code, lost context, and runaway cost.
The Paradigm Shift
- From “type the code” to “direct the work.”
- AI writes; engineers design, review, and own.
- Output scales; judgment still doesn’t.
Quality at Risk
- Speed amplifies mistakes, not just output.
- Without tests, every change is a coin flip.
- Without review, bugs ship to production.
Cost Escalation
- Long sessions re-bill the same context every turn.
- No caching → tokens compound.
- Cheap prompts become expensive at scale.
Your Foundation for Agentic Engineering
Four modules move from the discipline to the machinery — so you can use coding agents deliberately, not by instinct.
Why This Course Exists
Problem “Vibe coding” — asking AI to write code without process — produces unmaintainable, untested code that breaks in production.
5-Phase Framework
Extension Architecture
Live Demonstrations
Hands-On Learning
Who This Course Is For
| Software Engineers | Team Leads | Senior Developers | Architects & Leads |
|---|---|---|---|
| Add agentic workflows to your daily practice. | Roll out Claude Code safely across your team. | Tune skills, hooks, and the CLI to your stack. | Decide where agents belong — and where they don’t. |
What Is an Agent?
Problem One-shot prompts fail on complex tasks. Every LLM call has limited context, no planning, and no verification.
Concept An Agent is an intelligent orchestrator that decomposes work and decides what to do next.
What Is a Large Language Model?
A statistical model trained on text to predict the next token. No memory, no awareness — just pattern matching at scale.
The transformer: parallel attention over the whole context at once. Long-range coherence at scale — the architecture that made agents possible.
- Trained on billions of documents
- Absorbs patterns by exposure
- Predicts patterns, not meaning
- Predicts the next likely token
- Adds it back, repeats
- Simple mechanism, intelligent output
- Small: completes sentences
- Medium: summarizes paragraphs
- Large: writes code, debugs, reasons
- Looks at all words at once
- Decides which parts matter
- Long-range coherence
How LLMs Power Agents
The LLM is the brain. The agent is the body.
The Agent as Orchestrator
From single-intent assistants to purpose-based orchestrators that coordinate parallel subagents.
The Problem With “Vibe Coding”
Prompt → Code → Hope → Ship → Bug → Repeat
The 5-Phase Agentic Framework
Each phase has one owner and produces one deliverable. No phase is optional.
| # | Phase | Owner | Deliverable |
|---|---|---|---|
| 1 | Requirement Engineering | You | REQ document — what to build |
| 2 | System Architecture | You + Claude | ARCH doc — data models, APIs, modules |
| 3 | Task Generation | Claude | Task list with tests + scope + REQ trace |
| 4 | TDD Implementation | Claude | Working code + passing tests |
| 5 | Review & Merge | You + Claude | Approved PR — 16 parallel checks |
Three Scenarios, One Framework
The same 5-phase pipeline — different entry points. The discipline never changes.
| Scenario | REQ | ARCH | TASKS | TDD | REVIEW | Note |
|---|---|---|---|---|---|---|
| Greenfield | 1 | 2 | 3 | 4 | 5 | Blank slate — all 5 phases. |
| New Feature | — | 2 | 3 | 4 | 5 | System exists — skip REQ. |
| Bugfix | RCA | — | 3 | 4 | 5 | Root-cause analysis first — understand why. |
What Did We Learn?
- One-shot prompts fail — complex work needs agents.
- ”Vibe coding” skips steps — 5 phases give AI a process.
- The framework adapts — mindset never changes, every skip needs a reason.
Claude Code: Your Agentic CLI
Problem The 5-phase framework needs a tool — one that reads codebases, runs tests, and loads skills.
Concept Claude Code is Anthropic’s official CLI — your terminal interface to agentic engineering.
The .claude/ Directory
Problem Skills, hooks, settings, rules — scattered. Without the map, you waste hours searching.
A Real ~/.claude/ — Config, Skills & Agents
Demo What actually lives in your global config directory — the pieces you configure and invoke directly.
CLAUDE.md — global instructions loaded into every session. Your coding standards, response format, workflow rules — applies before any project-level rules.
settings.json — default model, permission allowlists, trusted tools, env vars. Overridden by project-level settings.json.
skills/ — global slash-command definitions. Available in every project, every session.
agents/ — subagent specs with a description, focused tool set, and own instructions. Claude picks the right one automatically.
plugins/ — installed skill packages. The dev-pipeline plugin lives here.
A Real ~/.claude/ — Memory, History & More
Demo Directories Claude manages itself — memory, audit trails, costs, and custom providers.
file-history/ — 69 files tracked across all sessions. Claude knows what changed and when.
projects/ — per-project state: tasks, plans, stored context.
cost-log.jsonl — token spend per session, automatically tracked.
transcripts/ — 84 full conversation logs. Every decision, recoverable.
ollama.json, omlx.json, lmstudio.json — local model configs.
Claude Code is not locked to Anthropic — route to any compatible model.
How ~/.claude/projects/ Works
Demo Every project you’ve ever worked on gets its own directory — named after the path on your machine.
/Users/your-name/projects/my-app
→ -Users-your-name-projects-my-app/
One directory per unique path — worktrees get their own entry too.
This project has 18 sessions logged. Full history: every message, every tool call, every file edit.
What Claude remembers about this codebase lives here.
The Root ~/.claude.json
Demo Claude Code’s global runtime state — usage history, per-project snapshots, and last-session metrics.
customApiKeyResponses — which providers you approved (lmstudio) or rejected (ollama).
tipsHistory — every onboarding tip Claude has shown you, tracked so it doesn’t repeat.
cacheReadTokens: 1,516,400 vs cacheCreation: 38,994 — cache doing its job.
lastModelUsage — both Haiku and Sonnet used; Haiku for lightweight calls.
The Status Line — Your Live Dashboard
Concept Every number visible the moment Claude Code opens — and every one of them is customizable.
agentic-swe-vod — project.
main — git branch.
$3.93 — session cost so far.
145790 tokens — total this session.
read: 144k — tokens served from cache.
write: 0k — new cache created.
shift+tab cycles: plan → default → accept edits.
+623 -107 — lines changed.
Skills: Automate Your Workflows
Problem Every session starts from zero. You re-explain conventions — every single time.
Solution Skills = markdown in .claude/skills/, loaded on demand via slash command.
Dissecting a Skill
Skills aren’t only files you write — they ship with the CLI, arrive via plugins, or live in your repo. Same anatomy, three sources.
/batch /loop /claude-api /init
commit-commands → /commit /changelog
frontend-design → UI / component review
dev-pipeline → /req /arch /tdd /review (this course)
.claude/skills/ → your repo, your team’s rules
Built-in Skills: Natural Language Invocation
You don’t have to type /init to trigger the init skill — ask in plain language and Claude’s LLM matching does the rest.
/chrome-devtools-cli
/claude-api
/claude-automation-recommender
/code-review
/create-worktrees
/debug /debug-optimize-lcp
/fewer-permission-prompts
/init /insights /loop …
● Skill(init) — auto-triggered
└ Successfully loaded skill
Built-in Agents: Explore Before You Build
Two read-only agents shipped inside Claude Code — and the targets your skills can delegate to via context: fork.
Demo: Automation Recommender
A read-only skill that analyzes your codebase and surfaces the top 1–2 automations across all five extension points — with why, not just what.
| Hooks | Auto-actions on tool events — format, lint, block edits |
| Subagents | Specialized reviewers that run in parallel |
| Skills | Packaged workflows, invoked by user or Claude |
| Plugins | Collections of skills, installed once |
| MCP Servers | External integrations — DB, APIs, browser, docs |
Demo: Recommendation → Skill → Output
The recommender suggested a release-notes skill for claude-lens. We built it on the spot and ran it — here’s what happened.
Why: Project is at v1.1.0, distributed via npx github:foyzulkarim/claude-lens. A skill that drafts a changelog from git log since the last tag saves time before each version bump.
Demo: Let Bash Do the Work
Three versions of the same commit skill — each one moves more work out of the LLM and into bash. The tokens follow.
Claude runs each git command itself:
git status
git diff —stat
git diff —cached
Asks: “what to stage?”
Asks: “commit this?”
Multi-turn, interactive.
Dynamic Context Injection
Prefix a line with ! — the command runs before Claude reads the skill; its output replaces the line. Cheap, fast, live state.
Skill Frontmatter — The Top of the File
Every skill is a markdown file. The YAML between the --- markers configures how it loads, what tools it can call, and when Claude can auto-invoke it.
Skill Frontmatter — Beyond the Basics
The fields that handle the long tail: arguments, paths, lifecycle, sharing, and control. Most skills use only a subset — pick what your workflow actually needs.
Under the Hood.
You’ve seen what to build — skills, the .claude directory, the workflow. Before we build, we open the machine. Tokens, the context window, the request loop, and caching — the four things that explain why agents forget, why long sessions get expensive, and why structure beats memory. After this, nothing in the build is magic.
What Is a Token?
Before the model reads anything, your text is chopped into tokens. The model never sees letters or words — only tokens.
Not letters, not words
Everything is tokens
Bengali costs more
Next-token prediction
What’s in the Context Window
The context window is the model’s working memory for one request — finite, about 200K tokens for Sonnet. And most of it is loaded before you type a single word.
The Server Remembers Nothing
Every message, Claude Code packages the entire context into one payload and ships it. The server holds nothing between calls. The model is a pure function of the text you send.
The Loop: How Tools Run
The model can’t run anything. It returns text, or a request to use a tool. Claude Code runs the tool, appends the result, and sends the whole thing back. Repeat.
Multi-turn = one goal, many round-trips. What looks like one answer may be six turns under the hood.
Why Sessions Get Expensive
Problem Every turn re-sends a growing context. You pay input tokens for the whole window — again and again. Twenty turns deep, you’re re-billing the same 50K tokens twenty times.

Why It’s Expensive: Tokenize, Prefill, Decode
When you hit Enter, the server doesn’t just “read and reply.” Three stages run in sequence — and the middle one is where almost all the cost lives.
Live: Prefill vs. Decode
Same machine — a Mac Mini M4 Pro running a local LLM via oMLX. Two screenshots, seconds apart. First the prefill pipeline ingests the prompt. Then generation begins.


KV Cache: Compute Once, Reuse
Solution 1 To emit each new token, attention must look at the Key and Value of every earlier token. So compute each token’s K/V once, store them, and reuse — instead of re-deriving the whole history at every step.
Inside the Lookup: How Attention Picks
Previously we called attention a soft dictionary lookup. Here’s the actual mechanic — three steps that turn the current token’s Query into one blended answer. Worked on a real sentence.
mat 4.0
sat 0.3
the 0.1
mat 10%
sat 3%
the 2%
+ .10·V(mat)
+ .03·V(sat) …
→ “it” ≈ cat
Where the KV Cache Lives
The cache is not inside the model’s weights. Inside the inference server there are three distinct regions — and your tokens’ K/V only ever land in one of them.

The Boxes, Live in oMLX
The three boxes aren’t an abstraction — the inference server exposes each one as its own panel. Same oMLX dashboard running Qwen locally on a Mac Mini. Each panel is one box.

~7.12 GB est · panel total 29.4 GB
146 entries · 0 evictions
~6 GB — the gap between 7.12 GB weights and 29.4 GB total
Demo
Live walkthrough — oMLX inference server running Gemma-4, watching the three memory boxes in real time.
What Caching Actually Skips
Back to the three stages from 21E1. Two of them get confused — and only one is ever cached. The trap: thinking “tokens are already computed, so what’s left to cache?”
”The cat” → [464, 2415]
Prompt Caching: Same Store, Kept Warm
Solution 2 Prompt caching is the same KV store — the server just chooses not to free it. It keeps the prefix’s K/V alive across requests, so the next turn loads them instead of re-prefilling. You still send everything every turn; the server stays stateless.
Across requests: the prefix’s K/V is retained.
Prompt caching is the KV cache the server didn’t throw away.

What Is Your Stable Prefix?
Prompt caching works because your context has a predictable structure. The front never changes; only the tail does — and knowing this changes where you should write your instructions.
~10% of input price from turn 2 onward.
Full input price every turn.
Live: Without Cache
I ran the same prompt through Claude Code with cache disabled. Left: oMLX shows the serving mechanics. Right: Claude Code shows what you pay. Every turn recomputed from scratch.

Live: With Cache
Same prompt. Same model. Same machine. The only difference: cache is enabled. Watch the prefix stay warm.

Spend Fewer Tokens, Do More
Everything so far was the machine. Here’s how you work it without bleeding tokens — habits that fall straight out of how context and caching actually behave.
Stable first, volatile last
Don’t pre-load “just in case”
Keep the window lean
Mind Bengali weight
Use the speed.
Understand the machine.
Keep the discipline.
You now have the framework, the Claude Code surface, the skill patterns, and the systems model needed to work with agents deliberately.