AI CODING TOOLS / LESSON 04
The Agentic Loop.
Understand how Claude Code thinks, decides, and acts

Loading the lesson…
Loading activities…
AI CODING TOOLS / LESSON 04
Understand how Claude Code thinks, decides, and acts

Loading the lesson…
Loading activities…
Ask Claude Code to do something and it won't just blurt out one answer and walk away. It runs a repeating cycle... gather information, take action, check the results. Once you understand that cycle, you'll work with it better and write better prompts.
"Agentic" means acting like an agent, something that takes actions on its own to reach a goal. Claude Code keeps looping through steps until the job's actually done, instead of answering once and calling it a day.
Picture a good tradesman working through a project.
That cycle is the agentic loop.
Every time you hand Claude Code a task, it drops into this loop.
Claude reads files, searches code and collects the context it needs. This is where it works out what exists, what's relevant and what rules it has to play by.
Say you ask Claude to "fix the bug in my login page." Here's what it'll do.
Same as a mechanic popping the hood before touching anything.
Now Claude makes changes, like editing files, creating new ones or running commands. Every action is a deliberate step toward the goal.
During this step Claude asks permission before changing things (depending on your permission mode), so you stay in control.
After acting, Claude checks that the change actually worked. It might re-read the file, run tests or look for errors. If something's off, it loops right back to Gather with what it just learned.
That self-correcting part is what makes Claude Code so powerful. When something breaks, it reads the error, plans a fix and takes another swing instead of just giving up.
I watched this loop do something kinda nuts in a demo. Claude Code spun up 13 subaccounts, crawled the sites and rebuilt the forms in just under 12 minutes. That's gather, act, verify, over and over, FAST.
Claude doesn't pick tools at random. It follows a decision tree based on what it needs.
On Mac and Linux, Claude searches by running grep and find through its Bash tool. On Windows it gets dedicated Grep and Glob tools for the same job.
The context window is Claude's working memory during a session. Everything lives in there.
It's fixed-size. Once it fills up, Claude's reasoning gets worse because there's less room left for new thinking. That's why managing context is a core skill (we'll cover it in a later lesson).
Bigger tasks mean lots of gather-act-verify loops back to back. Here's what a typical "add a feature" job looks like.
Every loop is small and focused. Claude isn't trying to cram everything into one giant move.
Between the Act phase and the thing actually happening, there's a permission check. What it does depends on your mode.
That's your safety net. You decide how much freedom Claude gets.
Knowing the bottlenecks helps you write better prompts.
| Bottleneck | Cause | Fix |
|---|---|---|
| Too much Gathering | Vague prompt, Claude searching everywhere | Give specific file paths |
| Repeated Verify failures | Flawed approach, keeps trying same fix | Interrupt and redirect |
| Large file reads | Reading entire files when only one section matters | Point to specific functions/lines |
| Unnecessary loops | Claude doing things you didn't ask for | Add constraints to your prompt |