๐ 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.
In this module
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
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:
โ 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:
- Claude shows you what it will do before doing it. When Claude plans to edit a file, it shows you the proposed changes (a diff โ lines removed in red, lines added in green) and asks for approval.
- You can say No. If Claude proposes something wrong, type "no" or explain what's wrong. Claude will try again.
-
Use Git to protect yourself. If your project is a Git repository,
every change Claude makes can be undone with
git checkout. Module 11 covers this.
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
| Option | What it means | When 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:
| Command | What it does |
|---|---|
/help | Show all available commands |
/clear | Clear the conversation history (frees up context window) |
/exit | Exit Claude Code |
/compact | Summarise the conversation to free up space |
Ctrl+C | Interrupt what Claude is currently doing |
โ arrow key | Recall your previous message |
| Type normally | Send a message to Claude |
/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.
- Ask Claude: "Describe what this project is about based on the files you can see."
- Give Claude a real task from your own work โ something small but useful. Use the 4-part prompt formula.
- When Claude proposes a change, read it carefully before approving.
- 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.