Notes
All notes

Dev Tools and Capstone (AI Engg #15)

The capstone chapter has two halves. First, the tools that change how you write software: AI code editors and completion tools. Second, the capstone — a single project that exercises everything from the previous chapters, so you leave with a system in your portfolio and not just a reading list.

Use the first half with judgment. An AI coding assistant can double your speed on boilerplate and tests, and can also produce confident, plausible, subtly wrong code at scale. The same disciplines you applied to LLM features — constrain output, verify, test — apply to the assistant writing your own repo.

The coding-tool landscape

Tool Shape Best at
Claude Code terminal agent multi-file refactors, shell work, long tasks
Cursor AI-first editor inline edits, codebase chat
OpenAI Codex cloud/terminal agent parallel tasks, PR-sized changes
Gemini CLI / Code Assist terminal/IDE GCP stacks, large context
GitHub Copilot IDE completion line/tab autocomplete, tests
Devin / Replit autonomous agent scoped tickets, hosted builds

Three modes of use, increasingly autonomous:

  1. Completion — accept/reject suggestions inline. Lowest risk, highest volume.
  2. Instruction — “add a test for this function,” “refactor this module.” You review the diff.
  3. Agentic — a tool plans, edits many files, runs commands, and opens a PR. Highest leverage, highest risk.
\begin{tikzpicture}[font=\rmfamily, >=stealth,
  b/.style={draw, thick, rounded corners=4pt, minimum width=2.05cm, minimum height=0.7cm, font=\rmfamily\small},
  a/.style={->, thick}]
  \node[b, fill=green!12] (c) at (-3.3,0) {completion};
  \node[b, fill=orange!14] (i) at (-0.9,0) {instruction};
  \node[b, fill=red!10] (ag) at (1.8,0) {agentic};
  \node[font=\rmfamily\small, text=black!60, anchor=north] at (-0.7,-0.6) {leverage \& risk both increase $\to$};
  \draw[a] (c) -- (i); \draw[a] (i) -- (ag);
\end{tikzpicture}

Getting value without shipping bugs

Rules that keep AI-assisted coding honest:

Used this way, coding agents are force multipliers; used carelessly they are a high-velocity bug generator. The same eval mindset from Chapter 13 — golden cases, regression tests, CI gates — is what makes AI-written code safe to merge.

The capstone: build a grounded support assistant

One project, all chapters. It should take a weekend to a week and produce something you would actually demo.

The product. A support assistant over a small knowledge base (10–50 documents you own), which answers with citations, refuses when unsure, and handles one tool-backed action.

\begin{tikzpicture}[font=\rmfamily, >=stealth,
  b/.style={draw, thick, rounded corners=4pt, minimum width=2.0cm, minimum height=0.68cm, font=\rmfamily\small, align=center},
  a/.style={->, thick}]
  \node[b, fill=gray!10] (u) at (-4.6,0) {user};
  \node[b, fill=red!10] (g) at (-2.5,0) {guard};
  \node[b, fill=orange!14] (r) at (-0.3,0) {RAG\\context};
  \node[b, fill=blue!10] (m) at (1.9,0) {LLM};
  \node[b, fill=green!12] (t) at (4.1,0) {tool\\+ trace};
  \draw[a] (u) -- (g); \draw[a] (g) -- (r); \draw[a] (r) -- (m); \draw[a] (m) -- (t);
\end{tikzpicture}

Requirements, mapped to chapters:

  1. Ingest documents — chunk by structure with metadata (Ch. 10).
  2. Embed and index locally, with tenant/persona metadata (Ch. 8–9).
  3. Retrieve hybrid + rerank, filter by metadata (Ch. 9–10).
  4. Prompt with role, rules, citations, and a “not found” path (Ch. 3–4).
  5. Force a structured answer ({"answer", "citations", "confidence"}) (Ch. 3).
  6. One tool — e.g. look up an order status — with a safe read and a gated write (Ch. 11–12).
  7. Guardrails — moderation, PII redaction, tenancy (Ch. 13).
  8. Trace every request — prompt version, context IDs, tokens, cost, latency (Ch. 13).
  9. Golden eval set — 50 (query, expected_doc, expected_fact) cases; recall@5 and a faithfulness judge (Ch. 13).
  10. Regression gate — a script or CI job that fails on quality drop (Ch. 13).
  11. Optional multimodal — accept a screenshot, describe it into the context (Ch. 14).

A starting skeleton:

support-assistant/
  ingest.py        # load, chunk, embed, index          (Ch. 8-10)
  retrieve.py      # hybrid search + rerank + filters    (Ch. 9-10)
  answer.py        # prompt, model, structured output    (Ch. 3-5)
  tools.py         # get_order (read), refund (gated)    (Ch. 11-12)
  guard.py         # moderation, PII, tenancy            (Ch. 13)
  trace.py         # logging + cost/latency              (Ch. 13)
  evals/
    goldens.jsonl  # 50 labeled cases                    (Ch. 13)
    run_evals.py   # deterministic + judge + gate        (Ch. 13)
  app.py           # wire it together

Grading rubric — grade yourself honestly:

Criterion Pass looks like
Retrieval recall@5 ≥ 0.9 on goldens
Faithfulness judge ≥ 4.2⁄5 average
Refusal answers “not found” when evidence is absent
Citations every factual claim maps to a retrieved source
Safety moderation + PII redaction + tenant filter present
Observability every request traced with cost and latency
Regression changing the prompt triggers the eval gate
Cost a per-1K-request cost estimate you can defend

If you can show all eight, you have demonstrated the whole course: models, prompting, context, retrieval, agents/tools, safety, evals, and operations. That is what an AI engineer is hired to do.

Where to go next

Pitfalls

QQuestionFinal self-check

What are the eight boxes in the AI engineer’s loop, and which two multiply everything else? What should the capstone prove?

ASolution

Request → context → model → parse → act → log/trace → evaluate → feed back into context. Context quality and eval coverage multiply model capability; either at zero zeroes the product. The capstone should prove you can build a grounded, cited, tool-using, guarded, measured system whose quality is regression-tested — not just a demo that answers once.

Next: System One Models and Jev (AI Engg #16) — fast, typed, calibrated decisions, and how they sit beside the reasoning LLMs.