Module 2 ยท Beginner ยท ~25 min

๐Ÿš€ Your First Session

Learn how to have a productive conversation with Claude Code. Understand what makes a good prompt, how to give feedback, and how to get real work done.

Anatomy of a Claude Code session

When you type claude in your terminal and press Enter, here's what happens:

What Claude Code does when it starts

๐Ÿ“
Scans your folder
Reads file structure & names
๐Ÿ“‹
Reads CLAUDE.md
If it exists (Module 3)
๐Ÿง 
Builds context
Understands your project
๐Ÿ’ฌ
Waits for you
Shows the > prompt

You'll see something like this in your terminal:

# You typed: claude

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ โœป Welcome to Claude Code!               โ”‚
โ”‚   Working directory: ~/my-project       โ”‚
โ”‚   Type /help for available commands     โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

> 

That > is your prompt โ€” where you type your instructions to Claude.

Giving your first real task

Let's start with something concrete. Navigate to a folder with some data or code in it, start Claude Code, and try these:

Try typing these at the > prompt:

> Look at my do files and summarise what each one does in one sentence

> I have a dataset called hh_survey.dta โ€” write a do file that
  loads it, creates a table of summary statistics, and exports
  it to a CSV called summary_stats.csv

> This regression in line 45 of analysis.do is giving a
  "variable not found" error โ€” fix it

Try typing these at the > prompt:

> Look at my R scripts and tell me what packages they use

> I have a CSV called survey_data.csv โ€” write an R script that
  loads it with readr, creates a summary table using skimr,
  and saves a ggplot histogram of the income variable

> My RMarkdown file won't knit โ€” look at the error and fix it

Try typing these at the > prompt:

> What Python files are in this project and what do they do?

> I have a CSV called panel_data.csv โ€” write a pandas script
  that cleans it: fix column names, handle missing values,
  and create a summary statistics table

> There's a KeyError on line 23 of clean_data.py โ€” debug it

These work regardless of your tools:

> What files are in this folder? Summarise what this project seems to be about.

> Create a README.md file that explains what this project does,
  based on the files you see.

> Rename all the CSV files in the data/ folder to follow
  snake_case naming (e.g. "HH Survey Round 1.csv" โ†’ "hh_survey_round_1.csv")

Prompting effectively

The quality of Claude's output is directly related to the quality of your instructions. Here's the most important principle:

๐ŸŽฏ
The golden rule: Give context, not just commands Don't just say what you want. Say why you want it and what constraints apply. Think of it like briefing a very smart but new research assistant who doesn't know your project yet.
โŒ Weak prompts
  • "Clean my data"
  • "Fix the code"
  • "Write a regression"
  • "Make this better"
โœ… Strong prompts
  • "Clean hh_data.csv: standardise the district names to title case, drop rows where income is negative, and flag observations where age is outside 15โ€“80"
  • "The loop in clean.do runs too slowly on large datasets โ€” rewrite it without a loop using Stata's egen or reshape commands"
  • "Run an OLS regression of log income on education years and household size, with robust standard errors, and export the results table to LaTeX"

The 4-part prompt formula

For complex tasks, structure your prompt like this:

1. CONTEXT: What is this file/project about?
2. TASK: What exactly do you want done?
3. CONSTRAINTS: What rules must be followed? (format, style, tools)
4. OUTPUT: What should the result look like?

--- Example ---
> [CONTEXT] I have a Stata do file (analysis.do) that runs
  regressions for my job market paper on agricultural insurance takeup.
  [TASK] Rewrite the summary statistics table section (lines 20-55) to
  also include median and IQR, not just mean and SD.
  [CONSTRAINTS] Keep the same variable labels. Use Stata's putexcel to
  export to Excel, not estout.
  [OUTPUT] Replace lines 20-55 in the file directly.

Reviewing what Claude does

Claude Code doesn't just answer โ€” it takes actions on your files. This is powerful, but it means you need to review what it does. Here's how:

๐Ÿ”
Always read the diff When Claude shows you proposed file changes, actually read them. A few seconds of review can prevent hours of debugging. Trust but verify โ€” especially for statistical code.

Permissions: staying in control

Claude Code is designed to always ask before taking actions that could be risky. You'll see prompts like:

Claude wants to:
  Edit file: analysis/clean_data.do

[a] Allow once    [A] Always allow    [d] Deny    [?] Help
OptionWhat it meansWhen to use it
a โ€” Allow once Permit this specific action, ask again next time When you want to stay in control step by step
A โ€” Always allow Permit this type of action for the whole session When you trust Claude with a specific task
d โ€” Deny Block this action When the proposed change looks wrong
Esc โ€” Interrupt Stop Claude mid-task When you realise Claude is going in the wrong direction

Key commands cheat sheet

These are the commands you'll use most in your first sessions:

CommandWhat it does
/helpShow all available commands
/clearClear the conversation history (frees up context window)
/exitExit Claude Code
/compactSummarise the conversation to free up space
Ctrl+CInterrupt what Claude is currently doing
โ†‘ arrow keyRecall your previous message
Type normallySend a message to Claude
๐Ÿ“–
What is the context window? Claude can only "see" a limited amount of text at once โ€” about 200,000 tokens (roughly 150,000 words). This is called the context window. Long conversations or large files eventually fill it up. Use /compact or /clear when your session gets very long. Think of it like Claude's working memory โ€” it can get full.
๐ŸŽฏ

Module 2 Exercise: First real task

Pick a real project folder on your computer (anything with data or code files). Navigate to it in the terminal and start Claude Code.

  1. Ask Claude: "Describe what this project is about based on the files you can see."
  2. Give Claude a real task from your own work โ€” something small but useful. Use the 4-part prompt formula.
  3. When Claude proposes a change, read it carefully before approving.
  4. After the task is done, ask: "What could go wrong with what you just did? Are there any edge cases I should check?"

Pro tip: That last question โ€” asking Claude to critique its own work โ€” is one of the most powerful habits you can develop. It will catch errors before they become problems.

Terminal Any tool (Stata/R/Python) ~20 min