Claude Code: an agent in your terminal

Free preview 7 min to read

In the agents course you built a loop by hand. The model asked for a tool, your code ran it, the result went back into the conversation, and the loop continued until the model said it was done. That loop fits on one screen, and it is the whole idea behind every coding agent.

This course puts that loop in your terminal. Claude Code is Anthropic's coding agent. It runs the same kind of loop with your files, a shell and git as its tools, and you point it at a Rails app. Over seven lessons you will install it, drive it, teach it your team's procedures, give it a development method, make it review its own work, and fence in what it may do.

The loop, again

Claude Code works in three phases: gather context, take action, verify the result. They blend together and repeat. A question about your code needs only the first phase. A bug fix cycles through all three several times: read the failing test, edit the model, run the test, read the new failure, edit again.

flowchart LR
  P["Your prompt"] --> G["Gather context: read, search"]
  G --> A["Act: edit, run commands"]
  A --> V["Verify: run tests, read output"]
  V -->|"not done"| G
  V -->|"done"| R["Report back"]

Each phase uses tools. The built-in ones fall into a few groups:

Group Tools In a Rails app
Files Read, Edit, Write Open app/models/order.rb and change a method
Search grep and find through Bash (the Glob and Grep tools on Windows) Find every caller of Order#total
Execution Bash Run bin/rails test, git diff, bin/rails routes
Web WebFetch, WebSearch Read a gem's changelog
Delegation Agent Send a subagent to investigate in its own context

The model picks the next tool each time. Nobody wrote "first grep, then read, then edit" anywhere, and that is what makes it an agent.

Who owns the control flow

Earlier courses drew a line between two kinds of multi-step system. A workflow runs model calls through code paths you wrote. An agent lets the model direct its own process and decide when it is done. Claude Code sits on the agent side of that line.

That changes your job. You no longer write the steps. You design the loop around them, and the design comes down to three questions:

Question What answers it Lessons
What does it know? Project instructions, skills, the files it reads 2 and 3
What counts as done? Tests, checks and reviews that pass or fail 4 and 5
What may it do? Permission rules, hooks, isolated checkouts 6

The workflow patterns from earlier courses still matter, because they reappear inside the agent. Each lesson points one out. Explore, plan, implement is a chain. A skill description is a router. A fresh subagent per task is orchestrator-workers. A review loop is evaluator-optimizer.

Install it

Claude Code needs an account: a Claude Pro, Max, Team or Enterprise subscription, or a Claude Console account with API credits. On macOS, Linux or WSL, the native installer is one line, and it keeps itself up to date:

curl -fsSL https://claude.ai/install.sh | bash

Homebrew works too. A Homebrew install doesn't update itself, so you upgrade it with brew from time to time:

brew install --cask claude-code

Then start it from the root of a Rails app:

cd ~/code/bookshelf
claude

The first run asks you to log in through the browser. The first session in a new folder also asks whether you trust it, because a project can ship its own settings. Inside a session, /help lists the commands and /login switches accounts.

A first session, read-only

Start with a question, not a change. Claude reads files without asking for permission, so a question is safe, and it shows you how the agent explores.

How does a request to POST /orders reach the database? Name the
files involved, in order.

Watch the tool calls scroll past. A typical run searches config/routes.rb for orders, reads OrdersController#create, follows the call into the model and checks for callbacks. The answer comes back with file paths you can open.

Two habits from this first session carry through the course. First, the transcript is your evidence: every claim in the answer should trace to a file the agent read. Second, scope decides cost. "Explain the app" reads dozens of files and fills the context window. "How does checkout compute tax?" reads five.

Permission modes: the autonomy dial

The loop asks for your approval before risky actions. How often it asks depends on the permission mode. Press Shift+Tab during a session to cycle through the interactive modes; the status bar shows the current one. dontAsk and bypassPermissions stay out of that cycle unless you start claude with a flag such as --permission-mode dontAsk.

Mode Runs without asking Good for
default Reads only Learning the tool, sensitive work
acceptEdits Reads, file edits, common file commands like mkdir and mv Iterating on code you review as it lands
plan Reads; edits wait until you approve a plan Exploring before changing anything
auto Most actions, checked by a background classifier Long tasks
dontAsk Reads and pre-approved tools; anything that would prompt is denied Scripts and CI
bypassPermissions Everything Throwaway containers and VMs only

Recent versions usually start an interactive session in auto. While you learn, press Shift+Tab once to switch to Manual mode, which settings call default; the status bar shows ⏸ manual mode on. Then approve each edit and command yourself. You see what the agent wants to do before it does it, which is the fastest way to learn how it behaves. Lesson 6 replaces most of those prompts with rules: safe commands run on their own and dangerous ones never run.

What this course covers

  1. Claude Code: an agent in your terminal (you are here).
  2. Driving the loop on a Rails app: project instructions, plans, tests as the definition of done, checkpoints.
  3. Skills: procedures Claude loads on demand, and writing one for your app.
  4. Superpowers: a development method built from skills.
  5. Review loops: /code-review for bugs, /simplify for cleanup.
  6. Guardrails: permission rules, hooks and worktrees.
  7. Putting it together: one feature from idea to pull request, and a challenge where you build a permission evaluator.

Next: turning a vague request into a loop that knows when it is done.

Key takeaways

  • Claude Code runs the agent loop from the agents course: gather context, act, verify, repeat until done.
  • The model chooses each tool call, so your job moves from writing steps to designing the loop around them.
  • Three questions define that design: what the agent knows, what counts as done, and what it may do.
  • Install with the native installer or Homebrew, then run claude from the root of your app.
  • Permission modes set how much it does without asking; learn in default, and widen autonomy as your rules and checks improve.
Lesson 1 of 7 · free

Keep going with lesson 2

Driving the loop on a Rails app

Covers CLAUDE.md, prompts with a checkable definition of done, plan mode, rewind limits and keeping context clean.

A free account also gives you the quizzes, your progress and notes, and the discussion.

Type to start searching...