Steering and extending

Programming with LLMs for Data Practitioners

Julia Silge | Posit PBC

Hello!

@juliasilge

@juliasilge.com

juliasilge.com

Day 2: Build with AI

  1. Intro to AI coding assistants
  2. Working in your editor
  3. Steering and extending (this session!)
  4. Agentic workflows

From asking to steering

  • Before lunch: ask a question, get an answer, fix an error
  • This session: give the agent structure so it works the way you do
  • Plans, memory, skills, and new tools

Plan before doing

Think first, edit second

  • For anything bigger than a one-liner, let the assistant itself plan before it writes any code
  • /plan proposes an approach and waits for your approval
  • You catch a wrong direction before the edits, not after

Your turn

Activity

Use plan mode on a bigger crash question:

  • Try something like: “Analyze how risk factors relate to crash severity”
  • Read the plan and push back or refine it
  • Approve it, then let the assistant carry it out
10:00

Memory and project context

Stop re-explaining your data

  • The assistant re-learns your project every session
  • A memory file (AGENTS.md) gives it durable context that loads automatically
  • For the crash data, it should know:
    • What the severity codes 1 to 5 mean
    • That the coordinates are UTM, not latitude and longitude
    • Your preferred packages and plotting style

Your turn

Activity

Build a memory file for the crash project:

  • Ask the assistant to explore the data and write an AGENTS.md
  • Check it! Look at what it knows about severity codes, the UTM coordinate note, key columns
  • Use /savememory to refine it, then start a fresh chat and watch it remember
10:00

Skills

Reusable expertise, loaded on demand

  • Skills are bundles of instructions the assistant loads when they are relevant
  • Built in: shiny-bslib, predictive-modeling, quarto-authoring, and more
  • You can write your own SKILL.md for your team’s patterns
  • They are literally just markdown!
  • Let’s look at the one I built for estimating timing for this workshop

Your turn

Activity

Pick one built-in skill and put it to work on the crash data:

  • shiny-bslib: ask for a small dashboard
  • quarto-authoring: ask for a short report
  • predictive-modeling-python: ask it to model crash severity

Watch the skill load on its own. You do not have to call it by name!

08:00

Tools via MCP

Extending the agent

  • Model Context Protocol: a standard way to give the agent new tools and data
  • Install or write a server once, use it from any MCP client
  • People have mixed experiences! Every server’s tools sit in context and cost tokens every turn
  • Skills load only when relevant, so prefer a skill to teach the model, MCP for a real new tool or data source
  • With that caveat, let’s wire one in and see

Set up our MCP server

Demo

Wire up the crash MCP server that ships in the repo (mcp/crash-server.py):

  • Add it to your assistant config
  • MCP server requires uv but no complex Python setup
  • Restart and confirm the utah-crash tools appear

Your turn

Activity

Ask something that uses the new tools:

  • Try: “Plot the 10 deadliest crash locations on a map”
    • It reprojects UTM to lat/long
  • Or: “What does crash severity 4 mean here?”
    • It reads the codebook
  • Notice it now knows things about this dataset that it could not have guessed
12:00

Managing context

Long sessions, finite context

  • /context shows how full the context window is
  • /compact summarizes earlier turns so you can keep going
  • /new starts fresh when you switch to a different task

Thanks!

@juliasilge

@juliasilge.com

juliasilge.com