Code Agents

How does AI write code, run tests, and fix bugs? From Copilot to Claude Code

Code Agent Autonomous Coding Claude Code
About 10 min read
Chapter 01

Autocomplete vs. Code Agent — Three Generations

AI-assisted programming has evolved through three distinct generations. Each one dramatically increased AI's autonomy and capability boundary, while reshaping the human developer's role.

// INTERACTIVE: Three Generations of AI Coding

Hover over each card. Watch the autonomy bar grow with each generation:

Gen 1 — Autocomplete
Code Completion

Predicts the next line of code based on context. Pioneered by GitHub Copilot (early versions).

Human drives, AI assists
Gen 2 — Chat
Conversational Coding

Ask questions about code, generate functions from descriptions, explain logic. Powered by ChatGPT, Copilot Chat.

Human orchestrates, AI executes
Gen 3 — Agent
Autonomous Code Agent

AI reads the codebase, plans changes, writes code, runs tests, fixes errors, creates PRs. Claude Code, Cursor Agent, OpenAI Codex.

AI drives, human reviews

From spell-checker (Gen 1) to translation assistant (Gen 2) to simultaneous interpreter (Gen 3) — AI's role in programming grows increasingly proactive with each generation.

Chapter 02

The Agentic Loop

A code agent doesn't generate code in one shot. It follows an iterative loop — much like a senior developer's daily workflow. It cycles through "read - plan - code - test - fix" until the task is complete.

// INTERACTIVE: The Agent Workflow Loop

Click each step to see what the agent does at that stage:

📖
Read
🧠
Plan
✏️
Code
Test
🔧
Fix
Read: Understand the codebase structure, read relevant files, search for patterns and dependencies. The agent builds a mental model of the project first.

The code agent's loop mirrors a senior developer's workflow — read code to understand context, plan the approach, write code, run tests, fix bugs. The difference: the agent never gets tired and can iterate relentlessly.

Chapter 03

The Toolbox — What Can a Code Agent Do?

What makes a code agent powerful is that it doesn't just "generate text" — it can invoke tools to interact with real development environments. File systems, terminals, browsers, Git... these tools give the agent true "hands-on" capability.

// INTERACTIVE: Agent Tool Palette

Click a tool card to see it in action:

📁
File
Read, write, edit files
🔍
Search
Glob patterns, Grep regex
💻
Shell
Run commands, install deps
🔀
Git
status, diff, commit, push
🧭
Code Intel
Go-to-definition, references
🌐
Web
Search docs, fetch APIs

A code agent's tools are like a developer's IDE + Terminal + Browser — except AI is the one operating them. More tools = more capability.

Chapter 04

Claude Code in Action — From Request to PR

Let's watch a real example: a user tells Claude Code "Add dark mode to the settings page". Observe how the agent works through understanding the requirement to committing the code.

// INTERACTIVE: Terminal Log Replay

Click "Play" to watch Claude Code work:

$ claude "Add dark mode to the settings page"
▶ Read Scanning project structure... found src/pages/settings.tsx
▶ Read Reading settings.tsx, theme.config.ts, globals.css
▶ Plan Need: CSS variables, Toggle component, state management, localStorage
▶ Code Creating CSS variables: --bg, --text, --surface (light/dark sets)
▶ Code Adding ThemeToggle component + useTheme hook
▶ Code Integrating Toggle into settings.tsx
▶ Test npm run test... 1 FAILED SettingsPage.test.tsx
▶ Read Error: Cannot find ThemeToggle data-testid
▶ Fix Adding data-testid="theme-toggle" to ThemeToggle
▶ Test npm run test... ALL PASSED
▶ Commit "feat: add dark mode toggle to settings page"
✓ Done Changed 4 files, added 1 component, fixed 1 test

Notice the key moment: when the test failed, the agent didn't give up. It read the error message, diagnosed the root cause, fixed the code, and re-ran the tests. This is precisely what distinguishes an "agent" from a "code generator."

Agentic coding is changing how software is built — the developer's role shifts from writing every line of code to reviewing AI-generated changes.

Claude Code is like a tireless junior developer — you describe the requirement, it writes the code, runs the tests, and fixes the bugs. Your job is to review.

Chapter 05

Challenges & the Road Ahead

Code agents are powerful, but far from perfect. Understanding their limitations helps you collaborate with them more effectively. At the same time, this field is evolving at breakneck speed.

⚠️ CURRENT CHALLENGES

Loop Traps

Agents can get stuck in "fix bug, introduce new bug" loops, wasting tokens and time.

Context Window Limits

Large codebases can't fit entirely in context, causing the agent to miss important dependencies.

Over-Modification

Sometimes overwrites working code or makes changes beyond the scope of the request.

Safety Boundaries

Requires sandboxed execution, permission systems, and human approval for destructive actions.

🔭 FUTURE DIRECTIONS

Multi-Agent Collaboration

Multiple agents working in parallel — one on frontend, one on backend, one on tests.

Self-Improvement

Agents that learn from past mistakes, gradually reducing repeat errors and becoming more efficient.

End-to-End Generation

From requirements doc to complete project — architecture, code, tests, deployment, all generated.

The Human Role Shift

From "write code" to "review code" and "define requirements" — developers become AI navigators.

Chapter 06

Summary

🚀

Three Generations

AI coding evolved from passive autocomplete to active autonomous agents, each generation granting AI greater autonomy.

🔄

The Loop: Read-Plan-Code-Test-Fix

Code agents complete tasks through iterative cycles, not one-shot generation.

🧰

More Tools = More Capability

An agent's power is defined by the tools it can invoke — files, shell, Git, browser.

👥

From Writing to Reviewing

The developer's core value shifts to requirement definition, architecture decisions, and code review.

Code agents won't replace programmers — they'll replace programmers who don't use code agents.

Back to Academy