AI-Augmented Development for Science

From Petabytes to Pipelines: How AI Dev Tools Accelerate Research Software

James Westover | Westover Labs
westoverlabs.eu | [email protected]

GitHub
James Westover

James Westover

Physicist → 10M QPS* at Uber → AI & Applied ML → Ready to catalog the solar system

Uber HERE University of Rochester UCF

Petabyte-scale pipelines · Distributed systems · Python · HPC clusters · AI-augmented dev

NDS Westover Labs Founder — Westover Labs

The Problem We All Share

Science software is getting harder to build, not easier:

  • Datasets growing exponentially (LSST: 20 TB/night, 60 PB over 10 years)
  • Pipelines spanning multiple languages, frameworks, and institutions
  • Small teams, big ambitions, limited engineering bandwidth
  • "It works on my laptop" doesn't scale to production

What if your development tools were as smart as the science they support?

Glossary: AI Development Terms (1/2)

Term Definition
Agentic AI AI that can take actions — read files, run tests, call APIs — not just generate text
Sequential Reasoning AI technique where the model plans step-by-step before acting (think vs. autocomplete)
Claude Code Anthropic's CLI tool for AI-assisted development — the main tool demonstrated today
MCP Model Context Protocol — open standard that lets AI agents call your tools and access your data
Knowledge Graph A database that stores entities and their relationships; here used for persistent AI memory

Glossary: AI Development Terms (2/2)

Term Definition
pgvector PostgreSQL extension for vector similarity search — enables semantic memory
ONNX Runtime Cross-platform ML inference engine — runs AI models efficiently on CPU or GPU
CI/CD Continuous Integration / Continuous Deployment — automated testing and deployment pipelines
GitHub Actions GitHub's automation platform for CI/CD workflows — triggers on push, PR, schedule
Ansible Infrastructure-as-code tool — automates server setup and deployment repeatably

These terms will come up during the demo. Refer back to this slide anytime!

Resources & Links

Follow along with the demo:

This presentation: lsst.westoverlabs.eu

What is AI-Augmented Development?

Not "AI writes code for you." Instead:

AI as a force multiplier for the developer

  • Context-aware: Understands your codebase, not just syntax
  • Tool-integrated: Runs tests, reads docs, searches code, calls APIs
  • Conversational: Explain what you want in natural language
  • Persistent: Remembers decisions across sessions

Think: a senior colleague who has read every file in your repo.

Two Breakthroughs That Changed Everything

1. Sequential Reasoning (Chain of Thought)

AI that plans before it acts — explores your code, reads tests, checks docs, then writes.
Not autocomplete. A reasoning engine.

2. Persistent Memory (Knowledge Graphs)

Context that survives between sessions. Why you chose Healpix over R-trees.
What the team decided about coordinate systems. Architectural decisions preserved forever.

These aren't nice-to-haves. They're what make AI dev tools actually work for science.

The Stack: What You Can Build Today

Layer Tool Purpose
AI Engine Claude Code (CLI) Interactive dev agent with tool use
Memory Knowledge Graph (pgvector) Persistent context across sessions
Tool Access MCP (Model Context Protocol) Let AI call your APIs, read your data
Automation Ansible + GitHub Actions Infrastructure as code
Deployment Cloudflare + Tailscale Edge + secure access

All open, all self-hostable. No vendor lock-in.

What is MCP? (Model Context Protocol)

MCP lets you give your AI agent access to your tools and data.

┌─────────────┐     MCP      ┌──────────────────────┐
│  Claude Code │ ◄──────────► │  Your MCP Server     │
│  (AI Agent)  │   (JSON-RPC) │  ┌── Fink API        │
└─────────────┘              │  ├── Database access  │
                              │  ├── Telescope queue  │
                              │  └── Pipeline control │
                              └──────────────────────┘

Build one with Claude itself — describe what tools you need, Claude writes the MCP server. Your entire instrument suite becomes AI-accessible.

Why Deploy a Knowledge Graph?

Without memory, every session starts from zero:

Monday:   "We chose SQLite for storage because no server overhead."
Tuesday:  "Why are we using SQLite?"  ← AI has no idea

With a KG (PostgreSQL + pgvector):

Monday:   Decision stored → "SQLite: no server, WAL mode, fits HPC"
Tuesday:  AI queries KG → "We chose SQLite because [full rationale]"

Every architectural decision, every pipeline choice, every gotcha — preserved.

Cost: One PostgreSQL instance. Value: Never re-explain your project again.

Let's Slow Down and Define the Words

We've used four terms loosely. If you've never seen them, these next slides are for you:

  • RAG — how the AI pulls in the right facts before it answers
  • Knowledge Graph — where those facts live between sessions
  • Context Engineering — the real skill: what the model can see
  • Hooks — the tiny switch that wires it together

The goal isn't to make you a software engineer — it's to make the tooling disappear, so your time goes to the science.

What is RAG? (Retrieval-Augmented Generation)

The model is brilliant — but it only knows what's in front of it right now. RAG fixes that in three moves:

  • Retrieval — go find the relevant facts (your notes, your code, your survey docs)
  • Augmented — add those facts to your prompt, automatically
  • Generation — the model writes its answer from your material, not the generic internet

In your world: you ask "why do we use proper elements to find asteroid families?" — RAG quietly pulls your own knowledge base into the prompt, so the answer is grounded in your project.

Think of it as an open-book exam where the right page is already turned to.

What is a Knowledge Graph? (your project's memory)

A small database of the things in your world and how they connect:

  • Entities — the nouns: objects, families, observations, pipeline stages, decisions
  • Relations — the links: "this candidate was flagged by that filter", "this family shares those proper elements"

Why it matters: it's the AI's persistent memory. It survives across sessions — tomorrow's session already knows what today decided. You stop re-explaining your survey's quirks every single day.

RAG is how facts get in; the Knowledge Graph is one of the places RAG retrieves them from.

What is Context Engineering?

The real skill isn't clever prompting. It's getting the right facts in front of the model at the right moment. The model is smart but blind — it can only reason about what it can see.

Same question……different context
No contextthe AI guesses a column name or a file path — and gets it wrong
The right contextthe AI uses your actual schema, your real paths

RAG is how we do context engineering automatically. And the switch that turns it on is a hook.

What is a Hook?

You already think in pipelines. A data-reduction run is a chain of stages:

raw frames  ->  calibrate  ->  extract sources  ->  catalog

A hook is a point in an existing pipeline where you slot in your own step — to fit extra data in before the next stage runs. You don't rebuild the pipeline; you tap into it.

Your AI tool is a pipeline too, and Claude Code and Codex both expose these hook points. The one that matters runs the instant you press Enter: UserPromptSubmit.

The One Hook: UserPromptSubmit

Your question-to-answer path is itself a little pipeline. UserPromptSubmit lets you insert one stage — retrieve the relevant facts and attach them — right before the model runs:

your question
   ->  [ UserPromptSubmit:  retrieve from your KG, attach the facts ]
   ->  model
   ->  a grounded answer, about YOUR data

That's RAG — fitting the right data into the pipeline at the right stage. The attached facts ride along as hookSpecificOutput.additionalContext. About a page of glue, not a framework.

Why the Hook Is the Simple Lever

You manage nothing. No copy-pasting context, no remembering which file, no re-explaining your project. You just ask — and the retrieve-and-attach stage runs every time, so the facts are already in place when the model runs.

And the stage is safe to add:

  • Fails open — if the retrieval is slow or down, the stage is skipped and your prompt flows straight through. It never stalls the pipeline.
  • Pull it anytime — one file removes the stage mid-session; the pipeline runs exactly as before.

This is the "magic": the plumbing disappears, and you're left doing science.

Toy Demo: RAG Over a KG in ~90 Lines

A tiny, self-contained repo you can clone and run right now — a small astronomy knowledge base plus one UserPromptSubmit hook that searches it and injects the hits:

git clone https://github.com/neherdata/lsst-hook-rag-demo.git
cd lsst-hook-rag-demo

Ask a question in Claude Code or Codex and watch your facts show up — without pasting anything.

The whole point: you already have the pieces. This is the "hello world"; the Fink pipeline (next) is the real thing.

What's in the Box

lsst-hook-rag-demo/
|- ground_with_kg.py          # the ~90-line UserPromptSubmit hook (stdlib only)
|- astro_kg.json              # the KG: asteroid families, orbital elements, LSST facts
|- demo.py                    # before/after viewer -- zero setup
|- .claude/settings.json      # Claude Code hook config (works on clone)
|- .codex/hooks.json          # Codex hook registration
`- README.md                  # intro + run steps + before/after

The same ~90-line ground_with_kg.py — unchanged — grounds prompts in both Claude Code and Codex. Each tool registers it with its own tiny file (.claude/settings.json vs .codex/hooks.json), same UserPromptSubmit event, same hookSpecificOutput.additionalContext output.

See It in 10 Seconds — No Editor Needed

python3 demo.py "Why do we use proper elements to find asteroid families?"

It prints two panels, side by side:

WITHOUT the hookWITH the hook
a generic, hedge-y answer — it never saw your KGanswers straight from your astro_kg.json facts, injected automatically

You changed nothing about how you ask. The hook did the retrieval.

In Claude Code

cd lsst-hook-rag-demo
claude                 # .claude/settings.json auto-registers the hook

You: "What do we know about the Themis family?"

The hook fires on every prompt. Type /hooks to confirm it's registered — you'll see it listed on the UserPromptSubmit event.

Nothing to install — the repo ships the wiring. Clone, open, ask.

In Codex — The Same Hook, Unchanged

# same repo, same question -- run codex in the folder
cd lsst-hook-rag-demo && codex

You: "What do we know about the Themis family?"

The same ~90-line ground_with_kg.py — unchanged — grounds prompts in both Claude Code and Codex. Each tool registers it with its own tiny file (.claude/settings.json vs .codex/hooks.json), same UserPromptSubmit event, same hookSpecificOutput.additionalContext output.

Codex won't silently run a program a cloned repo dropped into your project — approve the grounding hook once, then it's automatic.

One hook, two small registration files — RAG over a KG is ~90 lines, and you already have the pieces.

Demo: LSST Alert Pipeline with Fink

A Real Project — github.com/fedorets/lsst-extendedness

Built in 2 days with AI-augmented dev:

Metric Value
Timeline Started yesterday, production-ready today
Commits 30+
Lines of Code 21,000 (11K source + 10K tests)
Test Functions 587
Source Modules 32
CI/CD GitHub Actions, Dependabot, auto-merge
Alert Sources 5 pluggable (ANTARES, Kafka, Fink, File, Mock)

Let's see how the prompts worked...

Step 1: Scaffolding from a Prompt

You: "Create a Python package that pulls astronomical alerts from
     the Fink broker REST API (api.fink-portal.org), filters for
     objects with high extendedness scores, and stores them in
     SQLite. Use Pydantic for data models and Click for the CLI."

Claude: [reads Fink API docs via web search]
        [creates src/pipeline/models.py with AlertRecord]
        [creates src/pipeline/fink_client.py with REST calls]
        [creates src/pipeline/storage.py with SQLite]
        [sets up pyproject.toml with PDM]
        [writes initial tests with fixture data]

Time: ~5 minutes. The AI knows Pydantic, Click, SQLite patterns — and it researched the Fink API structure.

Step 2: Domain Logic — The Hard Part

You: "The extendedness field maps from Fink's classtar:
     extendedness = 1 - classtar. Filter for extendedness > 0.7.
     Also detect SSO reassociations by tracking ss_object_id
     changes over time."

Claude: [reads Fink field documentation]
        [implements extendedness conversion with edge cases]
        [adds state tracking for reassociation detection]
        [creates SQL views for minimoon candidates]
        [writes parametric tests with real ZTF fixture data]

Key insight: The AI researches domain-specific formats — Fink field mappings, Julian date conversions, magnitude-to-flux — so you don't read RFCs for hours.

Step 3: Build an MCP Server for It

You: "Now wrap this pipeline as an MCP server so the AI agent
     can query alerts, run filters, and check pipeline status
     as tools."

Claude: [creates mcp_server.py with tool definitions]
        [exposes: query_alerts, run_pipeline, get_stats]
        [adds to Claude Code MCP config]
        [tests tool calling end-to-end]

Now the AI agent can use your pipeline as a tool:

"How many minimoon candidates did we find this week?"
→ AI calls query_alerts tool → returns structured data → answers naturally.

Step 4: Knowledge Graph Persistence

Session 1: "We decided to use Healpix for spatial indexing
           because it handles the celestial sphere natively."

  → KG: Entity "Decision: Healpix Spatial Index"
        Observation: "Chosen over R-tree for celestial data"
        Relation: depends_on → "astropy-healpix"

Session 2 (days later):
You: "Why did we use Healpix instead of a simple R-tree?"
Claude: [queries KG] → "We chose Healpix because it handles
        the celestial sphere natively, avoiding distortion at
        the poles that an R-tree in Cartesian coords would have."

No context lost between sessions.

Recommendations for Science Teams

  1. Deploy a Knowledge Graph — PostgreSQL + pgvector. Store all decisions.
    One CREATE EXTENSION vector; away from persistent AI memory.

  2. Build MCP servers for your instruments — Let Claude call your telescope
    queue, query your catalog, run your pipeline. Claude can write the MCP server for you.

  3. Use sequential reasoning — Don't use autocomplete-style AI. Use agents
    that plan, explore, test, then write. Claude Code's agentic mode.

  4. Start small, iterate fast — One pipeline. One MCP tool. One KG entity.
    The compound effect is enormous.

  5. Infrastructure as code from day one — Ansible + GitHub Actions.
    If you SSH to fix something, you've already lost.

Getting Started

  1. Install Claude Code: npm install -g @anthropic-ai/claude-code
  2. Point at your repo: cd your-project && claude
  3. Start talking: "Help me understand this codebase"
  4. Build up context: AI learns your patterns over time

For science teams specifically:

  • Deploy PostgreSQL + pgvector for a knowledge graph
  • Build an MCP server for your data sources (Claude can help!)
  • Use Claude Code's sequential reasoning — not autocomplete

Contact & Consulting

Westover Labs — AI development consulting for science teams:

  • AI dev workshops and hands-on training
  • Pipeline architecture review and Knowledge Graph deployment
  • MCP server development for instruments and data sources
  • CI/CD and infrastructure automation

James Westover | westoverlabs.eu | [email protected]

2x BS Rochester, MS + PhD (ABD) UCF, MBA Quantic
Ex-Uber/HERE/Postmates — I speak both science and engineering fluently.

Westover Labs · Westover Labs · westover.dev