Foundations
From lesson: Your First Day as an AI Engineer
AI Engineer 90-Day Plan & Skills Checklist
ChecklistA self-assessment and week-by-week plan to go from developer to job-ready AI engineer.
ai-engineer-90-day-plan.md
From lesson: Tokens: What Models Actually Read
Token & Cost Calculator
PythonCount tokens exactly with tiktoken (or estimate offline) and price any request before you ship it.
token_budget.py
From lesson: Next-Token Prediction & Temperature
Generation Settings Cheat Sheet
ChecklistWhich temperature, top_p, max_tokens and stop settings to use for each type of task.
generation-settings.md
From lesson: How LLMs Are Built (and Why They Hallucinate)
Model Selection Scorecard
ChecklistPick the right model for a feature with evidence: a weighted scorecard you fill in with your own eval results.
model-scorecard.md
From lesson: Context Windows, Latency & Cost
Chat History Trimmer
PythonKeep long conversations under a token budget: always keep the system prompt, drop the oldest turns first.
trim_history.py
Prompting & LLM APIs
From lesson: Anatomy of an LLM API Call
Production LLM Client (Anthropic + OpenAI)
PythonA small wrapper with timeouts, retries, stop-reason checks and token/cost logging, for either provider.
llm_client.py
From lesson: Streaming Responses
Streaming Chat Endpoint (FastAPI + SSE)
PythonA backend endpoint that streams model output to the browser token by token, plus the browser code to read it.
stream_server.py
From lesson: Prompt Engineering That Works
Production Prompt Template
TemplateA battle-tested system-prompt structure: role, context, rules, examples, output format.
prompt-template.txt
From lesson: Reasoning Models & Chain of Thought
Self-Consistency Voting Wrapper
PythonSample several answers in parallel and return the majority answer with an agreement score: higher accuracy on hard questions.
self_consistency.py
From lesson: Structured Output (JSON)
Validated JSON with Pydantic + Retry
PythonTurn any model reply into a typed, validated Python object, with an automatic retry that feeds back the error.
structured.py
From lesson: Tool Use (Function Calling)
Tool Registry with Auto-Generated Schemas
PythonRegister Python functions as LLM tools with a decorator; schemas are built from type hints and docstrings.
tools.py
Retrieval (RAG)
From lesson: Embeddings & Similarity
Semantic Search in 40 Lines
PythonEmbed documents once, search by meaning with NumPy. Fast enough for tens of thousands of chunks.
semantic_search.py
From lesson: Chunking Documents
Recursive Text Chunker
PythonSplit documents on paragraphs, then sentences, then words, with overlap and metadata. A solid default for RAG.
chunker.py
From lesson: Building a RAG Pipeline
Production RAG on Supabase pgvector
SQLSQL to set up a vector store in Supabase (table, HNSW index, search function) plus the Python to use it.
supabase_rag.sql
From lesson: Hybrid Search & Reranking
Hybrid Search: BM25 + Vectors + RRF
PythonCombine keyword and semantic search with Reciprocal Rank Fusion: better results on codes, names and meaning.
hybrid_search.py
From lesson: Evaluating RAG: Recall, MRR & Faithfulness
RAG Retrieval Eval Script
PythonScore any retriever on recall@k and MRR from a labeled JSONL file, and compare configs side by side.
rag_eval.py
Agents
From lesson: Workflows vs Agents
Workflow vs Agent Decision Checklist
ChecklistDecide in 5 minutes whether you need a prompt, a workflow or an agent, and which pattern to use.
agent-decision-checklist.md
From lesson: The Agent Loop
Production Agent Loop
PythonA provider-agnostic agent loop with step limits, tool errors as text, human approval for risky tools, and tracing.
agent.py
From lesson: Memory for Assistants & Agents
Long-Term Memory Store (SQLite)
PythonSave, rank and delete user memories with recency + importance + relevance scoring. No infrastructure needed.
memory_store.py
From lesson: Multi-Agent Systems
Orchestrator-Workers Template
PythonA lead agent plans sub-questions, workers research in parallel, and the lead synthesizes. Provider-agnostic.
orchestrator.py
From lesson: MCP: Model Context Protocol
Your First MCP Server (Python)
PythonA working MCP server (Python SDK v2) with a tool and a resource, plus the config to plug it into an AI app.
mcp_server.py
Evals & Production
From lesson: Evals: Testing LLM Systems
Eval Harness + LLM-Judge Rubric
PythonRun a JSONL test set through your system, grade with code checks and a judge, and fail CI on regressions.
eval_harness.py
From lesson: Prompt Injection & Guardrails
Prompt-Injection Defense Checklist
ChecklistA layered checklist to review any LLM feature or agent before launch, based on the OWASP LLM Top 10.
llm-security-checklist.md
From lesson: Reliability, Cost & Observability
Resilient LLM Call: Backoff, Jitter, Timeouts
PythonDrop-in retry wrapper with exponential backoff + full jitter, retry-after support and cost logging.
resilient_call.py
From lesson: Observability: Traces, Latency & Cost
Minimal LLM Tracer
PythonNested spans with timing, tokens and cost written to JSONL, plus a p50/p95 report. Upgrade path to OpenTelemetry included.
tracing.py
From lesson: Cutting LLM Costs: Caching, Batching & Routing
LLM Cost-Cutting Playbook
ChecklistA prioritized checklist with the math to estimate each saving before you build it.
cost-playbook.md
ML for AI Engineers
From lesson: Neural Networks in One Lesson
Neural Network from Scratch (NumPy)
PythonA 2-layer network with backpropagation that learns XOR. The whole training loop in ~50 readable lines.
tiny_mlp.py
From lesson: How Models Learn: Gradient Descent
Gradient Descent from Scratch (NumPy)
PythonLinear regression trained with mini-batch gradient descent, plus a learning-rate comparison you can run.
gradient_descent.py
From lesson: Data Splits, Overfitting & Leakage
Leak-Free Dataset Splitter
PythonDeduplicate, then split into train/val/test reproducibly, and verify no example leaks across splits.
split_dataset.py
From lesson: Prompting vs RAG vs Fine-Tuning
Fine-Tuning Data Kit
PythonThe chat-format JSONL that fine-tuning APIs expect, plus a validator that catches common data mistakes.
finetune_data.py
Build an AI SaaS
From lesson: Pick an AI Feature People Pay For
AI SaaS Idea Scorecard & Unit Economics
ChecklistScore ideas in 10 minutes and check the margin per user before you write any code.
ai-saas-scorecard.md
From lesson: Call AI From Your App, Safely
Secure LLM Endpoint (FastAPI)
PythonA production-shaped /api/generate: auth, validation, quota, timeout, fallback model, clean errors, cost logging.
generate_endpoint.py
From lesson: Protect User Data
PII Redaction Module
PythonRedact emails, cards, phones and IDs before prompts and logs, with optional restore after the model answers.
pii.py
From lesson: Usage Limits & Pricing That Cover AI Costs
Quotas & Rate Limits (Postgres/Supabase + Python)
PythonAn atomic daily quota in SQL, a per-minute rate limiter, and the plan table that ties them to pricing.
usage_limits.py
From lesson: AI UX People Trust
AI UX Checklist
ChecklistShip-ready checklist for AI features people trust: speed, transparency, control, failure and feedback.
ai-ux-checklist.md
From lesson: Launch, Measure, Improve
AI SaaS Launch Checklist & Weekly Metrics
ChecklistEverything to check before launch, and the weekly dashboard that tells you what to fix next.
launch-checklist.md