<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by TanBuildsAI on Medium]]></title>
        <description><![CDATA[Stories by TanBuildsAI on Medium]]></description>
        <link>https://medium.com/@tanbuildsai?source=rss-3455b42172c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JgbXXAzXecsMk_s2RgqfhA.jpeg</url>
            <title>Stories by TanBuildsAI on Medium</title>
            <link>https://medium.com/@tanbuildsai?source=rss-3455b42172c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 01:10:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tanbuildsai/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How a UX Designer Became a Claude Certified Architect]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://tanbuildsai.medium.com/how-a-ux-designer-became-a-claude-certified-architect-5e2b2078ce47?source=rss-3455b42172c6------2"><img src="https://cdn-images-1.medium.com/max/2600/1*FBlShvx-UwgFjgPBkWdXuA.png" width="3840"></a></p><p class="medium-feed-snippet">Eleven courses, 4 builds, and a daily quiz that ran for two months.</p><p class="medium-feed-link"><a href="https://tanbuildsai.medium.com/how-a-ux-designer-became-a-claude-certified-architect-5e2b2078ce47?source=rss-3455b42172c6------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://tanbuildsai.medium.com/how-a-ux-designer-became-a-claude-certified-architect-5e2b2078ce47?source=rss-3455b42172c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e2b2078ce47</guid>
            <category><![CDATA[exam]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[claude-certification]]></category>
            <dc:creator><![CDATA[TanBuildsAI]]></dc:creator>
            <pubDate>Tue, 27 Oct 2026 10:37:43 GMT</pubDate>
            <atom:updated>2026-10-27T10:37:43.027Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Claude on Google Cloud With Only 5 Lines of Code]]></title>
            <link>https://tanbuildsai.medium.com/claude-on-google-cloud-with-only-5-lines-of-code-ef9b9372b06b?source=rss-3455b42172c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef9b9372b06b</guid>
            <category><![CDATA[claude-api]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[vertex-ai]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[claude]]></category>
            <dc:creator><![CDATA[TanBuildsAI]]></dc:creator>
            <pubDate>Fri, 16 Oct 2026 08:34:42 GMT</pubDate>
            <atom:updated>2026-10-16T08:34:42.708Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Notes from course #11 of my Claude Certified Architect track: Claude on Google Cloud. See previous: </em><a href="https://tanbuildsai.medium.com/context-is-everything-rag-parallel-agents-mcp-and-other-features-from-claude-with-amazon-bedrock-e0d0a0235c10?sharedUserId=tanbuildsai"><em>Claude with Amazon Bedrock Pt. 2</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wWi1hnOAILM3pTFIJwqIWA.png" /></figure><p>Vertex lets you run Claude inside the Google Cloud environment you already use, so authentication goes through your existing gcloud credentials and IAM, and billing and access controls stay in one place instead of adding a separate vendor account and API key.</p><p>It puts Claude next to Google’s other AI tooling, such as embedding models and vector search, so a RAG pipeline can live on one platform. For teams with enterprise security and procurement requirements, that usually makes approval simpler, and the global endpoints add dynamic routing for better availability.</p><h3>Setting Up for Vertex</h3><p><strong>1. Find the model.</strong> In the Vertex AI dashboard, open Model Garden, search “Anthropic,” and click the model you want.</p><p><strong>2. Enable it.</strong> If the model page has an Enable button, click it. If there’s no button, you already have access.</p><p><strong>3. Install the gcloud CLI.</strong> Google’s install docs cover it.</p><p><strong>4. Authenticate. </strong>Then, set your project ID and set your default credentials</p><pre>gcloud init<br>gcloud auth login<br>gcloud config set project YOUR_PROJECT_ID<br>gcloud auth application-default login</pre><p>The last command is the one people skip. auth login authenticates you in the terminal. application-default login creates the credentials your code picks up. The Anthropic SDK finds them on its own, so you never paste a key into a notebook.</p><h4>The client</h4><pre>%pip install &quot;anthropic[vertex]&quot;</pre><p>The [vertex] extra pulls in the pieces that talk to Google Cloud.</p><pre>from anthropic import AnthropicVertex<br><br>client = AnthropicVertex(region=&quot;global&quot;, project_id=&quot;your-project-id&quot;)<br>model = &quot;claude-sonnet-4@20250514&quot;</pre><p>Your project ID is in the console’s project selector. Store the model name in a variable so you change it in one place.</p><p>Two details matter here. Vertex model IDs use an @ before the date, where the Claude API uses a hyphen. And region=&quot;global&quot; isn’t arbitrary: Starting with Claude Sonnet 4.5, Google offers global endpoints with <strong>dynamic routing</strong> for maximum availability, and Anthropic’s docs recommend them. A specific region like us-east1 still works if you need data to stay put.</p><h4>The request</h4><p>create takes three parameters as usual:</p><ul><li>model: which Claude you’re calling</li><li>max_tokens: a ceiling on response length. Claude doesn’t aim for it, it just can’t exceed it.</li><li>messages: the conversation so far</li></ul><p>You get back a large response object. For just the text:</p><pre>message.content[0].text</pre><p>You’ll type that line constantly.</p><h3>Embeddings: the part Claude can’t do</h3><p>Claude doesn’t generate embeddings. If you’re building RAG, you need a separate embedding model, and the course uses text-embedding-005 through Google’s own SDK:</p><pre>pip install google-genai</pre><pre>from google import genai<br>client = genai.Client(<br>    project=&quot;YOUR_PROJECT_ID&quot;,<br>    location=&quot;global&quot;,<br>    vertexai=True<br>)<br>def generate_embedding(text):<br>    response = client.models.embed_content(<br>        model=&quot;text-embedding-005&quot;,<br>        contents=text<br>    )<br>    if not response.embeddings:<br>        return []<br>    return [e.values for e in response.embeddings]</pre><p>Pass it a chunk of text and you get back a list of floats that encodes meaning. Those vectors power semantic search in a RAG system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LHWBKfKHq6kGkrs8.png" /></figure><p>Note that this client is a different object from the Claude one. Two SDKs, two clients, two jobs. Claude generates the answer, and another model finds the right material to hand it.</p><p>Google’s embeddings docs have moved on a little since the course was recorded. text-embedding-005 is still listed as the model specialized in English and code, but gemini-embedding-001 now unifies the older specialized models and produces 3072-dimensional vectors. The pattern doesn’t change if you swap models. The one rule is to use the same embedding model for everything in a given index.</p><h3>Things to note:</h3><p>Everything on Vertex works like the Claude API once you’re authenticated. The difference is the enterprise plumbing around it: enabling a model, logging in twice, and reaching for a second model whenever you need vectors.</p><p>Four steps of setup, five lines of code, and one admission baked into the architecture: for retrieval, you’ll need a model that isn’t Claude.</p><p>Most of this course was repetition from Amazon Bedrock and Building with Claude API so kept this brief.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef9b9372b06b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Context Is Everything: RAG, Parallel Agents, MCP and Other Features from Claude with Amazon Bedrock]]></title>
            <link>https://tanbuildsai.medium.com/context-is-everything-rag-parallel-agents-mcp-and-other-features-from-claude-with-amazon-bedrock-e0d0a0235c10?source=rss-3455b42172c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0d0a0235c10</guid>
            <category><![CDATA[agentic-rag]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[amazon-bedrock]]></category>
            <dc:creator><![CDATA[TanBuildsAI]]></dc:creator>
            <pubDate>Thu, 15 Oct 2026 10:18:03 GMT</pubDate>
            <atom:updated>2026-10-16T09:29:17.123Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Notes (part 2) from course #10 of my Claude Certified Architect track: Claude with Amazon Bedrock. Part 1 covered Regional Model Inference, Messages and Tool use. See previous: </em><a href="https://tanbuildsai.medium.com/claude-on-amazon-bedrock-same-claude-different-plumbing-44e53368cec4?sharedUserId=tanbuildsai"><em>Claude with Amazon Bedrock Pt. 1</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vhfDeP1akFmGtQ6R.png" /></figure><p>How do you get the right information in front of Claude? What breaks when you don’t? Tool use, MCP basics, and workflows vs agents carry over from the Claude API course, so I’ll only touch what’s new.</p><h3>RAG: worth it, sometimes</h3><p>RAG pays off when you have large documents or collections, users ask narrow questions, and you care about speed and cost per query. Sometimes pasting everything into the prompt is fine. The real question is whether chunking, search, and retrieval overhead earns its keep for your app.</p><p>Chunking depends on the documents:</p><ul><li><strong>Character-based — </strong>The safe fallback, especially for user uploads with no formatting guarantees</li><li><strong>Sentence-based — </strong>Prose. It struggles with code and technical text, where periods mean other things</li><li><strong>Section-based — </strong>Well-structured internal documents</li></ul><p>Start simple, test on your own documents, then refine.</p><h3>The pipeline</h3><ol><li>Chunk the documents.</li><li>Embed each chunk.</li><li>Store the embeddings in a vector database.</li><li>Embed the user’s question.</li><li>Find the closest chunks with cosine similarity.</li><li>Add those chunks to the prompt with the question.</li><li>Send it to Claude.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SvWdwAwnTzGwG12R.png" /></figure><p>An embedding is a list of numbers representing meaning. The course used Amazon Titan (1024 dimensions), which you may need to request access to in the Bedrock console. Store the original text next to each embedding, or you’ll retrieve arrays of numbers you can’t use.</p><pre>def generate_embedding(<br>    text,<br>    embedding_model_id=&quot;amazon.titan-embed-text-v2:0&quot;,<br>    dimensions=1024,<br>    normalize=True,<br>):<br>    request_body = {<br>        &quot;inputText&quot;: text,<br>        &quot;dimensions&quot;: dimensions,<br>        &quot;normalize&quot;: normalize,<br>    }<br>    <br>    request_json = json.dumps(request_body)<br>    response = client.invoke_model(<br>        modelId=embedding_model_id,<br>        body=request_json,<br>        accept=&quot;application/json&quot;,<br>        contentType=&quot;application/json&quot;,<br>    )<br>    <br>    response_body = json.loads(response.get(&quot;body&quot;).read())<br>    return response_body[&quot;embedding&quot;]</pre><p>When you run this function on a text chunk, you get back a list of 1024 numbers that represent the semantic meaning of that text.</p><h3>Three upgrades</h3><h4><strong>1. Hybrid search</strong></h4><p>Add BM25, a keyword-based search, next to semantic search and merge the two ranked lists with RRF (reciprocal rank fusion). BM25 fixes the incident ID problem by ranking the sections that contain the exact term. Each index implements the same two methods, add_document() and search(), so you can plug in new retrieval types later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BOPZJmZWdsaSRbKL.png" /></figure><h4><strong>2. Re-ranking</strong></h4><p>After merging results from the hybrid approach, ask Claude to reorder results by relevance to the question. Give each chunk an ID first and have Claude return only IDs, like [&quot;1p5g&quot;, &quot;51n3&quot;, &quot;ab83&quot;]. Copying full text back would be slow. The cost is added latency, and the gain is better ordering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NKBBN5p9DHLgn4ib.png" /></figure><p>System prompt must be very specific: return the most relevant documents in order of decreasing relevance.</p><h4><strong>3. Contextual retrieval</strong></h4><p>Chunking cuts each piece off from its document. So before storing a chunk, send Claude the chunk plus the source document and ask for a short snippet that situates it. Claude might write that a chunk is Section 2 of an annual research review, follows Methodology, and precedes Financial Analysis. The snippet gets stored with the chunk in both indexes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JTAreiwmPQr_SsKb.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VLWxPxO_uPC1JyVj.png" /></figure><p>For documents too big for one prompt, pass the first few chunks plus the ones just before the target. <strong>Simple documents won’t show dramatic gains. Cross-referenced ones will.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e9_-ad0Rq_hBqXLy.png" /></figure><h3>MCP, revisited: who’s in control</h3><p>Tools, resources, and prompts aren’t just three categories. Each is controlled by a different part of the stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ded5S2xilqVVujsc.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rfxhhg7sbV1BAnNlGAYHmw.png" /></figure><p>Claude’s “Add from Google Drive” button is a resource: the app fetches the list, then injects the chosen document. The workflow buttons under the chat box are prompts. A JavaScript execution tool Claude picks up on its own is a tool.</p><h3>Claude Code, in parallel</h3><p>Running several Claude Code instances at once is one of the biggest productivity gains. The problem is file conflicts, since the instances can’t see each other. <strong>Git worktrees</strong> solve it: each worktree is a separate folder and branch with a full copy of the project, and each instance works in its own.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wDwQq_1lYKtOroGp.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D30xNRLmV5-v-3Un.png" /></figure><p>You can have Claude set up the worktrees too. Custom slash commands live as .md files in .claude/commands and accept $ARGUMENTS, so /project:create_worktree feature_a builds one called “feature_a”. A second command handles the merge, and Claude can resolve conflicts itself.</p><h3>Claude in production instance</h3><p>A chatbot works locally, but on AWS Amplify the spreadsheet feature fails silently. The request goes through and no data appears.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xitl-BDgOK4mUNtp.png" /></figure><p>The fix is a daily GitHub Action that pulls the last 24 hours of CloudWatch logs, has Claude dedupe the errors, attempt fixes, and open a pull request for review. Cap how many errors it processes so you stay inside the context window, and check the permissions for log access and PR creation.</p><h3>Computer use, in one paragraph</h3><p>It’s the same tool use loop you already know. The tool schema you send is small and expands behind the scenes into mouse, keyboard, and screenshot actions. Claude doesn’t control anything directly. It requests actions, and your infrastructure (in the reference setup, a Docker container running Firefox) performs them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*01vt50N8zkSzeCx-.png" /></figure><p>To set up computer use, you need:</p><ol><li>A Docker runtime installed on your system</li><li>An AWS profile configured locally (usually “default”)</li><li>The reference implementation from the Anthropic quickstarts repository</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*66A235aoQROruGre.png" /></figure><p>This makes it particularly valuable for tasks like quality assurance testing, where you need to interact with a user interface and verify that everything works as expected.</p><h3>What good agents have in common</h3><p>Across Claude Code and Computer Use, the same pattern shows up. In one Claude Code task, three of four tool calls only read the environment. Observe first, then act.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xVApubohSRURNA91.png" /></figure><ul><li><strong>Focused tools in loops.</strong> A few simple tools, run until success, an error, or an iteration limit.</li><li><strong>Context gathered through tools.</strong> Claude knows nothing about your environment until it reads it.</li><li><strong>High-value tasks with low error costs.</strong> Code is a good fit. High-stakes economic or safety decisions aren’t.</li><li><strong>Continuous evaluation.</strong> Testing against real scenarios is the only reliable way to improve.</li></ul><p>Claude never sees your production environment. It sees what you hand it. Hand it the logs.</p><p>Part two picks up with RAG, MCP, Agents and Features of Claude within Amazon Bedrock. This was a great refresher. Looking forward to the next one: <a href="https://tanbuildsai.medium.com/claude-on-google-cloud-with-only-5-lines-of-code-ef9b9372b06b?sharedUserId=tanbuildsai">Claude on Google Cloud</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0d0a0235c10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Claude on Amazon Bedrock: Same Claude, Different Plumbing]]></title>
            <link>https://tanbuildsai.medium.com/claude-on-amazon-bedrock-same-claude-different-plumbing-44e53368cec4?source=rss-3455b42172c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/44e53368cec4</guid>
            <category><![CDATA[llm-inference]]></category>
            <category><![CDATA[amazon-bedrock]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[claude]]></category>
            <dc:creator><![CDATA[TanBuildsAI]]></dc:creator>
            <pubDate>Wed, 14 Oct 2026 07:57:47 GMT</pubDate>
            <atom:updated>2026-10-15T10:18:49.137Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Notes from course #10 of my Claude Certified Architect track: Claude with Amazon Bedrock. See previous: </em><a href="https://tanbuildsai.medium.com/before-i-trust-an-mcp-server-i-want-to-see-the-wire-73ca7302dc2a?sharedUserId=tanbuildsai"><em>Introduction to Model Context Protocol and Model Context Protocol: Advanced Topics</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OHGka6HjtoYJeFRTp7k6rQ.png" /></figure><p>The thing about running Claude through AWS is that the model is the one you already know, but the plumbing around it is new: a different client, a different message format, different names for familiar settings. This course repeats a lot from the Claude API course, so I’m keeping the overlap short and spending the words on what’s new. As before, I’ve written it to be skimmed.</p><h4><strong>The 30-second version</strong></h4><ul><li>Same models, same concepts, different SDK (boto3) and a converse call</li><li>Not every model lives in every region, and <strong>inference profiles</strong> fix that</li><li>Message content is a <em>list</em>, because messages can be multimodal</li><li>Nothing remembers your conversation. You resend the full history every time</li><li>Tool use is the big new chunk: schemas, tool results, batch tools, forced structured output</li><li>The text editor tool gives Claude file access, but you write the implementation</li></ul><h3>What carries over from the Claude API course</h3><ul><li><strong>Models:</strong> Opus, Sonnet, and Haiku, Claude Fable 5</li><li><strong>Request flow:</strong> user → your server → model provider (AWS Bedrock) → model → back the same way.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ya2h8r-nCMBPDxO0.png" /></figure><ul><li><strong>System prompts</strong> set role and behavior. <strong>Temperature</strong> (0 to 1) sets how predictable the output is.</li></ul><pre>def chat(messages, system=None, temperature=1.0):<br>    params = {<br>        &quot;modelId&quot;: model_id,<br>        &quot;messages&quot;: messages,<br>        &quot;inferenceConfig&quot;: {&quot;temperature&quot;: temperature}<br>    }<br>    <br>    if system:<br>        params[&quot;system&quot;] = [{&quot;text&quot;: system}]<br>    <br>    response = client.converse(**params)<br>    return response[&quot;output&quot;][&quot;message&quot;][&quot;content&quot;][0][&quot;text&quot;]</pre><ul><li><strong>Streaming</strong> shows text as it generates instead of after a 10 to 30 second wait</li><li><strong>Prefill and stop sequences</strong> control output format</li><li><strong>Evals</strong> run a dataset through your prompt and score the results with code, model, or human graders</li><li><strong>Prompt engineering</strong> still means clear instructions, XML tags, and examples</li></ul><p>On Bedrock the streaming call is converse_stream. Everything else works the way you remember, with different names.</p><h3>Your first Bedrock request</h3><p>You need three things:</p><ol><li>A <strong>Bedrock Runtime client</strong></li><li>A <strong>model ID</strong></li><li>A <strong>user message</strong></li></ol><pre>import boto3<br>client = boto3.client(&quot;bedrock-runtime&quot;, region_name=&quot;us-west-2&quot;)</pre><h4>The region problem</h4><p>Not every model is available in every region. Ask for one that isn’t and you get a cryptic “model doesn’t exist” error. The fix is an <strong>inference profile</strong>: a resource that defines a model and one or more regions it can route requests to where the model is hosted. You pass its ID where the model ID would go, and AWS sends your request to a region that actually hosts the model, even if you’re connecting from somewhere else.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-nB2wOvr_yOmpiav.png" /></figure><p><strong>Where to find the ID:</strong> in the Bedrock console, look under <strong>Cross-region inference</strong>, not the main model catalog. Copy the profile ID from there. You specify it as the modelId in a Converse request.</p><pre>response = client.converse(<br>    modelId=model_id,<br>    messages=[user_message]<br>)<br>response[&quot;output&quot;][&quot;message&quot;][&quot;content&quot;][0][&quot;text&quot;]</pre><p><strong>One caution for regulated work.</strong> With geographic cross-region profiles, data is stored only in the source region by default, but your prompts and outputs might move outside it during inference. If you have data residency requirements, read that page before you pick a profile.</p><h3>Messages are lists, not strings</h3><p>A user message looks heavier than it needs to:</p><pre>user_message = {<br>    &quot;role&quot;: &quot;user&quot;,<br>    &quot;content&quot;: [{&quot;text&quot;: &quot;What&#39;s 1+1?&quot;}]<br>}</pre><p>content is a list because one message can mix text, images, and other media. The shape is consistent. The assistant’s reply uses the same structure with a different role, which makes chaining a conversation easy.</p><pre># Make the call with converse:<br>response = client.converse(modelId=model_id, messages=[user_message])<br><br># And dig out the text:<br>response[&quot;output&quot;][&quot;message&quot;][&quot;content&quot;][0][&quot;text&quot;]</pre><h4>Nothing remembers anything</h4><p>Each call is independent. The model keeps no conversation state between requests. To hold a conversation, you:</p><ol><li>Keep the full list of messages in your own code</li><li>Send the entire list with every follow-up</li></ol><h4>A reusable chat function</h4><pre>def chat(messages, system=None, temperature=1.0):<br>    params = {<br>        &quot;modelId&quot;: model_id,<br>        &quot;messages&quot;: messages,<br>        &quot;inferenceConfig&quot;: {&quot;temperature&quot;: temperature}<br>    }<br>    if system:<br>        params[&quot;system&quot;] = [{&quot;text&quot;: system}]<br>    response = client.converse(**params)<br>    return response[&quot;output&quot;][&quot;message&quot;][&quot;content&quot;][0][&quot;text&quot;]</pre><p>Two Bedrock quirks live in there:</p><ul><li><strong>Temperature</strong> goes inside inferenceConfig, not at the top level</li><li><strong>System prompts</strong> are a list of dictionaries with &quot;text&quot; keys, and they can’t be empty strings</li></ul><p>System prompts are processed before any user messages. Skip one and Claude responds as its default self.</p><blockquote><strong><em>Remember:</em></strong><em> Bedrock names things differently (</em><em>inferenceConfig, </em><em>converse, </em><em>toolUse), but the ideas are the ones you already know.</em></blockquote><h3>Tool use:</h3><p>This is where Claude stops being a chatbot and starts doing things.</p><h4>The four-step loop</h4><ol><li><strong>Initial request:</strong> you send a question plus instructions on how to get extra data</li><li><strong>Tool request:</strong> Claude decides it needs external data and asks for it</li><li><strong>Data retrieval:</strong> your server runs the code and fetches the result</li><li><strong>Final response:</strong> Claude uses that data to answer</li></ol><p>Claude never runs anything itself. It asks, you execute.</p><h4>Write good schemas</h4><p>Each tool needs a <strong>JSON Schema</strong>, which tells Claude what arguments your function takes. JSON Schema is a general data validation standard, so plenty of online tools can generate one for you.</p><h4>Handle the request</h4><p>A response can hold a text part followed by <strong>one, two, or more</strong> toolUse parts. Code for the single-request case and you’ll eventually break. Filter defensively:</p><pre>def run_tools(parts):<br>    tool_requests = [p for p in parts if &quot;toolUse&quot; in p]<br>    tool_result_parts = []<br>    for tool_request in tool_requests:<br>        tool_use_id = tool_request[&quot;toolUse&quot;][&quot;toolUseId&quot;]<br>        tool_name = tool_request[&quot;toolUse&quot;][&quot;name&quot;]<br>        tool_input = tool_request[&quot;toolUse&quot;][&quot;input&quot;]<br>        # run the tool, build a result part</pre><p>Each tool result part needs three things:</p><ul><li>toolUseId — Must match the original tool use part’s ID</li><li>content— Your tool’s output, serialized as a string</li><li>status — &quot;success&quot; or &quot;error&quot;</li></ul><h4>Why Claude stopped</h4><p>In multi-turn tool conversations, the stop reason tells you what to do next:</p><ul><li>&quot;tool_use&quot;: Claude wants to call a tool</li><li>&quot;end_turn&quot;: Claude finished its response</li><li>&quot;max_tokens&quot;: it hit the output limit</li><li>&quot;stop_sequence&quot;: it hit a stop sequence you set</li></ul><p>Loop until you get something other than tool_use.</p><blockquote><strong><em>Remember:</em></strong><em> match the </em><em>toolUseId, handle multiple tool parts, and let the stop reason drive your loop.</em></blockquote><h3>The batch tool trick</h3><p>Claude <em>can</em> request several tools in one message. In practice it often doesn’t, even for independent operations, and makes calls one at a time. The course’s workaround is a <strong>batch tool</strong>: a tool whose job is to invoke other tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HBq6q5YhsPLymqCo.png" /></figure><p>Its schema takes an array of invocations, each with a tool name and arguments encoded as a JSON string. The handler loops through them:</p><pre>def run_batch(tool_input):<br>    batch_output = []<br>    for invocation in tool_input[&quot;invocations&quot;]:<br>        args = json.loads(invocation[&quot;arguments&quot;])<br>        tool_output = run_tool(invocation[&quot;name&quot;], args)<br>        batch_output.append({&quot;tool_name&quot;: invocation[&quot;name&quot;], &quot;output&quot;: tool_output})<br>    return batch_output</pre><p>Add a case to run_tool for batch_tool. Pass tool_input straight through, without the splat operator (**), because the batch tool needs the raw structure.</p><p>Run the same date calculation query and you see one call to the batch tool with both sub-calls inside, instead of two separate calls.</p><p><strong>A nuance worth stating.</strong> That loop runs the sub-calls one after another on your server. What you save is round trips to the model, not wall-clock execution time. It’s still a real gain, as long as you know which one you’re getting.</p><h3>Structured data with tools</h3><p>Prefill plus stop sequences is quick to set up. Tools are more work but more reliable.</p><h4>The idea</h4><p>Don’t ask Claude to format its answer as JSON. Create a tool whose input schema <em>is</em> the structure you want, then force Claude to “call” it. The arguments are your data.</p><ol><li>Write a JSON schema for the structure</li><li>Create a tool with that schema as its input spec</li><li>Send your data and the tool to Claude</li><li>Force the tool with toolChoice</li><li>Read the structured data out of the tool call arguments</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RhBprbpH-_oYpH09T_6G0Q.png" /></figure><p>There’s no follow-up. You take the data and end the conversation.</p><h4>Three toolChoice modes</h4><pre>{&quot;toolChoice&quot;: {&quot;auto&quot;: {}}}                          # model decides (default)<br>{&quot;toolChoice&quot;: {&quot;any&quot;: {}}}                           # must use some tool<br>{&quot;toolChoice&quot;: {&quot;tool&quot;: {&quot;name&quot;: &quot;tool-name&quot;}}}       # must use this tool</pre><p>For extraction you almost always want the third one.</p><h4>Skip the schema: the flexible to_json tool</h4><p>Writing detailed schemas gets old. The shortcut is a single generic to_json tool that accepts any object (set the schema to allow additional properties). You describe the structure you want in the <em>prompt</em>:</p><pre># When you call to_json, pass in the following structure:<br>{<br>    &quot;title&quot;: str,        # title of the article<br>    &quot;author&quot;: str,       # author of the article<br>    &quot;topics&quot;: List[str]  # topics mentioned in the article<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t_ilVpN7PFsribQt.png" /></figure><p>Then force it with tool_choice=&quot;to_json&quot;. Changing the structure means editing one line of the prompt, not rewriting a schema.</p><ul><li>Use the flexible tool for — Rapid prototyping, Simple extraction, Requirements that keep changing</li><li>Use a dedicated schema for — Critical production extraction, Complex nested structures, Maximum accuracy</li></ul><p>The course’s rule of thumb is about 90% of the quality for 10% of the setup.</p><h4>Two updates to check before you build on this</h4><p><strong>Structured output is now built in on Bedrock.</strong> For Converse, you use the outputConfig.textFormat request field, and the model’s response conforms to your JSON schema. It covers newer models like Claude Haiku 4.5, Sonnet 4.5, and Opus 4.5 and 4.6. <strong>One limit: structured outputs are incompatible with citations for Anthropic models.</strong> The tool-forcing pattern still teaches you how tool use works, and you’ll meet it in existing code. For new projects, check the native option first.</p><p><strong>Prefill is gone on newer models.</strong> Starting with Claude 4.6, prefilling the last assistant turn is no longer supported, and such requests return a 400 error. Another reason the structured output options above matter.</p><h3>The text editor tool</h3><p>Claude has a built-in capability for working with files, and it behaves unlike your custom tools. For a custom tool you write the schema and the function. Here Claude already knows the schema. <strong>You</strong> write the code that handles its requests. It can:</p><ul><li>View a file or directory</li><li>View a range of lines</li><li>Replace text</li><li>Create new files</li><li>Insert text at a line number</li><li>Undo recent edits</li></ul><p>Your run_tool routes each command to a handler (view, str_replace, and so on):</p><pre>if command == &quot;view&quot;:<br>    return text_editor_tool.view(tool_input.get(&quot;path&quot;, &quot;&quot;))<br>elif command == &quot;str_replace&quot;:<br>    return text_editor_tool.str_replace(path, old_str, new_str)</pre><p>Ask for “a function that calculates pi to the 5th digit in main.py, plus a test file” and Claude reads, writes, creates, and tests on its own. This is the foundation of AI-powered code editors.</p><p><strong>The tool IDs in my notes are out of date.</strong> Check <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages-tool-use.html#model-parameters-anthropic-anthropic-defined-tools">AWS’s documentation</a> for up-to-date IDs.</p><p>Part two picks up with RAG, MCP, Agents and Features of Claude within Amazon Bedrock. This was a great refresher. Looking forward to the next one: <a href="https://tanbuildsai.medium.com/context-is-everything-rag-parallel-agents-mcp-and-other-features-from-claude-with-amazon-bedrock-e0d0a0235c10">Claude with Amazon Bedrock Pt. 2</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44e53368cec4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Before I Trust an MCP Server, I Want to See the Wire.]]></title>
            <link>https://tanbuildsai.medium.com/before-i-trust-an-mcp-server-i-want-to-see-the-wire-73ca7302dc2a?source=rss-3455b42172c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/73ca7302dc2a</guid>
            <category><![CDATA[sampling]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[mcp-protocol]]></category>
            <category><![CDATA[claude]]></category>
            <dc:creator><![CDATA[TanBuildsAI]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 09:26:28 GMT</pubDate>
            <atom:updated>2026-10-13T09:26:28.110Z</atom:updated>
            <content:encoded><![CDATA[<h4>The MCP Server That Works Locally and Breaks in Production</h4><p><em>Notes from course #7 and #8 of my Claude Certified Architect track: Introduction to Model Context Protocol and Model Context Protocol: Advanced Topics. See previous: </em><a href="https://tanbuildsai.medium.com/building-mcp-workflows-and-agents-with-claude-api-a-product-managers-guide-b18ac202350a?sharedUserId=tanbuildsai"><em>Building with Claude API Pt. 3</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F124KrlNJM7grG-Vqjs_HA.png" /></figure><h3>Model Context Protocol (MCP)</h3><p>MCP is a communication layer between your AI app and outside services (like GitHub or a document store) that gives Claude ready-made tools to use them, so you don’t write the integration code yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/0*jihPzOb92LkkxLjb.jpg" /></figure><p><strong>MCP (protocol)</strong> = the standard way a client and server talk to each other</p><ul><li><strong>MCP server</strong> = packages the tool schemas <em>and</em> the functions that run them. It can also expose resources (data) and prompts (instruction templates).</li><li><strong>MCP client</strong> = lives in your app, connects to the server, asks what’s available, and requests that tools run.</li></ul><p>MCP servers ship tool schemas and functions already defined, so your team doesn’t write and maintain that integration code. Anyone can build a server, and service providers often publish official ones.</p><p><strong>MCP is not an API </strong>— MCP servers provide pre-defined tool schemas and functions. If you call an API directly, you’re responsible for authoring those tool definitions yourself.</p><p><strong>MCP is not just tool use </strong>— Tool use is the mechanism. With MCP, the tool definitions simply come from the server instead of being hardcoded in your app.</p><p>The MCP client is the bridge between your app and the server. It’s <strong>transport agnostic</strong>: stdio on the same machine is the most common setup, but HTTP and WebSockets work too. Two message pairs matter most: ListToolsRequest/Result and CallToolRequest/Result.</p><p>The full loop:</p><ol><li>The user asks something.</li><li>Your server asks the client for tools.</li><li>Claude gets the question plus the tool list.</li><li>Claude requests a tool call.</li><li>The client runs it on the MCP server.</li><li>Results flow back to Claude, which writes the answer.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/0*VrAP_6FT6CKFcZGE.jpg" /></figure><h3>Build a server, build a client</h3><p>You build an MCP server and a client from scratch, then connect them to Claude. The lessons run in order: define tools, test them in the Inspector, write the client, add prompts.</p><p>The idea to keep is <strong>who is in control of each primitive</strong>:</p><ul><li><strong>Tools</strong> are model-controlled. Claude decides when to call them.</li><li><strong>Resources</strong> are app-controlled. Your application decides what data gets pulled in.</li><li><strong>Prompts</strong> are user-controlled. The person picks a prebuilt workflow.</li></ul><p>When you’re unsure which primitive to use, ask who triggers it.</p><p>The <strong>MCP Inspector</strong> is also worth your time. It’s a browser-based interface for testing and debugging a server before any client exists.</p><h3>The MCP Server That Works Locally and Breaks in Production</h3><p>Here’s the failure that ties both MCP courses together. You build a server, run it over stdio, and everything works. Progress updates stream and logs show up. Then you deploy it over HTTP, flip a config flag for scale, and half the protocol goes quiet. No error. The features just stop.</p><p>That’s where MCP stopped feeling like plumbing.</p><h3>MCP in 30 seconds</h3><p>Clients and servers talk in JSON messages. Servers expose <strong>tools</strong> (callable functions), <strong>resources</strong> (readable context), and <strong>prompts</strong> (reusable templates). Clients can offer <strong>sampling</strong> and <strong>roots</strong>, which come up below.</p><p>Messages come in two kinds:</p><ul><li><strong>Request → result pairs:</strong> always come in pairs — call tool, list prompts, read resource, initialize.</li><li><strong>Notifications:</strong> one-way, no reply. Progress, logging, tool list changed, resource updated.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RxwHhq7QBShGGYNU.png" /></figure><p>Every connection opens with the same handshake: initialize request, initialize result, initialized notification. Nothing else works until that finishes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7zGacGBFO49wZxdS.png" /></figure><p>The part that matters later: MCP is bidirectional. Servers can send requests to clients, not just answer them.</p><ul><li><strong>Client messages</strong> — requests to servers (like tool calls) and notifications that clients might send.</li><li><strong>Server messages</strong> — requests to clients and notifications that servers broadcast.</li></ul><h3>Sampling: let the client pay for the tokens</h3><p>Sampling allows a server to access a language model like Claude through a connected MCP client. Instead of the server directly calling Claude, it asks the client to make the call on its behalf. This shifts the responsibility and cost of text generation from the server to the client.</p><ul><li><strong>Server side:</strong> ctx.session.create_message(...) with your messages, max_tokens, and a system prompt.</li><li><strong>Client side:</strong> a sampling_callback that calls Claude and returns a CreateMessageResult, passed in when you create the ClientSession.</li></ul><p>The payoff is for public servers. You don’t want strangers running up your AI costs, so each client pays for its own usage and your server holds no credentials.</p><h3>Logging and progress: two calls, big difference</h3><p>Without feedback, a slow tool looks identical to a broken one. Progress bars, status messages, or detailed logs as the operation runs can change everything for the user’s experience. The Context object fixes that:</p><ul><li>context.info() sends log messages to client.</li><li>context.report_progress(20, 100) updates progress with current and total values.</li></ul><pre>@mcp.tool(<br>    name=&quot;research&quot;,<br>    description=&quot;Research a given topic&quot;<br>)<br>async def research(<br>    topic: str = Field(description=&quot;Topic to research&quot;),<br>    *,<br>    context: Context<br>):<br>    await context.info(&quot;About to do research...&quot;)<br>    await context.report_progress(20, 100)<br>    sources = await do_research(topic)<br>    <br>    await context.info(&quot;Writing report...&quot;)<br>    await context.report_progress(70, 100)<br>    results = await generate_report(sources)<br>    <br>    return results</pre><p>On the client, you pass a logging_callback when creating the session and a progress_callback on each call_tool. How you display it (terminal print, WebSocket, progress bar) is your call. It’s all optional.</p><pre>async def logging_callback(params: LoggingMessageNotificationParams):<br>    print(params.data)<br>async def print_progress_callback(<br>    progress: float, total: float | None, message: str | None<br>):<br>    if total is not None:<br>        percentage = (progress / total) * 100<br>        print(f&quot;Progress: {progress}/{total} ({percentage:.1f}%)&quot;)<br>    else:<br>        print(f&quot;Progress: {progress}&quot;)<br>async def run():<br>    async with stdio_client(server_params) as (read, write):<br>        async with ClientSession(<br>            read,<br>            write,<br>            logging_callback=logging_callback<br>        ) as session:<br>            await session.initialize()<br>            <br>            await session.call_tool(<br>                name=&quot;add&quot;,<br>                arguments={&quot;a&quot;: 1, &quot;b&quot;: 3},<br>                progress_callback=print_progress_callback,<br>            )</pre><p>Notification presentation options:</p><ul><li>CLI applications — Simply print messages and progress to the terminal</li><li>Web applications — Use WebSockets, server-sent events, or polling to push updates to the browser</li><li>Desktop applications — Update progress bars and status displays in your UI</li></ul><h3>Roots: permission and discovery in one</h3><p>Roots grant a server access to specific folders. They also solve a usability problem: Claude can’t search your whole file system, and nobody wants to type full paths. With roots, Claude calls list_roots, browses those directories, finds the video file, then calls the conversion tool with the full path.</p><p>One catch: <strong>the SDK doesn’t enforce roots.</strong> You write the check yourself, usually an is_path_allowed() helper that every file-touching tool calls before it does anything.</p><h3>Transport methods: where it gets interesting</h3><p>MCP is designed as a bidirectional protocol — both clients and servers can initiate communication. The communication channel used is called a <strong>transport</strong>, and there are several ways to implement this — from HTTP requests to WebSockets to even writing JSON on a postcard. Some transports, like the streamable HTTP transport, have limitations on which types of messages can flow in which directions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dHw5JOV8SNHDh3A3.png" /></figure><p><strong>stdio</strong> is the dev-time default. The client launches the server as a subprocess, and they trade messages over stdin and stdout. Either side can speak at any time, so all four patterns (client or server, request or response) just work. The limit is that both must run on the same machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pDmzyWyWn6Rq42lr.png" /></figure><p><strong>Streamable HTTP</strong> is the remote option, and it has a structural problem. Clients can find servers, but servers can’t easily call clients. That breaks sampling, progress, logging, and anything else server-initiated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n-_PRZgH_Wwvj23q.png" /></figure><p>The workaround is <strong>Server-Sent Events</strong>:</p><ol><li>The initialize result returns an mcp-session-id header, which goes on every later request.</li><li>The client opens a GET request, creating a long-lived SSE connection the server can push through.</li><li>Each tool call opens a second, short-lived SSE connection that closes when the result is sent.</li><li>Progress notifications ride the primary connection. Logs and tool results ride the per-call one.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Eh9PHB-TYCQx0Fz-.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vyHockpNZGRBumQp.png" /></figure><p>When the client makes a tool call, things get more complex. The system creates two separate SSE connections:</p><ul><li><strong>Primary SSE Connection</strong>: Used for server-initiated requests and stays open indefinitely — progress notifications</li><li><strong>Tool-Specific SSE Connection</strong>: Created for each tool call and closes automatically when the tool result is sent — sends logging messages, tool results</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*288AqTPvgL6q3MnI.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JR3x-JIq8Q7AlpG-.png" /></figure><h3>The two flags that break the workaround</h3><p>Two key settings control how the streamable HTTP transport behaves (default is false):</p><ul><li>stateless_http - Controls connection state management</li><li>json_response - Controls response format handling</li></ul><h4>stateless_http</h4><p>stateless_http=True exists for horizontal scaling. As your server grows, you might have thousands of clients trying to connect. Running a single server instance won’t scale to handle all that traffic. The typical solution is horizontal scaling — running multiple server instances behind a load balancer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*spa-bB8moCnAQYfO.png" /></figure><p>Behind a load balancer, the GET SSE (for receiving server-to-client requests) and POST requests (for calling tools and receiving responses) from one client can land on different instances, and those instances would have to coordinate. Stateless mode removes the problem by removing the features:</p><ul><li>No session IDs</li><li>No server-to-client requests, so no sampling</li><li>No progress reports</li><li>No resource subscriptions</li></ul><p>The one upside is that clients skip the initialization handshake.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*omp4uFDetDMtWpgE.png" /></figure><h4>json_response</h4><p><strong>json_response=True</strong> is milder. It disables streaming on POST responses, so you get only the final JSON result: no progress, no logs mid-run.</p><p>Both default to false. Use stateless when you need to scale and your tools don’t need the server to reach back to the client. Use JSON response when you want plain, non-streaming HTTP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5efsCFQ2hq0f-ZOM.png" /></figure><p>A server that works on your laptop is a demo. The moment it has to run somewhere else, the transport you picked is the architecture.</p><p>This covers 2 courses — <em>Introduction to Model Context Protocol</em> and <em>Model Context Protocol: Advanced Topics</em>. Even though the advanced topics was not in the curriculum, it was still worth doing as it gave me a more nuanced understanding of MCPs in a production context. As an AI product manager, I already know it will be useful. Looking forward to the next one: Claude with Amazon Bedrock!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73ca7302dc2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building MCP, Workflows and Agents with Claude API. A Product Manager’s Guide.]]></title>
            <link>https://tanbuildsai.medium.com/building-mcp-workflows-and-agents-with-claude-api-a-product-managers-guide-b18ac202350a?source=rss-3455b42172c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b18ac202350a</guid>
            <category><![CDATA[claude-api]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[writing-prompts]]></category>
            <dc:creator><![CDATA[TanBuildsAI]]></dc:creator>
            <pubDate>Mon, 12 Oct 2026 10:16:20 GMT</pubDate>
            <atom:updated>2026-10-12T10:16:20.230Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Notes (Part 3) from course #7 of my Claude Certified Architect track: Building with the Claude API covering MCP, Claude Code, Computer Use, Workflows and Agents. See previous: </em><a href="https://medium.com/@tanbuildsai/claude-forgets-everything-heres-what-i-learned-building-around-that-72639ac3ebe8?sharedUserId=tanbuildsai"><em>Building with Claude API Pt. 2</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k3SzdEPaiuwAIS6C.png" /></figure><p>Somewhere in your next sprint planning, an engineer will say “we can just use MCP.” Another will say “let’s make it an agent.” Both sentences sound like decisions. Neither is one until you know what you’re trading.</p><p>Part 3 of Anthropic’s Building with the Claude API course answers a single question in several forms: who does the work? With MCP, it’s who writes the tools. With workflows versus agents, it’s who decides the steps. Those are product questions as much as engineering ones.</p><h3>Model Context Protocol (MCP)</h3><p>MCP is a communication layer between your AI app and outside services (like GitHub or a document store) that gives Claude ready-made tools to use them, so you don’t write the integration code yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u3uOeyM6yk3553PG.jpg" /></figure><p><strong>MCP (protocol)</strong> = the standard way a client and server talk to each other</p><ul><li><strong>MCP server</strong> = packages the tool schemas <em>and</em> the functions that run them. It can also expose resources (data) and prompts (instruction templates).</li><li><strong>MCP client</strong> = lives in your app, connects to the server, asks what’s available, and requests that tools run.</li></ul><p>MCP servers ship tool schemas and functions already defined, so your team doesn’t write and maintain that integration code. Anyone can build a server, and service providers often publish official ones.</p><p><strong>MCP is not an API </strong>— MCP servers provide pre-defined tool schemas and functions. If you call an API directly, you’re responsible for authoring those tool definitions yourself.</p><p><strong>MCP is not just tool use </strong>— Tool use is the mechanism. With MCP, the tool definitions simply come from the server instead of being hardcoded in your app.</p><p>The MCP client is the bridge between your app and the server. It’s <strong>transport agnostic</strong>: stdio on the same machine is the most common setup, but HTTP and WebSockets work too. Two message pairs matter most: ListToolsRequest/Result and CallToolRequest/Result.</p><p>The full loop:</p><ol><li>The user asks something.</li><li>Your server asks the client for tools.</li><li>Claude gets the question plus the tool list.</li><li>Claude requests a tool call.</li><li>The client runs it on the MCP server.</li><li>Results flow back to Claude, which writes the answer.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Gwmn2vXNdr0yCxp-.jpg" /></figure><h4>What It Takes To Build An MCP Server</h4><p>Less than you’d guess.</p><ol><li>The Python SDK starts a server in one line: FastMCP(&quot;DocumentMCP&quot;).</li></ol><pre>from mcp.server.fastmcp import FastMCP<br>mcp = FastMCP(&quot;DocumentMCP&quot;, log_level=&quot;ERROR&quot;)</pre><p>2. The @mcp.tool decorator generates the JSON schema from type hints, and Pydantic’s Field adds parameter descriptions. You write business logic and the SDK handles the protocol.</p><p>3. Check if Python environment is activated. mcp dev mcp_server.py opens the Inspector on port 6277, where you can call tools in isolation.</p><h4>What It Takes To Build An MCP Client</h4><p>The client is what allows our application to communicate with the MCP server and access its functionality. The MCP client consists of two main components:</p><ul><li>MCP Client — A custom class we create to make using the session easier</li><li>Client Session — The actual connection to the server (part of the MCP Python SDK)</li></ul><p>The client side is a custom class wrapping a ClientSession, mainly so cleanup happens automatically. It needs two methods: list_tools() and call_tool().</p><p>List tools:</p><pre>async def list_tools(self) -&gt; list[types.Tool]:<br>    result = await self.session().list_tools()<br>    return result.tools</pre><p>Call tool:</p><pre>async def call_tool(<br>    self, tool_name: str, tool_input: dict<br>) -&gt; types.CallToolResult | None:<br>    return await self.session().call_tool(tool_name, tool_input)</pre><p>We pass the tool name and input parameters (provided by Claude) to the server and return the result.</p><h3>Tools, Resources, Prompts</h3><p>Each MCP server can expose different types of functionality to Claude through three main components: Tools (for taking actions), Prompts (for templates), and Resources (for accessing data).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4exRAn31JLndwpMv5xcMVw.png" /></figure><h4>Resources</h4><p>Resources provide a clean way to make data available to MCP clients. They’re perfect for scenarios where you need to fetch information rather than perform actions. Resources are defined using the @mcp.resource() decorator.</p><p>Resources follow a <strong>request-response pattern</strong>. Your client sends a ReadResourceRequest with a URI, and the MCP server responds with the data. The URI acts like an address for the resource you want to access.</p><p>There are two types of resources: either <strong>direct </strong>(static) or <strong>templated </strong>(parameters pulled from the URI). <strong>MIME types</strong> tell the client how to parse what comes back, so JSON gets decoded and text stays text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ENGZnSGwQGy7FUUb.jpg" /></figure><p>Here&#39;s how to create both types — Direct Resource (List Documents):</p><pre>@mcp.resource(<br>    &quot;docs://documents&quot;,<br>    mime_type=&quot;application/json&quot;<br>)<br>def list_docs() -&gt; list[str]:<br>    return list(docs.keys())</pre><p>Templated Resource (Fetch Document):</p><pre>@mcp.resource(<br>    &quot;docs://documents/{doc_id}&quot;,<br>    mime_type=&quot;text/plain&quot;<br>)<br>def fetch_doc(doc_id: str) -&gt; str:<br>    if doc_id not in docs:<br>        raise ValueError(f&quot;Doc with id {doc_id} not found&quot;)<br>    return docs[doc_id]</pre><h4>Prompts</h4><p>Prompts return ready-to-send messages. The client calls list_prompts() and get_prompt(name, args), and your args get interpolated into the template. Treat them like product copy: specific, tested, and worth more than what users would write themselves.</p><p>The basic structure looks like this:</p><ul><li>Define prompts using the @mcp.prompt() decorator</li><li>Add a name and description for each prompt</li><li>Return a list of messages that form the complete prompt</li><li>These prompts should be high quality, well-tested, and relevant to your MCP server’s purpose</li></ul><p>List Prompt:</p><pre>async def list_prompts(self) -&gt; list[types.Prompt]:<br>    result = await self.session().list_prompts()<br>    return result.prompts</pre><p>Get Prompt:</p><pre>async def get_prompt(self, prompt_name, args: dict[str, str]):<br>    result = await self.session().get_prompt(prompt_name, args)<br>    return result.messages</pre><p>When the client calls get_prompt, the arguments dictionary should contain the expected keys. The MCP server will pass these as keyword arguments to the prompt function, allowing dynamic content to be inserted into the prompt template.</p><h3>Where Anthropic Apps Fit: Claude Code &amp; Computer Use</h3><p>Claude Code and Computer use are agentic apps that integrate tools, execute multi-step tasks, interact with environment and solve problems autonomously.</p><h4>Claude Code</h4><p>Claude Code is a terminal assistant that reads and edits files, runs commands, searches the web, and connects to MCP servers. Setup: install Node, run npm install -g @anthropic-ai/claude-code, then claude to log in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9d1URisNDbaeulfk.jpg" /></figure><ul><li><strong>/init</strong> scans the codebase and writes CLAUDE.md, which loads into every later conversation. It comes in project, local, and user scopes.</li><li><strong>#</strong> adds a note to CLAUDE.md on the spot.</li><li><strong>/clear</strong> resets context.</li></ul><p>The recommended workflow reads like a good spec process: give it the relevant files, ask for a plan with no code, then implement. <strong>The test-driven variant has Claude propose test cases, write them, then iterate until the code passes.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UyD719qdyIAi2n5a.jpg" /></figure><p>Add your own server with claude mcp add documents uv run main.py.</p><h3>Workflows: when you can picture the steps</h3><p>A workflow is a predefined series of Claude calls. Each step handles one narrow task, which tends to raise accuracy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SWgTZIH2NveJbSoZOyVNCg.png" /></figure><h4>Evaluator-optimizer pattern:</h4><ul><li>Producer: Takes input and creates output (Claude using CadQuery to model the part and create a rendering)</li><li>Grader: Evaluates the output against some criteria</li><li>Feedback loop: If the grader doesn’t accept the output, feedback goes back to the producer for improvement</li><li>Iteration: The cycle repeats until the grader accepts the output</li></ul><h4>Parallelization:</h4><p>Instead of cramming everything into one request, you can split the task into multiple parallel requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KZ5_FkgbnuGhla_V.jpg" /></figure><p>The parallelization pattern follows a simple structure:</p><ul><li>Split a single task into multiple sub-tasks — Break down the complex decision into focused, specialized evaluations</li><li>Run the sub-tasks in parallel — Execute all evaluations simultaneously for faster processing</li><li>Aggregate the results together — Combine the specialized analyses into a final decision</li><li>The parallelized sub-tasks don’t need to be identical — Each can have a specialized prompt, set of tools, or evaluation criteria</li></ul><h4>Chaining Workflow</h4><p>A chaining workflow breaks down a large, complex task into smaller, sequential subtasks. Instead of asking Claude to do everything at once, you split the work into focused steps that build on each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*abXAKvCB9gwfe8KF.jpg" /></figure><p>Step 1: Send your initial prompt and accept that the first result might not be perfect.</p><p>Step 2: Make a follow-up request that focuses specifically on fixing the issues.</p><h4>Routing workflows:</h4><p>Instead of using a one-size-fits-all prompt, you can categorize incoming requests and route them to specialized processing pipelines. The routing process happens in two steps:</p><ol><li>Categorization — Send the user’s topic to Claude with a request to categorize it into one of your predefined genres</li><li>Specialized Processing — Use the category result to select the appropriate pipeline. Each pipeline can have its own workflow, prompts, or tools optimized for that category</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j7aLfkbf0L__axCE.jpg" /></figure><h3>Agents: when you can’t define the steps</h3><p>An agent gets a goal and a set of tools, then works out the steps. It can handle tasks nobody planned for and can ask the user for more input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZCvhwazJNX0hBCze.jpg" /></figure><p>Two design rules from the course. Give agents abstract tools they can combine rather than hyper-specialized ones. And make them inspect their environment: a screenshot after every click, a file read before every edit. Claude is blind otherwise. Inspection gives it a way to track progress, catch errors, and verify work before calling it done.</p><h4>Environment Inspection</h4><p>When building AI agents, one crucial concept often gets overlooked: environment inspection. Claude operates blindly — it needs to be able to observe and understand the results of its actions to work effectively.</p><p>From Claude’s perspective, clicking a button could navigate to a new page, open a menu, or trigger any number of changes. Without being able to see the results, Claude has no way to understand whether its action succeeded or what the new state of the environment looks like.</p><p>You can guide Claude to inspect its environment through system prompts.</p><h3>The decision: Workflows or Agents</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XPeaP5onX_B5AYlY.jpg" /></figure><p>Workflows are easier to test, more predictable, and more accurate. Agents are flexible but complete tasks less reliably, and they’re harder to instrument because you don’t know the steps in advance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DavwlU9Ep2peYAhy.jpg" /></figure><p>The course’s guidance is blunt: <strong>default to workflows, and use agents only when the task truly can’t be pinned down.</strong></p><p>Users never ask whether you built an agent. They ask whether it worked on Tuesday.</p><p>This covers MCP, Claude Code, Computer Use, Workflows and Agents. This course was ginormous but definitely worth it. Everything was super practical and concise while being very thorough. Next up is Introduction to MCP!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b18ac202350a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Claude Forgets Everything. Here's What I Learned Building Around That.]]></title>
            <link>https://tanbuildsai.medium.com/claude-forgets-everything-heres-what-i-learned-building-around-that-72639ac3ebe8?source=rss-3455b42172c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/72639ac3ebe8</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[claude-ai]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <dc:creator><![CDATA[TanBuildsAI]]></dc:creator>
            <pubDate>Fri, 09 Oct 2026 06:18:19 GMT</pubDate>
            <atom:updated>2026-10-12T10:16:54.130Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Notes (Part 2) from course #7 of my Claude Certified Architect track: Building with the Claude API covering tools, RAG, thinking, vision, caching, and code execution. See previous: </em><a href="https://tanbuildsai.medium.com/what-happens-after-you-hit-send-on-the-claude-api-12fb4cd587e4?sharedUserId=tanbuildsai"><em>Building with Claude API Pt. 1</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UbwRC9OZFY2-wP5c.png" /></figure><p>Every request starts from zero. The model that just wrote you a paragraph and it will forget it did unless you send it back. Part 2 of Building with the Claude API is a tour of what follows from that: what you pass in, what you get and what you decide to keep.</p><h3>Tool use: you run the loop</h3><p>Tools allow Claude to access information from the outside world, extending its capabilities beyond what it learned during training. Tool functions are Python functions that Claude can call when it needs additional data to help users. Tool use solves this limitation by creating a structured way for Claude to request and receive fresh information. Key benifits include:</p><ul><li><strong>Real-time Information</strong> and <strong>dynamic responses</strong> based on latest information</li><li><strong>External System Integration</strong> with databases, APIs, and other services</li><li><strong>Structured Interaction </strong>since Claude knows exactly what information it needs and how to ask for it</li></ul><h4><strong>The flow:</strong></h4><p>Tool use follows a specific back-and-forth pattern between your application and Claude:</p><ul><li>Initial request: You send a question plus tool schemas.</li><li>Tool Request: Claude replies with a text block and a tool_use block.</li><li>You run the function, send a tool_result back inside a user message</li><li>Repeat until stop_reason stops saying &quot;tool_use&quot;</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4kOWRVD9d_jmUuGM.png" /></figure><p><strong>Each tool schema</strong> has three parts: name, description, input_schema. This schema acts as documentation that Claude reads to understand when and how to call your tools. Write the description in 3–4 sentences covering what the tool does, when to use it, and what it returns.</p><blockquote>Pro-tip: paste your function and the Anthropic tool-use docs into Claude and ask it to write the schema.</blockquote><ul><li><strong>Store Conversation History:</strong> append response.content whole, text block and tool block both. Drop one and the context breaks.</li></ul><pre>messages.append({<br>    &quot;role&quot;: &quot;assistant&quot;,<br>    &quot;content&quot;: response.content<br>})</pre><ul><li><strong>Every Tool Use Result has an ID:</strong> every tool_result needs the matching tool_use_id. Claude can request several tools in one response, so match carefully and set is_error on failures.</li><li><strong>Errors:</strong> validate inputs (empty or invalid) and raise clear errors when they arise. The validation is particularly important because Claude sees and learns from errors, and might retry the function call with corrected parameters.</li><li>For better <strong>type checking</strong>, import and use the ToolParam type from the Anthropic library to prevent type errors when you use the schema with Claude’s API.</li><li><strong>Follow-up calls</strong> still need the schema, even if you expect no more tool requests. Claude needs the schema to understand the tool references in your conversation history.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GkrcvKZ4CM8ZKlyYMB9oaQ.png" /></figure><ul><li><strong>Adding a tool later:</strong> write the function, write the schema, add it to the tools list, add a case to your router.</li></ul><h4>A Full Conversation Loop</h4><p>To handle this pattern, you need a conversation loop that continues until Claude stops requesting tools:</p><pre>def run_conversation(messages):<br>    while True:<br>        response = chat(messages)<br><br>        add_assistant_message(messages, response)<br><br>        if response.stop_reason != &quot;tool_use&quot;:<br>            break  # Claude is done, no more tools needed<br><br>        tool_result_blocks = run_tools(response)<br>        add_user_message(messages, tool_result_blocks)<br>        <br>    return messages</pre><h4><strong>Fine-Grained Tool Calling:</strong></h4><p>By default, the API holds chunks until a full top-level key-value pair validates against your schema, so you see pauses, then bursts. Fine-grained tool calling turns JSON validation off. Chunks arrive immediately and you own the broken-JSON handling. Worth it when buffering hurts the UX and you’re ready to catch bad JSON. Enable it by adding <strong>fine_grained=True</strong> to your API call:</p><pre>run_conversation(<br>    messages, <br>    tools=[save_article_schema], <br>    fine_grained=True<br>)</pre><h3>Built-in tools</h3><h4><strong>Text editor:</strong></h4><p>The schema is built into Claude. User needs to write functions to handle Claude’s requests to create files, read directories, replace text, and so on. This tool gives Claude the ability to work with files and directories just like you would in a standard text editor. Claude asks to view, replace, create, insert, or undo, and you write the code that touches the files. You still send a small schema stub, and the exact one depends on the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UNhMRNlrUNH4ZbXC.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G6f7pKgp14QXc28m.png" /></figure><h4><strong>Web search:</strong></h4><p>Claude includes a built-in web search tool that lets it search the internet for current or specialized information to answer user questions. You provide a schema (type, name, max_uses, optionally allowed_domains) and Claude handles the rest.</p><pre>web_search_schema = {<br>    &quot;type&quot;: &quot;web_search_20250305&quot;,<br>    &quot;name&quot;: &quot;web_search&quot;,<br>    &quot;max_uses&quot;: 5,<br>    &quot;allowed_domains&quot;: [&quot;nih.gov&quot;]<br>}</pre><p>When Claude uses the web search tool, the response contains several types of blocks:</p><ul><li>Text blocks — Claude’s explanation of what it’s doing</li><li>ServerToolUseBlock — Shows the exact search query Claude used</li><li>WebSearchToolResultBlock — Contains the search results</li><li>WebSearchResultBlock — Individual search results with titles and URLs</li><li>Citation blocks — Text that supports Claude’s statements</li></ul><blockquote>Your org has to enable it in the console first. The response shows the query it ran, the results, and citations.</blockquote><h3>Retrieval Augmented Generation (RAG)</h3><p>RAG chunks a big document and sends only the relevant pieces. You trade simplicity for scale. Now you own preprocessing, a search mechanism, and the risk that a retrieved chunk is missing the context Claude needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1oPpeRYdY103OqS5.jpg" /></figure><h4>Text Chunking</h4><p>Text Chunking makes or breaks the quality of your entire system. <strong>Chunking options include:</strong></p><ul><li><strong>Size-based</strong> (add overlap): divide your text into strings of equal length. works on anything, including code. The production default. Drawbacks: Words get cut off mid-sentence, Chunks lose important context from surrounding text</li><li><strong>Structure-based:</strong> divides text based on the document’s natural structure — headers, paragraphs, and sections. cleanest chunks, but only if you control the formatting (Markdown).</li><li><strong>Sentence-based:</strong> regex split, grouped with optional overlap. Good middle ground for most text documents.</li><li><strong>Semantic:</strong> NLP groups sentences by meaning. Best chunks, most expensive.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R6k8ZADUiigtFx_9.jpg" /></figure><h4><strong>Embeddings</strong></h4><p>Embeddings are a list of numbers, each between -1 and 1, representing a text’s meaning. Nobody knows what each dimension encodes. The model learned them. Anthropic doesn’t offer embeddings, and the course recommends VoyageAI. Vectors come back normalized to length 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*23ecqvsEWfPyII47.jpg" /></figure><p>The embedding API typically performs a <strong>normalization </strong>step that scales each vector to have a magnitude of 1.0. We can visualize these embeddings on a unit circle, where each point represents one of our text chunks.</p><p><strong>Cosine Similarity</strong> is the cosine of the angle between two vectors. Results range from -1 to 1:</p><ul><li>Values close to 1 mean high similarity</li><li>Values close to -1 mean very different</li><li>0 means perpendicular (no relationship)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p4DhAG5wh4kEAvSi.jpg" /></figure><p><strong>Cosine distance</strong> is (1 - cosine similarity). Values close to 0 mean high similarity, larger values mean less similarity</p><p><strong>The pipeline:</strong></p><ol><li>Chunk the document.</li><li>Embed each chunk (with normalization).</li><li>Store the vectors in a vector database <em>with the original text</em>, because you need to return words, not numbers.</li><li>Embed the user’s query with the same model.</li><li>Pull the nearest chunks and build the prompt.</li></ol><p><strong>Semantic search</strong>: The most common approach for finding relevant chunks that uses text embeddings to understand the meaning and context of both the user’s question and each text chunk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NjTPqzV9S4Xepxqy.jpg" /></figure><h4><strong>Hybrid search</strong></h4><p>To get the best results, run both semantic and lexical searches in parallel, then merge the results. Semantic search finds conceptually related content using embeddings. BM25 (BestMatch 25) Lexical search finds exact term matches using classic text search. It tokenizes the query, counts term frequency, weights rare terms higher, and ranks documents by the heaviest matches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-hwl-1OCuMYC2SZZ.jpg" /><figcaption>BM25 Lexical Search</figcaption></figure><p>The Retriever class acts as a coordinator that forwards user queries to both indexes, collects their results, and merges them using a technique called reciprocal rank fusion:</p><pre>RRF_score(d) = Σ(1 / (k + rank_i(d)))</pre><p>The course uses k=1 for readability, though 60 is common.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8WqbpHmOn1LL0cPh.jpg" /></figure><p>This modular approach keeps the implementation extensible. Since all indexes implement the same SearchIndex protocol with <strong>add_document()</strong> and <strong>search()</strong> methods, you can easily add new search methodologies like keyword-based index, graph-based search, specialized domain index etc.</p><h3>Extended thinking: scratch paper, billed by the token</h3><p>The response gains a thinking block alongside the text block. You pay for the tokens and wait for the latency but get accuracy and transparency. The rule I’m keeping: run your evals <em>without</em> thinking first, and turn it on only if accuracy still lags after you’ve tuned the prompt.</p><ul><li>max_tokens must be larger than thinking budget.</li><li>A <strong>cryptographic signature</strong> stops anyone from editing the thinking text.</li><li><strong>Redacted thinking</strong> shows up as encrypted blocks when safety systems flag the reasoning. Pass them back unchanged.</li><li>It doesn’t play well with prefilling or temperature changes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YZlKlQ9kOCdBWeSH.jpg" /></figure><p>One update to my own notes: the manual budget_tokens setup is the older mechanism. On Claude 4.7 and later models, manual extended thinking returns a 400 error, and Anthropic&#39;s docs point to adaptive thinking instead.</p><pre>def chat(<br>    messages,<br>    system=None,<br>    temperature=1.0,<br>    stop_sequences=[],<br>    tools=None,<br>    thinking=False,<br>    thinking_budget=1024<br>):</pre><h3>Vision and PDFs</h3><p>You can ask Claude to describe what’s in an image, compare multiple images, count objects, or perform complex visual analysis tasks.</p><ul><li>Up to 100 images across all messages in a single request</li><li>Max size of 5MB per image</li><li>When sending one image: max height/width of 8000px</li><li>When sending multiple images: max height/width of 2000px</li><li>Images can be included as base64 encoding or a URL to the image</li><li>Each image counts as tokens based on its dimensions: <strong>tokens = (width px × height px) / 750</strong></li></ul><pre>with open(&quot;image.png&quot;, &quot;rb&quot;) as f:<br>    image_bytes = base64.standard_b64encode(f.read()).decode(&quot;utf-8&quot;)<br>add_user_message(messages, [<br>    # Image Block<br>    {<br>        &quot;type&quot;: &quot;image&quot;,<br>        &quot;source&quot;: {<br>            &quot;type&quot;: &quot;base64&quot;,<br>            &quot;media_type&quot;: &quot;image/png&quot;,<br>            &quot;data&quot;: image_bytes,<br>        }<br>    },<br>    # Text Block<br>    {<br>        &quot;type&quot;: &quot;text&quot;,<br>        &quot;text&quot;: &quot;What do you see in this image?&quot;<br>    }<br>])</pre><p>PDFs use nearly identical code: type becomes &quot;document&quot; and media_type becomes application/pdf. Claude reads text, charts, tables, and document structure.</p><h4><strong>Citations</strong></h4><p><strong>A</strong>dd a title and citations: {&quot;enabled&quot;: True} to the document block. Each claim comes back with cited_text, document_index, document_title, and page numbers. It works on plain text too. Use it when users need to verify the answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8p5-ebMIdY46bLAg.jpg" /></figure><h3>Prompt caching</h3><p>Normally Claude throws away its preprocessing (tokenization, embeddings, and context analysis) after every response. Caching keeps it, so repeat requests run faster and cost less.</p><ul><li>Caching is manual. Add cache_control: {&quot;type&quot;: &quot;ephemeral&quot;} to a block, which means switching to the longhand text-block format.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*98W0MFJkAqDrDHWb.jpg" /></figure><ul><li>Everything <em>before</em> the breakpoint is cached, and only if the content up to it is identical on the next request.</li><li>You get <strong>four breakpoints</strong>. Processing order is tools, then system prompt, then messages.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Gwy068DJqT1943fZ.jpg" /></figure><ul><li>The cached content needs a minimum length (1024 tokens in the course), counted across everything you’re caching.</li><li>To cache tool schemas, put the breakpoint on the last tool. Copy the list first so you don’t mutate your originals.</li><li>Check cache_creation_input_tokens on the first call and cache_read_input_tokens after.</li><li>Change one character in your system prompt or tools and that component’s cache is gone. If you change your system prompt but keep the same tools, you’ll see a partial cache read (for tools) and a cache write (for the new system prompt).</li><li>Cache lasts <strong>one hour</strong> so use when applications need relatively frequent API usage rather than long-term storage.</li></ul><pre>if tools:<br>    tools_clone = tools.copy()<br>    last_tool = tools_clone[-1].copy()<br>    last_tool[&quot;cache_control&quot;] = {&quot;type&quot;: &quot;ephemeral&quot;}<br>    tools_clone[-1] = last_tool<br>    params[&quot;tools&quot;] = tools_clone</pre><p>This approach creates copies of both the tools list and the last tool schema before adding the cache control field.</p><h3>Files API and code execution</h3><p>The Files API lets you upload once, get a file ID, and reference it later instead of re-sending base64 every time.</p><p>Code execution is a server-side tool. You send a predefined schema and Claude runs Python in an isolated Docker container with no network access. That makes the Files API the only door in and out:</p><ol><li>Upload your CSV.</li><li>Reference the file ID in a container upload block.</li><li>Claude writes and runs code, possibly several rounds.</li><li>Generated files (a plot, say) appear in code_execution_output blocks with file IDs you download.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rW_rf0C5_CGkwA83.jpg" /></figure><p>Data analysis is the obvious use. Image processing, document parsing, and report generation fit too.</p><p>Everything in this course comes back to the message list. The model is the glamorous part. The list is the part you’ll end up debugging.</p><p>This covers tools, RAG, thinking, vision, caching, and code execution. Part 3 covers MCP, computer user, agents and workflows which gets me even more excited about the possibilities. Aaaaa! Can’t wait for the next one: <a href="https://tanbuildsai.medium.com/building-mcp-workflows-and-agents-with-claude-api-a-product-managers-guide-b18ac202350a?sharedUserId=tanbuildsai">Building with Claude API Pt.3.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72639ac3ebe8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happens After You Hit Send on the Claude API]]></title>
            <link>https://tanbuildsai.medium.com/what-happens-after-you-hit-send-on-the-claude-api-12fb4cd587e4?source=rss-3455b42172c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/12fb4cd587e4</guid>
            <category><![CDATA[ai-development]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[ai-evals]]></category>
            <category><![CDATA[claude-api]]></category>
            <category><![CDATA[claude]]></category>
            <dc:creator><![CDATA[TanBuildsAI]]></dc:creator>
            <pubDate>Sun, 04 Oct 2026 12:37:34 GMT</pubDate>
            <atom:updated>2026-10-04T12:37:34.070Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Notes (Part 1) from course #7 of my Claude Certified Architect track: Building with the Claude API. See previous: </em><a href="https://medium.com/@tanbuildsai/what-my-ai-agents-taught-me-about-being-fluent-not-just-fast-1ad21f311d14?sharedUserId=tanbuildsai"><em>AI Fluency: Framework &amp; Foundations</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fHgIGRdJ1oCFDzW3GnC62g.png" /></figure><p>Part 1 covers the request lifecycle, your first calls, system prompts, temperature, streaming, structured output, and the start of prompt evaluation and engineering.</p><blockquote><strong>The first rule of the Claude API is that you don’t call it from the browser. It sounds like a minor security footnote. But it’s actually the architecture. Store the key in a </strong><strong>.env file and add it to </strong><strong>.gitignore right away.</strong></blockquote><h3>The 5-Step Request Flow of An API</h3><p>Every interaction follows the same path:</p><ol><li>Client sends a request to <strong>your server</strong></li><li>Your server sends a request to the <strong>Anthropic API. </strong>Your server holds the key. Every request needs four fields: API key, Model, Messages, Max tokens.</li><li>The <strong>model processes</strong> it.</li><li>The API <strong>responds to your server</strong></li><li>Your server <strong>responds to the client</strong></li></ol><h4>Inside the model</h4><p>Once the request lands, Claude runs through four stages:</p><ol><li><strong>Tokenization:</strong> text splits into tokens: whole words, word fragments, spaces, or symbols</li><li><strong>Embedding:</strong> each token becomes numbers representing its meanings (numerical definition)</li><li><strong>Contextualization:</strong> numbers adjust based on surrounding words</li><li><strong>Generation:</strong> An output layer calculates probabilities for the next word with some controlled randomness, repeated until done</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J1zsN88HN4RvtYmP.png" /></figure><p>Claude stops when it hits <strong>max tokens</strong>, reaches a <strong>natural ending</strong>, or meets a <strong>stop sequence</strong>. The response returns the message, token usage, and a stop_reason.</p><h4>When Claude stops</h4><p>After every token, Claude checks three conditions:</p><ul><li><strong>Max tokens reached.</strong> It hit your limit.</li><li><strong>Natural ending.</strong> It generated an end-of-sequence token.</li><li><strong>Stop sequence.</strong> It encountered a phrase you told it to stop on.</li></ul><h4>What comes back</h4><p>The response has three parts: the <strong>message</strong> (generated text), <strong>usage</strong> (input and output token counts), and the <strong>stop reason</strong> (why generation ended). Your server takes the text and forwards it to the client.</p><h4>The ‘Create’ Function for Generation</h4><p>Everything runs through client.messages.create(). It takes three core parameters: model, max_tokens and messages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tu66qtfVcjH8bMuh.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pDNT_U3iF5yZvrzk.png" /></figure><p>Messages alternate between user and assistant roles. The course example used an older model ID, so check the current model list before copying.</p><pre>message = client.messages.create(<br>    model=model,<br>    max_tokens=1000,<br>    messages=[{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;What is quantum computing? One sentence.&quot;}]<br>)<br>message.content[0].text</pre><p>Pull the answer out with message.content[0].text.</p><h3>Shaping the output</h3><h4><strong>1. System prompt:</strong></h4><p>A plain string passed to create(). It sets role, tone, and focus.</p><h4><strong>2. Temperature (0 to 1):</strong></h4><p>Decimal from 0 to 1 that changes how Claude picks the next token. Low is predictable, high is creative. It shifts the odds and doesn’t guarantee different outputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fMIUJx4G5n8upazn.png" /></figure><h4><strong>3. Response Streaming:</strong></h4><p>Claude confirms it received your request right away, then sends a series of events, each carrying a small piece of the answer. Your server forwards those chunks to the client as they arrive, so text appears as it’s written.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U9j3p4HfTKFTlh4i.png" /></figure><p>The event types, in order:</p><ul><li><strong>MessageStart</strong>: a new message is beginning</li><li><strong>ContentBlockStart</strong>: a new block (text, tool use, or other) is starting</li><li><strong>ContentBlockDelta</strong>: chunks of the actual generated text</li><li><strong>ContentBlockStop</strong>: the current block is complete</li><li><strong>MessageDelta</strong>: the message is complete</li><li><strong>MessageStop</strong>: end of the message</li></ul><p>Use the SDK’s text_stream to skip manual parsing, then get_final_message() for the complete message to store.</p><h4>4. Getting structured output</h4><p>To remove unnecessary extra commentary use prefill + stop sequences. <strong>Prefill</strong> the assistant message with the opening of a markdown code block, so Claude behaves as though it already started one and continues with just the content. <strong>Set a stop sequence</strong> on the closing triple backticks, so generation halts the moment Claude tries to close the block.</p><p>Check your model first. Prefilled responses on the last assistant turn are <strong>no longer supported starting with Claude 4.6 models</strong>, and such requests return a 400 error. Use structured outputs on current models. The concept still transfers: control the wrapper and stop at the boundary.</p><h3>Evals: turning vibes into numbers</h3><p><strong>Engineering</strong> writes better prompts. <strong>Evaluation</strong> measures them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*imZL6fhIKx44uIJi.png" /></figure><p>The evaluation-first approach costs more upfront in time and test infrastructure. In return you catch problems in development instead of after users find them, compare versions objectively, and iterate on measurable improvement instead of vibes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*73QXwvlKiWPc9CBB.png" /></figure><h4>The five-step eval workflow</h4><ol><li><strong>Draft a prompt.</strong></li><li><strong>Create an eval dataset.</strong> Sample inputs that represent what the prompt will see in production. It can be tens, hundreds, or thousands of records, built by hand or generated with Claude.</li><li><strong>Feed each input through Claude.</strong> Merge each test case into your prompt template and send it.</li><li><strong>Feed the outputs through a grader.</strong> It scores each response, typically 1 to 10.</li><li><strong>Change the prompt and repeat.</strong></li></ol><p>Use the version with the best score and keep iterating.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*YWE0KSRsiHAeWyqnw7giCQ.png" /></figure><p>The pipeline is three functions: run_prompt, run_test_case, and run_eval. Each result holds the output, the test_case, and a score. That&#39;s most of what an eval system is. The complexity lives in the details: better prompts, smarter grading, and performance optimization.</p><h3>Three Kinds of Graders</h3><p>A grader takes model output and returns measurable feedback, usually a 1 to 10 number. There are 3 types of graders:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FmtJ4HjdekX3x-Kn.png" /></figure><ul><li><strong>Code:</strong> run programmatic checks for length checks, keyword checks, syntax validation</li><li><strong>Model:</strong> another Claude call judging quality, instruction following, or safety</li><li><strong>Human:</strong> the most flexible and the slowest. They’re useful for general quality, comprehensiveness, depth, conciseness, and relevance, and they’re tedious at scale.</li></ul><blockquote><strong>Pro tip:</strong> Set your criteria first. Ask a model grader for strengths, weaknesses, and reasoning with the score. Without that context, models drift toward a middling 6 on everything.</blockquote><p><strong>Combining scores:</strong> syntax validators return 10 if the output parses and 0 if it doesn’t. Average that with the model score. The baseline matters less than whether you can beat it.</p><h3>Prompt Engineering techniques to write better prompts:</h3><ul><li><strong>Loop:</strong> set a goal, write, evaluate, apply techniques, re-evaluate</li><li><strong>First line:</strong> be clear and direct. Use instructions with action verbs, not questions.</li><li><strong>Guidelines:</strong> add <em>output quality rules</em> (length, format, tone) to nearly every prompt, and <em>process steps</em> for complex reasoning to tell Claude how to think through the problem</li><li><strong>XML tags:</strong> use them to separate large or mixed content. XML tags can help serve as delimiters that make your prompt structure more obvious to Claude.</li><li><strong>Examples:</strong> one-shot sets a pattern and multi-shot covers edge cases. Wrap them in XML, explain why each is ideal, and target your common failures.</li></ul><p><strong>One-line recap:</strong> keep the key on the server, shape output with system prompts and temperature, and measure every prompt change with an eval.</p><p>That covers the foundation: how a request travels, how to shape a response, and how to measure whether your prompt is any good. This has been super practical and helpful so far. This course continues on with tool use, RAG and agentic search, MCP, and other exciting stuff. I’ll post those notes as soon as I’ve worked through them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12fb4cd587e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What My AI Agents Taught Me About Being Fluent, Not Just Fast]]></title>
            <link>https://tanbuildsai.medium.com/what-my-ai-agents-taught-me-about-being-fluent-not-just-fast-1ad21f311d14?source=rss-3455b42172c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ad21f311d14</guid>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[aifluency]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[framework]]></category>
            <dc:creator><![CDATA[TanBuildsAI]]></dc:creator>
            <pubDate>Sat, 26 Sep 2026 10:31:52 GMT</pubDate>
            <atom:updated>2026-09-26T10:31:52.734Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Notes from course #6 of my Claude Certified Architect track: AI Fluency: Framework &amp; Foundations. See previous: </em><a href="https://tanbuildsai.medium.com/claude-code-doesnt-need-your-trust-it-needs-your-hooks-ff32acbcf3ab?sharedUserId=tanbuildsai"><em>Claude Code in Action</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJqW_kM8B2H6eBkG39DxMw.png" /></figure><p>A few months ago I fell into one of those spiraling threads about AI and what it means for my work (it was not fun). It was the kind where you’re lying awake wondering what expertise you actually have left to offer once using AI stops being a skill and starts being a prerequisite for having a job at all.</p><p>Somewhere in that spiral I started asking friends how they actually use it day to day. Everyone said some version of “yeah, of course I use AI.” But when I pushed past that, most of them meant the same thing:</p><blockquote>open a chatbot, type a question, get an answer.</blockquote><p>That’s one way to use it. It is not the only way, and it’s not close to the most useful one. Anthropic’s AI Fluency framework was super helpful in putting this into words and perspective for me.</p><h3><strong>Three modes, not one</strong></h3><p>The framework splits human-AI collaboration into:</p><ul><li><strong>automation </strong>(AI executes a task you hand it),</li><li><strong>augmentation </strong>(you and AI think and build together), and</li><li><strong>agency </strong>(you configure AI to work independently, on your terms by establishing its knowledge and behavior patterns, rather than assigning it one job at a time).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ejr2wAGJnkMUe8wLcgCp4w.png" /></figure><p>Most people I work with default to describing everything as automation, even when what they’re actually doing is augmentation or agency. That’s not a vocabulary nitpick. If you don’t know which mode you’re in, you can’t tell what kind of oversight the situation actually needs.</p><p>AI fluency matters now for the same reason literacy mattered once reading stopped being a specialized skill and became the baseline for participating in anything. The chatbot version of “using AI” my friends described isn’t wrong, it’s just table stakes — the equivalent of being able to sound out words without being able to read for comprehension.</p><blockquote>The gap that actually separates people at work right now isn’t access to AI, everyone has access. It’s whether you can tell the difference between automation, augmentation, and agency, and choose deliberately between them instead of defaulting to whichever one you stumbled into.</blockquote><p>That choice is what determines whether AI makes you faster at the same work or genuinely changes what you’re capable of building.</p><h3><strong>What’s actually happening under the chatbot</strong></h3><p>None of my friends were wrong that they’re “using AI.” They just hadn’t looked at what’s running underneath the box they type into, which makes it hard to imagine using it any other way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gi_r0JCKpjGvFttVjnU3MA.png" /></figure><p><strong>Generative AI</strong> creates new content instead of just sorting or analyzing existing data. The large language models behind it are trained to predict and generate human language, using billions of parameters — mathematical values, tuned during training, that function something like synaptic connections. Getting here took three things arriving at once:</p><ol><li><strong>Algorithms</strong> changed first, with the 2017 transformer architecture giving models a way to track relationships between words across long stretches of text instead of just the last few.</li><li><strong>Data </strong>came next: an explosion of digital text gave models enough raw material to build a genuinely broad map of language and the concepts inside it.</li><li>And none of that mattered without the <strong>computational power </strong>— GPUs, TPUs, distributed clusters — to actually train on data at that scale.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RrAQ-7HNj1_GD9OYi6NJ8g.png" /></figure><p>Put those three together and you get <strong>scaling laws</strong>: the finding that <strong>bigger models, trained on more data with more compute, get better in predictable ways.</strong> The surprising part is what showed up uninvited once they scaled — step-by-step reasoning, adapting to a new task from a few examples, none of it explicitly built in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GJfcvmN-zV7XLPq9g-KExw.png" /></figure><p>Training itself happens in two passes.</p><ol><li><strong>Pre-training</strong> is the model reading billions of examples and learning to predict what word comes next, over and over, until it’s built a working sense of how language and ideas fit together.</li><li><strong>Fine-tuning</strong> comes after — teaching it to follow instructions, be useful, and not generate harmful content, usually with human feedback shaping the process.</li></ol><p>Even after all that, there’s a hard ceiling on how much a model can hold in mind at once: <strong>the context window</strong>, which covers your prompt, its response, and everything else in play at that moment. Push past it and earlier parts of the conversation start falling out of reach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yI_zSFQi-Wx1_r1c0-wuEw.png" /></figure><p>That’s also where the limitations live, not just the capabilities. Yes, a model is versatile across tasks, holds context across a conversation, and can now reach out to external tools mid-task. But it also has a knowledge cutoff, it can hallucinate with total confidence, and it can lose the thread on genuinely complex reasoning. None of that is a flaw to route around. It’s the actual shape of the tool, and <strong>fluency starts with knowing that shape well enough to know when you’re asking it to do something it’s structurally bad at.</strong></p><h3><strong>The 4D framework — the core of AI Fluency</strong></h3><p>AI Fluency means engaging with AI in ways that are effective, efficient, ethical, and safe. Underneath the three modes sit four competencies, and this is where the course earned its place in my notes folder. Understanding the nuances of each competency is such a meta-mindset shift you don’t realize you need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PiZ7IH3IjfUc_PQQLfR1rw.png" /></figure><h4><strong>Delegation</strong></h4><p>Delegation is the decision layer — what you hand off, what you build together, and what you keep entirely to yourself. The course breaks it into three moves.</p><ul><li><strong>Problem Awareness</strong> comes first: understanding your actual goal before AI enters the picture at all, because you can’t delegate a problem you haven’t defined.</li><li><strong>Platform Awareness</strong> is knowing what the tool in front of you can and can’t do — a Copilot Studio agent and a pro-code one fail in different places, and pretending otherwise is how you end up debugging the wrong layer.</li><li><strong>Task Delegation</strong> itself, the actual distribution of work between you and the AI. Most people skip straight to that third step and wonder why the output feels off. The problem was usually upstream.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pi8CyScqi0QhiGJZ3nYQpQ.png" /></figure><p>Effective delegation requires both domain expertise and an understanding of AI capabilities. The most effective applications combine human and AI strengths, with humans providing critical thinking, judgment, creativity, and ethical oversight. <strong>The goal isn’t to automate everything, but to create the most effective human-AI partnership for any given task or goal.</strong></p><h4><strong>Description</strong></h4><p><strong>Description</strong> is where most prompt-engineering advice lives, but the course splits it in a way that’s more useful than “write better prompts.”</p><ul><li><strong>Product Description</strong> is the output spec — format, audience, length, the thing you’d put in a creative brief.</li><li><strong>Process Description</strong> is different: it’s telling the AI <em>how</em> to get there, not just what to deliver, which matters enormously for anything reasoning-heavy.</li><li><strong>Performance Description </strong>is the one everyone forgets — specifying tone and behavior, whether you want the AI to challenge you or support you, concise or expansive. I’d been doing Product Description for a year and calling it prompting. I’d never once specified Performance.</li></ul><p>Prompt engineering is simply the practice of designing effective instructions for AI systems, combining familiar human communication principles with AI-specific considerations. Six foundational prompting techniques:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qN83lOnsRU1eYRBpYyVNHQ.png" /><figcaption>Six foundational prompting techniques</figcaption></figure><h4><strong>Discernment</strong></h4><p><strong>Discernment</strong> flips the lens from what you’re telling the AI to what you do with what it gives back.</p><ul><li><strong>Product Discernment</strong> is the obvious one — is the output actually good, accurate, appropriate for the context.</li><li><strong>Process Discernment</strong> is harder: did the AI’s reasoning hold up, or did it arrive at a right-looking answer through a broken path.</li><li><strong>Performance Discernment</strong> is the one nobody trains for — evaluating whether the AI’s behavior <em>during</em> the collaboration actually served you, independent of whether the final output was fine.</li></ul><p>You can get a good output from a collaboration that went badly. Discernment is supposed to catch that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*lTQmJYqSqJeagpvH3TVTGw.png" /><figcaption>Discernment works hand-in-hand with Description in a continuous feedback loop</figcaption></figure><h4><strong>Diligence</strong></h4><p><strong>Diligence</strong> is the accountability layer, and it’s the one enterprise work makes non-negotiable. This competency ensures you interact with AI responsibly. Ask yourself: Are you willing to take ownership and be accountable for the AI assisted work?</p><ul><li><strong>Creation Diligence </strong>is choosing which AI systems you use and how, deliberately, rather than defaulting to whatever’s already open.</li><li><strong>Transparency Diligence </strong>is being honest about AI’s role in the work with the people who need to know — a very different bar in a personal project than in a client deliverable with my name attached.</li><li><strong>Deployment Diligence </strong>is the sharpest one: actually verifying and standing behind what you ship, not just producing it.</li></ul><p>While the other competencies primarily address effectiveness and efficiency, Diligence addresses ethical and safety aspects that are equally crucial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w4CD8DZlHu5br9KjK5C8-Q.png" /></figure><h3><strong>Where this framework cracks when </strong>pressure-tested</h3><p>Here’s the tension the framework doesn’t fully sit with: <strong><em>Diligence assumes you’re close enough to the work to verify it.</em></strong></p><p>That’s easy in augmentation mode, where you’re in the loop on every exchange. It gets much harder in agency mode — the exact mode I run for several of my deployed agents, where the whole point is that they act without me reviewing every step.</p><p>The framework tells you diligence means “taking ownership for AI-assisted outputs you share with others.” Fair. But at scale, with an agent making dozens of independent calls a day, ownership starts to mean something closer to <em>designing the guardrails in advance</em>, not reviewing after the fact. The course doesn’t quite say that part out loud, and I think it’s the part that matters most for anyone doing this work inside an enterprise rather than a single chat window.</p><p>Discernment has the same wrinkle. Evaluating “is this output correct” is one skill. Evaluating “did the AI reason its way here correctly, and is its behavior in this collaboration actually serving me” is a different, harder one — and it’s the one nobody trains for, because it assumes you already know what good reasoning looks like in the domain you’ve handed over.</p><p>I came out of this course with a cleaner mental model and a slightly less comfortable one. Cleaner, because I can now name what I’m actually doing with each agent I run instead of calling all of it “using AI.” Less comfortable, because naming it made obvious how much of my current diligence is reactive — checking outputs after they land — when the agents I’ve built for agency mode need diligence baked into the architecture, not bolted on after deployment.</p><p>That’s the redesign I’m doing next. Not the prompts. The guardrails.</p><p><em>Next up: the certification’s seventh course: Building with the Claude API. AI Fluency is the going to be the most precious skill. This course was a great way to learn how to think about working with AI and build that foundation. Looking forward to the next one.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ad21f311d14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Claude Code Doesn’t Need Your Trust. It Needs Your Hooks.]]></title>
            <link>https://tanbuildsai.medium.com/claude-code-doesnt-need-your-trust-it-needs-your-hooks-ff32acbcf3ab?source=rss-3455b42172c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff32acbcf3ab</guid>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <dc:creator><![CDATA[TanBuildsAI]]></dc:creator>
            <pubDate>Wed, 09 Sep 2026 18:34:28 GMT</pubDate>
            <atom:updated>2026-09-26T10:33:26.627Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Notes from course #5 of my Claude Certified Architect track: Claude Code in Action. See previous: </em><a href="https://tanbuildsai.medium.com/the-delegation-problem-every-pm-has-and-what-cowork-actually-does-about-it-1cbc854f8ffb?sharedUserId=tanbuildsai"><em>Introduction to Claude Cowork</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r_NHOO5de8zDnqZTpUv_fA.png" /></figure><p>Course five of my Claude Certified Architect track just wrapped, and it’s the first one that made me rethink how I actually work with agents day to day, not just how I explain them to stakeholders.</p><blockquote>The thesis of Claude Code in Action, if I had to compress it: <strong>the interesting design problem isn’t getting Claude to do the work. It’s deciding how much of the work you’re willing to not watch.</strong></blockquote><h3>Scope first, Steer second</h3><p>Before Claude writes a line of code, <strong>plan mode</strong> lets it read and propose without touching anything. That’s the scoping step, and skipping it is how you end up debugging a refactor you never actually asked for.</p><p>Once it’s running, you steer. This is where the rewind menu earns its keep — double-tap escape on an empty prompt and you get four ways to correct course:</p><ul><li>roll back code and conversation together,</li><li>just the chat,</li><li>just the files, or</li><li>summarize everything before or after a given checkpoint.</li></ul><p>That last pair matters more than it looks. “Summarize up to here” compresses a long setup phase while leaving the actual implementation intact. I’ve had sessions where the first twenty minutes were me and Claude negotiating requirements — no reason to keep dragging that around in context once the work starts.</p><p>Compaction follows the same logic. Running bare /compact throws away your old messages and keeps whatever the summary decided was important — which may not be what <em>you</em> decided was important.</p><p><strong>Tell it what to preserve. Add instructions after the </strong><strong>/compact command to tell Claude how to summarize.</strong></p><h3>CLAUDE.md is a rulebook, not a contract</h3><p>Here’s the reframe that stuck with me:</p><blockquote>CLAUDE.md is guidance Claude follows, not configuration it’s bound to. A hook is code that runs and can actually block an action. Different category entirely.</blockquote><p>That distinction changes where you put things.</p><ul><li>Conventions — naming, file structure, the stuff that’s always true — belong in <strong>CLAUDE.md</strong>.</li><li>Procedures tied to a specific kind of task belong in a <strong>skill</strong>.</li><li>Anything Claude must never be able to skip belongs in a <strong>hook</strong>.</li></ul><p>And the file itself should be lean. Emphasis is a budget, not a decoration — spend it on the two or three rules that actually hurt when broken, not on everything you can think of. <strong>Imports keep a long file organized, but they don’t shrink what gets loaded; Claude expands them inline at launch. </strong>Organizing isn’t the same as reducing.</p><blockquote>Emphasis is a budget — Spend it on the two or three rules that really hurt when they get broken, and let the rest sit at normal volume.</blockquote><p>This file can live in four places, and Claude loads all of them together at launch:</p><ul><li>Managed policy — the org-level file your platform team controls. You can’t exclude it, so org policy is always in play.</li><li>User — your personal preferences that follow you across every project on your machine.</li><li>Project — the file shared with your team, checked into the repo.</li><li>Local — ignored by git. Your personal notes for this one repository only.</li></ul><h3>The classifier that watches intent, not correctness</h3><p>Auto mode is the one I’ll actually reach for on real work. Claude runs unsupervised, but every action passes through a second model first — a classifier, which is essentially just a smaller, faster model trained to make one kind of judgment call instead of doing the work itself. Think of it as a reviewer standing next to Claude, not doing the task, just watching each move before it’s allowed to happen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YG3L4JKZHvRg50wYICpa6Q.png" /><figcaption>The six permission modes<br>Each mode draws a different line between what runs freely and what needs your sign-off.</figcaption></figure><p>What it’s watching for: force pushes, production deploys, sensitive data heading to an external endpoint. Anything that escalates past what you actually asked for.</p><p>The catch is right there in how narrow its job is. It judges intent, not whether the code works. Ask Claude to refactor auth and it may ship broken auth. The classifier would waves it through because broken isn’t dangerous — it’s just wrong. That’s the real argument for <strong>pairing auto mode with a stop hook that runs your test suite</strong>. The classifier catches Claude doing something reckless mid-run. The test suite catches Claude finishing a run with something that doesn’t actually work. Two different failure modes, two different checks. Neither substitutes for the other.</p><p>Bypass permissions belongs only inside isolated containers and VMs.</p><h3>Routines, headless mode, and knowing which one you need</h3><p>For anything recurring, start with a <strong>routine: a saved prompt, a repo, and a trigger</strong> (eg. cron, an HTTP call, or a GitHub event) bundled together and run on Anthropic’s infrastructure. No script, nothing to host. It’s still a research preview, capped at hourly for scheduled runs, and each execution starts from a fresh clone of your default branch that can only push to claude/-prefixed branches unless you loosen that per repo.</p><blockquote>Routine: Every Monday at 9am, kick off a prompt against your repo that checks for outdated dependencies and opens a PR if it finds any. No script, no server — you set it up once at claude.ai/code/routines or run the /schedule command and forget it.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iI4Eo2hjQQ50FrMPkfnLPA.png" /></figure><p><strong>Headless mode</strong> is what you drop into when the job needs your own environment or your own logic wrapped around it — claude -p (short for --print) piping in and out like any shell tool, skipping auto-discovery of hooks, skills, and CLAUDE.md entirely so it starts faster and behaves predictably. Pair it with a JSON schema when you need structured output back instead of prose, and --resume when a plan produced in one pass needs to be executed in a second.</p><blockquote>Headless mode: Your CI pipeline needs to summarize a diff, pipe the result into a Slack message, and fail the build if the summary flags a breaking change. That logic — the piping, the conditional fail — lives in your own script, so you reach for claude -p and wire it into the pipeline yourself.</blockquote><p>There are two ways Claude shows up on GitHub, and they do different jobs.</p><ol><li><strong>Code Review</strong> is for whenever a pull request opens, Claude reads the code and leaves comments — right on the lines that matter, like a colleague marking up a draft. It never approves the PR and never blocks it from merging; that decision stays with a person. It also doesn’t fix anything itself. If you agree with a comment, you pull the code down and fix it yourself, using a command called /code-review --fix.</li><li><strong>The GitHub Action</strong> is for when you want Claude to actually <em>do</em> something, not just comment. Say someone leaves a PR comment saying “implement this,” or you want a report generated every night on a schedule — that’s not reviewing anymore, that’s a task. The Action is what runs Claude as part of an automated job like that. Because there’s no person watching it in real time, you set a hard limit on how many steps it’s allowed to take (--max-turns), so it can&#39;t get stuck looping forever.</li></ol><h3>Judgement is forever yours.</h3><p>None of this replaces judgment, and the course was pretty direct about that: <strong>keep unsupervised runs in auto mode, not bypass permissions</strong>. Read the diff yourself. Turn tests into a hook instead of a habit. Get a second opinion on anything with real stakes.</p><p>I’ve sat and watched an agent work through a multi-step migration in real time before, convinced that watching <em>was</em> the verification step. It isn’t. Watching tells you what Claude tried. It doesn’t tell you what actually held up once the run ended — that’s what the hooks are for.</p><h3><strong>How to Micro-Manage Less</strong></h3><p>Describe what ‘DONE’ means</p><h4>Goal</h4><p>Sometimes you know what finished looks like but not the path to it. That’s what /goal is for: you describe the completion condition, and Claude keeps working across turns until a fast evaluator confirms it&#39;s actually met. Run /goal clear to cancel it.</p><h4>Loop</h4><p>Loop is the sibling command for a different shape of problem: work that depends on something outside your control changing. It runs a prompt on an interval — fixed or self-paced — so you can point it at a CI run or a deploy and have it act the moment the state shifts.</p><p>How is this different from Routines or Headless mode? Loop happens inside a session you’re already in. You’re sitting there (or Claude is running) and it keeps re-checking something — like polling a CI run — between turns of the same conversation. It’s temporary: press escape and it stops, and it doesn’t outlive the session.</p><h4>Worktrees</h4><p>Worktrees solve a third problem entirely: running more than one agent on the same codebase without them fighting over the same files. Two Claude sessions editing in parallel is two steering wheels in one car — unsafe, and it ends in conflicts.</p><p>A worktree gives each session its own independent copy of the file tree, so nothing gets clobbered, and it’s automatically cleaned up when the session exits. A .worktreeinclude file at the repo root lists git-ignored files to copy into each worktree. This is useful for things like an environment variable file or a local config that you need in every worktree but don&#39;t want to commit to version control.</p><h4>Verification Skill</h4><p>A skill folder can hold more than instructions. The folder around it can carry other things, and this is what makes skills powerful for verification.</p><ul><li>Drop a reference.md next to the skill for detailed material, then link to it from skill.md. Claude only reads it when it actually needs that depth.</li><li>Put scripts in the folder too. Claude executes them rather than loading their contents into context. That means a skill can carry its own tooling, like a check.sh that runs all the gates.</li></ul><h4>Multi Step Automation</h4><p>For work that happens across multiple steps, you don’t have to cram everything into one command. Capture the session’s ID from the JSON output and resume it later:</p><pre>claude --resume &quot;$(jq -r .session_id /tmp/plan.json)&quot;</pre><p>One script kicks off the work. Another resumes it later with full context.</p><h4>Deterministic runs for CI</h4><p>The --bare flag gives you deterministic mode. It&#39;s the right choice when you&#39;re running Claude Code inside a pipeline and you want repeatable, predictable output rather than anything that varies run to run.</p><h3>Keep Your Code Hooked</h3><p>Hook is deterministic code that runs at a fixed point in the loop so it can guarantee behavior. Claude Code fires around 30 hook events over the course of a session.</p><ul><li><strong>PreToolUse </strong>fires before a tool call. This is your enforcement primitive. It’s the one that can stop something before it happens.</li><li><strong>PostToolUse </strong>fires after a successful tool call. This is usually where auto-formatting or an auto-lint goes.</li><li><strong>Stop </strong>fires when Claude wants to end its turn. You can refuse and say “no, you’re not done yet” if some condition isn’t met. There’s a matching SubagentStop for when a sub-agent finishes.</li><li><strong>PreCompact </strong>and <strong>PostCompact </strong>fire before and after compaction.</li><li><strong>InstructionsLoaded </strong>fires when a CLAUDE.md or rule file loads. Handy for auditing what actually made it into context.</li><li><strong>SessionStart </strong>fires at the start and primes the environment. Use the startup source if you only want it on fresh starts.</li></ul><h3>Here’s the quick decision guide:</h3><ul><li>Routines are the default for repeat work. They run on Anthropic’s infrastructure with nothing for you to host.</li><li>Headless mode with -p is for when the job needs your pipeline and you want to pipe data through a script.</li><li>--bare is for when CI needs the same results every single run.</li><li>The Agent SDK is for when the work belongs inside your own product.</li></ul><p>Start with routines. Drop down the spectrum only when the job actually needs the extra control.</p><ul><li>For PR reviews, take the managed path. Enable Code Review, let the GitHub app post inline findings, and apply fixes locally with /code-review --fix.</li><li>Reach for the action when the job is more than review. Use /install-github-app for setup, one workflow for @claude mentions, one for cron, and all the tuning lives in claude_args.</li></ul><p>Start with the managed service. Move to the action the moment you need Claude to actually do something in CI, not just comment on it.</p><h3>General best practices:</h3><p>Keep unattended runs in auto mode rather than bypass permissions. Make the check as serious as the run was unsupervised:</p><ul><li>Read the diff yourself.</li><li>Turn the tests into a hook that gates the turn.</li><li>Verify headless runs by their JSON result and exit code.</li><li>Get a cold second opinion on anything that matters.</li></ul><p>Next up: the certification’s sixth course: <a href="https://tanbuildsai.medium.com/what-my-ai-agents-taught-me-about-being-fluent-not-just-fast-1ad21f311d14?sharedUserId=tanbuildsai">AI Fluency Framework &amp; Foundations</a>. This course was a super practical approach to using Claude Code. As an intermediate coder, it was very helpful to contextualize technical details in practical ways. Happy Claude Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff32acbcf3ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>