Guides
Building AI that survives production
Most AI demos work once and break in production. These are my engineering guides for shipping real AI — agents, RAG, grounded chatbots, MCP, and the cost, latency and guardrails it takes to run an LLM for real.
Building an AI demo takes an afternoon; putting it in production is a different job. A model is a fluent text predictor that sometimes invents, so the hard part is never the prompt — it is the engineering around it. These guides separate what is real from what is hype: when you actually need an agent versus a workflow, how to give a model your data without it hallucinating, and what breaks the moment real users arrive.
The thread tying it together is to treat the LLM call like an unreliable network dependency that occasionally lies: ground it in your data with retrieval, wrap it in guardrails that live outside the prompt, cap its cost and latency, and protect every change with evals and observability. From 'what is an agent?' to shipping an LLM in production, that is the path these guides walk.
The guides

What Is an AI Agent? A Builder's Plain-English Guide
A clear, jargon-free definition of an AI agent — agent vs chatbot vs LLM call vs workflow, how the loop/tools/memory work, real ROI use cases, and when you actually need one.
Read →
Claude Code Tutorial: Install It, Log In, and Ship Your First Task
Learn what Claude Code is and where it runs, install it with one command, log in, and complete your first real task. A practical, copy-paste getting-started guide for developers.
Read →
Claude Code vs Cursor AI (2026): Terminal Agent vs AI-Native IDE — An Honest Comparison
A sourced, engineer's comparison of Claude Code and Cursor AI: what each one is, the model story, real pricing, workflow fit, extensibility, and a decision rule. No universal winner — you can even run Claude Code inside Cursor.
Read →
Advanced Claude Code: Subagents, Hooks, and Slash Commands (2026 Power-User Guide)
Once Claude Code is installed, four features turn it from a helpful assistant into a configured teammate: CLAUDE.md and auto memory, subagents in their own context window, lifecycle hooks, and skills/slash commands. Code- and JSON-heavy engineer's guide with real .claude/agents/ and settings.json examples, plus permissions, plan mode, and MCP. Verified against code.claude.com.
Read →
Claude Code in CI: headless with claude -p, --bare and GitHub Actions
Run Claude Code non-interactively in scripts and CI: add -p to any command and it reads stdin and prints a result. Auto-approve tools with --allowedTools and permission-rule syntax, get JSON with total_cost_usd and structured_output, lock down runs with --bare, and wire PR review into GitHub Actions and GitLab CI.
Read →
How to Build an AI Agent with Python: A 2026 Hands-On Guide
Build a working AI agent in Python in ~40 lines, then make it production-safe. The honest 2026 guide: the agent loop, frameworks, real costs, and when not to.
Read →
How to Use the Claude API: First Call in cURL, Python, TS
A complete getting-started guide to the Claude API: get a key, make your first call in cURL, Python, and TypeScript, pick a model, stream, use tools, and control cost.
Read →
Build an Autonomous Agent with Claude Sonnet 5: Tool Use, the Agentic Loop, and Self-Verification
A hands-on, engineer's tutorial: build an autonomous tool-using agent on the Claude Messages API with claude-sonnet-5 — tools, the agentic loop, self-verification, cheap.
Read →
Take Your Claude Sonnet 5 Integration to Production: Streaming, Stop Reasons, Retries and Errors
The happy-path Claude Sonnet 5 call breaks in prod. Harden it with streaming, every stop_reason, typed-exception retries, idempotency and queues — real Python.
Read →
Tune Claude Sonnet 5 for Cost and Quality: Effort, Prompt Caching and the Batch API
A Spanish-first playbook to get more quality per peso from Claude Sonnet 5: the effort parameter, prompt caching, the Batch API, and routing — with real Python.
Read →
Claude Fable 5 Refusals: A Developer Fallback Guide
Claude Fable 5 redeploys July 1 with new safety classifiers that raise false positives in routine coding. On the raw API a block is a stop_reason of "refusal", not an auto-fallback. Copy-paste routing to Opus 4.8, detection, and monitoring.
Read →
How to Connect an AI Agent to Your Data and Tools: MCP + APIs (2026)
Give an AI agent your real data and the power to act: RAG for knowledge, tool calling for live data and actions, and MCP — the open standard any agent can use.
Read →
How to Build Your Own MCP Server in Python (FastMCP, 2026): Expose Your Tools to Any Client
Write one MCP server and any client — Claude Code, Claude for Desktop, the Agent SDK — can use your tools. A code-heavy Python tutorial: FastMCP, @mcp.tool(), resources, transports, connecting it, and security.
Read →
Claude Agent SDK: Build Production Agents with Claude Code as a Library (Python Tutorial)
A code-heavy, Spanish-first tutorial for the Claude Agent SDK: install it, write your first agent with query() and ClaudeAgentOptions, use the built-in tools, plug in your own MCP servers, and reach for hooks, subagents, permissions, and sessions — with a clear breakdown of when to use the SDK vs the raw Claude API, the Claude Code CLI, or Managed Agents.
Read →
Migrate Your MCP Server to the 2026-07-28 Stateless Spec (Before It Ships)
MCP's 2026-07-28 spec goes stateless: the initialize handshake is gone, capabilities ride in _meta per request. The migration plan, the breaking changes, the timeline.
Read →
How to Secure an MCP Server: A Builder's Hardening Checklist (2026 CVEs Included)
A narrow, operational checklist to harden the MCP servers you connect to your agents — real 2026 CVEs, the 5 attack families, and what to lock down before any tool touches payments.
Read →
How to Let an AI Agent Charge with Stripe — Safely — Using the Agent Toolkit and a Restricted Key (rk_)
Giving an AI agent access to your Stripe account is a security decision, not a feature. Install the Stripe Agent Toolkit, gate it with a restricted key (rk_) scoped to exactly the actions it needs, wire it into your framework, and require human approval before money moves — so a prompt-injected agent stays boxed in. Code in TS and Python.
Read →
Connect Your Agent to the Hosted Stripe MCP Server (mcp.stripe.com): OAuth, the 14 Tools, and a Safe Setup
Point any MCP client at the hosted Stripe server at mcp.stripe.com, authenticate with OAuth or a restricted rk_ Bearer key, and let your agent create payment links, invoices, and refunds — without writing the tool code yourself. Configs, the tool list, and the safety posture that bounds the blast radius.
Read →
Indirect Prompt Injection: How an Attacker Hijacks Your Tool-Calling Agent (and the Defense Layers That Actually Stop It, Python 2026)
Indirect prompt injection hides malicious instructions in content your agent reads — a web page, PDF, email, tool output — and hijacks its tools against you. Working attack demo + the defense layers, with Python code and the deterministic tool-call allowlist.
Read →
Secure an AI Agent That Reads Email or WhatsApp: The Tool-Allowlist Defense (Python, 2026)
Your AI agent reads email or WhatsApp, so attackers send it instructions. Here's the operational defense: keep inbound text out of the instruction channel and gate every tool behind a deterministic allowlist in your code — with runnable Python.
Read →
Redact CURP, RFC and CLABE Before They Reach the LLM: A Presidio Tutorial for Mexican AI Agents
Step-by-step: redact CURP, RFC, CLABE and MX phones before your AI agent sends text to an LLM. Build custom Presidio recognizers and wire them as middleware.
Read →
RAG vs Fine-Tuning: Which Does Your Business Need? (2026)
RAG gives a model current facts; fine-tuning shapes behavior. A practical 2026 guide to deciding between RAG, fine-tuning, both, or just a better prompt.
Read →
How to Add an AI Chatbot to Your Website That Doesn't Hallucinate (2026)
A practitioner's guide to adding a grounded AI chatbot that answers only from your real content, cites sources, says "I don't know," and escalates to a human.
Read →
Build a Task-Specific WhatsApp AI Agent (Cloud API + Claude + RAG, 2026)
Meta banned general-purpose chatbots on WhatsApp. Here's how to build the kind it allows: a task-specific, RAG-grounded business agent with Cloud API and Claude.
Read →
How Much Does It Cost to Add AI to Your App? (2026 Guide)
An honest 2026 breakdown of what it costs to add AI to your app: one-time build bands, ongoing per-request run cost, real model prices, and a worked example.
Read →
AI Agents vs Automation (n8n, Zapier, Make): When to Use Which in 2026
A practitioner's honest guide to AI agents vs automation in 2026: when to use n8n, Zapier, or Make, when to add one AI step, and when you truly need an agent.
Read →
Self-Host n8n + Claude: Build Your First AI Agent
Self-host n8n with Docker and build your first AI automation powered by Claude: Anthropic credential, AI Agent + tool, system prompt, costs and the honest privacy truth.
Read →
Self-host n8n in production: Docker Compose, PostgreSQL, HTTPS, and queue mode
A production self-hosting guide for n8n. Why the defaults (SQLite, no TLS, an ephemeral key) break under load, plus a copy-paste docker-compose.yml with PostgreSQL, the env vars that matter (N8N_ENCRYPTION_KEY, WEBHOOK_URL), a reverse proxy for HTTPS, queue mode with Redis workers, backups, updates, and a security checklist.
Read →
What Is Cursor AI and How to Use It (2026): The AI-Native VS Code Fork, Tab to Agent
Cursor is an AI-native code editor — a VS Code fork by Anysphere where your extensions, themes, and keybindings carry over. This engineer's guide covers what it is, install from cursor.com, and how to actually use its four AI surfaces: Tab, Cmd+K inline edit, Cmd+L chat, and Cmd+I Agent — plus @ context, codebase indexing, Rules, model choice, and pricing.
Read →
Putting an LLM in Production: Cost, Latency, and Guardrails (2026 Guide)
The demo worked, then production broke. A practitioner's deep guide to running an LLM in production in 2026: cost levers, latency, guardrails, evals, and ops.
Read →
The Minimum Eval Harness for a Production AI Agent (Most Teams Skip This)
89% of teams watch their AI agents but only 37% grade them. Here is the minimum eval harness a solo builder can ship this week — Spanish-first.
Read →
Claude Structured Outputs in Production: Schema-Guaranteed JSON for CFDI Extraction and Webhook Routing
Claude Structured Outputs went GA Feb 4, 2026. The exact API (output_config.format), and two payments jobs it fixes: CFDI extraction and Stripe/Mercado Pago webhook routing.
Read →
Cut Your Claude Agent's Token Bill with Prompt Caching: A Practical Tutorial (2026)
Step-by-step: stop re-paying full input price every turn. Where to put cache_control, the per-model minimums, read vs write economics, and how to verify a cache hit.
Read →
How to Build a RAG System with Claude (Voyage Embeddings + pgvector, 2026)
A hands-on, end-to-end tutorial: chunk your docs, embed them with Voyage, store the vectors in pgvector, retrieve the top-k for a question, and have Claude generate a grounded, cited answer. Real Python and SQL you can run.
Read →
Vector Database for RAG: pgvector vs Pinecone vs Qdrant (2026)
Which vector database should you use for RAG? Decision rule first: already on Postgres → pgvector; want zero-ops managed → Pinecone; open-source self-hostable → Qdrant; quick prototype → Chroma. Trade-offs, not invented benchmarks.
Read →
Fix a RAG That Retrieves the Wrong Chunks: Hybrid Search + Reranking (with Before/After Metrics, 2026)
Your RAG retrieves similar-but-wrong chunks. Fix it with hybrid search (dense + BM25), fuse with RRF (k=60), rerank with Voyage rerank-2.5 to top-10 — and prove the lift with Recall@k, MRR, and NDCG in Python.
Read →
Chunking Strategies for RAG (and Anthropic's Contextual Retrieval): The Engineer's Guide
How you split documents decides what RAG can ever find — no reranker downstream can recover a badly cut chunk. Start with recursive 512-token chunks and 10-20% overlap, then use Anthropic's Contextual Retrieval (prepend a Claude-generated 50-100-token context before you embed and BM25-index) to cut retrieval failures by up to 67%. With Python.
Read →
Streaming Chat + Tool Calling with Claude and the Vercel AI SDK 7 (Next.js + TypeScript)
Production TypeScript guide to building a streaming chat with Claude and the Vercel AI SDK 7: install ai + @ai-sdk/anthropic + zod, stream streamText from a Next.js Route Handler to useChat, add tool calling with a Zod inputSchema and execute, and bound the loop with stopWhen. Covers the v7 ESM-only gotcha, the renamed stream helper, model-id caveats, and error/abort handling.
Read →
Structured Outputs with the Vercel AI SDK: generateObject + Zod + Claude (TypeScript)
Stop parsing free-text LLM output by hand. Define a Zod schema, call generateObject with anthropic('claude-sonnet-5'), and get back a typed object that matches the schema — with automatic repair on invalid output. Includes streamObject for progressive UI, enums, nested schemas, and real receipt/CFDI extraction. AI SDK 7, TypeScript.
Read →
Work with me on this
FAQ
- Do I need an AI agent or just a workflow?
- Most things people call "agents" should be workflows — fixed steps with maybe one AI step for the fuzzy part. Reserve a true agent for when the path genuinely cannot be predefined and you can tolerate the variance, cost and latency.
- RAG or fine-tuning?
- RAG gives the model current knowledge at query time; fine-tuning shapes behavior (format, tone), not facts. To answer from your company data, you almost always want RAG, not fine-tuning.
- Why does my chatbot hallucinate, and how do I stop it?
- An ungrounded model answers from training memory, so it invents prices and policies. You ground it with retrieval (RAG) so it answers only from your real content, cites the source, and says "I do not know" when there is no context.