40 min read

In Chapter 3, we surveyed the landscape of AI coding tools — from Claude Code's deep reasoning capabilities to GitHub Copilot's inline completions to Cursor's AI-native editing experience. You now understand what these tools can do. In this chapter...

Chapter 4: Setting Up Your Vibe Coding Environment


Learning Objectives

After completing this chapter, you will be able to:

  • Identify the hardware and software prerequisites for a productive vibe coding environment (Remember)
  • Install Python 3.10+ correctly on Windows, macOS, and Linux (Apply)
  • Configure Visual Studio Code with extensions optimized for AI-assisted development (Apply)
  • Set up Claude Code CLI with API key authentication (Apply)
  • Install GitHub Copilot and activate it within VS Code (Apply)
  • Configure Cursor as an AI-native IDE alternative (Apply)
  • Customize your terminal and shell for efficient development workflows (Apply)
  • Install Git and configure it for version control (Apply)
  • Create Python virtual environments and manage packages with pip (Apply)
  • Verify your complete setup by running a comprehensive validation script (Evaluate)
  • Troubleshoot common installation and configuration issues across all three major operating systems (Analyze)

Introduction

In Chapter 3, we surveyed the landscape of AI coding tools — from Claude Code's deep reasoning capabilities to GitHub Copilot's inline completions to Cursor's AI-native editing experience. You now understand what these tools can do. In this chapter, you will get them all working on your machine.

Setting up a development environment is often the most frustrating part of learning to code. Installers fail silently, paths get misconfigured, and version conflicts create mysterious errors. This chapter takes a methodical, step-by-step approach to eliminate that frustration. By the end, you will have a fully functional vibe coding environment — verified by a script you will run yourself — and you will be ready for the hands-on work that begins in Chapter 6.

We cover every major operating system: Windows, macOS, and Linux. Where instructions differ, we provide separate blocks clearly labeled for each platform. Where they are the same, we say so once and move on. Follow the instructions for your operating system and skip the others.

Note

This chapter is intentionally detailed. If you are an experienced developer who already has Python, Git, and VS Code installed, skim Sections 4.1 through 4.3, focus on Sections 4.4 through 4.6 for the AI tool setup, and then jump to Section 4.10 to verify everything works together.


4.1 System Requirements and Prerequisites

Before installing anything, let us make sure your computer meets the minimum requirements for a productive vibe coding environment.

Hardware Requirements

Component Minimum Recommended
Processor Dual-core, 1.6 GHz Quad-core, 2.0 GHz+
RAM 4 GB 8 GB or more
Storage 5 GB free space 20 GB free (SSD preferred)
Display 1280 x 720 1920 x 1080 or higher
Internet Broadband connection Stable broadband (AI tools require internet)

Intuition: AI coding tools like Claude Code, Copilot, and Cursor all communicate with cloud-based models over the internet. Your computer does not run the AI — it sends your prompts to remote servers and receives responses back. This means your internet connection matters more than raw processing power. An older laptop with a good internet connection will outperform a powerful desktop with a flaky Wi-Fi signal.

Operating System Requirements

  • Windows: Windows 10 version 1903 or later (64-bit). Windows 11 is fully supported.
  • macOS: macOS 11 (Big Sur) or later. Both Intel and Apple Silicon (M1/M2/M3/M4) are supported.
  • Linux: Ubuntu 20.04+, Fedora 36+, Debian 11+, or other modern distributions with glibc 2.31+.

Software Prerequisites

Before we begin installing development tools, make sure your operating system is up to date. Operating system updates often include security patches, driver improvements, and library updates that development tools depend on.

  • Windows: Open Settings > Windows Update and install any pending updates. Restart if prompted.
  • macOS: Open System Settings > General > Software Update and install any available updates.
  • Linux: Run sudo apt update && sudo apt upgrade (Ubuntu/Debian) or sudo dnf update (Fedora).

You should also have administrator/sudo access on your machine. Most installation steps require elevated privileges to install software system-wide. If you are on a managed work computer, you may need to contact your IT department to get installation permissions.

Real-World Application: In corporate environments, IT departments often restrict software installation. If you are in this situation, talk to your IT team early. Explain that you need Python, Node.js, Git, and VS Code — all widely used, open-source development tools. Many companies have pre-approved lists of development software, and these tools are usually on them. For AI-specific tools like Claude Code and Copilot, you may need additional approval depending on your company's AI policy.

What You Will Install

Here is the complete list of tools we will set up in this chapter, along with an estimate of installation time for each:

  1. Python 3.10+ — The programming language we use throughout this book (~5 minutes)
  2. Visual Studio Code (VS Code) — Our primary code editor (~5 minutes)
  3. Claude Code — Anthropic's CLI-based AI coding assistant (~10 minutes including API key setup)
  4. GitHub Copilot — AI-powered inline code completion (~10 minutes including account setup)
  5. Cursor — An AI-native IDE built on VS Code (~5 minutes)
  6. Git — Version control system (~5 minutes)
  7. A configured terminal — Bash, Zsh, or PowerShell with sensible defaults (~10 minutes)

The total installation time is approximately 60-90 minutes for a first-time setup, or 30-45 minutes if you already have some of these tools installed.

Common Pitfall: Do not try to install everything at once without reading ahead. Some tools depend on others. For example, Claude Code requires Node.js, and GitHub Copilot requires a GitHub account. Follow the sections in order to avoid dependency issues.

Accounts You Will Need

Before you begin, create accounts for the following services (all are free to start):

  • GitHub (https://github.com) — Required for Copilot and Git workflows
  • Anthropic (https://console.anthropic.com) — Required for Claude Code API access
  • Cursor (https://cursor.com) — Required for the Cursor IDE

Take a moment now to create these accounts if you do not already have them. You will need them in Sections 4.4 through 4.6.


4.2 Installing Python 3.10+

Python is the programming language we use throughout this book. While AI coding tools support many languages, Python's readability and popularity make it the ideal language for learning vibe coding. We need version 3.10 or later because it includes important features like structural pattern matching and improved error messages.

Why Python 3.10 Specifically?

You might wonder why we require Python 3.10 rather than an older version. Python 3.10 introduced several features that make vibe coding significantly better:

  • Improved error messages: Python 3.10 added much more helpful error messages. Instead of a cryptic SyntaxError: invalid syntax, you get messages like SyntaxError: '{' was never closed with a clear pointer to the problem line. When you are reading AI-generated code and something goes wrong, these improved messages save significant debugging time.

  • Structural pattern matching: The match/case statement (similar to switch in other languages) was introduced in Python 3.10. AI coding tools frequently generate code using this feature because it produces cleaner, more readable code for complex conditional logic.

  • Type hint improvements: Python 3.10 improved the type hint syntax, allowing you to write list[int] instead of List[int] (no import needed). Since this book emphasizes type hints as a way to communicate intent to both AI tools and human readers, the simplified syntax matters.

  • Performance improvements: Each Python version brings performance improvements. Python 3.12, the version we recommend, is significantly faster than 3.10, with some benchmarks showing 10-25% speed improvements.

Note

If you already have Python 3.10 or 3.11 installed, those versions work fine for everything in this book. We recommend 3.12 for new installations because it is the latest stable version, but we do not use any 3.12-specific features that would break on 3.10 or 3.11.

Checking for an Existing Installation

First, check whether Python is already installed on your system. Open a terminal (we will configure terminals properly in Section 4.7, but for now use whatever terminal your system provides) and run:

python --version

If that does not work, try:

python3 --version

If you see Python 3.10.x or higher (for example, Python 3.12.4), you already have a suitable version. Skip ahead to Section 4.3.

If you see Python 3.9.x or lower, or if the command is not found, follow the installation instructions below for your operating system.

Windows Installation

  1. Visit https://www.python.org/downloads/ and download the latest Python 3.12.x installer for Windows.

  2. Run the installer. On the very first screen, check the box that says "Add python.exe to PATH". This is critical.

Common Pitfall: If you forget to check "Add python.exe to PATH" during installation, Python will install correctly but your terminal will not be able to find it. You would see 'python' is not recognized as an internal or external command. If this happens, uninstall Python and reinstall it with the PATH checkbox checked. It is easier to reinstall than to fix PATH manually.

  1. Click "Install Now" for the default installation, or choose "Customize installation" if you want to change the install directory.

  2. When the installation completes, you will see a screen with an option to "Disable path length limit". Click this button — it prevents issues with long file paths on Windows.

  3. Close and reopen your terminal, then verify:

python --version
# Expected output: Python 3.12.x
pip --version
# Expected output: pip 24.x.x from ...

macOS Installation

macOS comes with Python 2.7 pre-installed on older versions (which is deprecated and unsuitable), and some newer versions include Python 3. However, it is best to install Python yourself for a clean, up-to-date version.

Option A: Using the official installer (simplest)

  1. Visit https://www.python.org/downloads/macos/ and download the latest Python 3.12.x universal installer.
  2. Open the .pkg file and follow the installation prompts.
  3. After installation, the python3 command will be available.

Option B: Using Homebrew (recommended for developers)

If you have Homebrew installed (we cover Homebrew in Section 4.7), run:

brew install python@3.12

After installation, verify:

python3 --version
# Expected output: Python 3.12.x
pip3 --version
# Expected output: pip 24.x.x from ...

Note

On macOS, the commands are typically python3 and pip3 rather than python and pip. This is because macOS historically reserved python for the system Python 2. You can create an alias (covered in Section 4.7) to make python point to python3.

Linux Installation

Most Linux distributions include Python 3, but it may be an older version.

Ubuntu/Debian:

sudo apt update
sudo apt install python3.12 python3.12-venv python3-pip

If Python 3.12 is not available in your distribution's default repositories, add the deadsnakes PPA first:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.12 python3.12-venv python3-pip

Fedora:

sudo dnf install python3.12 python3-pip

After installation, verify:

python3 --version
# Expected output: Python 3.12.x
pip3 --version
# Expected output: pip 24.x.x from ...

Best Practice: Regardless of your operating system, always verify the installation by checking the version number in a new terminal window. Some terminals cache the PATH and will not see newly installed programs until they are reopened.


4.3 Setting Up VS Code

Visual Studio Code (VS Code) is a free, open-source code editor from Microsoft. It is the most popular editor in the world among developers, and it is the foundation on which many AI coding tools are built. Even if you plan to use Cursor (Section 4.6) as your primary editor, install VS Code first — it provides the baseline experience and is needed for GitHub Copilot.

Installing VS Code

Windows:

  1. Visit https://code.visualstudio.com/ and download the Windows installer.
  2. Run the installer. On the "Select Additional Tasks" page, check all boxes, especially: - "Add to PATH" (important for launching VS Code from the terminal) - "Register Code as an editor for supported file types" - "Add 'Open with Code' action to Windows Explorer context menu"
  3. Complete the installation and launch VS Code.

macOS:

  1. Visit https://code.visualstudio.com/ and download the macOS .zip file.
  2. Extract the zip file and drag Visual Studio Code.app to your /Applications folder.
  3. Launch VS Code. Open the Command Palette (Cmd+Shift+P) and type "shell command". Select "Shell Command: Install 'code' command in PATH". This lets you open files from the terminal by typing code filename.

Linux:

# Ubuntu/Debian — download the .deb package from code.visualstudio.com, then:
sudo dpkg -i code_*.deb
sudo apt install -f  # Fix any dependency issues

# Or use snap:
sudo snap install code --classic

# Fedora:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
sudo dnf install code

After installation, open VS Code and verify it launches. You should see the Welcome tab.

Essential Extensions for Vibe Coding

Extensions are add-ons that give VS Code new capabilities. Install the following extensions by clicking the Extensions icon in the left sidebar (or pressing Ctrl+Shift+X / Cmd+Shift+X) and searching for each one:

Extension Publisher Purpose
Python Microsoft Python language support, IntelliSense, debugging
Pylance Microsoft Fast Python type checking and auto-completion
GitHub Copilot GitHub AI code completion (installed in Section 4.5)
GitLens GitKraken Enhanced Git integration and blame annotations
Error Lens Alexander Show errors and warnings inline with your code
indent-rainbow oderwat Color-coded indentation levels (helpful for Python)
Material Icon Theme Philipp Kief Better file icons in the explorer panel

To install an extension from the terminal, use:

code --install-extension ms-python.python
code --install-extension ms-python.vscode-pylance
code --install-extension eamodio.gitlens
code --install-extension usernamehw.errorlens
code --install-extension oderwat.indent-rainbow
code --install-extension PKief.material-icon-theme

Configuring VS Code for Python Development

Open VS Code settings (Ctrl+, or Cmd+,) and configure these important settings. You can also edit the settings.json file directly by pressing Ctrl+Shift+P / Cmd+Shift+P and typing "Preferences: Open Settings (JSON)":

{
    "python.defaultInterpreterPath": "python3",
    "editor.fontSize": 14,
    "editor.tabSize": 4,
    "editor.insertSpaces": true,
    "editor.formatOnSave": true,
    "editor.wordWrap": "on",
    "files.autoSave": "afterDelay",
    "files.autoSaveDelay": 1000,
    "terminal.integrated.fontSize": 13,
    "python.analysis.typeCheckingMode": "basic",
    "editor.minimap.enabled": false,
    "workbench.colorTheme": "Default Dark Modern"
}

Intuition: The editor.formatOnSave setting automatically formats your code every time you save. This is especially valuable in vibe coding because AI-generated code sometimes has inconsistent formatting. Auto-formatting on save keeps everything clean without you having to think about it.

The VS Code Interface at a Glance

If you are new to VS Code, here is a quick orientation:

  • Activity Bar (left edge) — Icons for Explorer, Search, Source Control, Extensions, etc.
  • Side Bar (next to the Activity Bar) — Shows the content for whichever Activity Bar icon is selected
  • Editor (center) — Where you write and read code
  • Panel (bottom) — Terminal, Problems, Output, and Debug Console tabs
  • Status Bar (very bottom) — Shows your current Python interpreter, branch, and other context

The integrated terminal (Ctrl+`` or Cmd+``) is one of VS Code's best features. You can run Python scripts, Git commands, and AI tools without leaving the editor.

Real-World Application: Professional vibe coders keep VS Code open with the terminal panel visible at all times. They write prompts in Claude Code (in the terminal), see the generated code appear in their files, and iterate — all without switching windows. This tight feedback loop is the heart of productive vibe coding.


4.4 Installing and Configuring Claude Code

Claude Code is Anthropic's command-line interface (CLI) for interacting with Claude directly from your terminal. As discussed in Chapter 3, Claude Code excels at deep reasoning tasks, multi-file edits, and agentic workflows where the AI can read and modify your project files.

Prerequisites

Claude Code requires Node.js 18 or later. Let us install that first.

Windows:

  1. Visit https://nodejs.org/ and download the LTS (Long Term Support) version.
  2. Run the installer with default settings.
  3. Reopen your terminal and verify:
node --version
# Expected: v20.x.x or v22.x.x
npm --version
# Expected: 10.x.x

macOS:

# With Homebrew:
brew install node

# Or download the installer from https://nodejs.org/

Linux:

# Ubuntu/Debian:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

# Fedora:
sudo dnf install nodejs

Verify on all platforms:

node --version
npm --version

Installing Claude Code

With Node.js installed, install Claude Code globally using npm:

npm install -g @anthropic-ai/claude-code

Common Pitfall: On macOS and Linux, you may get a permissions error when running npm install -g. If this happens, do not use sudo npm install -g — that can create permission issues later. Instead, configure npm to use a directory in your home folder: ```bash mkdir -p ~/.npm-global npm config set prefix '~/.npm-global'

Then add ~/.npm-global/bin to your PATH (see Section 4.7)

```

After installation, verify:

claude --version

You should see the Claude Code version number.

Setting Up Your API Key

Claude Code needs an Anthropic API key to communicate with Claude. Here is how to get one:

  1. Go to https://console.anthropic.com/ and sign in (or create an account).
  2. Navigate to API Keys in the left sidebar.
  3. Click "Create Key" and give it a descriptive name like "Claude Code - My Laptop".
  4. Copy the key. It starts with sk-ant-. Save it somewhere safe — you will not be able to see it again after closing this page.

Now configure Claude Code to use your key. You have two options:

Option A: Environment variable (recommended)

Set the ANTHROPIC_API_KEY environment variable. We will cover permanent configuration in Section 4.7, but for now:

# macOS/Linux (temporary, for current session):
export ANTHROPIC_API_KEY="sk-ant-your-key-here"

# Windows PowerShell (temporary, for current session):
$env:ANTHROPIC_API_KEY = "sk-ant-your-key-here"

Option B: Interactive login

Simply run claude in your terminal. If no API key is configured, it will prompt you to enter one or log in through your browser.

claude
# Follow the interactive prompts to authenticate

Best Practice: Never paste your API key directly into code files or commit it to Git. Use environment variables or a .env file (covered in Section 4.9 and in the code examples). API keys are secrets — treat them like passwords.

Testing Claude Code

Let us verify Claude Code works. Run:

claude "What version of Python is installed on this system? Run python3 --version to check."

Claude Code should execute the command and report your Python version. If you see a response, congratulations — Claude Code is working.

You can also try a more interactive session. Run claude without any arguments to enter interactive mode:

claude

This opens an interactive session where you can have a multi-turn conversation with Claude. Type your message and press Enter. To exit the session, type /exit or press Ctrl+C.

Try asking Claude to do something practical:

Create a Python file called hello.py that prints "Hello from Claude Code!" and includes a main function with a docstring.

Claude should create the file in your current directory. You can then run it with python3 hello.py to verify.

Intuition: When you run Claude Code inside a project directory, it can see and modify your project files. This is what makes it "agentic" — it does not just suggest code, it can actually create files, edit existing ones, and run commands. We will use this capability extensively starting in Chapter 6. The key difference between Claude Code and a regular chatbot is that Claude Code has agency — it can take action on your behalf, not just give you advice.

Common Claude Code Commands

Here are some useful patterns for working with Claude Code that you will use throughout this book:

# Ask Claude to explain code
claude "Explain what the function on line 42 of main.py does"

# Ask Claude to fix a bug
claude "I'm getting a KeyError on line 15. Fix the bug."

# Ask Claude to add a feature
claude "Add input validation to the create_user function in api.py"

# Ask Claude to write tests
claude "Write unit tests for the Calculator class in calculator.py"

# Ask Claude to review code
claude "Review main.py for potential bugs and security issues"

Note

Claude Code works best when you give it specific, clear instructions. Vague requests like "make the code better" produce vague results. Specific requests like "add type hints to all functions in utils.py" produce specific, useful results. We will cover prompt engineering in depth in Part II of this book.

Understanding Claude Code Usage and Costs

Claude Code uses the Anthropic API, which is a pay-per-use service. Each interaction sends tokens (roughly, words and code characters) to and from Claude. The cost depends on the model and the number of tokens:

  • Input tokens (your prompts and file context): charged at one rate
  • Output tokens (Claude's responses): charged at a higher rate

For learning purposes, the cost is very manageable — typically a few dollars per month of moderate use. Anthropic provides a free tier with limited usage to get started, and you can set spending limits in the console to avoid surprises.

Note

Pricing changes over time. Check https://anthropic.com/pricing for current rates. As of this writing, Claude Sonnet is the most cost-effective option for day-to-day coding, while Claude Opus provides deeper reasoning for complex tasks.


4.5 Installing GitHub Copilot

GitHub Copilot is an AI pair programmer that provides inline code suggestions as you type. As we discussed in Chapter 3, Copilot excels at autocomplete-style assistance — finishing lines, suggesting function bodies, and generating boilerplate code.

Prerequisites

  • A GitHub account (free at https://github.com)
  • A Copilot subscription (see below)
  • VS Code installed (from Section 4.3)

Getting a Copilot Subscription

GitHub Copilot is a paid service, but there are free options:

  • Free tier: GitHub Copilot Free provides a limited number of completions and chat interactions per month. This is sufficient for learning.
  • Pro plan: Unlimited completions for $10/month (or $100/year).
  • Student/Teacher: Free through the GitHub Education program at https://education.github.com.

To sign up:

  1. Go to https://github.com/features/copilot
  2. Choose your plan and complete the sign-up process
  3. If you are a student, apply through GitHub Education first — it can take a day or two to verify

Installing the VS Code Extension

  1. Open VS Code.
  2. Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X).
  3. Search for "GitHub Copilot".
  4. Install the GitHub Copilot extension (published by GitHub). This will also install GitHub Copilot Chat as a companion extension.
  5. After installation, VS Code will prompt you to sign in to GitHub. Click "Sign in to GitHub" and follow the browser authentication flow.

Alternatively, install from the terminal:

code --install-extension GitHub.copilot

Verifying Copilot Is Working

  1. Open a new Python file in VS Code (File > New File, save it as test_copilot.py).
  2. Type the following and pause:
def calculate_fibonacci(n):
  1. After a brief moment, you should see a grayed-out suggestion for the function body. Press Tab to accept it.

If you see suggestions appearing in gray text as you type, Copilot is working correctly.

Common Pitfall: If Copilot suggestions do not appear, check the Copilot icon in the bottom status bar of VS Code. If it has a line through it, Copilot is disabled for the current file type. Click the icon and enable it. Also ensure you have completed the GitHub sign-in process — the extension will not work without authentication.

Configuring Copilot Settings

Open VS Code settings and search for "copilot" to configure the following:

{
    "github.copilot.enable": {
        "*": true,
        "plaintext": false,
        "markdown": true,
        "yaml": true
    },
    "github.copilot.editor.enableAutoCompletions": true
}

These settings enable Copilot for most file types while disabling it for plain text files where you probably do not want code suggestions.

How Copilot Works in Practice

Understanding Copilot's behavior helps you use it more effectively. Here is what happens behind the scenes:

  1. You start typing. Copilot monitors every keystroke in the editor.
  2. Context gathering. Copilot sends the current file content, open tabs, and your cursor position to GitHub's servers.
  3. Suggestion generation. The AI model generates one or more completion suggestions based on the context.
  4. Display. The top suggestion appears as grayed-out "ghost text" after your cursor.
  5. Your decision. You press Tab to accept, Esc to dismiss, or Alt+] to see alternatives.

The quality of suggestions depends heavily on context. Copilot performs better when:

  • Your file has descriptive variable names and comments
  • There are similar functions nearby that establish a pattern
  • You write a docstring or comment before the function body (Copilot uses these as instructions)
  • The file has imports at the top that indicate which libraries you are using

Intuition: Think of Copilot as a very fast typist who has read millions of code files. It recognizes patterns and can complete them quickly, but it does not truly understand your business logic. It is excellent at "I have seen code like this before" tasks and less reliable for novel, domain-specific logic. This is why Claude Code — with its ability to reason about your specific requirements — complements Copilot so well.

Real-World Application: Many vibe coders use Copilot and Claude Code together. Copilot handles the small stuff — completing lines, suggesting variable names, filling in boilerplate — while Claude Code handles the big stuff — generating entire features, refactoring code, and debugging complex issues. They complement each other well, like having both a spell-checker and an editor.


4.6 Setting Up Cursor

Cursor is an AI-native code editor built on the VS Code foundation. As discussed in Chapter 3, Cursor integrates AI more deeply into the editing experience than VS Code with extensions can. It offers inline editing, multi-file changes, and an AI chat panel that understands your entire codebase.

Installing Cursor

  1. Visit https://cursor.com and click the download button for your operating system.
  2. Run the installer: - Windows: Run the .exe installer - macOS: Open the .dmg file and drag Cursor to Applications - Linux: Download the .AppImage file and make it executable (chmod +x cursor-*.AppImage)

  3. Launch Cursor. On first launch, it will offer to import your VS Code settings and extensions. Accept this — it brings over your Python extension, themes, and keybindings.

Signing In and Setting Up

  1. Cursor will prompt you to create an account or sign in. Use your email or GitHub account.
  2. Choose your AI model preferences. Cursor offers a free tier with limited requests, and a Pro tier ($20/month) for unlimited access.
  3. The main interface will look very familiar if you have used VS Code — that is intentional.

Key Cursor Features to Know

Cursor extends the VS Code interface with several AI-specific capabilities. Here are the features you will use most:

  • Ctrl+K / Cmd+K (Inline Edit): Select code and press this shortcut to ask the AI to modify it. Type your instruction (for example, "add error handling") and Cursor will edit the selected code in place. This is Cursor's signature feature — it feels like having an AI that can reach into your code and make precise changes where you point.

  • Ctrl+L / Cmd+L (Chat Panel): Opens the AI chat panel where you can have longer conversations about your code. Unlike a separate chat window, this panel has full context of your open files. You can ask questions like "Why does this function return None in some cases?" and the AI can see the function you are referring to.

  • Ctrl+I / Cmd+I (Composer): Opens the Composer for multi-file edits. Describe what you want at a high level, and Cursor will propose changes across multiple files simultaneously. For example, "Add a logging system with a logger in each module" might touch five or six files. The Composer shows you all proposed changes in a diff view before you accept them.

  • @ symbols in chat: Reference specific files (@filename), documentation (@docs), or the web (@web) to give the AI more context. For example, typing @utils.py explain the parse_config function directs the AI to look at a specific file. This is more precise than hoping the AI picks up on the right context.

  • Tab completion: Like Copilot, Cursor provides inline code completions as you type. These are context-aware and often quite accurate because Cursor indexes your entire project.

Common Pitfall: When you first start using Cursor, you may feel overwhelmed by the number of AI features available. Do not try to learn them all at once. Start with just Ctrl+L (chat) to ask questions about your code. Once that feels natural, add Ctrl+K (inline edit) for making changes. Save the Composer for later, once you are comfortable with the simpler features.

Verifying Cursor Is Working

  1. Open Cursor and create a new file called test_cursor.py.
  2. Press Ctrl+L / Cmd+L to open the chat panel.
  3. Type: "Write a function that checks if a number is prime."
  4. The AI should respond with a Python function. Click "Apply" to insert it into your file.

If the function appears in your file, Cursor is working correctly.

Note

You do not need to choose between VS Code and Cursor — you can use both. Many developers use VS Code with Copilot for some projects and Cursor for others, depending on the task. Feel free to experiment and find what works best for you.

Best Practice: If you are just starting out and feel overwhelmed by having both VS Code and Cursor, pick one as your primary editor. We recommend starting with VS Code plus Copilot because it is more widely documented and supported. You can always add Cursor later when you are comfortable with the basics.


4.7 Terminal and Shell Configuration

The terminal is where you will run Python scripts, Git commands, and Claude Code. A well-configured terminal makes everything faster and more pleasant.

Understanding Terminals and Shells

A terminal (also called a terminal emulator) is the application — the window you see. A shell is the program running inside that window that interprets your commands. Common shells include:

Shell Default On Notes
Bash Linux, older macOS The most widely documented shell
Zsh macOS (Catalina+) Bash-compatible with extra features
PowerShell Windows Microsoft's modern shell
CMD Windows (legacy) Older Windows command prompt — avoid

Intuition: Think of the terminal as a TV screen and the shell as the channel you are watching. You can change which shell runs inside your terminal, just like changing channels. The terminal provides the window; the shell provides the language.

Windows Terminal Setup

Windows ships with PowerShell and the older CMD. We recommend using Windows Terminal with PowerShell:

  1. Install Windows Terminal from the Microsoft Store (free). It may already be installed on Windows 11.
  2. Open Windows Terminal. It defaults to PowerShell, which is what we want.

For a more Linux-like experience on Windows, consider installing Git Bash (which comes with Git in Section 4.8) or Windows Subsystem for Linux (WSL):

# Install WSL (optional, but recommended for advanced users):
wsl --install

Note

Throughout this book, command-line examples use Bash syntax. If you are using PowerShell, most commands work identically. Where they differ (for example, setting environment variables), we show both versions.

macOS Terminal Setup

macOS comes with the Terminal app and the Zsh shell. This works well out of the box. For an enhanced experience:

  1. Install Homebrew (the macOS package manager):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. After installation, follow the instructions Homebrew prints to add it to your PATH.

  2. Optionally, install iTerm2 for a better terminal experience:

brew install --cask iterm2

Linux Terminal Setup

Linux distributions come with a terminal emulator and Bash. This is already an excellent setup. No changes are needed for most users.

Configuring Your Shell Profile

Your shell profile is a file that runs every time you open a new terminal. It is where you set environment variables, aliases, and PATH modifications.

Shell Profile File
Bash ~/.bashrc or ~/.bash_profile
Zsh ~/.zshrc
PowerShell $PROFILE` (run `echo $PROFILE to see the path)

Add these useful configurations to your shell profile:

Bash/Zsh (~/.bashrc or ~/.zshrc):

# Python aliases
alias python='python3'
alias pip='pip3'

# Anthropic API key (replace with your actual key)
export ANTHROPIC_API_KEY="sk-ant-your-key-here"

# Make Claude Code available (if installed via npm global)
export PATH="$HOME/.npm-global/bin:$PATH"

# Useful aliases for vibe coding
alias ll='ls -la'
alias gs='git status'
alias gc='git commit'
alias gp='git push'

PowerShell ($PROFILE):

# Anthropic API key
$env:ANTHROPIC_API_KEY = "sk-ant-your-key-here"

# Useful aliases
Set-Alias -Name python -Value python3
function gs { git status }
function gc { git commit @args }

After editing your profile, reload it:

# Bash/Zsh:
source ~/.bashrc   # or source ~/.zshrc

# PowerShell:
. $PROFILE

Common Pitfall: When editing your shell profile, be careful not to delete existing content. Open the file, scroll to the bottom, and add new lines there. A typo in your shell profile can prevent your terminal from starting correctly. If that happens, you can usually fix it by opening the file with a basic editor like nano ~/.bashrc or by launching the shell with bash --norc to bypass the profile.

Essential Terminal Commands for Vibe Coding

These commands come up constantly in vibe coding workflows:

Command Purpose Example
cd Change directory cd ~/projects/my-app
ls / dir List files ls -la
mkdir Create a directory mkdir my-project
pwd Print working directory pwd
cat Display file contents cat README.md
which / where Find a command's location which python3
echo Print text or variables echo $ANTHROPIC_API_KEY
clear Clear the terminal screen clear
Ctrl+C Cancel a running command (keyboard shortcut)
Up arrow Recall previous command (keyboard shortcut)

Real-World Application: The which (or where on Windows CMD) command is invaluable for troubleshooting. When a tool is not working, running which python3 tells you exactly which Python installation your shell is using. If it points to the wrong version, you know the issue is with your PATH configuration.


4.8 Git Installation and Configuration

Git is the version control system used by virtually every software project in the world. It tracks changes to your files over time, lets you undo mistakes, and enables collaboration with others. Even for solo projects, Git is essential — it gives you a safety net and a history of every change you make.

Installing Git

Windows:

  1. Download Git from https://git-scm.com/download/win
  2. Run the installer. The default settings are fine for most options. On the "Adjusting your PATH environment" screen, select "Git from the command line and also from 3rd-party software" (this is the recommended default).
  3. On the "Configuring the line ending conversions" screen, select "Checkout Windows-style, commit Unix-style line endings".
  4. Complete the installation.

This also installs Git Bash, a Bash terminal for Windows that many developers prefer.

macOS:

Git is often pre-installed on macOS, or it comes with the Xcode Command Line Tools:

# Check if Git is installed:
git --version

# If not installed, macOS will prompt you to install Xcode Command Line Tools.
# Or install via Homebrew:
brew install git

Linux:

# Ubuntu/Debian:
sudo apt install git

# Fedora:
sudo dnf install git

Configuring Git

After installation, configure your name and email. These appear in every commit you make:

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Set the default branch name to main (the modern standard):

git config --global init.defaultBranch main

Configure a default editor for Git commit messages:

# Use VS Code:
git config --global core.editor "code --wait"

# Or use nano (simpler):
git config --global core.editor "nano"

Verify your Git configuration:

git config --list

You should see your name, email, and other settings listed.

Best Practice: Use the same email address for your Git configuration that you used for your GitHub account. This ensures that GitHub correctly attributes your commits to your profile.

Essential Git Commands for Getting Started

While we cover Git comprehensively in Chapter 31, here are the commands you need right now to follow along with this chapter:

Command What It Does When You Use It
git init Create a new repository in the current directory Once, at the start of a new project
git status Show which files have changed Before every commit, to see what will be included
git add <file> Stage a file for the next commit After making changes you want to save
git add . Stage all changed files When you want to commit everything
git commit -m "message" Save staged changes with a description After staging files with git add
git log --oneline Show a brief history of commits To see what has been done so far
git diff Show changes since the last commit To review what you changed before committing

Intuition: Think of Git as an "undo" system on steroids. Every time you git commit, you create a snapshot of your entire project. You can always go back to any previous snapshot. This is especially valuable in vibe coding, where you might ask an AI to make sweeping changes to your code — if the changes do not work out, you can revert to the previous commit.

Creating Your First Repository

Let us create a project directory that we will use for the rest of this chapter:

mkdir -p ~/vibe-coding-workspace
cd ~/vibe-coding-workspace
git init

You should see: Initialized empty Git repository in .../vibe-coding-workspace/.git/

On Windows with PowerShell, the commands are:

mkdir $HOME\vibe-coding-workspace
cd $HOME\vibe-coding-workspace
git init

Note

We will cover Git in much more depth in Chapter 31 (Version Control Workflows). For now, you just need it installed and configured. The key commands you will use immediately are git init, git add, git commit, and git status. Do not worry about branches, merging, or remote repositories yet — those come later.


4.9 Virtual Environments and Package Management

When you install Python packages (libraries that other people have written), they go into a global location by default. This creates problems when different projects need different versions of the same library. Virtual environments solve this by giving each project its own isolated set of packages.

Why Virtual Environments Matter

Imagine you are working on two projects:

  • Project A needs requests version 2.28
  • Project B needs requests version 2.31

Without virtual environments, you can only have one version installed globally. With virtual environments, each project has its own copy, and they never conflict.

Intuition: Think of a virtual environment as a separate room for each project. Each room has its own set of tools. You can have different versions of the same tool in different rooms without confusion. When you "activate" an environment, you walk into that room and use its tools.

Creating a Virtual Environment

Navigate to your project directory and create a virtual environment:

cd ~/vibe-coding-workspace
python3 -m venv .venv

This creates a .venv directory inside your project that contains a copy of Python and an empty set of packages. The .venv name is a convention — the dot makes it a hidden directory on macOS and Linux.

Activating the Virtual Environment

You must activate the virtual environment before using it:

macOS/Linux:

source .venv/bin/activate

Windows (PowerShell):

.venv\Scripts\Activate.ps1

Windows (CMD):

.venv\Scripts\activate.bat

Windows (Git Bash):

source .venv/Scripts/activate

When activated, your terminal prompt changes to show the environment name:

(.venv) $

Common Pitfall: On Windows, you may encounter an execution policy error when running the PowerShell activation script. Fix it by running PowerShell as Administrator and executing: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser. You only need to do this once.

Installing Packages with pip

With your virtual environment activated, use pip to install packages:

pip install requests
pip install python-dotenv
pip install rich

These packages will be useful throughout the book:

  • requests — Making HTTP requests (API calls)
  • python-dotenv — Loading environment variables from .env files
  • rich — Beautiful terminal output with colors and formatting

To see what is installed:

pip list

To save your project's dependencies to a file:

pip freeze > requirements.txt

To install all dependencies from a requirements file (for example, when setting up on a new machine):

pip install -r requirements.txt

Managing Environment Variables with .env Files

Many AI tools require API keys stored in environment variables. Rather than setting these in your shell profile (where they apply to everything), you can use a .env file that is specific to each project.

Create a .env file in your project root:

# ~/vibe-coding-workspace/.env
ANTHROPIC_API_KEY=sk-ant-your-key-here
OPENAI_API_KEY=sk-your-openai-key-here
PROJECT_NAME=my-vibe-project
DEBUG=true

Then load it in your Python code using python-dotenv:

from dotenv import load_dotenv
import os

load_dotenv()  # Loads variables from .env file

api_key = os.getenv("ANTHROPIC_API_KEY")
print(f"API key loaded: {api_key[:10]}...")  # Print only first 10 chars for safety

Common Pitfall: Never commit your .env file to Git. It contains secrets. Add it to your .gitignore file immediately: bash echo ".env" >> .gitignore We will include this in our setup verification script in Section 4.10.

Understanding pip and PyPI

When you run pip install requests, pip downloads the requests package from PyPI (the Python Package Index, https://pypi.org). PyPI is a repository of over 500,000 Python packages, covering everything from web frameworks to data science tools to AI libraries. Anyone can publish a package on PyPI, which makes it an incredibly rich ecosystem but also means you should be thoughtful about what you install.

Here are some additional pip commands you will use frequently:

# Install a specific version of a package
pip install requests==2.31.0

# Install the latest version within a range
pip install "requests>=2.28,<3.0"

# Upgrade an existing package to the latest version
pip install --upgrade requests

# Uninstall a package
pip uninstall requests

# Show details about an installed package
pip show requests

# Check for outdated packages
pip list --outdated

Common Pitfall: Be careful with pip install --upgrade when working with AI-generated code. AI tools sometimes suggest upgrading packages without considering that newer versions might have breaking API changes. If your code works with the current version, there is usually no reason to upgrade unless you need a specific new feature.

Deactivating the Virtual Environment

When you are done working on a project, deactivate the environment:

deactivate

Your prompt returns to normal, and Python commands use the global installation again.

Best Practice: Create a new virtual environment for every project. It takes only a few seconds and prevents hours of debugging dependency conflicts. Make it a habit: create directory, initialize Git, create virtual environment — in that order.

Virtual Environments and AI Tools

One important thing to understand: your virtual environment affects Python packages, but it does not affect system-wide tools like Claude Code, Git, or VS Code. Those tools are installed globally and are available regardless of whether a virtual environment is active. The virtual environment only controls which Python packages are available when you run python or import statements.

This means you can use Claude Code to generate code that uses specific packages, and as long as those packages are installed in your active virtual environment, the generated code will run correctly. If Claude suggests installing a package, make sure you run the pip install command with your virtual environment activated.


4.10 Verifying Your Setup: The Hello Vibe Test

You have installed Python, VS Code, Claude Code, Copilot, Cursor, Git, and configured your terminal. Now let us verify that everything works together.

The Verification Script

We have created a comprehensive verification script that checks every component of your setup. You will find it in this chapter's code directory as example-01-verify-setup.py.

Navigate to your workspace and create the verification script, or copy it from the book's code repository:

cd ~/vibe-coding-workspace

Run the verification script:

python3 code/example-01-verify-setup.py

The script checks for:

  1. Python version (3.10+)
  2. pip availability
  3. Git installation and configuration
  4. Node.js (required for Claude Code)
  5. Claude Code CLI
  6. VS Code
  7. Virtual environment functionality
  8. Required Python packages
  9. Environment variable configuration
  10. .gitignore file with proper entries

For each check, it prints a green checkmark or a red X with a helpful message explaining how to fix any issues.

The Hello Vibe Test Program

After verifying your tools, run the "Hello Vibe" program (example-03-hello-vibe.py) that exercises your complete setup:

python3 code/example-03-hello-vibe.py

This program:

  1. Confirms Python is working with type hints and modern syntax
  2. Demonstrates loading environment variables from a .env file
  3. Creates a sample file using Python's file I/O
  4. Reads the file back and displays it with formatted output
  5. Checks Git integration by running git status
  6. Prints a congratulatory message confirming your environment is ready

Real-World Application: Professional developers often create setup verification scripts for their teams. When a new team member joins, they run the script to ensure their environment is configured correctly before writing any code. The script you create here serves the same purpose — it is your personal "environment health check" that you can run any time something seems wrong.

Troubleshooting Common Issues

Here are the most common problems students encounter when setting up their environment, along with solutions:

Problem: python command not found

  • Windows: Reinstall Python with "Add to PATH" checked
  • macOS/Linux: Use python3 instead of python, or create an alias (see Section 4.7)

Problem: pip install gives a permission error

  • Make sure your virtual environment is activated (you should see (.venv) in your prompt)
  • Never use sudo pip install — it installs packages globally and can break your system Python

Problem: Claude Code says "API key not found"

  • Check that ANTHROPIC_API_KEY is set: echo $ANTHROPIC_API_KEY
  • If it is empty, re-read the API key setup in Section 4.4
  • Make sure you have reloaded your shell profile or restarted your terminal

Problem: Copilot not showing suggestions

  • Check the Copilot icon in the VS Code status bar
  • Sign out and sign back in to GitHub within VS Code
  • Ensure your Copilot subscription is active at https://github.com/settings/copilot

Problem: Git says "Please tell me who you are"

  • Run the git config commands from Section 4.8 to set your name and email

Problem: Virtual environment activation fails on Windows PowerShell

  • Run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser in an elevated PowerShell
  • Try using Git Bash instead of PowerShell

Problem: npm install -g fails with EACCES (permission denied)

  • Follow the npm permission fix in Section 4.4
  • Alternatively, use npx to run Claude Code without global installation: npx @anthropic-ai/claude-code

Best Practice: When troubleshooting, change one thing at a time and test after each change. If you change three things at once and it starts working, you will not know which fix actually solved the problem — and you might have introduced new issues with the other two changes.

Understanding What the Scripts Check

Let us briefly walk through what the verification script checks and why each component matters:

  1. Python version (3.10+): Ensures you can use modern Python features like structural pattern matching and improved type hints. Without this, AI-generated code may use syntax your Python does not understand.

  2. pip availability: Ensures you can install packages. Some Linux distributions separate pip from Python, requiring a separate installation.

  3. Git installation and configuration: Checks that Git is installed and that you have set your name and email. Without Git configuration, you cannot make commits, and without commits, you have no safety net for AI-generated changes.

  4. Node.js (18+): Required by Claude Code. Claude Code is built with Node.js, so without it, the claude command will not work.

  5. Claude Code CLI: Checks that the claude command is available. If Node.js is installed but Claude Code is not, this will fail.

  6. VS Code: Checks that the code command is available, which means VS Code is installed and on your PATH.

  7. Virtual environment support: Some Python installations (especially on Linux) do not include the venv module by default. This check catches that issue.

  8. Required packages: Checks for requests, python-dotenv, and rich — the three packages we use frequently in this book.

  9. API key configuration: Checks that ANTHROPIC_API_KEY is set in the environment.

  10. .gitignore file: Verifies that your project has a .gitignore that excludes .env, .venv/, and __pycache__/.

Creating Your Project Template

Now that everything is verified, let us create a project template that you can copy for every new project in this book:

mkdir -p ~/vibe-project-template
cd ~/vibe-project-template
git init
python3 -m venv .venv
source .venv/bin/activate  # or .venv\Scripts\Activate.ps1 on Windows
pip install requests python-dotenv rich
pip freeze > requirements.txt

Create a .gitignore file:

.venv/
.env
__pycache__/
*.pyc
.DS_Store
.vscode/
*.egg-info/
dist/
build/

Create a .env.example file (a template that can be committed, unlike .env):

ANTHROPIC_API_KEY=your-key-here
PROJECT_NAME=my-project
DEBUG=false

Make your first commit:

git add .
git commit -m "Initial project setup"

Intuition: This template embodies a professional habit: starting every project with a clean foundation. Version control from the start, isolated dependencies, secret management, and a .gitignore that prevents common mistakes. As you progress through this book, you will add to this template, but the core structure stays the same.

Maintaining Your Environment Over Time

Your development environment is not a "set it and forget it" thing. Over time, you will need to:

  • Update Python packages periodically to get bug fixes and security patches. Run pip list --outdated inside your virtual environment to see what can be updated.
  • Update VS Code when prompted. VS Code auto-updates by default, but sometimes you need to restart the editor to complete an update.
  • Update Claude Code with npm update -g @anthropic-ai/claude-code to get the latest features and model support.
  • Update Git occasionally, especially on Windows where Git does not auto-update.

Best Practice: Set a calendar reminder to update your tools once a month. This prevents the "I haven't updated in a year and now everything is broken" problem. Small, frequent updates are much less disruptive than rare, large updates.

When you update tools, re-run the verification script to make sure everything still works together. Occasionally, an update to one tool can break compatibility with another. Catching this early, right after the update, makes it easy to identify and fix.

What Comes Next

With your environment set up and verified, you are ready to write real code with AI assistance. In Chapter 5, we cover the Python essentials you need as a vibe coder — not an exhaustive Python course, but the specific knowledge that makes you effective at reading, understanding, and directing AI-generated Python code. Then in Chapter 6, you will build your first complete application using the tools you just installed.

Your vibe coding journey has moved from understanding (Chapters 1-3) to doing. The environment you built in this chapter is the launchpad for everything that follows.


Chapter Summary

In this chapter, you set up a complete vibe coding environment from scratch. You installed Python 3.10+ as your programming language, configured VS Code as your primary code editor with essential extensions, set up three AI coding tools (Claude Code, GitHub Copilot, and Cursor), configured your terminal and shell, installed and configured Git for version control, learned to create virtual environments and manage packages with pip, and verified everything works with a comprehensive test script.

The key insight is that a well-configured environment reduces friction. Every minute spent on proper setup saves hours of troubleshooting later. The tools you installed form an integrated system: VS Code is your editor, Copilot provides inline completions, Claude Code handles complex reasoning and file manipulation, Cursor offers an AI-native editing alternative, Git tracks your changes, virtual environments isolate your projects, and your terminal ties everything together.

You now have everything you need to start vibe coding. The next chapter ensures you have the Python knowledge to make the most of it.


Key Terms

Term Definition
API key A secret string that authenticates you with a web service, like a password for programmatic access
CLI Command Line Interface — a program you interact with by typing text commands in a terminal
Extension An add-on that gives VS Code (or Cursor) new capabilities
IDE Integrated Development Environment — a program that combines a code editor with debugging, testing, and other development tools
Node.js A JavaScript runtime needed to run Claude Code and many other developer tools
npm Node Package Manager — used to install Node.js packages like Claude Code
PATH An environment variable listing directories where your shell looks for executable programs
pip Python's package manager, used to install libraries
Shell The program (Bash, Zsh, PowerShell) that interprets your typed commands in the terminal
Shell profile A configuration file that runs every time you open a new terminal session
Terminal An application that provides a text-based interface for running commands
Token The basic unit of text that AI models process, roughly corresponding to a word or word fragment
venv Python's built-in virtual environment module
Virtual environment An isolated Python installation for a specific project, preventing package conflicts