AI For Engineers, Part 6: Anthropic Deep Dive — Claude, MCP, Skills & Sandboxed Agents
Series Track: AI FOR ENGINEERS · PART 06 / 09
Episode ID: ai-for-engineers-part-6
Architectural Scope: Claude Opus/Sonnet/Haiku Compute Trade-Offs, Constitutional AI & RLAIF, Hybrid Extended Thinking, KV Prompt Caching, Native Span Citations, Model Context Protocol (MCP), Progressive-Disclosure SKILL.md Playbooks, and Kernel-Sandboxed Agent Execution [2]
1. Transformer Runtime Foundations & Claude Model Tier Trade-Offs (Modules 01–02)
Building on Part 5's inspection of stateful APIs and cloud coding containers, Episode 6 (Modules 01–12, anchored by Aero-Blue and Aero-Pink) maps Anthropic's entire engineering stack onto fixed-weight Transformer inference, finite token budgets, open tool protocols, and deterministic verification gates [7][9]. At runtime, every Claude checkpoint is an autoregressive deep neural network composed of L stacked Transformer decoder blocks with fixed hidden dimension d_model [7]. Input text, code diffs, and telemetry files tokenize into discrete subword IDs—averaging roughly three-quarters of an English word—whose embeddings route context across layers via multi-head scaled dot-product self-attention [7]:
Attention(Q, K, V) = Softmax((Q · K⊤) / √d_k + M_causal) · V
Linear Query (Q), Key (K), and Value (V) projections compute compatibility scores scaled by 1 / √d_k to prevent Softmax saturation, while the upper-triangular causal mask M_causal sets future indices to -∞ so position t attends strictly to positions ≤ t [7]. During inference, layer count L, hidden width d_model, and all learned weights remain frozen; longer inputs increase sequence length N and O(N² · d_model) prefill attention FLOPs without altering neural weights [4][7]. At the output head, positive temperature τ > 0 scales logits z_i / τ, whereas temperature = 0 selects the greedy argmax rule—producing mostly deterministic token sequences that remain subject to GPU floating-point reduction non-associativity, dynamic batching, and backend updates (system_fingerprint), and never guaranteeing factual truth [6][7].
Anthropic structures its frontier family into three compute tiers—Claude Opus, Claude Sonnet, and Claude Haiku—balancing parameter depth and vector width against latency and cost across 200K to 1M-token context windows [2][5][7]:
| Claude Model Tier | Architectural Compute Profile | Primary Engineering & Agent Role [2] | Context Budget & Latency Trade-Off [5] |
|---|---|---|---|
| Claude Opus | Highest parameter scale, layer depth, and per-token FLOP allocation [2][7]. | Cross-repository root-cause synthesis, deep specification auditing, and lead multi-agent planning [2][6]. | Shared 200K–1M token limit; highest TTFT and token cost reserved for ambiguous architectural decisions [5][7]. |
| Claude Sonnet | Balanced reasoning depth with high interactive token throughput [2][7]. | Primary software engineering loop, MCP tool execution, iterative code diffs, and GUI coordinate parsing [2]. |
Shared 200K–1M token limit; primary Pareto balance between multi-step tool accuracy and low latency [2][5]. |
| Claude Haiku | Compact parameter footprint tuned for sub-second TTFT and concurrency [2][7]. | High-volume log filtering, schema extraction, request routing, and parallel worker subagents [2][5]. | Shared 200K–1M token limit; lowest per-token cost for well-scoped classification and extraction tasks [5][7]. |
Across every tier, system prompts, reference files, MCP tool schemas, thinking tokens, and output completions share one finite context window (Total Tokens ≤ Context Limit) [2][5][7].
2. Constitutional AI Alignment, Post-Training Trade-Offs & Hybrid Extended Thinking (Modules 03–04)
After self-supervised pre-training via next-token cross-entropy loss over large code and text corpora, checkpoints undergo post-training alignment to curb sycophancy and unsafe completions [2][3]. Classical Reinforcement Learning from Human Feedback (RLHF, Ouyang et al., 2022) fits a separate neural reward model to human preference comparisons and updates policy weights via online reinforcement learning (such as PPO) regularized by KL divergence [3]. Direct Preference Optimization (DPO, Rafailov et al., 2023) reparameterizes that KL-constrained objective analytically, updating policy weights offline via binary cross-entropy classification loss on preferred/dispreferred pairs without fitting an explicit reward model or running online RL rollouts [3]. Anthropic extends post-training through Constitutional AI (Bai et al., 2022) [2]:
- Stage 1 — Supervised Critique & Self-Revision: The model critiques and rewrites its own draft responses against an explicit written constitution of honesty, harmlessness, and epistemic principles, generating supervised fine-tuning pairs [2].
- Stage 2 — Reinforcement Learning from AI Feedback (RLAIF): An AI preference evaluator conditioned on constitutional principles scores candidate completions to supply reward signals for policy optimization [2].
- Plausibility Bias vs. Structured Abstention: Both RLHF/RLAIF and offline DPO optimize instruction adherence, which can inadvertently reward polished, confident prose over abstention when evidence is absent [3][6]. Production workflows must therefore enforce primary-source grounding and explicit
'UNKNOWN'abstention (NIST AI 600-1) alongside Anthropic's AI Safety Levels (ASL-1toASL-4) pre-release capability gates [2][6].
During inference, Claude Opus and Sonnet operate as hybrid reasoning models inside a single checkpoint [2][7]. Leaving Extended Thinking off yields direct completions; specifying an integer budget_tokens (≥ 1,024, billed as output tokens) allocates an inference-time scratchpad inside the context window to test edge cases and prune invalid branches before writing the final answer [4][7]. With interleaved thinking (Think → Call Tool → Observe → Fresh Think Block → Act), Claude invokes a shell runner or MCP tool, inspects live stdout, SQL rows, or test failures in a fresh thinking block, and adapts its plan dynamically without updating model weights [2][7].
3. KV Prompt Caching, Long-Context Positional Discipline & Native Span Citations (Modules 05 & 07)
Multi-turn engineering workflows repeatedly send identical system rules, tool schemas, and reference specifications [2][4]. Because causal self-attention at step t depends on the Key (K) and Value (V) projections of all preceding tokens, recomputing static prefixes repeats expensive O(N² · d_model) prefill work [4][7]. Storing computed K and V tensors in accelerator memory—the KV cache—converts per-step decoding into single-token incremental updates [4]. Standard uncompressed KV caching preserves the exact mathematical outputs of causal self-attention and never drops tokens or causes memory loss [4]. Anthropic's Prompt Caching reuses exact prefix KV tensors across a 5-minute ephemeral or 1-hour extended TTL—cutting cached input token cost by up to 90% and reducing TTFT—while the asynchronous Message Batches API processes offline test suites within 24 hours at a 50% token discount [2][4].
Crucially, advertising a 200K or 1M-token window governs maximum token capacity—not uniform recall fidelity [5]. Empirical benchmarks (Liu et al., 2023/2024, Lost in the Middle) reveal a U-shaped positional recall curve: accuracy peaks at the very start (primacy) and very end (recency) of the input context, but degrades substantially when critical evidence sits in middle positions due to Softmax attention dilution [4][5]. Engineering teams enforce four context and output controls:
- Workspace Grounding (
Claude Projects): Curating reference specs (such asSPEC-201.json) in a Project injects non-parametric retrieval evidence (Lewis et al., 2020) at inference time while neural weights remain fixed [6][7]. - Boundary-Placed 5-Part Prompts (
Role + Context + Task + Format + Verify): Positioning acceptance criteria and'UNKNOWN'abstention rules at prompt boundaries mitigates middle-context recall decay [5][6]. - Native Citations API Span Grounding: Citations mode anchors grounded claims to exact character index intervals in plain-text files or page-number ranges in PDF documents, returning verbatim
cited_textsnippets outside billed output tokens [1]. Inline span citations accelerate human verification and curb fabricated quotes, but do not guarantee complete claim coverage, prevent threshold misinterpretation, or validate the underlying source document's factual truth [1][6]. - Sandboxed
Claude Artifacts: Standalone HTML tools, React views, SVG schematics, and Mermaid diagrams execute inside a restricted browseriframewith discrete per-turn version snapshots for safe diff inspection [2].
4. Model Context Protocol (MCP) & Progressive-Disclosure SKILL.md Playbooks (Modules 06 & 08)
To eliminate N × M custom connector glue between N AI harnesses and M engineering systems, Anthropic open-sourced the Model Context Protocol (MCP) over JSON-RPC 2.0, reducing integration complexity to N + M across three roles [2]:
- MCP Host & Clients: The Host application (IDE, desktop client, or CI harness) manages isolated
1:1MCP Client sessions [2]. - MCP Servers & Transports: Servers expose capabilities over local
stdiostreams or remote OAuth-authenticated Streamable HTTP across three typed primitives: Resources (application-controlled, URI-addressed read-only data likeLOG-104.csv), Tools (model-invoked JSON Schema functions—where strict schemas guarantee JSON syntax only on completed, non-refused responses, requiring callers to handle refusals,max_output_tokenstruncation, and semantic errors), and Prompts (user-triggered workflow templates) [2][6]. Pairing remoteMCPconnectors with on-demand Tool Search loads needed schemas dynamically without flooding the context window [2][5].
Complementing MCP, modular Skills (SKILL.md) prevent procedural prompt bloat [5][6]. A Skill bundles YAML frontmatter (name, description), Markdown step-by-step rules, and deterministic scripts (verify_document.py) [6][8]. Via two-stage progressive disclosure, startup loads compact skill metadata only, injecting the full SKILL.md playbook strictly when triggered [2][5]. Both SKILL.md files and persistent task-graph disk checkpoints operate purely as context and state artifacts without retraining model weights [6][7].
5. Claude Code Subagents, Visual GUI Hierarchy, Kernel Sandboxes & Data Governance (Modules 09–11)
Claude Code and the Python/TypeScript Claude Agent SDK read repository rules from CLAUDE.md to run terminal and headless CI loops [2]. Invoking read-only Plan Mode disables write and mutation tools until engineers approve the change specification [2]. For cross-repository searches, Claude Code spawns isolated Subagent Contexts—pairing an Opus lead planner with Sonnet or Haiku workers—so raw grep/log outputs stay in disposable subagent windows rather than polluting lead-agent attention [2][5]. When driving external software, engineers follow a strict latency-and-token priority order: direct CLI / MCP APIs first (tens of tokens, milliseconds), structured DOM Browser Use (Claude in Chrome / Playwright selectors) second, and pixel Desktop Computer Use (Screenshot → (X, Y) Coordinate → Virtual Input → Visual Verify) strictly last for API-less legacy GUIs due to multi-thousand image-token overhead [2][7].
Because untrusted codebases and web DOMs carry prompt-injection risk, safety requires deterministic system boundaries alongside separated enterprise data controls [2][6]:
| Governance Layer | Technical Control Mechanism | Mandatory Operational & Verification Scope [1] |
|---|---|---|
| Permission Tiers | Four operator levels: Read-Only Plan → Ask Default → Accept Edits → Container Bypass [2]. |
Reserve Container Bypass strictly for disposable, network-isolated VMs or ephemeral CI runners [2]. |
| Kernel Sandboxes & Egress | macOS Seatbelt and Linux bubblewrap (bwrap) syscall containment [2]. |
Restricts workspace writes, blocks ~/.ssh / .env reads, and filters domains via proxy; similarly, when routing Claude on Google Cloud Vertex AI behind VPC-SC (which protects supported Google-managed service perimeters only, not arbitrary third-party internet APIs on its own), teams must enforce independent egress firewalls, disabled untrusted web/MCP tools, connector allowlists, and tested IAM routes [2]. |
| Lifecycle Hooks | Deterministic PreToolUse and PostToolUse shell/Python gates [2][8]. |
PreToolUse non-zero exit blocks destructive git/rm commands beforehand; PostToolUse runs linters and verify_document.py immediately after edits [2][8]. |
| Separated Data Controls | (1) Training opt-out / frozen weights, (2) API safety logs vs. ZDR, (3) 5m/1h KV caches, (4) Project stores [2][4][6]. |
Commercial no-training defaults do not eliminate short-term operational/safety request logs; Zero Data Retention (ZDR) must be separately contracted and verified on eligible stateless endpoints alongside KV cache TTLs and workspace file retention [2][4]. |
6. End-to-End Verification Synthesis: Reproducible Synthetic Pump Case Audit (Module 12)
Episode 6 integrates every layer on the illustrative, reproducible synthetic engineering case bundle (evidence/LOG-104.csv, evidence/SPEC-201.json, pump_report_draft.md, verify_document.py, pump_report_verified.md, and audit_report.json packaged in -sources.zip) [8]:
[MCP Resource Server: LOG-104.csv + SPEC-201.json]
│ (URI-Addressed Read-Only Primary Context)
▼
[Prompt-Cached Context Window (5m / 1h KV TTL, Up to -90% Prefill Cost)]
├── Boundary-Placed 5-Part Spec + Triggered SKILL.md Playbook
├── Claude Opus / Sonnet + Extended Thinking (budget_tokens >= 1,024)
└── Native Citations API (Character / PDF Span Anchors)
│ (Emits Atomic Tagged Draft: pump_report_draft.md)
▼
[macOS Seatbelt / Linux bubblewrap Kernel Sandbox]
├── PreToolUse Hook ──► Blocks out-of-scope shell / network mutations
└── PostToolUse Hook ──► Executes verify_document.py against evidence/
│
▼
[Audited Output: pump_report_verified.md + audit_report.json]
(Quarantines 94.2 °C FAIL_NUMERIC_DRIFT & SPEC-992 FAIL_PHANTOM_CITATION)
In synthetic telemetry LOG-104.csv, prototype centrifugal pump measurements record: 14:05:00 (suction_psi = 34.2, vapor_pressure_psi = 14.8, discharge_drop_psi = 1.2, external seal-housing peak housing_temp_c = 84.2 °C, THERMAL_RISE_DETECTED); 14:08:12 (suction_psi = 33.8, discharge_drop_psi = 18.4 psi, housing_temp_c = 83.9 °C, PRESSURE_DROP_EVENT); and 14:12:00 (suction_psi = 34.0, discharge_drop_psi = 17.9 psi, housing_temp_c = 82.5 °C, HOLD_TEST_REQUIRED) [8]. Acceptance criteria in SPEC-201.json mandate max_housing_temp_c = 85.0 °C, max_allowed_drop_psi = 5.0 psi, min_suction_margin_psi = 10.0 psi, and next_verification_test = "30-minute pressure hold at 120 psi" [8]. Consequently, the 84.2 °C external seal-housing peak stays within SPEC-201's 85.0 °C ceiling (0.8 °C margin, while internal seal-face temperature is unmeasured / UNKNOWN), suction margin (19.0–19.4 psi) exceeds 10.0 psi, and the 18.4 psi discharge drop breaches the 5.0 psi limit by 13.4 psi [6][8].
Running verify_document.py inside a PostToolUse hook deterministically audits all four atomic claims in pump_report_draft.md [8]:
| Claim ID | Draft Statement (pump_report_draft.md) [8] |
Evidence Ground Truth (LOG-104 / SPEC-201) [8] |
verify_document.py Disposition |
|---|---|---|---|
CLAIM-01 |
Discharge pressure dropped 18.4 psi at 14:08:12 (discharge_drop_psi=18.4, LOG-104) [8]. |
LOG-104.csv row 14:08:12 confirms discharge_drop_psi = 18.4 (13.4 psi over SPEC-201's 5.0 psi limit) [8]. |
PASS — Exact numeric match retained [8]. |
CLAIM-02 |
Peak housing temperature reached 94.2 °C prior to event (housing_temp_c=94.2, LOG-104) [8]. |
LOG-104.csv records [84.2, 83.9, 82.5] °C; 84.2 °C stays within SPEC-201's 85.0 °C ceiling (94.2 °C fabricates a false +9.2 °C breach) [8]. |
FAIL_NUMERIC_DRIFT — Quarantined to UNKNOWN / NEEDS VERIFICATION [6][8]. |
CLAIM-03 |
Seal rating verified against aerospace standard SPEC-992 (max_seal_temp_c=150.0) [8]. |
SPEC-992 does not exist in evidence/; internal seal-face rating is unmeasured [6][8]. |
FAIL_PHANTOM_CITATION — Quarantined to block phantom standards [1][6][8]. |
CLAIM-04 |
Proposed next test is a 30-minute pressure hold at 120 psi (SPEC-201) [8]. |
SPEC-201.json defines next_verification_test = "30-minute pressure hold at 120 psi" [8]. |
PASS — Verified against primary specification [8]. |
Combining MCP resource grounding, KV Prompt Caching, Extended Thinking, span Citations, SKILL.md progressive disclosure, Seatbelt/bubblewrap containment, and PostToolUse deterministic auditing establishes an end-to-end engineering verification loop—setting up Part 7's exploration of Google AI, Gemini multimodal live APIs, NotebookLM grounding, and the Antigravity harness [1][2][8][9].
Primary References, Runnable Case Bundles & Provenance
- [1] Anthropic Platform Documentation — Citations Mode Span Grounding & Verification Caveats (S11 / R12) — Anthropic (2026). Build with Claude: Citations Documentation (Character, Page, and Content-Block Spans). Consulted 15 November 2026. · Official Primary Source · Highlighted Verification Note
- [2] Bai et al. (2022) Constitutional AI (arXiv:2212.08073) & Model Context Protocol (MCP) Specification — Bai, Y. et al. (2022). Constitutional AI: Harmlessness from AI Feedback (arXiv:2212.08073); Model Context Protocol (MCP) JSON-RPC 2.0 Specification (Consulted 15 November 2026). · Official Primary Source · Highlighted Verification Note
- [3] Rafailov et al. (2023) — Direct Preference Optimization (DPO) & Ouyang et al. (2022) RLHF (arXiv:2305.18290, S10 / R8) — Rafailov, R., Sharma, A., Mitchell, E., Ermon, S., Manning, C. D., & Finn, C. (2023). Direct Preference Optimization: Your Language Model is Secretly a Reward Model. NeurIPS 2023 (arXiv:2305.18290); Ouyang, L. et al. (2022) InstructGPT (arXiv:2203.02155). Consulted 15 November 2026. · Official Primary Source · Highlighted Verification Note
- [4] Hugging Face Transformers v5.12 — Key-Value (KV) Cache Explanation (R3) — Hugging Face (2026). Transformers Documentation: Cache Explanation (KV Caching Mechanics). Consulted 15 November 2026. · Official Primary Source · Highlighted Verification Note
- [5] Liu et al. (2023/2024) — Lost in the Middle: How Language Models Use Long Contexts (arXiv:2307.03172, S7 / R7) — Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., & Liang, P. (2024). Lost in the Middle: How Language Models Use Long Contexts. TACL 12:157-173 (arXiv:2307.03712 / 2307.03172). Consulted 15 November 2026. · Official Primary Source · Highlighted Verification Note
- [6] Lewis et al. (2020) RAG (arXiv:2005.11401), Es et al. (2024) Ragas & NIST AI 600-1 Generative AI Profile — Lewis, P. et al. (2020) Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (NeurIPS, arXiv:2005.11401); Es, S. et al. (2024) Ragas (EACL, arXiv:2309.15217); NIST AI 600-1 (2024) Generative AI Profile. · Official Primary Source · Highlighted Verification Note
- [7] Vaswani et al. (2017) — Attention Is All You Need (NeurIPS 2017, arXiv:1706.03762) — Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., & Polosukhin, I. (2017). Attention Is All You Need. NeurIPS 30 (arXiv:1706.03762). · Official Primary Source · Highlighted Verification Note
- [8] Reproducible Synthetic Engineering Case Bundle — LOG-104.csv, SPEC-201.json & Runnable verify_document.py — AI Foundations Reproducible Synthetic Engineering Dataset (Bundled in -sources.zip: LOG-104.csv, SPEC-201.json, pump_report_draft.md, verify_document.py, audit_report.json). · Highlighted Case Dossier & Runnable Files · Download Runnable .zip
- [9] Episode Production Provenance & Module Transcript — AI For Engineers, Part 6: Anthropic Deep Dive — Claude, MCP, Skills & Sandboxed Agents — Generator Studio Remediated Episode Transcript (ai-for-engineers-part-6, Consulted 15 November 2026 — Module Continuity Provenance Only). · Open Studio Video · Module Transcript Reader
Related Topic Artifacts
- Topic Briefing: AI For Engineers, Part 6: Anthropic Deep Dive — Claude, MCP, Skills & Sandboxed Agents
- Verified Sources & Runnable Case (9): AI For Engineers, Part 6: Anthropic Deep Dive — Claude, MCP, Skills & Sandboxed Agents
- Infographic: AI For Engineers, Part 6: Anthropic Deep Dive — Claude, MCP, Skills & Sandboxed Agents
- Interactive Mind Map: AI For Engineers, Part 6: Anthropic Deep Dive — Claude, MCP, Skills & Sandboxed Agents
- Studio Master Video: AI For Engineers, Part 6: Anthropic Deep Dive — Claude, MCP, Skills & Sandboxed Agents