Heidelberg AICurriculum
Track 13 · Advanced
13.2.2

Claude Code

Terminal agent that reads, writes, and runs your codebase

5 lessons 2026-08-06 AI-generated

1Overview

Anthropic's own entry in the agentic-coding category — it treats your whole repository as its workspace rather than one open file, and keeps iterating through a failing test instead of stopping at the first error.

Claude Code is Anthropic's agentic coding tool that runs in your terminal, VS Code, JetBrains, or browser and interacts with your actual codebase — not a sandboxed snippet. It reads every file in a project, makes coordinated multi-file edits, runs tests, creates git commits, and opens pull requests, iterating on failures until they're fixed. → Requires a paid Claude subscription; no free tier.

1.2After this chapter you can
Read and edit multiple files in a single turn for refactors spanning several modules
Run your code directly and iterate on failures until tests pass
Use git-aware commits, branches, and pull requests without leaving the terminal
1.3Best for

Refactors spanning several files, and letting an agent run your code and fix its own failures — reads a traceback, patches the bug, re-runs.

1.4Watch out

No free tier — a paid Claude subscription ($17–20/mo minimum) is mandatory. 'Fast mode' burns tokens ~6x faster; watch usage on Max plans.

1.5Free vs paid

Claude Pro ($17/mo annual, $20/mo monthly) minimum; Max plans at $100/mo (5x usage) and $200/mo (20x usage) for heavier workloads.

2Lessons 5

2.1 Install the Claude Code CLI

The Claude Code command‑line interface that lets you run Claude directly from your terminal.

You will have a working claude command on your system.

  1. Open a terminal on macOS, Linux or WSL.
  2. Run the native install script: curl -fsSL https://claude.ai/install.sh | bash.
  3. If you are on Windows PowerShell, run: irm https://claude.ai/install.ps1 | iex.
  4. After installation finishes, verify the command is available by running claude --help.
  • You'll see claude prints its usage information, confirming the CLI is installed.
  • Takeaway CLI tools can be added to your PATH with a single install script, enabling immediate use from any terminal session.

2.2 Start a Claude Code session in a local project

A Claude Code interactive session that can read and edit files in the directory you point it to.

You will launch Claude inside a sample project and be ready to give it commands.

  1. Create or navigate to a small codebase, e.g., mkdir demo && cd demo and add a simple file like echo "console.log('hi');" > index.js.
  2. In the project root, run claude to start a session.
  3. When prompted for login, either sign in with your Anthropic account or set the environment variable ANTHROPIC_API_KEY beforehand.
  4. Wait until Claude shows the prompt ready for input.
  • You'll see Claude displays a chat‑style prompt inside the terminal, indicating it has loaded the project files.
  • Takeaway Launching Claude in a directory gives the model full visibility of every file, enabling multi‑file reasoning and edits.

2.3 Ask Claude to generate tests for an uncovered function

A request to Claude Code to create test files that match the project's existing testing framework.

Claude will add a new test file with scaffolding for the target function.

  1. Identify an untested function, e.g., add function add(a,b){return a+b;} to math.js.
  2. In the Claude session, type: find functions in math.js that are not covered by tests and press Enter.
  3. When Claude replies with the uncovered function, ask: write Jest tests for the add function covering typical and edge cases.
  4. Review the diff Claude proposes; if it looks correct, click (or type) accept to apply the changes.
  • You'll see A new file such as math.test.js appears with several test cases, and the terminal shows a + indicator confirming files were added.
  • Takeaway Claude can automatically generate test scaffolding that follows your project's conventions, accelerating test coverage work.

2.4 Create a git commit for the changes

A Claude‑driven command that stages modified files, writes a descriptive commit message, and records the commit.

Your repository will have a new commit containing the test additions.

  1. Ensure you are inside a git repository (git init if needed).
  2. In the Claude session, type: commit my changes with a descriptive message.
  3. Claude will stage the changed files and propose a commit message; review the suggested message.
  4. Approve the commit by responding with accept.
  • You'll see git log -1 shows the new commit with the message you approved, confirming the changes are recorded.
  • Takeaway Claude can automate routine git operations, reducing context switches between editor and terminal.

2.5 Open a pull request for the new tests

A Claude‑initiated workflow that pushes a branch to GitHub and opens a PR.

A pull request containing your test additions will appear on GitHub.

  1. Make sure the repository has a remote on GitHub (git remote add origin ).
  2. In the Claude session, type: create a pr for my changes.
  3. Claude will create a new branch, push it to the remote, and open a PR; it will display the PR URL.
  4. Open the displayed URL in a browser to verify the PR contains the test files and the commit message.
  • You'll see GitHub shows an open pull request with your changes, ready for review or merge.
  • Takeaway Claude can bridge local development and remote collaboration platforms, streamlining the code‑review pipeline.

3You’ll know it worked 10 checkable outcomes in this chapter

  • Endpoint returns aggregated row counts grouped by status and appears in OpenAPI docs
  • All 30 files compile with tsc --noEmit and downstream teams see autocompletion
  • PID controller unit tests achieve 100% branch coverage in Unity
  • The no-std Rust crate compiles for Cortex-M4 and property tests detect an unreachable transition that was silent in the C version
  • A validation_report.csv lists all changes and flags, and no study_id appears more than once
  • Claude Code scans only the file with the named failure
  • Claude Code outputs flagged anomalies to stdout, which can be captured by CI
  • The skill authenticates using the new provider without errors

10 outcomes in all — one per recipe below.

4FAQ, Tips & How-to 10

one problem, one solution, one action

Internal tools & ops5

How-to Claude Code Founder +1

Need a FastAPI summary endpoint for report statuses

The endpoint is live and tested within 20 minutes: five files change consistently, and the generated OpenAPI spec is correct on the first try because the agent already caught its own mistakes.

~8 min · low code AI-generated
How-to Claude Code Robotics

PID code mixed with hardware

The PID module gains 100 % branch coverage in a host-side Unity test suite; a tuning bug in the derivative term is caught before it reaches a patient fitting.

~8 min · low code AI-generated
How-to Claude Code Robotics

Port a C grip‑pattern state machine to Rust

The Rust crate compiles for the Cortex-M4 target; the property-based tests catch an unreachable transition that had been silently dead in the C version for two firmware generations.

~8 min · low code AI-generated
How-to Claude Code developer

Vague prompts push Claude Code to scan the whole codebase before it can even start fixing anything.

~8 min · low code AI-generated
How-to Claude Code developer

Need to spot odd entries in the last part of a log file

The same headless mode lets /schedule run Claude Code Routines on a recurring schedule.

~8 min · low code AI-generated

Knowledge & docs1

How-to Claude Code Operations +1

JavaScript utility with no types

A 30-file library is fully typed in one session; downstream teams immediately benefit from autocomplete and compile-time safety.

~8 min · low code AI-generated

Dashboards & analytics1

How-to Claude Code Finance +1

Manual month‑end data pull takes half a day

The analyst's monthly close reporting cycle drops from a half-day manual pull to a 90-second script run; the output matches CFO expectations on the first pass.

~8 min · low code AI-generated

Research & data tools1

How-to Claude Code Physician

Messy patient registry with duplicate IDs and bad dates

A 3,000-row registry export that would take an afternoon to clean by hand in a spreadsheet is validated in minutes, with a full change log the physician reviews before using the data for any analysis.

~8 min · low code AI-generated
How-to Claude Code Everyone

Need to tweak AI behavior or swap authentication

You can tailor the AI's behavior and technology choices (like swapping authentication providers) by modifying the skill's internal files, creating a personalized template for future projects.

youtube.com ↗ Summary → AI-generated
How-to Claude Code Everyone

Can't tell if AI‑generated code has security holes

AI agents may miss security vulnerabilities, so you can install separate skills (like an OWASP Top 10 scanner) to automatically audit your generated projects for common security issues.

youtube.com ↗ Summary → AI-generated

The same set on /recipes, filtered by tool and role.

5Videos 3

6FAQ 12

What exactly is Claude Code, and is it different from the regular Claude chatbot?

Claude Code is a coding assistant that runs inside your computer's terminal (command line), not a browser chat window. Unlike the regular Claude chatbot, it can directly read your project files, edit them, run programs, and use tools like Git — all through plain English instructions. Think of it as an AI colleague who sits in your project folder and can do real work on your files, rather than just giving you text advice to copy-paste.

What is MCP, and do I need to worry about it as a beginner?

MCP (Model Context Protocol) is an open standard that lets Claude Code connect to external tools and data sources — for example, reading files from Google Drive, querying a database, or pulling data from other apps. As a beginner doing local data analysis you do not need MCP at all. It becomes useful later if you want Claude to interact with services beyond your own computer.

Does Claude Code work in VS Code or other editors, or do I have to use the terminal?

Claude Code is available in multiple environments: the terminal (full CLI), a desktop app for macOS and Windows, a VS Code extension, JetBrains IDE plugins, and a browser. For someone new to the terminal, the desktop app or VS Code extension may feel more comfortable. All environments use the same underlying engine, so your CLAUDE.md instructions and settings work everywhere.

How do I get the best results from Claude Code as a beginner?

The official docs recommend being specific: instead of 'fix this script', say 'the script crashes when the CSV has missing values in column 3 — fix it and re-run the analysis'. Start a session by asking 'what does this project do?' so Claude understands your files before making changes. For risky changes, use Plan Mode (Shift+Tab twice) to have Claude propose a plan you can review before any files are touched.

What are Claude Code's limitations for scientific work? Should I trust its output without checking?

No — always review Claude Code's output before using it in a paper or analysis. It does not make scientific methodological decisions for you and can miss subtle statistical errors or domain-specific edge cases. It works best on clearly defined tasks with verifiable outputs ('run these tests', 'clean these column names'). The more precisely you specify your question, the more reliable the result. Treat its output as a first draft written by a capable but non-specialist assistant.

How much does using Claude Code actually cost in practice?

On a Pro or Max subscription, Claude Code usage is included within your plan's usage limits rather than billed per token. 'Fast mode' (priority inference) consumes credits faster, so heavy or long sessions on the lower plans can hit limits. For occasional use — a few analysis sessions a week — the Pro plan is usually enough; monitor your usage and step up to Max only if you regularly run out.

Do I need a paid subscription to use Claude Code? Which plan should I get?

Yes — Claude Code requires a paid Claude plan; the free plan does not include access. The Pro plan ($20/month) is the entry point and works well for occasional use. If you hit usage limits regularly, the Max plan starts at $100/month (5× more usage) or $200/month (20× more usage). For occasional data analysis scripts, Pro is usually sufficient to start.

How do I install Claude Code? Do I need to be a programmer to do it?

Installation uses a single command you paste into your terminal, and the native installer is self-contained — you do not need Node.js or Python pre-installed. After installing, type 'claude' in your terminal and follow the browser login prompt. The official Quickstart walks through it step by step.

Can I use Claude Code for data analysis even if I don't know how to code?

Yes. You describe your dataset and your question in plain English, and Claude Code writes and runs the analysis for you. One published demonstration had it analyze decades of weather records and produce charts and written summaries with no manual coding by the user. The key skill you supply is understanding what question you are asking — not how to write the Python or R to answer it.

What kind of data analysis tasks can Claude Code help with?

Claude Code can load data files (CSV, Excel, etc.), clean messy data, run statistical analyses, generate plots, write Python or R scripts, debug errors, and produce written summaries of findings. It is well-suited to tasks in biology: analysing sequencing results, cleaning field-survey spreadsheets, running regressions, or automating repetitive file processing. It does not replace your scientific judgement about which statistical method is appropriate — that remains your responsibility.

Does Claude Code remember what my project is about between sessions?

By default each session starts fresh. However, two mechanisms carry knowledge across sessions: a file called CLAUDE.md that you (or Claude) write in your project folder with project-specific instructions, and auto memory, where Claude saves learnings like build commands and your preferences. Run /init when you start a project to have Claude generate a CLAUDE.md automatically from your files.

How is Claude Code different from ChatGPT for coding and data analysis?

The biggest practical difference is that Claude Code runs inside your project and directly reads, edits, and executes your files, whereas ChatGPT in a browser requires you to copy-paste code back and forth. Claude's large context window means it can hold an entire research project in view at once, which is useful for multi-file analyses. Independent comparisons find Claude strong at generating efficient Python and at long-document analysis.

7Glossary 34 terms

Show the 34 terms
Claude Code
claude
The command you type in your terminal to start a Claude Code session; running it opens an interactive AI coding assistant in your project folder.
claude -p "query"
Runs Claude Code in print mode — Claude answers the query and exits immediately, making it useful in scripts and automated pipelines.
-p
Short form of --print; tells Claude Code to respond to a single query and exit without opening an interactive session.
claude --permission-mode plan
Starts Claude Code in plan mode so it describes what it intends to do before making any file or code changes, letting you review and approve first.
default
The standard permission mode where only read operations run without prompting; file edits and shell commands always ask for your approval.
acceptEdits
A permission mode that auto-approves file edits and common filesystem commands (mkdir, touch, rm, mv, cp, sed) without prompting, while still asking before other shell commands.
plan
A permission mode where Claude reads files and runs shell commands to explore your codebase, but cannot edit source files until you approve its proposed plan.
/
Typing a forward slash at the start of your message opens the command menu so you can see and filter all available Claude Code commands.
/help
Shows a list of available commands and a brief description of each.
/clear
Starts a fresh conversation with empty context; the previous conversation stays available via /resume.
/resume
Opens a picker to return to a previous conversation by name or ID, restoring the full message history.
/rewind
Rolls the conversation and code changes back to an earlier point, or summarizes from a selected message, letting you undo a direction that went wrong.
/usage
Shows session cost, plan usage limits, and activity statistics, including a breakdown by skill, subagent, and MCP server on paid plans.
/compact
Summarises the conversation so far to free up context space; you can optionally tell it what to focus on (e.g. /compact Focus on test output).
/context
Displays a visual breakdown of what is filling your context window and shows optimization suggestions and capacity warnings.
/model
Opens a picker to switch the AI model Claude Code uses; the choice is saved as your default for new sessions.
/config
Opens the Settings panel where you can change your theme, model, output style, and other preferences.
/mcp
Manages MCP server connections and OAuth authentication; run with no argument to open the interactive list.
/schedule
Creates or manages routines that run on Anthropic-managed cloud infrastructure on a schedule, even when your computer is off.
/loop
Runs a prompt repeatedly while the session stays open; omit the interval and Claude self-paces between iterations.
/skill-name
The pattern for invoking any custom skill you have created; replace skill-name with the actual name of your SKILL.md file (e.g. /review-pr).
.claude/skills/review-pr/SKILL.md
An example skill file path; a SKILL.md placed in .claude/skills/<name>/ defines a reusable workflow Claude loads when you run /<name>.
.claude/commands/*.md
The legacy location for custom command files; any .md file placed here also creates a slash command and continues to work alongside the newer .claude/skills/ layout.
model: haiku
A settings key that pins the AI model to Haiku (a faster, lower-cost Claude model) for a project or session.
PreToolUse
A hook event that fires just before Claude runs any tool, letting you inspect or block the action with a shell script before it takes effect.
Bash
Claude Code's built-in shell tool that executes terminal commands on your machine; it is the tool name used in permission rules and hooks.
pandas
A popular Python library for working with tabular data such as spreadsheets and CSV files; used in many data-analysis scripts.
seaborn.histplot
A Python function from the Seaborn visualisation library that draws a histogram (a bar chart showing how values are distributed).
pytest tests/ -q
Runs the automated test suite in the tests/ folder using pytest, with -q (quiet) flag to show only failures rather than every test name.
git diff
A git command that shows exactly which lines have been added or removed in your files since the last saved version.
gh
The official GitHub command-line tool; Claude Code uses it to create pull requests, read comments, and interact with GitHub repositories.
aws
The Amazon Web Services command-line tool; lets you control cloud services such as S3 storage and Lambda functions from the terminal.
None
Python's built-in value meaning 'nothing' or 'no result'; a function returns None when it has no explicit return value.
ValueError
A standard Python error raised when a function receives an argument of the right type but an unacceptable value, such as a negative number where a positive one is required.

8See also

💬 Discuss this chapter

Ask, share, or report — over on the Heidelberg AI community forum.