Portada del libro electrónico Claude Code in Action, de Fran Orellana

Claude Code in Action

Install, Configure, and Program with AI from Scratch: 120 Exercises with Claude Code CLI in the Terminal, Also on Windows

By Fran Orellana

Available in: DE EN ES

Synopsis

Claude Code can write, modify, and reorganize your code from the terminal, but it only truly helps if you know what to ask it and what has changed. This book teaches you how to use it from scratch, even if you have never worked with an AI agent and only have basic programming knowledge. How do you install Claude Code, and where do you begin? You’ll go through it step by step. First, you’ll install and set it up on your computer, including on Windows. Then you’ll give Claude Code CLI your first commands. From there, you’ll progress through 120 practical, progressively challenging exercises, starting with the basics and working up to everyday use in real projects. Is it enough to accept whatever the AI generates? No. You’ll learn to delegate tasks precisely and review every change before approving it. You’ll also automate real workflows without losing control of your code. Each exercise has a specific objective, so you’ll see Claude Code in action from the very first page, without filler theory. It’s designed for students, junior developers, self-taught programmers, and professionals who code from time to time. If you want to make the most of AI without blindly depending on it, this book is for you. By the end, you’ll have your own judgment for working with an AI agent. You’ll know what to ask it, when to trust its response, and when to correct it. That is what separates someone who masters the tool from someone who merely copies what it produces. Open the terminal and start today with the first exercise.

Read the beginning

From the chapter «Set Up Your Environment»

For example, to open Claude Code and ask it to review a file, you only need a computer, a terminal, and a Claude account with access to Claude Code. You do not need to install a special editor or know how to use artificial intelligence.

To work through the exercises, you will need:

A computer running macOS, Linux, or Windows. An Internet connection. A Claude account with a plan that includes Claude Code, or an Anthropic account with credits for using the API. A terminal. Git, to save changes and go back if something goes wrong. Python, because some exercises may use small programs and test files. A text editor.

Claude Code is not completely free software. Access depends on your Claude plan or API usage. Git, Python, Visual Studio Code, and the terminals mentioned in this chapter, on the other hand, are free.

You do not need to know Git or Python before you begin. Here, you will only prepare what you need to follow the exercises.

A terminal is a window where you type commands. Claude Code runs inside it.

If you use macOS, open the Terminal application:

Press Command + Space. Type Terminal. Press Return.

If you use Linux, open the application called Terminal.

If you use Windows, you have two recommended options:

PowerShell, which is already installed. WSL, a Linux environment for Windows.

To begin, PowerShell is sufficient. Open it like this:

Press the Windows key. Type PowerShell. Open Windows PowerShell or PowerShell.

Type this command to check that the terminal responds:

You should see:

If you see that text, the terminal is working. If an error message appears, close the window, open it again, and repeat the command.

Git keeps a history of changes to your files. This lets you see what has changed and restore an earlier version.

On macOS, install Git with Apple’s developer tools:

If it is already installed, macOS will tell you. Accept the installation if a window appears.

On Ubuntu or another Debian-based distribution, type: […]

Table of contents

  1. How to Use This Book
  2. Set Up Your Environment
  3. Getting Started with Claude Code
    • Exercise 1 · Starting a Session in a Folder
    • Exercise 2 · Requesting a Project Inventory
    • Exercise 3 · Locate a Specific Function
    • Exercise 4 · Explain a file without editing it
    • Exercise 5 · Asking a Question About the Code
    • Exercise 6 · Exiting and Resuming Work
  4. Provide context and request small changes
    • Exercise 7 · Creating a Simple Function
    • Exercise 8 · Adding Useful Comments
    • Exercise 9 · Rename a Variable with Limited Scope
    • Exercise 10 · Adjusting an Error Message
    • Exercise 11 · Adding an option to a menu
    • Exercise 12 · Requesting a summary of the changes
  5. Edit Safely
    • Exercise 13 · Breaking a Task into Steps
    • Exercise 14 · Adding Input Validation
    • Exercise 15 · Protecting an Operation with Errors
    • Exercise 16 · Extracting a Repeated Function
    • Exercise 17 · Updating an Interface Between Modules
    • Exercise 18 · Applying a Change with Constraints
  6. Verify before accepting
    • Exercise 19 · Run the modified program
    • Exercise 20 · Creating a Test for a Function
    • Exercise 21 · Covering an Edge Case
    • Exercise 22 · Interpreting a Test Failure
    • Exercise 23 · Review a diff before saving it
    • Exercise 24 · Undoing an Incorrect Change
  7. Claude Code with Git
    • Exercise 25 · Inspect the Repository Status
    • Exercise 26 · Create a branch for a task
    • Exercise 27 · Preparing a Selected Change
    • Exercise 28 · Writing a confirmation message
    • Exercise 29 · Comparing Two Versions of the Code
    • Exercise 30 · Resolving a Simple Conflict
    • Exercise 31 · Review a branch as if it were a proposal
  8. Debugging and Improving Existing Code
    • Exercise 32 · Tracing an Error with Logs
    • Exercise 33 · Reproducing a Bug with a Test
    • Exercise 34 · Correcting a Mistake Without Hiding It
    • Exercise 35 · Identifying a Performance Problem
    • Exercise 36 · Reducing Repeated Calls
    • Exercise 37 · Reorganizing Related Modules
    • Exercise 38 · Updating a Dependency with Precautions
  9. Repeatable Workflows
    • Exercise 39 · Create a project instruction file
    • Exercise 40 · Prepare a Request Template
    • Exercise 41 · Automating Quality Assurance
    • Exercise 42 · Generate Documentation from Code
    • Exercise 43 · Preparing a Security Review
    • Exercise 44 · Analyzing an Ambiguous Change Request
  10. Final Project: A Maintainable Application
    • Exercise 45 · Planning a Console Application
    • Exercise 46 · Build the Project Skeleton
    • Exercise 47 · Adding Data Persistence
    • Exercise 48 · Add End-to-End Tests
    • Exercise 49 · Review and Harden the Application
    • Exercise 50 · Preparing a Reproducible Submission
  11. Solutions
    • Solution 1 · Start a session in a folder
    • Solution 2 · Request a project inventory
    • Solution 3 · Locate a specific function
    • Solution 4 · Explain a File Without Editing It
    • Solution 5 · Ask a question about the code
    • Solution 6 · Exit and Resume Work
    • Solution 7 · Create a Simple Function
    • Solution 8 · Adding Useful Comments

You may also like