All in One View

Content from Before We Use AI: What Are We Practising?


Last updated on 2026-11-07 | Edit this page

Estimated time: 45 minutes

Overview

Questions

  • What are we practising in this lesson?
  • When does an AI coding tool help me learn, and when does it get in the way?
  • How do I decide whether to trust a result the AI gave me?

Objectives

  • Tell code generation, code understanding and code validation apart.
  • Use a checkpoint to decide whether to run, revise or reject an AI-generated result.
  • Reject a plausible wrong result with evidence from a check you chose yourself.

This is not a lesson about letting AI do the work


It is tempting to treat an AI coding agent as a machine that turns a sentence into a finished script. You type “clean this data,” code appears, it runs, and you move on.

This lesson teaches the opposite skill. You learn to inspect, question, constrain and validate AI-generated code until a result is trustworthy enough for research. You will often explain what the AI did, and not only run what it produced.

Three skills are easy to confuse:

  • Code generation is getting the AI to produce something that runs.
  • Code understanding is saying in plain language what the code does and why.
  • Code validation is having evidence that the code is correct for your data and your research question.

Generation is the easy part now. Understanding and validation make code trustworthy, and they are still your job.

Callout

Code can appear before understanding does

An agent can produce a working-looking script faster than you can read it. If the code shows up before you understand it, you skip the step where learning happens.

Research adds a second cost. Working code is not the same as trustworthy code. A script can run cleanly, pass a quick check, and still change a threshold, drop rows or misread a date format in a way that changes your conclusion.

Why generated code can raise your cognitive load


It sounds backwards. If the AI writes the code, you should have less to do. But to judge generated code you have to hold four things in mind:

  • what you asked for,
  • what the code does,
  • what assumptions it made,
  • and whether those assumptions fit your data.

Reviewing unfamiliar generated code can add load, especially when it uses a library, a language feature or an abstraction you have not met. We name these moments when they come up.

Reset expectations before learners open a terminal. Some arrive expecting a productivity demo. Say clearly that the workshop measures whether they can explain and validate AI output, not how fast they can generate it.

Watch for these signs throughout the workshop:

  • Learners who are impressed that the agent can read their files but cannot say what it changed.
  • Learners who accept output they cannot explain because “it ran.”
  • Learners who turn to the AI before a helper, which hides where they are stuck.

Bring AI confusion back into the room. Treat confusing output as a shared teaching example and not a personal failure.

The run, revise or reject checkpoint


Every time the AI hands you something, you make a decision. Make it on purpose. Two different questions are involved:

  • Action permission: may this command run? Check what it reads and writes.
  • Result approval: is this result good enough to use? That needs evidence.

Permission to run an action is not approval of its result. Ask:

  1. Can I explain what this does? If not, you are not ready to approve it.
  2. What did it assume about my data? Name at least one assumption.
  3. What evidence shows it is correct? “It ran” is not evidence.
  4. Decision: run it, revise it or reject it.

You will use this checkpoint, in more detail, throughout the lesson.

Challenge

Challenge: practise the checkpoint

An agent produced this snippet when asked to “remove the bad rows from my data”:

PYTHON

import pandas as pd
df = pd.read_csv("data.csv")
df = df.dropna()
df.to_csv("clean.csv", index=False)

Without running anything, answer in a sentence or two each:

  1. What does this script do, in plain language?
  2. What does it assume “bad rows” means?
  3. Name one way it could quietly damage a real research dataset.
  4. Would you run it, revise it or reject it for a dataset where missing values carry meaning, such as a survey where “no answer” is a valid response?
  1. It reads data.csv, drops every row with a missing value in any column, and writes the result to clean.csv.
  2. It assumes “bad rows” means “rows with any missing value.” That is the AI’s reading, not yours.
  3. dropna() with no arguments removes a row if any column is empty. In a wide dataset, one empty optional field deletes an otherwise complete observation, and the sample shrinks without notice.
  4. Revise or reject. If missingness has meaning, dropping those rows changes what the data represent. You would limit which columns to check, or impute. The code runs perfectly and is still wrong for your question.
Challenge

Quick check: what does dropna() remove?

A table has columns site, date, score and notes. Only notes has blank cells. What does df.dropna() with no arguments do?

  1. Drops rows where every column is blank.
  2. Drops rows where the notes column is blank.
  3. Drops rows where any column is blank, including notes.
  4. Drops the notes column and keeps all rows.

3. With no arguments, dropna() checks every column and drops a row if any of them is blank, even in a column you think of as optional. Options 1 and 2 describe common wrong assumptions about how it scopes the check. Option 4 confuses dropping rows with dropping a column, which is a different method (drop(columns=...)).

Challenge

A result can pass one check and still be wrong

The source documentation says site C writes dates as day-month-year. The first record in data/site_C.csv is SC001,05-01-2023,69.4,7.0,14.2.

Before you run code or ask an agent, write down:

  1. What ISO date should SC001 have?
  2. Would keeping all 20 site C rows prove the dates are correct?
  3. What must you see before you approve these dates for a plot?

With a partner, read this candidate transformation. It is in your project folder as date_review.py. Explain what each line does.

PYTHON

import pandas as pd

raw = pd.read_csv("data/site_C.csv")
candidate = pd.DataFrame({
    "sample_id": raw["StationID"],
    "date": pd.to_datetime(raw["DateTime"], format="mixed").dt.strftime("%Y-%m-%d")
})
print("Rows:", len(candidate))
print(candidate.head(2).to_string(index=False))

Run python date_review.py. It reads the raw file and prints output. It does not change the raw data. Permission to run this action is separate from accepting its result.

Now add these checks to the end of the script. Fill in the blank from the source format, without AI.

PYTHON

assert len(candidate) == 20
actual = candidate.set_index("sample_id").loc["SC001", "date"]
assert actual == "__________", f"SC001 became {actual}"

Run it again. Which check fails? What does the passing check establish?

Change the date parser, by hand or by asking for one change. Read the changed line, rerun, and write one of: approve, revise, reject. Add your evidence. Also say what a check on one record does not yet establish.

SC001 should be 2023-01-05. The faulty parser gives 2023-05-01. Both are valid dates, and the row-count check still passes. SC002 becomes 2023-12-01 and not 2023-01-12.

Replace format="mixed" with format="%d-%m-%Y". Both checks then pass. They cover the row count and one expected date. They do not show that every date and score is right. Before you approve the full output, compare every sample’s date with its source record under the documented format.

A strong answer names the wrong value, the independent expected value, the failed assertion and the coverage that is still missing.

If a learner cannot run the script, give them the saved output in instructors/files/date-review-output.txt:

Rows: 20
sample_id       date
    SC001 2023-05-01
    SC002 2023-12-01
AssertionError: SC001 became 2023-05-01

Ask for the same prediction, explanation and decision. Do not wait for a live agent to make this mistake. The script is deliberately faulty, and nothing here claims that every agent makes it.

After two failed attempts, give the learner a working script. After the repair, show the reference validator catching eight mismatched dates in the faulty version and none in the repaired one (instructors/files/backup_validate_data.py). Do not present the saved transcript as the learner’s own run.

Discussion

Feedback checkpoint: what do you want from AI?

On a sticky note or in the shared Etherpad, write one line: what do you most want an AI tool to do for your research, and what worries you most about it? Working alone? Write the line in your notes file. You will return to it at the end of the lesson.

Key Points
  • This lesson teaches you to inspect, question, constrain and validate AI output. It does not teach you to hand off your thinking.
  • Generation, understanding and validation are different skills. Generation is the easy one.
  • Reviewing unfamiliar generated code can cost real effort, especially when it brings in ideas you do not know.
  • Working code is not the same as trustworthy code. A result can pass one check and still be wrong.
  • Permission to run an action is separate from approval of its result.

Content from CLI-Based AI


Last updated on 2026-11-07 | Edit this page

Estimated time: 50 minutes

Overview

Questions

  • What can each kind of AI tool see, and what can it change?
  • Why use a command-line tool for this lesson?
  • What goes in a project instruction file, and what does it not do?

Objectives

  • Describe what an AI tool can read and change in your configuration.
  • Show the working directory, the files an agent can see and one change as a diff.
  • Create a short instruction file (CLAUDE.md) with a source-backed constraint and a check you can run.

A version number confirms the executable. It does not confirm that learners can use the tool. Ask every learner to check five things:

BASH

claude --version
python --version
ls data/
  • Python runs and imports pandas.
  • The three input files are listed.
  • The account works and one read-only agent action succeeds (the claude -p check below).
  • Everyone selected the same available model with /model. Record the resolved model name, the tool version and the relevant settings. An identical selection does not guarantee identical output.

A learner without an account uses the saved-output route. It has the same terminal and Python files, with saved plans, diffs and command transcripts, and the same approval decisions and tests.

Why a command-line tool for this lesson


An agent in your terminal works with files, commands, output and diffs in one place. That is why this lesson uses one. You can see which folder it works in, what it ran and what it changed.

The reason is visibility for learning, not capability. Browser and editor assistants increasingly offer connectors, file upload and coding features of their own. What an AI tool can do depends on its configured tools, integrations and permissions, and not on its category. Check the actual configuration of the tool in front of you.

If you have not used a command-line agent before, you are in good company. A survey of 868 scientists who program (a 2025 preprint, revised in 2026) found that browser-based chat tools made up most primary tool choices, and command-line or agentic tools a small minority (O’Brien et al.).

A command-line interface (CLI) agent runs in your terminal, where you run Python scripts and move around with ls and cd. In your configured setup it can:

  • Read your files and data, inspect the directory structure and write scripts to disk. You do not copy and paste between a chat window and an editor.
  • Call software you have installed, such as GDAL, R packages or your own scripts.
  • See an error in the terminal and try again.

What the tool can see, and what it can change


Before you trust an AI tool, ask what it can see and what it can do. More access helps more, and gives it more chances to go quietly wrong. These kinds of tools sit along that range.

Tool type What context it has What it can do What can go wrong What to verify
Chatbot What you paste in, plus any files or connectors you enable Suggests code and text May guess your file structure; you copy code by hand That the code matches your actual columns and files
IDE assistant The open file, sometimes nearby files Suggests and inserts code inline Sees part of the project; may fit the line and miss the goal That the suggestion does what you intended
CLI agent Your project folder, as configured Reads files, runs code, writes scripts Can edit or delete real files; can act on a misread of your data What it read, changed and ran, before you approve
Multi-step agent workflow Whatever you grant, across many steps Plans and runs a chain of actions Errors compound; hard to see where it went wrong That you can explain each step and reproduce the result

Further down the table, the tool can do more for you and more to you. Nothing in the table removes your responsibility to understand the result.

Learners are often impressed that an agent can read their files and run their code. Impressive access is not a correct result. Watch for learners who can say what the agent can do but not what it just did.

Before a learner approves a command that changes files, ask them to say aloud what the agent read, what it will change and why. If they cannot, slow down.

Caution

Data privacy and institutional context

Use only the supplied synthetic data in this workshop. Do not read permission for institutional research data into a personal subscription or into the name of a campus-approved product.

Your institution decides which AI tools may touch which kinds of data. At UCLA, consult the current campus tool comparison for eligibility, price and data classifications. Approved access is tied to a UCLA account and a specific service. UCLA’s footnote says P1 to P3 data are allowed in a UCLA account, and P4 data need approval from the Unit Head and the CISO. UCLA’s AI use guide also names data that must not go into AI tools unless approved in a secure environment, such as FERPA records, health data, personnel data and unpublished research. Send questions to grc@ucla.edu.

Use a backend with sensitive data only after the responsible campus or unit authority confirms the specific account, configuration and data category. A tool that can run on a given cloud service is not thereby approved for sensitive data. Consult your campus data policy before you use any AI tool with restricted data, including protected health information.

If your research needs fully local processing, these skills transfer to open-weight models run on your own machine. Check the licence and the exact version first. Hardware needs depend on the model and the speed you want, so test your chosen configuration.

From writer to active reviewer


People sometimes describe this shift as moving from “writer” to “orchestrator”, as if the AI does the work and you conduct. That picture misleads a learner.

AI can reduce the need to remember every detail of syntax. It increases the need to understand intent, dependencies, assumptions, tests and failure modes. You do not hand off the thinking. You move your effort from typing toward reading, questioning and judging. That is harder to do well.

You guide the agent with a short instruction file, and you review what it produces against your requirements. The diagram shows the loop. You state the goal, the agent proposes a plan, you approve it before any code is written, and you verify the result before it counts as done.

graph TD
    accTitle: Approval and verification loop
    accDescr {A researcher defines a goal in CLAUDE.md, the agent proposes a plan, and the researcher approves it or sends it back at an approval gate. Only after approval does the agent draft code, which then passes a verification step or returns for refinement.}
    A[Researcher] -->|Define goal| B(CLAUDE.md\ninstruction file)
    B --> C[Request a plan]
    C --> D{Approval Gate}
    D -->|Approve| E(AI Agent executes)
    D -->|Revise| C
    E -->|Draft code| F{Verification}
    F -->|Passed| G[Final Output]
    F -->|Failed| H[Refinement]
    H --> B
    style D fill:#bbf,stroke:#333,stroke-width:2px
    style F fill:#f9f,stroke:#333,stroke-width:2px

Description of the diagram: a loop. The researcher defines a goal in CLAUDE.md, and the agent proposes a plan. The researcher approves the plan or sends it back at an approval gate. Only after approval does the agent draft code. The code then passes a verification step or returns for refinement.

Ask learners whether they have used a chatbot to write code that looked right and failed when they ran it. Use their answers to show that the goal is to check the AI’s intent against yours, and not only to fix code.

Reviewing generated code adds verification load. You check the agent’s actions against your requirements.

Callout

Managing cognitive load

You may feel out of the loop when an AI writes many lines quickly. Anchor your understanding. Read the comments it generates, and test small pieces often. If a block is confusing, ask the AI to explain it before you move on.

Caution

Security responsibility

Starting an agent in your project folder sets its working context. It does not on its own create a security boundary. Inspect what the agent can actually read, write and reach over the network, and which integrations are on.

A buggy or misconfigured agent could delete files or reach sensitive data such as passwords. Keep your files backed up or under version control (such as Git) so you can revert a change.

Long context

A model has limited working memory. In LLM tools this is the context window. Current models have long windows, but a large window does not mean the agent should load your whole project. A better pattern has the agent open the files it needs, within the access you configured.

Callout

A large context window is not a free pass

The more you load into a session, the more the model has to track. Past some point quality can fall. The model may lose earlier instructions, produce inconsistent output or fixate on the wrong files. Choosing what goes into the context is part of the workflow.

Let’s make sure this works


Open a terminal and type claude --help. This lists the command-line flags. Use the in-session help for interactive commands. Claude Code starts an interactive session by default. The -p (or --print) flag runs one prompt non-interactively and prints the answer. We use it for quick checks.

Go to your project folder and run a read-only check:

BASH

cd coastal-water-quality
pwd
claude -p "What operating system am I on? List the files here and in data/."

Compare the answer with what ls and ls data/ show. Did the AI describe your project accurately? It should return something like:

You are on macOS (Darwin). This looks like a data-cleaning project.
Top level: README.md, CLAUDE.example.md, validate_data.py, data/, expected_outputs/
data/: site_A.csv, site_B.csv, site_C.csv

Note three things: the folder where you started (pwd), the files the agent could see, and whether it changed anything. It should not have changed anything.

A first look at the data

Look at the data yourself before the agent touches anything:

BASH

head data/site_A.csv

Then ask the agent to describe the same file and compare:

BASH

claude -p "Describe the columns in data/site_A.csv and note anything inconsistent or risky for analysis."

Did its description match what head showed? Where it added an interpretation, such as a guess at what a column means, treat that as the agent’s assumption and not as fact. Checking what the tool claims against the data is the habit this lesson builds.

Callout

Working directory matters

Start Claude Code from inside your project folder. The agent uses the current directory to find your files and instructions. Starting from the wrong folder, such as your home folder, is a common source of confusion.

Create the instruction file

Claude Code has an /init command. It creates a CLAUDE.md file that describes your project. Run it once, here.

BASH

claude

You are now in a Claude Code session. Type / to see the slash commands. Run:

BASH

/init

Watch what it inspects. When it finishes, look at what it made. Start a line with ! to run a shell command inside the session:

BASH

!ls
!cat CLAUDE.md

The generated file looks something like this:

MARKDOWN

# CLAUDE.md

## Project Overview

This is a data-cleaning project. The `data/` directory holds three water quality
files (`site_A.csv`, `site_B.csv`, `site_C.csv`) with inconsistent column names and
date formats. The goal is to merge them into `data/master_dataset.csv` and analyse
water quality trends. See `README.md` for the target schema.

## Key Files

- **`data/site_*.csv`**: raw per-site measurements (do not edit).
- **`validate_data.py`**: checks for the merged dataset.
- **`CLAUDE.md`**: project context and rules, loaded automatically each session.

The agent scanned the folder and described the real project. You still edit the file by hand to add your goals and constraints. Do not expect /init to make the agent more correct. A short file that a person has reviewed makes the agent’s instructions easy to audit.

The instruction file


A CLI agent can load a project instruction file at the start of a session. For Claude Code that file is CLAUDE.md, and this lesson uses it.

Other tools use other conventions. Check what your tool actually loaded:

  • Recent Claude Code versions can also load AGENTS.md, depending on version and settings. CLAUDE.md is the file this lesson supports. An explicit @AGENTS.md import in CLAUDE.md still helps portability.
  • Codex CLI uses AGENTS.md. Check the official documentation for the current behaviour.
  • Cursor supports scoped rules in .cursor/rules and AGENTS.md. .cursorrules is the older form.
  • Gemini CLI uses GEMINI.md by default, and the file names are configurable.

A tool that does not load a file will not read it unless you say so: “Read AGENTS.md and then…”

What to put in the file

  • The current goal.
  • Technical constraints, such as “use pandas for dataframes.”
  • Source facts the data documentation states, such as a site’s date format.
  • How you will check that the work is correct.

A requirement in this file is a request to the model. It is not an enforced boundary. Tool permissions and isolation enforce access limits. Your checks test the result.

Callout

Keep a short record of constraints and decisions

A model does not carry your project’s rules from one session to the next. Keep your constraints and decisions in plain files that live with the project, so people can inspect them:

  • CLAUDE.md holds durable rules, goals and constraints, and loads each session.
  • PLAN.md holds the plan for one task. You meet it in the next episode.
  • A dated notes file holds what you tried, what worked and why you chose it.

For research, the notes file is provenance. It lets you, a reviewer or your future self rebuild what happened. Version control makes the record reviewable. This does not guarantee that the model follows every instruction. Your checks do that job.

Challenge

Challenge: add a constraint and a check

Open the CLAUDE.md that /init created. Add two things:

  1. One constraint taken from the data documentation. For example: “Site C dates are day-month-year. Parse them explicitly.”
  2. One check you could run to see whether the constraint was met. For example: “After cleaning, SC001 must have the date 2023-01-05.”

Then show one change as a diff. Ask the agent to add a line to CLAUDE.md, and compare the file before and after (for example with git diff or diff). Which line changed?

MARKDOWN

# Project: Coastal Water Quality Trends

## Goal
Clean and merge three site files into data/master_dataset.csv, then plot score
over time by site.

## Rules
- Use pandas for data and matplotlib for plots.
- Site C dates are day-month-year (05-01-2023 is 5 January). Parse them explicitly.
- Fill a missing score with the median of that site's observed scores.
- Do not edit data/site_*.csv. Do not drop rows. The merge has 60 rows.

## Checks
- SC001 must have the date 2023-01-05 after cleaning.
- python validate_data.py passes.

The constraint comes from the source documentation. The check is something you can run. The median rule is this exercise’s fixed choice, and a real study would have to justify it.

Discussion

Feedback checkpoint: describe the agent’s context

Turn to the person next to you and answer aloud: when you ran /init, what did the agent look at, and which file did it create? If you are not sure, say so. Paste one surprise into the shared Etherpad. Working alone? Answer aloud to yourself, or write it as a comment at the top of your CLAUDE.md. Saying or writing it surfaces the gaps.

Key Points
  • Ask what an AI tool can see and do, in its actual configuration, before you trust it.
  • A CLI agent can read, run and edit your real files, so checking what it changed is part of the work.
  • Run /init once to create CLAUDE.md, then edit it by hand.
  • An instruction file records constraints for people and tools to read. It is not an enforced boundary. Tests check the result.
  • Check which instruction file your tool loaded before you rely on it.

Content from Best Practices for Prompting


Last updated on 2026-11-07 | Edit this page

Estimated time: 55 minutes

Overview

Questions

  • How do I write a prompt that gets a result I can check?
  • How do I review a plan before the agent acts on it?
  • How do common AI failures show up, and how do I catch them?

Objectives

  • Repair a vague prompt so it states the input, the intended change, the constraints and the evidence you will accept.
  • Review an agent’s plan, mark one unsupported assumption and approve only a bounded action.
  • Name common AI failure modes and a check for each.
Callout

Working inside Claude Code

Type the prompts in this episode inside an active Claude Code session. Start one in your project folder:

BASH

cd coastal-water-quality
claude

Run shell commands such as python script.py in a separate terminal, or inside the session by starting the line with !.

A short prompt checklist


Effective prompting is clear technical communication. A good prompt names four things:

  1. Input: which files and columns the agent should use.
  2. Intended change: what should happen.
  3. Constraints: what must not happen, and the facts the data documentation gives you.
  4. Evidence: how you will check the result.

Vague requests produce generic answers. Precise ones produce code you can test. Start with a small request and add detail in follow-up prompts.

The table shows each item at work.

Aspect Weak prompt Better prompt
Input and change “Clean this data.” “In data/site_C.csv, convert DateTime to ISO YYYY-MM-DD. Do not change any other column.”
Constraint “Fix the dates.” “Site C dates are day-month-year. Parse them with %d-%m-%Y and do not let pandas guess.”
Evidence “Make sure it works.” “After the change, print SC001’s date. It must be 2023-01-05.”

The CO-STAR framework is an optional way to structure longer prompts. It is on the reference page.

Prompts that preserve learning


A prompt can be specific and still take away the understanding you came to build. These prompts keep you in the loop. The AI helps, and you still do the thinking that makes the result yours.

  • “Do not give me the final code yet. Ask me three questions about the data first.”
  • “Write the simplest version. Avoid list comprehensions, classes and extra libraries.”
  • “State the assumptions you are making about my data.”
  • “Give me one small change to make myself, and tell me where.”
  • “Ask me to predict the output before you show it.”
  • “Give me a hint, not the solution.”
Callout

Prompts to avoid, and what to ask instead

The left column feels efficient but hands over the parts that make code trustworthy.

Avoid Ask instead
“Do this exercise for me.” “Walk me through how to approach this. Do not write the final answer.”
“Fix everything.” “List the problems you see, ranked. I will choose which to fix first.”
“Make this production ready.” “Name the three biggest risks in this script for research use.”
“Clean this data.” “Tell me what inconsistencies you find in these files. Do not change anything yet.”
“Write the whole pipeline.” “Outline the pipeline in steps. We will build and check one step at a time.”

Generated code often brings in syntax, libraries or abstractions the lesson has not introduced. Signs that AI output is adding extra load:

  • The agent uses an advanced feature, such as a comprehension, a class or a decorator, before it has been taught.
  • It imports a library that is not installed.
  • It writes several files where one short script would do.
  • The answer is correct and the learner cannot explain it.

Ask the learner to request a simpler version, remove one abstraction, trace the code line by line or compare it with a minimal reference. Slowing down here is the lesson, not a detour.

Challenge

Challenge: repair a prompt

Start with this prompt, typed inside your Claude Code session:

Plot my data.

Notice which file it used, whether the plot is useful and where it saved it. Then write a repaired prompt that states the four checklist items for data/site_A.csv: the input (file and columns), the intended change (a scatterplot of WaterQualityScore over Collection_Date), the constraints (label the axes, do not change the data) and the evidence you will accept (the output path and the number of points plotted).

Using data/site_A.csv, write a Python script that plots WaterQualityScore over
Collection_Date as a scatterplot. Label the axes. Do not modify the data file.
Save the plot to fig/site_A_scatter.png and print the number of points plotted.

Check that the printed count matches the number of rows with a score. Missing scores are not plotted, so the count may be one less than the row count.

Did naming the output path save you from searching for the file? Did the evidence line give you something to check?

Many people find the CLEAR checklist (Concise, Logical, Explicit, Adaptive, Reflective, from Leo Lo) a useful reminder once they have repaired a prompt like this. It says: be concise, order your steps, state scope and format, rephrase or split a task when the result is poor, and check the output against other sources.

Plan before you act


For a larger task, asking for code at once costs more rewrite time. Ask for a plan first and review it.

Plan mode

Claude Code has a plan mode. Start a session in it with:

BASH

claude --permission-mode plan

You can also switch modes in a session. Check /help for your version, because the command has changed between releases. Plan mode restricts source edits and supports exploration. It is not a universal no-side-effect sandbox. Check the installed mode, the available tools and your settings. Keep the active mode and the approved scope visible while you work.

Review the plan, push back on steps you disagree with and ask for alternatives. When you are satisfied, approve one bounded action and let the agent continue.

Checkpoint prompts

Break a large task into phases and review each one:

Step 1 only: read the three CSV files and tell me what inconsistencies you find. Do not write any code yet.

This catches misunderstandings about your data before they spread into broken code.

The plan file

For a complex task, ask the agent to write the plan to a file that you can read and edit:

Write a PLAN.md outlining the steps to clean and merge these files. I will review and edit it before you write any code.

PLAN.md and CLAUDE.md do different jobs. The instruction file holds rules that last across sessions. The plan holds the steps for one task. Plans are temporary, and instructions are durable.

Challenge

Challenge: review a plan against the evidence

In plan mode, type:

Read the three site files in data/ and README.md. They have inconsistent column names and date formats. Outline a step-by-step plan for cleaning and merging them into data/master_dataset.csv. Do not write files.

Review the plan:

  1. Mark one step that rests on an assumption the files do not support.
  2. Revise that step from the evidence in the files and README.md.
  3. Write down the single action you approve, such as “write clean_and_merge.py and run it on a copy.”
  • An audit step that inspects the files before changing them.
  • A step that harmonises column names.
  • A date step that names each site’s format.
  • A missing-value rule.
  • A step that checks the output.

If the plan guesses a date format, a column meaning or a missing-value rule, send it back with the evidence that corrects it. The aim is to catch gaps in the plan and not only in the code.

AI failures


AI agents are built to be helpful, and that can lead them to take shortcuts.

Common failure modes

  • Run-to-run variation. The same task can give different output across runs or after a model update. No setting makes an agentic run reproducible. Log the tool version, the model, the prompt and the relevant outputs so you can compare runs. A log lets you compare. It does not guarantee identical output.
  • Over-correction loops. An agent that runs its own tests may change the test to match its buggy code. Write your own requirements and key checks.
  • Synthetic data substitution. The agent may invent data if it cannot find the real file.
  • Silent failure. The agent may wrap code in try/except blocks that hide errors.
  • Plausible wrong results. Output can look right and be wrong, as the date exercise in Episode 0 showed.
Discussion

How to catch failures

Have you seen an AI make a confident mistake? What signs tell you an answer is wrong?

Strategies to try:

  • Ask: “Show me the first 10 rows of the data you loaded.”
  • Ask: “How did you calculate that value? Show the intermediate steps.”
  • Check file sizes. Is the cleaned file 0 bytes?
  • Run an independent check you wrote from the source documentation.

Asking the agent to review its own work

You can ask an agent to critique its output:

  • “Review the code you just wrote. Which edge cases could make it fail?”
  • “Did you hard-code any file paths?”

This often surfaces problems. It cannot decide which problems matter for your research. Treat what it finds as something to verify and not as proof.

Reasoning effort

Some models let you raise a reasoning-effort setting. Availability and defaults depend on the model, the tool version and your organisation’s settings. Use the setting your workshop tested, and record it. Check /status for the model and effort in use, since both change over time. Higher effort costs more time and tokens, and it does not always give a better answer.

Challenge

Challenge: ask for a check, then read it

Ask the agent to draft a check for the coastal data:

Write a short Python script, check_site_C_dates.py, that reads data/site_C.csv and prints the ISO date for SC001 and SC002, using the day-month-year format. Do not change any files.
  1. Before you run it, predict both dates.
  2. Read the script. Which line sets the date format? Did the agent use the format the documentation gives?
  3. Run it. Do the printed dates match your prediction? If the agent let pandas guess, how would you tell?

SC001 should print 2023-01-05 and SC002 2023-01-12. The script should name %d-%m-%Y explicitly.

If the script lets pandas infer the format, the output can still look plausible. Your prediction is what shows the difference. A prediction written before the run is evidence. A check that only confirms the output looks like a date is not.

Discussion

Feedback checkpoint: paste one line you don’t understand

In the shared Etherpad, paste one line of AI-generated code from this episode that you cannot fully explain. We will work through a few together. Not understanding a line carries no penalty. Shipping it without knowing what it does does. Working alone? Ask the agent to explain the line, then check its explanation against what you already know before you accept it.

Key Points
  • Name four things in a prompt: input, intended change, constraints and evidence.
  • Review the plan before the agent acts. Mark an unsupported assumption and approve one bounded action.
  • Plan mode restricts source edits. It is not a universal sandbox.
  • Prefer prompts that preserve learning: ask for plans, hints and the simplest version.
  • An agent’s self-review is a lead to check, not proof.

Content from Data Cleaning with AI


Last updated on 2026-11-07 | Edit this page

Estimated time: 98 minutes

Overview

Questions

  • Can I trust AI to standardise inconsistent files?
  • How do I check that a cleaning script did what I needed, and not only what the AI assumed?

Objectives

  • Predict what a cleaning script must handle before you prompt for it.
  • Build a processing pipeline for inconsistent files from a plan and a set of requirements.
  • Read a diff and explain the changed lines before you run the code.
  • Validate AI-generated code against checks, and record where it came from.
Prerequisite

Prerequisites

Sign in to Claude Code and keep a session running in your project folder. Generating a script can take 10 to 30 seconds.

This episode uses live coding. Learners follow along on their own machines.

Callout

Working inside Claude Code

Type the prompts in this episode inside an active Claude Code session. Start one in your project folder:

BASH

cd coastal-water-quality
claude

Run Python scripts in a separate terminal window when the text tells you to.

Cleaning messy data


Cleaning and merging inconsistent files takes a lot of research time. In this episode you clean and merge the coastal water quality files into one analysis-ready dataset.

The project data


The data are synthetic. They were built for this lesson and describe no real study.

Your project folder (coastal-water-quality) holds three files in data/, one per monitoring site. Samples were taken weekly from January to May 2023. The files are site_A.csv, site_B.csv and site_C.csv, with 20 samples each and 60 in total.

The files are messy in the ways real multi-site data often are. Column names differ, date formats differ and a few values are missing. The folder’s README.md describes the target schema and what “done” looks like. The goal is one clean data/master_dataset.csv. In the capstone you plot score over time by site.

Callout

Optional: generate your own messy data

To practise on a new problem later, ask the AI to synthesise a similar dataset:

Create a python script named 'make_messy_data.py' that generates 3 CSV files with inconsistent column names, varied date formats, and some missing values, mimicking a multi-site study.

For the lesson, use the provided files so everyone works from the same data.

Cleaning with AI, one checkpoint at a time


It is tempting to type “clean and merge these files” and run whatever comes back. Do not. Work through checkpoints so you can explain the result and not only produce it. The pattern is: predict, plan, inspect, change, read the diff, check, reflect.

A. Predict before you prompt

Open the three files in data/ and look at them yourself. Do not use the AI yet. Write down two inconsistencies that any cleaning script has to handle. Real examples in this data:

  • The ID column is SiteID in site A, id in site B and StationID in site C.
  • The score column is WaterQualityScore, score and Quality_Index.
  • The dates differ: 2023/01/05 (A), Jan 5 2023 (B) and 05-01-2023 (C). Site C writes day-month-year, so 05-01-2023 is 5 January and not 1 May.

Keep your list. You will judge the AI’s proposal against it. For a faster overview, ask the AI to write an inspection script, and read its output against your list:

Write a Python script called 'inspect_data.py' that reads every CSV in data/. For each file, print the filename, the column names, and the number of missing values per column. Do not change any files.
Challenge

Quick check: site C’s date format

Site C stores dates as 05-01-2023, in day-month-year order. What date is that, and what would a parser that assumes month-day-year produce without warning?

  1. 5 January. A month-day-year parser also reads it as 5 January.
  2. 5 January. A month-day-year parser reads it as 1 May.
  3. 1 May. A month-day-year parser reads it as 5 January.
  4. There is not enough information to tell.

2. In day-month-year order, 05-01-2023 is day 05 of month 01, which is 5 January 2023. A parser that assumes month-day-year reads the same string as month 05, day 01, which is 1 May 2023. It raises no error. The string never changes. Only the format you tell the parser to assume changes.

B. Ask the AI for a plan only

Do not ask for code yet. Inside your Claude Code session, type:

Read 'CLAUDE.md' and the three CSVs in data/. Before writing any code, give me a numbered plan for cleaning and merging them into data/master_dataset.csv. Do not write any files yet.

Compare the plan with your list from step A. Did it catch the site C date format? Does it say how it will handle missing values? Does it propose anything you did not expect?

C. Approve or revise the plan

Mark one step in the plan that rests on an assumption the data do not support. Revise it from the evidence in the files and README.md. Approve only the bounded action you can describe.

If the plan lacks a constraint you care about, add it to CLAUDE.md. Do not only mention it in chat, because the file travels with the project. For example:

MARKDOWN

- Site C dates are day-month-year. Parse them explicitly. Do not let the tool guess.
- Fill a missing score with the median of that site's observed scores. Do not drop any rows. The merge must have 60.

The median rule is this exercise’s fixed choice. It is not automatically right for a real study. A real analysis would justify its method for missing values.

D. Generate the code

Now ask for the script and point it at your requirements:

Read 'CLAUDE.md' and the three CSVs in data/. Write a script called 'clean_and_merge.py' that follows the plan and the rules in CLAUDE.md. Save the result to data/master_dataset.csv. Add comments that link each code step to a rule.
Callout

Your script will not match the lesson’s

AI output varies, so your clean_and_merge.py will differ from your neighbour’s and from any example. Judge it against your requirements and the checks below, not against someone else’s code.

If a learner’s AI fails to produce working code twice, hand over the prepared versions from instructors/files/:

  • backup_inspect_data.py
  • backup_clean_and_merge.py

The learner still predicts, explains, tests and decides. Label which parts were supplied.

E. Explain before you run

Take your hands off the keyboard and read clean_and_merge.py. In pairs, each person explains one section aloud: what it does and which rule it serves. If a section uses something you have not seen, ask about that line. Working alone? Explain each section aloud, or write the explanation as a comment above it. Then ask the agent to compare your explanation with what the code does.

You are responsible for the final output. You cannot validate what you cannot explain.

F. Check against evidence

Run python clean_and_merge.py. A correct run prints something like Wrote data/master_dataset.csv with 60 rows. Then test the result with concrete checks. “It ran” is not a check.

  • Row count. There are 60 rows (3 sites x 20 samples). Nothing was dropped.
  • Missing values. Missing scores are filled by your rule. Nothing was filled that should stay blank.
  • Dates. Do not stop at “the dates parse and fall in 2023”. A wrong parse still produces valid-looking 2023 dates. Compare a few site C dates with the raw file by hand. 05-01-2023 must become 2023-01-05 and not 2023-05-01. Better, re-parse site C’s raw dates with the explicit %d-%m-%Y format and compare the result with your merged file row by row.

You can ask the AI to write these checks. Read them before you trust them. The project folder ships a validate_data.py with most checks written and one left for you. You finish it in the next episode.

G. Reflect

  • What did the AI handle well?
  • What did you already need to know to judge its answer?
  • Did anything in the script change the data in a way the plan did not mention?
Discussion

Feedback checkpoint: surprises and uncertainty

Post two short lines in the shared Etherpad. Write one thing the AI did that surprised you, and one thing it sounded certain about that you still doubt. Bring both back to the room. Working alone? Write both lines in your notes file and follow up on the doubt before you move on.

This is the most demanding episode. Generated cleaning code is where extra load shows up most. Watch for apply with lambdas, regular-expression date parsing, or several helper files where a short linear script would do. If a learner cannot explain a block in step E, ask them to request a simpler version before they continue.

Step E is a feedback checkpoint. It shows you who is lost. Ask helpers to note unresolved concepts, not only installation problems.

The next challenge changes existing code. If learners get stuck, suggest that they ask the AI to read clean_and_merge.py first.

Challenge

Challenge: read a diff, then run it

Imagine your analysis should cover February to May only, so you must leave out the January samples.

  1. Predict first. Before you prompt, write down how many rows you expect to remove and how many you expect to keep. Samples are weekly, and January has four sampling dates per site.
  2. Ask for a new script. Ask Claude Code to write a new script, clean_feb_onward.py. It reuses the cleaning logic from clean_and_merge.py, keeps only samples from February 2023 onward, and writes data/feb_onward.csv. It must not touch clean_and_merge.py or data/master_dataset.csv. The capstone and later episodes expect the full 60-row dataset.
  3. Read before you run. Compare the new script with clean_and_merge.py (for example, diff clean_and_merge.py clean_feb_onward.py). Pick one changed line and explain it to a partner. Check that the output path is data/feb_onward.csv.
  4. Check against your prediction. Run the new script. Compare the row count with your prediction. If they differ, explain why in one sentence. Then confirm that both files kept the counts you intended: 60 rows in data/master_dataset.csv and your predicted count in data/feb_onward.csv. Pay attention to site C. A naive parse can swap day and month for some rows and not others, so some misparsed January rows can land outside the window and vanish, while others land inside it and wrongly stay.

January has four weekly sampling dates per site (the 5th, 12th, 19th and 26th). A correct filter removes 12 rows and leaves 48.

A different number most likely comes from the site C date format. A naive parse swaps day and month for some rows only. For example, 05-01-2023 becomes 1 May and 12-01-2023 becomes 1 December, while 19-01-2023 parses correctly either way because 19 cannot be a month. A partial misparse does not shift the whole series to one edge. It scatters points. This is a small, safe version of a silent error that would bias a real trend analysis.

Read 'clean_and_merge.py'. Write a new script, 'clean_feb_onward.py', that reuses its cleaning logic, keeps only samples collected in February 2023 or later, and writes data/feb_onward.csv. Do not modify clean_and_merge.py or data/master_dataset.csv.

Did the AI edit the right part or rewrite the whole file? Did it parse the dates before it filtered? Did you read the changes before you ran the script?

Automating documentation

Ask the AI for a short pipeline summary. The folder already has a README.md that describes the schema and the target output, so ask for a differently named file:

Create a PIPELINE.md file that explains the data processing pipeline we just built. List the original files, the cleaning steps performed, and the final output format. Do not modify or overwrite README.md.
Challenge

Challenge: provenance tracking

For research to be reproducible, record which tool generated your code and when.

  1. Use Claude Code to add a provenance header to clean_and_merge.py.
  2. The header is a Python docstring with:
    • The tool version and the model name, if your session shows it (check /status or the status line).
    • The date.
    • A summary of the prompt.
Read 'clean_and_merge.py'. Add a docstring at the very top of the file as a provenance header. Include the tool version and the exact model name from this session (check /status if unsure), today's date, and a summary of the prompt: 'Standardise site IDs, format dates, and impute missing scores with site medians.'

Reflection

  • Why record the tool version, model name and date?
  • Does it matter if the model is updated later?
  • How does the header help someone rerun your work? A header records history. The code, the data, the environment and the commands are what let another person rerun it.
Key Points
  • Predict the inconsistencies yourself before you prompt, so you can judge the AI’s plan.
  • Ask for a plan first, mark the assumption the data do not support, then generate code.
  • Read the diff and explain a changed line before you run it.
  • Check with concrete evidence (row count, missing values, dates), not because the script ran.

Content from Validation Strategies: The Approval Gate


Last updated on 2026-11-07 | Edit this page

Estimated time: 95 minutes

Overview

Questions

  • What evidence makes AI-generated code safe to approve?
  • What can rewrite time tell me about my workflow, and what can it not?
  • How do I know my own check would catch a wrong result?

Objectives

  • Given an AI-generated script, state the evidence supporting it, name the missing evidence, and decide to approve, revise, or reject.
  • Describe the four-layer validation stack (recorded requirements, automated checks, metamorphic tests, domain plausibility).
  • Write one independent check in validate_data.py from the source documentation.
  • Show that a check fails on bad data and passes on good data.

The approval gate


When an agent writes your code, you spend more of your time reading, questioning and approving. The approval gate is the point where you decide a result is good enough to use.

This gate supports one decision: whether to accept a bounded piece of code. Passing it does not validate your study design or your scientific claim.

Callout

A review cycle

  1. Write the requirements.
  2. Let the agent implement one bounded change.
  3. Run checks you trust.
  4. Read the changes and decide.

The agent’s confidence is not evidence. Your checks are.

Rewrite time: a signal, not a score


Rewrite time is the effort, in minutes, you spend making AI output ready to trust. It is useful if you keep its limits in mind.

One timing on one task says little about productivity in general. People also misjudge their own productivity. A 2025 survey of 868 scientists who program, revised in 2026, found that feeling productive with a generative AI tool was linked to less programming experience and less use of testing and code review. The strongest predictor was how many lines of generated code a person accepted at once (O’Brien et al.). The survey measures perceived productivity. It does not show better correctness or a causal speed-up.

Treat rewrite time as a signal about this workflow on this task:

  • It is local.
  • High rewrite time usually means the task was underspecified, the model overreached, or you did not yet have the mental model to judge the output.
  • It tells you what to improve next: the prompt, the requirements, or the checks.
Caution

Do not turn rewrite time into a productivity claim

A low rewrite time on one script does not show that AI saved you time. It leaves out the time you spent prompting, reviewing, debugging and validating. It also says nothing about whether the result is correct.

Discussion

Think aloud while you work

Work in pairs. One person uses the AI for five minutes on a small task, such as adding one check to the cleaning script. Say out loud what you expect, what you trust and where you hesitate.

The observer takes notes. Where did the worker hesitate? Where did they trust the output without checking? Where did they backtrack?

Then discuss as a group. Which one change to the prompt, the requirements or the checks would have helped most?

Working alone? Keep a two-column log: what you expected before each step, and what you had to change afterward.

The four-layer validation stack


Layer 1: Recorded requirements

Write down what the result must satisfy before the agent writes code. Put the requirements in your CLAUDE.md so you and the agent can both read them.

Example from our project: “Do not change the column names in data/site_*.csv” and “Do not drop any rows: the merge must have 60.”

A requirement in a Markdown file is a request. It does not stop the agent from breaking it. Tool permissions and isolation enforce access limits. Tests show whether the output meets the requirements.

Layer 2: Automated checks you can run

Write checks that run. A check turns “it looked fine” into “these checks passed.” Your project ships validate_data.py with most checks written and one left for you.

Take your expected values from the raw files and the documentation. Do not take them from the cleaning script. If the script contains the error, a check that copies its logic copies the error.

Layer 3: Metamorphic and invariant checks

Test relationships in your data that should never change.

  • An invariant: the merged file has 60 rows (3 sites x 20 samples), and no sample_id is lost.
  • A metamorphic check: if you shuffle the input rows, the merged mean score does not change.

Layer 4: Domain plausibility

This is where your research expertise counts. A check can pass while the science is wrong. A water quality score above 100 is impossible. Site C’s January samples should not appear in May.

The clearest case is the date trap. If you miss it, the cleaning runs, the row count is right, and the trend you plot is still wrong.

Callout

Validation is yours to own

  • You cannot validate code you cannot explain. If you cannot say what it does, you are hoping.
  • Passing tests is not the same as being scientifically correct. Tests check what you thought to check.
  • A second model is a reviewer, not an authority. It has its own blind spots.
  • Domain plausibility is your job. No model knows what a sensible result looks like in your field better than you do.
Challenge

Challenge: write one independent check

Open validate_data.py. Six checks exist. Five are written for you. One is a stub: every sample’s date matches the raw source.

An unfinished check makes the script exit with an error. Run it now and read what it reports.

  1. Open README.md and find each site’s date format. Write them down. Do not copy them from clean_and_merge.py.

  2. Write the date check yourself, or ask the agent for a draft and read every line before you trust it. Re-parse each raw site file with its documented format and compare the result with data/master_dataset.csv, sample by sample. A check that only confirms the dates parse and fall in 2023 is too weak. A misparsed site C date still looks like a valid 2023 date.

  3. Run python validate_data.py. Fix the data or the cleaning script until every check passes. Never edit a value to satisfy a check. A passing run looks like this, captured from the reference validator (instructors/files/backup_validate_data.py, which has eight checks):

    [PASS] row count is 60
    [PASS] all canonical columns present
    [PASS] every original sample_id is present exactly once
    [PASS] every sample_id carries its source site
    [PASS] every sample's date matches the raw source
    [PASS] every score is a number within 0-100 (none blank or text)
    [PASS] observed scores are unchanged and missing scores use the site median
    [PASS] pH and temp_c keep their source values (blanks stay blank)
    
    All 8 checks passed.
  4. Now test the check. Copy data/master_dataset.csv to data/candidate.csv. In the copy, make site C’s dates month-first, as pd.to_datetime(..., format="mixed") would read them. Run python validate_data.py data/candidate.csv. A good date check fails:

    [FAIL] every sample's date matches the raw source - 8 mismatch(es), e.g. ['SC001', 'SC002', 'SC006']

    The run does not crash. The plot would not bunch site C at one edge either. Only some rows are wrong, because format="mixed" guesses each date on its own and gets some right by accident.

  5. Delete data/candidate.csv. Confirm data/master_dataset.csv is still the correct output, and run the validator on it once more.

If everything still passes in step 4, your date check is too weak.

A good date check rebuilds the expected date for each sample from the raw file and compares it exactly. It does not stop at “no error” or “the year is 2023.” See instructors/files/backup_validate_data.py for a reference.

A validator that cannot fail on a known-bad input does not protect you.

Challenge

Challenge: this check passes. Is the file right?

A colleague hands you a merged file. It has 60 rows. Every date matches the raw source. Every sample_id appears once. Every score is between 0 and 100. Every site value is A.

  1. Which of the checks you have run would catch this?
  2. Would you approve the per-site plot?
  3. What check would you add, and where would its expected values come from?

Row count, date accuracy, ID uniqueness and score range can all pass on this file. Reject the per-site plot. Row count and date accuracy do not show site identity.

The missing check compares each sample_id with the site its raw file says it belongs to. The reference validator and the starter both include it. Run it against the file and watch it fail, then fix the labels and watch it pass.

A passing validator tells you only what it checked. Any property you did not write a check for is still unverified.

Warn learners about approval fatigue, the habit of accepting suggestions without reading them. Ask for the check output before the diff discussion. Review the requirements and the critical changes yourself, and use independent checks to test defined properties. An agent’s assurance that its code is correct is not proof.

Before the session, run python instructors/files/test_validators.py. It builds a good file and eight bad ones in a temporary folder and confirms that the validator rejects each bad one for the right reason.

Challenge

Challenge: explain the approval gate

Take a script you or a partner generated earlier. Walk through the gate out loud or in writing. Answer all five:

  1. What did the AI produce?
  2. What evidence do you have that it works?
  3. What evidence is missing?
  4. Which domain assumption could still be wrong?
  5. Would you approve, revise or reject this output, and why?

A strong answer names the output precisely and points to specific checks as evidence: row counts, a failing-then-passing test. It admits gaps, such as “I have not checked the date parsing on the 2019 files.”

The domain-assumption answer is hardest and most useful. It shows you are judging the science and not only the code. Approve only when the evidence covers the claim. Otherwise the honest answer is “revise.”

Going further: a critique from a second model


This section is optional. A second model can widen your review. Switching models inside the same Claude Code session is not independent, because the second model sees the same conversation, tools and framing. Treat what it returns as a hypothesis to check.

Challenge

Challenge: get a critique from a second model

  1. Use one model to generate a data cleaning script.

  2. Give the specification, the code and any tests to a different model in a fresh session. Use a new terminal, a different tool, or at least /clear. Do not pass along the first model’s account of its own work. Then use this prompt:

    “Read this script. Act as a skeptical senior data scientist. Name three edge cases where this script could fail, such as empty strings, NaN values or encoding problems. Suggest specific assert statements to catch each one.”

  3. Reflect. Did the second model find something the first one missed? Which findings still need a deterministic check or your own judgment before you act on them?

Different models have different blind spots, so a second read can surface edge cases the first one skipped. But the second model shares training data and habits with the first, and a same-session switch shares even more. Treat its findings as questions to investigate with a check or your own expertise.

Key Points
  • The approval gate supports one decision: accept, revise or reject a bounded piece of code.
  • Passing checks does not validate the study or the scientific claim.
  • Take expected values from the source documentation, not from the code under test.
  • A check earns trust when it fails on a known-bad input.
  • Rewrite time is a local signal about your workflow, not a productivity score.
  • You cannot validate what you cannot explain.

Content from Limitations and Cautions


Last updated on 2026-11-07 | Edit this page

Estimated time: 45 minutes

Overview

Questions

  • When should I not use AI?
  • Which failure modes can pass a quick look?

Objectives

  • Name situations where AI help gets in the way of learning or of research integrity.
  • Describe spec drift and silent semantic drift, and the checks that catch them.
  • Check a package name against the official registry before you trust a model’s answer.

The four-hour pilot does not teach this episode as its own block. It folds the scope and privacy points into Episode 1 and the failure modes into Episodes 2 and 4. Use this episode in the extended course, or as a follow-on.

Callout

The jagged frontier

AI capability is uneven. A model may solve a hard differential equation and fail a simple logic puzzle. You need to find where AI is reliable and where it is a liability in your own field.

When not to trust AI code


AI-generated code can put research integrity at risk. Security-critical tasks such as authentication, encryption and sensitive data need expert oversight.

AI can also fail on new statistical methods or domain details. A model draws on its training data, which may not cover recent work or your specific sensor. In performance-critical code, it often picks a common algorithm over the most efficient one.

Callout

When not to use AI in a workshop exercise

The goal is not “never use AI.” Use it where it supports learning and rigour, and step back where it does not. Avoid AI when:

  • The exercise builds basic syntax fluency. A generated answer skips the practice.
  • You cannot yet explain the output. If you cannot judge it, you cannot use it responsibly.
  • The data are sensitive and the tool’s privacy terms are unclear.
  • The task involves security, authentication, encryption, access control or regulated data.
  • The model keeps bringing in ideas beyond the lesson.
  • Reaching for AI stops the instructor from seeing where the group is stuck.
Callout

When AI can support learning

AI helps most when it helps you understand, and not when it replaces understanding. Good uses:

  • Explaining an error message you are stuck on.
  • Giving a simpler example of a concept you just met.
  • Asking you concept-check questions before you answer.
  • Comparing two solutions so you can choose.
  • Suggesting tests for code you already understand.
  • Helping you document code after you understand what it does.

Common failure modes


Knowing the failure modes helps you catch errors before they reach your results.

Spec drift

Spec drift happens when the code and your requirements stop matching. An agent may change the code to make a check pass, or may fix a bug and leave the requirements out of date.

  • Prevention: compare the implementation with your approved requirements. If the code disagrees, do not just ask the agent to sync the requirements to the code. That can make an unintended change official. Decide whether the code or the requirement is wrong. Propose and justify any change to a requirement, and name the evidence that supports it.

Silent semantic drift

Semantic drift is a change that alters your data assumptions or logic without breaking the code.

  • Example: the code runs and the checks pass, but a filter threshold changed, or a column was renamed wrongly, and the research conclusion shifts.
  • Prevention: use invariant and metamorphic checks, and keep your own checks independent of the code under test.

Other failure modes

  • Hallucinated functions. The model uses libraries or APIs that do not exist.
  • Outdated approaches. The AI uses deprecated syntax from its training data.
  • Confident incorrectness. The AI states a wrong formula or logic as certain.
  • Prompt injection through tools. When an agent calls external tools, for example through MCP, a misconfigured or malicious server can slip instructions into the agent’s context through its tool descriptions or returned data. Install servers only from sources you trust and have reviewed. Treat everything a server returns as untrusted input, and limit its file and network access. Being listed in a registry does not certify that a server is safe.
  • Over-engineering. The model writes complex code for a simple problem.
Discussion

Resource cost

Data centres use large amounts of electricity and water. Frequent, iterative prompting has a resource cost. A web search has one too.

No model-specific comparison between an AI query and a web search was verified for this lesson, and published estimates vary widely with method and model size. The qualitative point holds: working code is not always efficient code, and inefficient software uses more resources over time.

Sustainable habits:

  1. Think before you prompt. A clear prompt can get the right answer in fewer attempts.
  2. Ask for optimisation once the logic is correct.
  3. Read the documentation when you need simple syntax.

Current models flag uncertainty more often than older ones, but they still hallucinate. Do not promise learners that it will not happen.

  • If the model refuses or hedges, point out that it recognised its own limit.
  • Keep a screenshot of a known hallucination ready in case the AI performs perfectly during the session.
Challenge

Challenge: test for a hallucination, then verify independently

Inside your Claude Code session, type:

How do I use the 'pypanda-researcher' library to automatically write my conclusion?

Notice whether the model admits it does not know, hedges, or invents instructions with confidence. Then check for yourself, without relying on the model. Search PyPI for pypanda-researcher. Record what you find and the date you checked. Would you accept, revise or reject the model’s answer based on that evidence and not on how confident it sounded?

A package that exists on the registry is not therefore the package you wanted. Existence does not prove identity, safety or fit.

You may get a clean “this does not exist.” That is the right answer when it happens, but do not count on it.

A 2026 study of five frontier models, using its own prompts, found that they invented nonexistent package names about 4.6 to 6.1 percent of the time. 127 of the invented names were produced identically by all five models (Churilov, 2026). Those are rates for that study’s models and prompts, and not current universal failure rates.

The second finding bears on your habits. Asking another model to double-check a package name is weaker protection than it sounds, because models can invent the same wrong name. Check the official registry or the documentation directly.

Open science and proprietary AI


Claude Code is not open source. That creates a tension in open research.

  • Closed-weight models (Claude, GPT, Gemini). You cannot inspect their training data, and they may be updated without notice. An institutional agreement can cover data privacy. It does not solve reproducibility.
  • Open-weight models (for example Qwen3, Gemma, gpt-oss). You can run them locally with a tool such as Ollama and keep a specific revision. Licence terms vary by model, so check them with the version. “Open-weight” means the weights can be downloaded. It does not make a system open source in the fuller sense, because training data, code and licence may still be closed.

Recommendation. No blanket choice fits prototyping and cleaning. Decide from your data’s classification and authorisation, the task’s reproducibility and audit needs, and cost. Whichever you use, archive the generated code, the inputs, the dependencies and the commands, so the analysis reruns without the model. If model inference is part of the analysis, also preserve the model files and inference settings, and test that results repeat.

Challenge

Quick check: which model class fits?

For each scenario, would a closed-weight or an open-weight model, run locally, fit better? Say why.

  1. A throwaway exploratory script you will discard today.
  2. A pipeline that must reproduce its output in five years for a methods reviewer.
  3. A first pass on de-identified patient records, at an institution with an approved, contracted AI tool.
  1. Either. Cost and convenience decide. Nothing about the task needs reproducibility or data controls.
  2. The key step is to archive the generated code, the inputs, the environment and the commands, so the pipeline reruns without any model. A pinned open-weight model helps only when inference is part of the analysis.
  3. Whichever tool your institution has approved for that data. An institutional agreement can cover privacy and compliance. It does not by itself settle reproducibility. Both questions can apply to one project.
Callout

Key lesson

AI can generate code. It does not take on your expertise or your responsibility. Your work shifts toward understanding, questioning and verifying what the AI produces. You remain accountable for the result.

Discussion

Feedback checkpoint: certainty and evidence

In the shared Etherpad, post one thing an AI tool told you this session with certainty that you have not verified. Those items deserve a second look. Working alone? Write it in your notes file, then go and verify it before you move on.

Key Points
  • Avoid AI for security-critical tasks, sensitive data and basic syntax practice.
  • Know when AI supports learning and when it gets in the way.
  • Compare code with your approved requirements. Do not sync the requirements to the code without evidence.
  • Check a package against the official registry. Existence on the registry is not proof of fit.
  • Archive code, inputs, environment and commands so your analysis reruns without the model.
  • You are responsible for the final output.

Content from From AI Output to a Review-Ready Bundle


Last updated on 2026-11-07 | Edit this page

Estimated time: 110 minutes

Overview

Questions

  • Can I take one task from prompt to a documented result that someone else can rerun?
  • What does “review-ready” include, beyond a script that runs?

Objectives

  • Run the full workflow on one project, from messy files to a checked, documented result.
  • Assemble a bundle that another person can rerun without AI.
  • Make and defend an approve, revise or reject decision on your own output.

You have practised each move on its own: requirements, a plan, a cleaning script, a validator. The capstone puts them together on the coastal water quality data. It ends with a descriptive statement: what pattern is visible in the water quality score at each site over the monitoring period?

A line plot can show a visible pattern. It does not establish a significant trend or a difference between sites. That needs a stated method and a measure of uncertainty, which this lesson does not cover. The data are synthetic, so the statement describes the exercise and not real coastal conditions.

The goal is not only a plot. It is a bundle that a collaborator, or you in six months, can rerun and trust.

The workflow, end to end


Reuse the cleaning script and the validator you already built. Do not repeat their planning and generation.

  1. Confirm the task. Write one sentence for what “done” means. For example: a merged 60-row dataset and a per-site plot, both checked and documented.
  2. Check your requirements. Open CLAUDE.md. Does it state the schema, the rules about dropped rows and site C dates, and the missing-value rule? Fix it before you generate anything.
  3. Reuse the pipeline. Run your clean_and_merge.py and validate_data.py. Every check must pass. An unfinished check is not a pass.
  4. Plan the plot. Ask the agent to outline a short script that reads data/master_dataset.csv and plots score over date, one line per site. Do not let it write code yet. Review the plan against your requirements.
  5. Generate and read the plot script. Ask for plot_trend.py, which saves fig/score_trend.png. Read the code. Explain one block aloud or in a comment. If you cannot, that block is not checked yet.
  6. Run it and look at the plot. Do all three lines run from January to May as a continuous weekly series? Does site C look scattered or out of order? That would suggest the date trap bit you. A plot can render cleanly and still be wrong.
  7. Record the environment. Save the Python and package versions you used, for example with python --version and pip freeze into environment.txt.
  8. Write the run instructions. Create RUN.md with the working directory and the exact commands, in order. A partner will follow it with no help from you.
  9. Write the provenance note. Record the tool version, the model name if you know it, the date, the relevant prompts, the changes you reviewed and the checks that passed.
  10. Decide. Approve, revise or reject. Write one line of evidence and one remaining uncertainty.
Callout

The likely failure is silent

If the cleaning script parses site C dates with format="mixed" and not the explicit %d-%m-%Y, some rows swap day and month. 05-01-2023 becomes 1 May. Other rows parse correctly by accident. The script runs, the row count is 60, and the plot misleads. The wrong points scatter, so looking at the plot alone will not reliably catch the error.

“It ran” would hide this. Your validator, which compares each sample’s date with its raw source, would not.

Challenge

Can another researcher rerun and assess your result?

Share one folder with a partner. Include:

  • The three unchanged synthetic source CSVs and their description.
  • CLAUDE.md, plus the approved plan or a short plan summary.
  • clean_and_merge.py, validate_data.py and plot_trend.py.
  • environment.txt with the Python and package versions you used.
  • RUN.md with the working directory and the exact commands, in order.
  • data/master_dataset.csv and fig/score_trend.png.
  • A provenance note: tool version, model name if known, date, relevant prompts, reviewed changes and test results.
  • Your approval decision, its evidence and one remaining uncertainty.

Your partner regenerates the dataset and the plot in a fresh copy of the folder, without AI. They confirm that:

  1. All 60 source IDs occur once, and each ID has the right site.
  2. Every date matches its source record under the documented source format.
  3. Every score is a number, none is blank, and all are between 0 and 100.
  4. Observed scores are unchanged. The three missing scores use their site’s median of observed scores: A004 = 72.0, B-006 = 71.5, SC002 = 71.6.
  5. Missing pH and temperature values stay missing, and all other values are preserved.
  6. The raw inputs are unchanged. The plot is regenerated from the checked output, with one labelled line per site and dates in order.
  7. The validator rejects a copy with wrong dates and a copy where every site is A.

Make the bad copies in a separate temporary folder. Restore the correct output before you make the plot.

Then write one descriptive statement about the synthetic series. Do not infer a significant trend, a causal effect or real coastal conditions. In one sentence, say why the workshop’s median rule is not automatically right for a real study.

Finally, write three sentences:

  • What did I understand? Name one part of the pipeline you could rebuild without AI.
  • What did I verify? Name the evidence, not the feeling.
  • What remains uncertain? Name one thing you would check before real use.

A complete bundle reruns without hidden files, agent access or manual edits to the data. The reviewer records each command, its result and any missing dependency.

A correct decision names the checks and limits its claim to those checks.

Transfer case. A candidate has 60 rows, correct dates, unique IDs and scores in range, but every site value is A. A validator without a site check can pass this file. Reject the per-site plot until the ID-to-site check fails on the candidate and passes after repair. Row count and date accuracy do not show site identity.

A “revise” decision that names a precise missing check is stronger than an unsupported approval. If a bundle cannot rerun, name the missing file or instruction. A prompt summary does not replace executable analysis code.

Spend most of the time on doing. Expect the site C date bug to surface for several learners. Treat it as the highlight, because it shows the lesson’s central point in one failure.

If a group falls behind, supply the reference cleaner and plot script from instructors/files/, and the completed validator. Label which parts you supplied. The learner must still explain one change, predict a failure and defend a decision on the transfer case.

Record whether the partner actually reran the bundle or only inspected saved output. Collect a few approval decisions and read them aloud. The honest “revise” answers teach the most.

Discussion

Feedback checkpoint: revisit your opening note

Look back at the note from Episode 1: what you wanted from AI and what you feared it would get wrong. Did the workshop change either answer? Post one line in the Etherpad, or add it to your notes file.

Key Points
  • A review-ready bundle holds requirements, code, checks, a result, the environment, exact commands, provenance and a decision. A script that runs is not enough.
  • Another person rerunning your work without AI is the strongest test of the bundle.
  • A descriptive plot is not a statistical finding.
  • A plot can render cleanly and still be wrong. Domain plausibility is your job.
  • “Revise” is an honest outcome when the evidence does not yet cover the claim.

Content from Resources and Next Steps


Last updated on 2026-11-07 | Edit this page

Estimated time: 40 minutes

Overview

Questions

  • Which tool should I reach for, and when?
  • How do I take this back to my own data?

Objectives

  • Pick an AI tool for a task and a data category, and say what evidence supports the choice.
  • Draft a workflow plan for one of your own datasets: tool, backend, no-go zones, opening prompt, check, provenance record and one unchecked claim.
  • Spot signs of AI hype using a stated set of criteria (scope, transparency, citations, privacy).

This episode is a short reference and a plan for what you do next. The skills you practised transfer across tools: state requirements, plan, check, judge and document.

A short tool table


Tools change fast. Treat this table as examples, and check each tool’s current documentation before you rely on it.

Tool What it is Reach for it when
Claude Code (used in this lesson) A command-line agent terminal-native work on your real files
Codex CLI, Cursor A command-line agent, an AI code editor you prefer another vendor or an editor-integrated agent
Aider with a local model runner An open command-line agent with a model on your machine you need data to stay on your machine
NotebookLM, Elicit, Consensus Document and literature tools you want answers grounded in your own PDFs or the literature, and not coding

Hardware needs for a local model depend on the model and the speed you want. Test your chosen setup. Many researchers use a cloud model for general scripting and a local model for sensitive data. Whether any given tool is approved for your data is your institution’s call.

Challenge

Quick check: which pairing gives you pause?

  1. Claude Code, for cleaning a public, already-published dataset.
  2. A local model, for a pipeline you must rerun in five years.
  3. Claude Code on its default cloud backend, with no institutional approval, for a first pass on sensitive, unpublished human-subjects data.
  4. NotebookLM, for questions grounded in a folder of your own PDFs.

3. Sending sensitive, unpublished human-subjects data to a general cloud endpoint with no approval behind it is the pairing to avoid. “Which approved backend” on the workflow card asks you to settle that before you start.

The others are reasonable. Public data carries no sensitivity limit (1). For (2), the key step is to archive the code, inputs, environment and commands so the pipeline reruns without a model. A pinned local model helps only if model inference is part of the analysis. A document tool used on your own files is what it was built for (4).

Caution

External tools and connectors

The Model Context Protocol (MCP) lets agents connect to external tools and data sources. Many servers are installed without institutional review. Prompt injection and data leaks remain real risks. Treat a server’s tool descriptions and returned data as untrusted input. Before you connect one, check that it is maintained and comes from a source you trust, limit its file and network access, and confirm that your institution’s policy covers it. Being listed in a registry does not show that a server is safe.

Citing and crediting AI


Transparent credit is part of open science. Follow the target publisher’s current disclosure policy, and keep enough provenance to explain AI’s role. Major publishers and COPE say that AI tools cannot be authors, because they cannot be held accountable.

  • In a repository README.md: note the tool, its role and who verified the output. For example: “Claude drafted the cleaning script. [Your name] verified it with validate_data.py.”
  • In a manuscript: name the tool in the methods or acknowledgements, and keep prompts and outputs available.
  • Check the current policy: COPE on AI authorship, CRediT taxonomy.
Challenge

Challenge: your Monday workflow card

Pick one real scenario from your own work and fill in a short plan you could use next week. The lesson ships a template, monday-worksheet.md, in learners/files/. Open it and fill it in.

Choose a scenario: a small public CSV, sensitive human-subjects data, large geospatial files, or an existing messy repository.

Write down:

  1. Tool and backend. Which tool, and for sensitive data, which approved backend? Name your evidence source, such as the campus policy page.
  2. What the AI can see and must not touch. These are the no-go zones for your CLAUDE.md. Note how access is enforced, not only requested.
  3. First prompt. Your “plan only, no code yet” opener.
  4. One likely error and the check that would catch it.
  5. Provenance. Where you will record the tool version, model, date and prompt, and where you will archive the code, data, environment and commands.
  6. One unchecked claim. What are you still taking on trust?

A good card is specific to your data. The check line is the test. If you cannot name a check that would fail when the result is wrong, you do not yet understand the task well enough to hand it off. That is fine. It means you start by understanding, not by generating.

Spotting hype


New tools appear daily, and many are more marketing than substance. Before you adopt one, ask:

  • Scope. Be wary of tools that claim to do everything. Specialised tools often work better.
  • Transparency. Can you see the intermediate steps, or only the answer?
  • Citations. Does it give real DOIs and URLs you can check?
  • Privacy. If it is free, is your data used for training?
Challenge

Quick check: spot the hype

For each description, name the criterion it fails most clearly.

  1. “Answers any research question instantly, in any field, with no setup.”
  2. “Summarises your uploaded PDFs and gives you a final answer. You do not need to see the search or the reasoning.”
  3. “Free forever. Sign up and start uploading your data today.”
  1. Scope. A tool with no stated domain limits often has little depth in any one domain.
  2. Transparency. If you cannot see the intermediate steps, you cannot check the work. You can only trust the answer.
  3. Privacy. A free tool that asks for your data and says nothing about what happens to it is the case this criterion exists for. Check before you upload.

Some sources that stay practical and skeptical: Simon Willison (AI engineering and security), Ethan Mollick (AI and cognitive work), Hamel Husain (systematic evaluation) and The Batch (industry news).

For the tool used here, see the Claude Code documentation. For the terms used in this lesson, see the learner reference page.

Key Points
  • The workflow transfers across tools. Match the tool and backend to the task and the data category.
  • Credit AI use openly. It cannot be an author.
  • Leave with a plan for your own data, including one check that would catch a likely error.
  • Before adopting a tool, check its scope claims, transparency, citations and privacy terms.