Lecture 28: Running Claude Code

Learning Objectives

By the end of this lecture, you will be able to:

  • Create a personal GitHub repository for your MRSA analysis work
  • Install git and the Claude Code CLI on macOS, Linux, or Windows (via WSL2)
  • Authenticate Claude Code with your provided API key
  • Clone your repository and launch Claude Code inside it
  • Direct Claude Code to fetch the class assemblies and start aligning them against the MRSA reference

0. Before We Start — Submit Your Assembly

ImportantAction required: submit your assembly URL via the form

Before today’s exercise, re-submit a link to your MRSA isolate assembly using this Google form:

https://forms.gle/NoAcPSddhjGT9noT6

The form asks for your email address and a URL to the FASTA file produced by your assembler.

The URL must point to a FASTA assembly. Nothing else.

  • ✅ A link to the FASTA dataset itself (e.g. a Galaxy dataset URL ending in ?to_ext=fasta, or a direct HTTPS link to a .fasta / .fasta.gz file)
  • ❌ Not a link to a Galaxy history (URLs with /u/<user>/h/...)
  • ❌ Not a link to a FASTQ, BAM, tabular report, or image
  • ❌ Not a link to a folder or shared drive

If you are unsure how to get a direct FASTA link from Galaxy: open the dataset, click the floppy-disk / save icon or the dataset title, and copy the URL that ends in /display?to_ext=fasta.


1. What Is Claude Code?

Claude Code is Anthropic’s command-line coding agent. You run it in a terminal inside any directory—a software project, an analysis folder, a notebook repo—and interact with it through natural-language prompts. The agent reads files, runs commands, edits code, and explains what it did, all with your approval policy in place.

Claude Code is not a chatbot; it is an interactive terminal program that spawns tools (shell, file editor, git, package managers) on your machine. Everything happens locally, under your user account, inside the directory where you started it.

In this lecture we will (1) create a GitHub repository to hold your MRSA analysis, (2) install Claude Code and git on your laptop, (3) clone that repository locally, and (4) launch Claude Code inside it so that all analysis we do in the next class happens in one place.


2. Prerequisites

  • A GitHub account (sign up at github.com if you do not have one)
  • A working terminal on one of the supported platforms:
    • macOS 11+ (Intel or Apple Silicon)
    • Linux x86_64 or ARM64 with at least 4 GB RAM (Ubuntu 20.04+, Debian 11+, or equivalent)
    • Windows 10/11 with WSL2 (Windows Subsystem for Linux) enabled
  • The Anthropic API key distributed earlier in the semester (the same one you used to configure gxy3 in Lecture 25)

You do not need Node.js, Python, or any IDE to get started—Claude Code ships as a single native binary.


3. Create an MRSA-analysis Repository on GitHub

We will keep all your isolate-alignment work in a fresh GitHub repository. Create it empty—Claude Code will fill it up.

  1. Go to github.com and sign in
  2. Click the + icon in the top-right corner → New repository
  3. Fill in the form:
    • Repository name: MRSA-analysis
    • Description (optional): “MRSA isolate alignment against NCTC 8325 reference”
    • Visibility: Public is fine—the repo will only contain your own work. Choose Private if you prefer
    • Initialize this repository with: check Add a README file. Leave .gitignore and license as None for now
  4. Click Create repository

GitHub now shows your new, almost-empty repository. Copy the HTTPS clone URL from the green <> Code button—it looks like:

https://github.com/<your-username>/MRSA-analysis.git

You will paste this URL in §8 when you clone the repo.

NoteNo sharing required

You do not need to add collaborators or change permission settings. A fresh, empty repository under your own account is all we need.


4. Installation: Claude Code on macOS

The officially recommended install method is the native installer. Open Terminal (Cmd+Space, type “Terminal”) and paste:

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

The script detects Intel vs. Apple Silicon automatically, downloads the right binary, and drops it on your PATH. Re-open the terminal (or exec $SHELL) so the new path is picked up.

TipHomebrew alternative

If you already use Homebrew and prefer it:

brew install --cask claude-code          # stable
# or
brew install --cask claude-code@latest   # rolling

Homebrew installations do not auto-update; you must run brew upgrade manually. The native installer auto-updates in the background.

Verify the install:

claude --version
claude doctor

claude doctor prints a detailed environment report—useful if something later goes wrong.


5. Installation: Claude Code on Linux (Ubuntu/Debian)

Same native installer as macOS:

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

If you prefer system package management, Anthropic also publishes an APT repository that auto-updates along with the rest of your system:

sudo install -d -m 0755 /etc/apt/keyrings
sudo curl -fsSL https://downloads.claude.ai/keys/claude-code.asc \
    -o /etc/apt/keyrings/claude-code.asc
echo "deb [signed-by=/etc/apt/keyrings/claude-code.asc] https://downloads.claude.ai/claude-code/apt/stable stable main" \
    | sudo tee /etc/apt/sources.list.d/claude-code.list
sudo apt update
sudo apt install claude-code

Verify:

claude --version
claude doctor

6. Installation: Claude Code on Windows (via WSL2)

On Windows, the recommended path is to run Claude Code inside WSL2—Microsoft’s lightweight Linux container that ships with Windows 10/11. This gives you a real Linux environment (shell, filesystem, package manager) while keeping your Windows desktop. Everything the agent does happens inside the WSL2 container.

NoteWhy WSL2 and not native Windows?

A native Windows installer exists (irm https://claude.ai/install.ps1 | iex), but most bioinformatics tooling—conda, samtools, fastp, salmon, and every pipeline we use in this course—was written for Unix. Running Claude Code in WSL2 means the commands the agent executes “just work.” Use native Windows only if your project is Windows-specific.

Step 1 — Install WSL2

Right-click the Start button, choose Terminal (Admin) or PowerShell (Admin), and run:

wsl --install --web-download -d Ubuntu

Reboot when prompted. After the reboot, an Ubuntu terminal opens automatically and asks you to create a Linux username and password. These are separate from your Windows login.

If Ubuntu does not open automatically, search for “Ubuntu” in the Start menu.

TipWindows 10 users

Run wsl --update in an admin PowerShell before Step 1 to make sure WSL2 is current. Windows 11 ships with WSL2 ready to go.

Step 2 — Install Claude Code inside WSL2

Everything from here on runs inside the Ubuntu window, not PowerShell. In the Ubuntu prompt, paste:

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

The exec bash at the end replaces your current shell with a fresh one so the new claude command appears on your PATH.

Step 3 — Verify

claude --version
claude doctor
TipWSL2 gotchas
  • Keep your work in the Linux filesystem (~/, not /mnt/c/...). Cross-filesystem reads from Windows (C:) into WSL2 are an order of magnitude slower and break some file-watching tools
  • The browser OAuth flow works: WSL2 can open your default Windows browser automatically on first claude run
  • To get back to your Ubuntu shell later, search for “Ubuntu” in the Start menu, or run wsl from any Windows terminal

7. Authenticate Claude Code with Your API Key

ImportantWe are authenticating with API keys in this class

Claude Code supports two auth flows: browser OAuth (sign in with an Anthropic account) and an API key. For this course we are using the API keys that were distributed earlier in the semester—the same key you used to configure gxy3 in Lecture 25. If you lost it, ask the instructor. Do not create a personal Anthropic account for this class; the provided key is already funded for your coursework.

In your terminal (Terminal on macOS, your Linux shell, or the Ubuntu window on Windows/WSL2), set the key as an environment variable:

export ANTHROPIC_API_KEY="sk-ant-..."

Replace sk-ant-... with the full key you were sent. This makes it available to the current shell.

To make the key persist across terminal sessions, append the same line to your shell’s startup file:

# macOS (zsh — the default since Catalina):
echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> ~/.zshrc

# Linux / WSL2 Ubuntu (bash):
echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> ~/.bashrc

Then reload the file: source ~/.zshrc (macOS) or source ~/.bashrc (Linux/WSL2).

ImportantAPI key security

The key is a password. Treat it accordingly:

  • Do not commit it to Git.zshrc / .bashrc are fine because they live outside any repo; never put the key in a file inside a project directory
  • Do not paste it into Slack, issue trackers, Zoom chat, or a shared notebook
  • Do not share it with classmates—each person has their own
  • A leaked key can run up charges on the class account. Tell the instructor immediately if you think yours has leaked, and we will rotate it

8. Install Git and Clone Your Repository

To get the empty MRSA-analysis repository you just created onto your laptop, you need git. It may already be installed; check with:

git --version

If the command is missing, install it on your platform:

  • macOS — either run xcode-select --install (the first time you use a developer command, macOS offers to install the Command Line Tools, which include git), or use Homebrew: brew install git
  • Linux (Ubuntu/Debian)sudo apt update && sudo apt install git
  • Windows (WSL2 / Ubuntu) — same as Linux: sudo apt update && sudo apt install git. Do not install Git-for-Windows; you want git inside WSL2 alongside Claude Code

Configure your identity once (this is what git stamps on each commit):

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

Use the email address associated with your GitHub account.

Now clone your repository. Replace <your-username> with your GitHub username:

cd ~                                 # start in your home directory
git clone https://github.com/<your-username>/MRSA-analysis.git
cd MRSA-analysis

You should see a single README.md file (created by GitHub when you initialized the repo). That is the project folder where all your analysis will live.

TipPushing back to GitHub

Cloning over HTTPS works out of the box. When you later run git push to send commits back, GitHub will ask for a Personal Access Token (not your password). The simplest way to handle this is to install GitHub’s CLI (gh) and run gh auth login, which sets up a credential helper for you—but you do not need this today, only cloning.


9. Launch Claude Code Inside Your Repository

Now that you are inside the MRSA-analysis folder, launch Claude Code:

claude

Because ANTHROPIC_API_KEY is set, Claude Code picks it up automatically, skips the browser flow, and drops you straight into an interactive session. On subsequent runs it reuses the same key.

TipAlways launch Claude Code from inside the project

Claude Code takes the directory you start it in as its workspace. Everything it reads, writes, and runs is scoped to that folder (and subfolders). Starting it from inside MRSA-analysis keeps all your generated scripts, downloaded data, and alignment outputs together—and makes them easy to commit and push to GitHub.

If you see a browser window open or a login prompt, the API key was not found—exit (Ctrl+D), check with echo $ANTHROPIC_API_KEY that your key is set in this shell, and try again.

Smoke test

At the > prompt, try:

List the files in this directory and summarize what the project does.

The agent should list the contents (just the README.md for now), read it, and give you a one-paragraph summary. If that works, you are set up.

Troubleshooting

Problem Fix
claude: command not found after install Open a new terminal or run exec $SHELL (macOS/Linux) / exec bash (WSL2)
Browser opens on first run (WSL2) The key is not set in this shell—re-source your shell rc file or re-run export ANTHROPIC_API_KEY=...
“API key invalid” on startup Run echo $ANTHROPIC_API_KEY — check for trailing whitespace or quoting errors; keys start with sk-ant-
Extremely slow file operations on Windows Make sure your project lives in ~/ inside WSL2, not under /mnt/c/
claude doctor reports a missing dependency Follow the doctor’s repair hint; usually a sudo apt install or a re-run of the installer

10. Download the Assemblies and Align Against the MRSA Reference

With Claude Code running inside MRSA-analysis, the rest of the exercise is just prompts. The 13 isolate assemblies are already committed to the course repository under:

data/assemblies/ on GitHub

The files are named assembly1.fasta.gz through assembly13.fasta.gz. Point Claude Code at that folder and it will pull them directly—no manual downloading, no manifest file.

A prompt like this is enough to kick things off:

Download assembly1.fasta.gz through assembly13.fasta.gz from https://github.com/nekrut/bda/tree/main/data/assemblies into a local assemblies/ directory. Keep them gzipped.

Claude Code will resolve the raw-file URLs and fetch each one. Leave the files compressed—every downstream tool we will use (minimap2, samtools, bwa) reads .fasta.gz directly, so there is no reason to waste disk on uncompressed copies.

The reference genome is Staphylococcus aureus NCTC 8325 (NC_007795.1). Ask Claude Code to fetch it:

Download the FASTA for NCBI accession NC_007795.1 as reference.fasta and index it with samtools faidx.

Once both the reference and the 13 assemblies are in place, ask Claude Code to align each assembly to the reference (e.g. with minimap2 -a) and save the per-isolate alignments under alignments/. We will iterate on this in the next class.


Next sections of this lecture will cover authoring your first custom slash command, configuring settings.json for permissions, and using subagents—to be added.