Harvard Data Science Initiative Harvard Faculty of Arts and Sciences

Generative AI for Scholarship

Harvard Data Science Initiative (HDSI) & Faculty of Arts and Sciences (FAS)
API Key for This Session
The key will be posted shortly before the session and will work until midnight on the day of the session.
Retrieve API Key (Harvard Key required)

Week 3 — Unleashing Claude Code Command Line Interface as a Problem Solver

Friday, March 6, 2026 · 4:00–5:30 pm · Northwest Building, Room B103

Important: The setup below installs an AI agent that can read, write, and execute code on your laptop. While we will run it in a sandboxed mode with restricted permissions, we recommend performing a full backup of your system (e.g. via Time Machine) before proceeding.
Windows users: This page covers Mac setup. See the Windows setup guide for PowerShell-based instructions.

This session focuses on Claude Code, Anthropic's agentic coding tool that runs in your terminal. We will use Claude Code to carry out programming and data analysis tasks interactively, from your command line.

Claude Code CLI vs. Claude Cowork

Anthropic offers two agentic AI tools. This session focuses on Claude Code CLI, but participants should be aware of Claude Cowork as well:

Claude Code CLI Claude Cowork
Interface Terminal (command line) Claude Desktop GUI
Primary focus Coding, programming, data analysis Knowledge work (documents, spreadsheets, research)
Typical outputs Code, scripts, plots, analysis pipelines Excel with formulas, PowerPoint, formatted documents
Requires Command line comfort Just the desktop app
Runs on Mac, Linux, Windows (WSL) Mac, Windows (x64)
Authentication API key (HUIT Bedrock for Harvard) Paid Anthropic subscription (Pro, Max, Team, or Enterprise)
Harvard billing Charged to PI's HUIT account Personal subscription ($20+/month)
Note: Claude Cowork authenticates through the Claude Desktop app login — it does not use API keys or environment variables, and cannot be routed through Harvard's HUIT Bedrock endpoint. Data sent through Cowork is subject to Anthropic's standard data policies, not Harvard's enterprise agreements.

Getting Claude Cowork (Optional)

If you have a paid Anthropic subscription and want to try Cowork:

  1. Download Claude Desktop from claude.ai/download (available for Mac and Windows x64)
  2. Log in with your Anthropic account
  3. Switch to Cowork mode using the mode selector in the app

For more details, see the Cowork getting started guide.

Prerequisites

We will support Mac (macOS) systems for this workshop.

Getting Started: Open Terminal and Test Python

Open the Terminal application on your Mac: in Finder, go to Applications → Utilities → Terminal and double-click to launch it. You will use this window for all the steps below.

Create your working directory

mkdir -p ~/GAIsandbox
cd ~/GAIsandbox

Verify Python is installed

Check that Python 3 is available on your system:

which python3

You should see a path like /usr/bin/python3 or /Library/Frameworks/Python.framework/.../python3. If you get no output, you will need to install Python 3 before continuing.

Run a test script

Create a file called hello.py with the following contents (or download it with the curl command below):

print("Hello! Python is working correctly.")
print()

import sys
print(f"Python version: {sys.version}")
print(f"Python location: {sys.executable}")

To download directly into your current directory instead:

curl -O https://astrostubbs.github.io/GenAI-for-Scholarship/hello.py

Then run it:

python3 hello.py

You should see output like:

Hello! Python is working correctly.

Python version: 3.x.x (...)
Python location: /usr/bin/python3

Test plotting

Create a file called plottest.py with the following contents (or download it with the curl command below):

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 4 * np.pi, 200)
y = np.sin(x)

plt.figure()
plt.plot(x, y)
plt.xlabel("x")
plt.ylabel("sin(x)")
plt.title("Sine Wave — Plot Test")
plt.grid(True)
plt.show()

To download directly instead:

curl -O https://astrostubbs.github.io/GenAI-for-Scholarship/plottest.py

Then run it:

python3 plottest.py

A window should appear showing a sine wave plot. Close the plot window to continue. If you get an error about missing packages, install them by running the following in your Terminal window:

pip3 install numpy matplotlib

Then run python3 plottest.py again in Terminal.

If both tests pass, you're ready to proceed.

Installing Claude Code

Still in your Terminal window, install Claude Code with a single command:

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

Full documentation: Claude Code installation and setup

Environment Setup

Before launching Claude Code, you need to set environment variables that configure it to use Harvard's Bedrock endpoint. Use the API key from the link at the top of this page.

Create a file called trainingsetup.sh with the following contents (or download it with the curl command below):

#!/bin/bash
export ANTHROPIC_BEDROCK_BASE_URL=https://apis.huit.harvard.edu/ais-bedrock-llm/v2
export ANTHROPIC_API_KEY=YourKeyHere
export ANTHROPIC_SMALL_FAST_MODEL=us.anthropic.claude-opus-4-5-20251101-v1:0
export CLAUDE_CODE_SKIP_BEDROCK_AUTH=1
export CLAUDE_CODE_USE_BEDROCK=1

To download directly instead:

curl -O https://astrostubbs.github.io/GenAI-for-Scholarship/trainingsetup.sh

Then make it executable:

chmod 755 trainingsetup.sh

Open trainingsetup.sh in nano (a simple terminal text editor):

nano trainingsetup.sh

Use the arrow keys to move the cursor to YourKeyHere on the second line. Delete it and paste your API key in its place. Then:

  1. Press Ctrl+O (the letter O) to save — press Enter to confirm the filename
  2. Press Ctrl+X to exit nano

Now source the file to set the environment variables:

source ./trainingsetup.sh

Security: Never Share Your API Key

Your API key is like a password — treat it with the same level of security.

Launching Claude Code

With the environment variables set, start Claude Code from your working directory:

cd ~/GAIsandbox
claude

You will be prompted to log in on first use. For this workshop we are using Harvard's API endpoint, so you do not need a personal Claude subscription.

This warning is expected and safe to ignore:
Auth conflict: Using ANTHROPIC_API_KEY
 instead of Anthropic Console key. Either
  unset ANTHROPIC_API_KEY, or run `claude
  /logout`.
This just means Claude Code is using your HUIT API key (from ANTHROPIC_API_KEY) instead of a personal Anthropic account. That's exactly what we want — no action needed.

Exercises

Next Steps: Running Claude Code on Your Own

After the workshop, if you want to continue using Claude Code with your own Anthropic account, we recommend enabling sandboxed mode. This restricts Claude Code to your working directory and limits network access, giving you an extra layer of safety.

To enable sandboxing, launch Claude Code and type:

/sandbox

Select auto-allow mode from the menu. You can also download this settings file to enable it automatically at launch: sandbox-settings.json

claude --settings ./sandbox-settings.json

For more details, see the Claude Code sandboxing documentation.

After the Session: Get Your Own API Key

Important: The API keys provided during this session will be disabled after the course ends. To continue using Claude Code, you will need to obtain your own Anthropic API key.

For Harvard users, we have prepared detailed instructions on how to set up API access through Harvard's HUIT system:

Setting Up Anthropic API Access for Harvard Users

Post-Session Survey

Please take a moment to share your feedback — it helps us improve future sessions.

Take the Post-Session Survey