: Mastering Claude Code — Talking to Machines
7

Chapter Seven

Mastering
Claude Code

Your AI pair programmer, from first
command to custom Skills.

There's a moment every coder remembers. You open a terminal, type a natural-language request, and watch an AI read your files, understand your architecture, write code across multiple files, run it, hit an error, fix the error, and run it again — all without you touching a single line. That's Claude Code.

It's not autocomplete. It's not a chatbot that writes snippets. Claude Code is an agentic coding tool — a command-line partner that can see your entire project, make changes across files, execute shell commands, and iterate on its own mistakes. It doesn't just suggest code. It ships code.

But here's the thing nobody tells you: the tool is only as good as the human steering it. Claude Code can write a thousand lines of perfect code in seconds — or a thousand lines of plausible-looking garbage. The difference is you.

How Claude Code Thinks

When you give Claude Code a task, it doesn't just start typing. It runs a loop, the same one that powers every AI agent:

Read. Scan the codebase — files, imports, tests, configs. Understand what exists.

Plan. Decide what to change, in which files, in what order.

Write. Make the edits. Create files. Modify code.

Run. Execute commands — build, test, lint. See what happens.

Fix. If something broke, read the error, adjust, and try again.

This read-plan-write-run-fix loop is what makes Claude Code different from a simple code generator. It doesn't hand you a snippet and walk away. It stays in the loop — iterating until the code actually works.

Think of it like pair programming. You describe what you want. Claude Code writes it. The tests fail. Claude Code reads the error, adjusts, re-runs. This cycle might happen three, five, ten times — all in seconds.

Terminal Playground

Watch Claude Code think, write, and run

Pick a task and watch how Claude Code breaks it down, writes the code, and verifies it works.

The CLAUDE.md File

Here's a secret that separates beginners from power users: you can give Claude Code permanent instructions.

Drop a file called CLAUDE.md in the root of your project, and Claude Code reads it at the start of every session. It's like a system prompt, but for your entire codebase.

CLAUDE.md

# My Project

Tech stack: Astro + React + Tailwind
Always use TypeScript with strict mode.
Put components in src/components/.
Write tests for every new function.
Use Prettier formatting — never change the config.

## Style Rules
- Prefer named exports over default exports
- Use CSS modules, not inline styles
- Keep components under 150 lines

Without a CLAUDE.md, you spend the first few minutes of every session re-explaining your preferences. With one, Claude Code already knows your stack, your conventions, and your boundaries. It's context engineering (Chapter 3) applied to coding.

Think of CLAUDE.md as your project's constitution.

It encodes the decisions you've already made — so the AI can focus on the decisions that are actually new. The more specific your CLAUDE.md, the less you have to repeat yourself.

Building Skills

A CLAUDE.md gives Claude Code general knowledge about your project. But what about specific, repeatable tasks? That's where Skills come in.

A skill is a set of instructions inside your CLAUDE.md that teaches Claude Code how to handle a particular kind of task. Think of it as a recipe: "When someone asks you to create a new React component, here's exactly how to do it."

Without skills, you explain the same steps every time. With skills, you explain once and the AI remembers forever.

A good skill has three parts:

T

Trigger

When does this skill activate? "When asked to create a component..." or "When fixing a test failure..." Clear triggers prevent the AI from using the wrong recipe.

S

Steps

What exactly should it do, in order? Numbered steps work best. Be specific about file locations, naming conventions, and required patterns.

E

Examples

Show what a successful result looks like. A before-and-after, an example file structure, or a sample output. Ambiguity dies in the presence of examples.

Skill Builder

Write reusable instructions for Claude Code

CLAUDE.md
Validation
Has clear trigger
Steps are specific
Includes examples
Test Scenario
User Request

"Create a UserProfile component that shows an avatar, name, and bio"

> Reading CLAUDE.md... found "React Component Generator" skill
> Skill matched on trigger: "Create a ... component"
Step 1: Create src/components/UserProfile.tsx
- TypeScript with Props interface
- Props: avatar (string), name (string), bio (string)
- Default export
Step 2: Add JSDoc comments
- @param avatar - URL of the user's profile image
- @param name - Display name of the user
- @param bio - Short biography text
Step 3: Create src/components/__tests__/UserProfile.test.tsx
- Test: renders name correctly
- Test: renders avatar with correct src
- Test: renders bio text
Result: 2 files created, all types valid, 3 tests passing.

Specify, Generate, Verify

When you work with Claude Code, your job changes. You're no longer the person who writes every line. You're the person who specifies what to build, lets the AI generate it, and then verifies that it's actually right.

This loop — specify, generate, verify — is the fundamental workflow:

01
Specify

Be precise about what you want. The clearer your request, the less time you spend fixing the output. Include edge cases, file locations, and expected behavior.

02
Generate

Let Claude Code do its thing. Watch the agent loop — reading, planning, writing, running, fixing. Resist the urge to interrupt mid-cycle.

03
Verify

This is your most important job. Read the code. Run the tests. Check edge cases. Does it actually do what you asked? Is it code you would sign your name to?

Most beginners skip step three. They see code appear, it looks reasonable, and they move on. Don't be that person. Generated code is a first draft. Your verification is the edit that makes it publishable.

The irony? The faster the AI generates code, the more important your verification becomes. Speed without judgment is just faster mistakes.

The Skill Paradox

Here's the uncomfortable truth about AI-assisted coding: you need to know enough to judge the output, even if you didn't write it yourself.

If you can't read the code Claude generates, you can't verify it. If you can't verify it, you're shipping someone else's guesses into production.

This creates a paradox: the tool that helps beginners write code also requires enough knowledge to evaluate that code. The way through? Use Claude Code to learn, not just to produce.

When Claude Code writes something you don't understand, don't just accept it. Ask: "Explain what this code does and why you chose this approach." Use the AI as a tutor, not just a typist.

The goal isn't to write every line — it's to understand every line.

The best Claude Code users aren't the ones who generate the most code. They're the ones who ask the best questions and catch the subtlest bugs. Your knowledge is your quality filter.

Refactor Race

You vs. Claude Code -- clean up this messy function

Below is a function with cryptic variable names, no types, and a hand-written bubble sort. Your job: refactor it into something readable. Claude Code will be doing the same thing beside you.

function d(a,b) { let r = []; for(let i=0;i<a.length;i++) { if(a[i].x > b) { r.push({n: a[i].n, v: a[i].x}); } } for(let i=0;i<r.length-1;i++) { for(let j=0;j<r.length-i-1;j++) { if(r[j].v < r[j+1].v) { let t=r[j]; r[j]=r[j+1]; r[j+1]=t; } } } return r; }

Key Concepts

What Claude Code Is

CLI agent that reads your codebase, writes files, runs commands, and iterates.

Skills

Reusable instruction sets that teach Claude Code how to handle specific tasks.

Specify → Generate → Verify

The core loop. Your job is clarity and judgment.

The Skill Paradox

You need enough knowledge to evaluate output, not to write every line.

The best coders in the AI era won't be the fastest typists. They'll be the clearest thinkers.

You've learned the tool. Next, we zoom out to the bigger picture — how to orchestrate AI across projects that are larger than any single conversation.