Claude Certified Developer · Foundations

Module 5: Make it reusable

Study notes written by Sanjay Shah. Not official Anthropic material. Facts marked "check before relying on it" may have changed.

Practice this module

On this page

Claude Developer (Foundations) · "Ship your first Claude feature to production" · study notes

Facts checked against Anthropic's public docs (including the Amazon Bedrock and Google Cloud platform pages) on 2026-11-25. Platform feature lists change often. Anything we could not confirm is marked check before relying on it.


What you'll be able to do

  • Package the triage feature as a module with a stable interface that other teams install instead of copying.

  • Version prompts, schemas and model IDs like code, and gate changes with the eval from Module 4.

  • Write a one-page requirements doc and plan the feature's lifecycle, including model updates and retirement.

  • Deploy it as a small container with configuration from the environment and the key from a secret store.

  • Choose between the Claude API, Amazon Bedrock and Google Cloud, and switch between them through config.

  • Draw the feature's trust boundaries on one page and put a check on every crossing.

  • Contribute an improvement back so every team benefits.

Where we are in the running example

The triage feature ships and passes its gate. Then three other teams copy triage.ts into their own repos. A month later there are three slightly different copies with three different bugs, and a prompt fix in one never reaches the others. Copy-paste is not reuse. This module turns the feature into something people install, version and trust.


Part 1: Packaging for reuse

Extract the feature into one package with a small, typed interface:

Text
packages/triage/
├── src/index.ts        # triage(create, input, opts)
├── src/providers.ts    # makeCreate(provider)
├── src/schema.ts       # JSON schema + Zod validator
├── prompts/triage.v3.md
├── CHANGELOG.md
└── package.json        # "name": "@acme-internal/triage", "version": "3.1.0"

(@acme-internal is the fake company scope from our demo data.)

TypeScript
// packages/triage/src/index.ts
import type Anthropic from "@anthropic-ai/sdk";
import { readFileSync } from "node:fs";
import { TRIAGE_JSON_SCHEMA, Triage, type TriageResult } from "./schema.js";
import type { CreateMessage } from "./providers.js";

export const PROMPT_VERSION = "triage.v3";
const SYSTEM = readFileSync(new URL(`../prompts/${PROMPT_VERSION}.md`, import.meta.url), "utf8");

export interface TriageInput { ticket: string; accountSummary?: string }
export interface TriageOptions { model: string; effort?: "low" | "medium" | "high" }

export async function triage(create: CreateMessage, input: TriageInput, opts: TriageOptions): Promise<TriageResult> {
  const msg = await create({
    model: opts.model,
    max_tokens: 4096,
    system: SYSTEM,
    output_config: { effort: opts.effort ?? "low", format: { type: "json_schema", schema: TRIAGE_JSON_SCHEMA } },
    messages: [{ role: "user", content: `<ticket>${input.ticket}</ticket>\n<account>${input.accountSummary ?? ""}</account>` }],
  });
  if (msg.stop_reason !== "end_turn") throw new Error(`triage stopped: ${msg.stop_reason}`);
  const text = msg.content.flatMap((b: Anthropic.ContentBlock) => (b.type === "text" ? [b.text] : [])).join("");
  return Triage.parse(JSON.parse(text)); // validate again on our side of the boundary
}

Design rules for a reusable Claude module:

  • The caller passes the client (here, a create function). No hidden global client, no key read inside the library, so every team keeps control of credentials, retries and tracing.

  • Typed input and output. Callers depend on TriageResult, not on prompt wording.

  • The model ID is an option, not a constant. Each team can pin it, and you can move it without a code change.

  • Validate the output again in the package, even with structured outputs. The package boundary is a trust boundary too.

  • The README has one example and one table of options. If it needs more, the interface is too big.


Part 2: Versioning prompts, schemas and models

A prompt is code that runs on a model. Treat it that way:

  • Prompts live in versioned files (prompts/triage.v3.md), never edited in place. A new behaviour gets a new file; the old one stays for rollback.

  • The model ID lives in config (CLAUDE_MODEL=claude-opus-5-5), set per environment. On the Claude API, IDs such as claude-opus-5-5 are pinned snapshots, so the model doesn't change under you; moving to a new model is a deliberate change.

  • Semantic versioning, applied to behaviour:

ChangeVersion bumpWhy
Typo or wording fix with no eval changePatch (3.1.0 → 3.1.1)Same behaviour
Prompt change that moves the eval score, or a new default modelMinor (3.1 → 3.2)Behaviour changed, interface didn't
Schema change (field added, renamed or removed)Major (3 → 4)Callers' code may break
  • The eval runs in CI on every pull request that touches prompts, schema or model config:

YAML
# .github/workflows/eval.yml
name: eval
on:
  pull_request:
    paths: ["packages/triage/prompts/**", "packages/triage/src/schema.ts", "config/models.json"]
jobs:
  eval:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22 }
      - run: npm ci
      - run: npm test           # stubbed client, free
      - run: npm run eval       # real calls; fails the job below the gate threshold
        env:
          ANTHROPIC_API_KEY: ${{ secrets.EVAL_API_KEY }} # a key in its own workspace with a low spend limit

Give the CI key its own workspace and a spend limit, so a looping job can't run up a bill. Only run the paid eval on paths that can change behaviour.


Part 3: Requirements and lifecycle

One page of requirements

Before anyone builds, write down what the feature does and what it never does:

Markdown
# Ticket triage: requirements (v3)
Does: classify (category, priority, needs_human), summarise, draft a reply for approval.
Never: sends anything to a customer; moves money; reads another tenant's data;
       stores ticket text outside the help-desk database.
Inputs: ticket text, attachments (PNG/JPEG/PDF), account summary for the same tenant.
Quality bar: eval pass rate ≥ 95%; all injection cases pass.
Cost bar: ≤ $0.01 per ticket on average at current prices.
Latency bar: classification p95 < 4 s; draft starts streaming < 2 s.
Owner: support-platform team. Escalation: on-call channel.

The "never" list is the most useful part: it becomes the trust boundaries (Part 6) and the Stop items in the gate.

The lifecycle loop

Requirements → build → eval gate → release → monitor → (improve or retire), and around again.

  • Monitor: the trace lines from Module 4 give you cost per ticket, latency, refusal and truncation rates, and cache hit rate. Watch for drift: a slow change in categories or a rising needs_human rate can mean the world changed, not the model.

  • Model updates: Anthropic publishes deprecation and retirement dates. For example, the docs commit to Claude Opus 5.5 staying available on Anthropic-operated platforms until not sooner than 22 September 2027. Partner platforms (Bedrock, Google Cloud) set their own dates. When a new model arrives, run the full eval on the new ID, compare cost per completed task, then switch through config, with a release note.

  • Retire on purpose: when the feature is replaced, remove the prompts, keys and data paths it used. Old agents with live credentials are a security risk.


Part 4: Deployment

A tiny HTTP service around the package:

TypeScript
// service/server.ts
import http from "node:http";
import { triage } from "@acme-internal/triage";
import { makeCreate } from "@acme-internal/triage/providers";

const { create, model } = makeCreate(process.env.CLAUDE_PROVIDER);
const MODEL = model(process.env.CLAUDE_MODEL ?? "claude-opus-5-5");

http.createServer(async (req, res) => {
  if (req.method === "GET" && req.url === "/health") return void res.end("ok");
  if (req.method !== "POST" || req.url !== "/triage") return void res.writeHead(404).end();
  let body = "";
  for await (const chunk of req) {
    body += chunk;
    if (body.length > 200_000) return void res.writeHead(413).end(); // cap input size
  }
  try {
    const result = await triage(create, JSON.parse(body), { model: MODEL });
    res.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify(result));
  } catch (err) {
    console.error(err);
    res.writeHead(502).end(JSON.stringify({ error: "triage failed" })); // no internals to the caller
  }
}).listen(Number(process.env.PORT ?? 8080));
Dockerfile
# service/Dockerfile
FROM node:22-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
USER node
EXPOSE 8080
CMD ["node", "dist/server.js"]

Deployment rules:

  • All config from the environment: provider, model, region, port. The same image runs in staging and production.

  • The key comes from a secret store (your cloud's secret manager), injected at runtime. Never bake it into the image, never put it in .env files in the image, and never log it.

  • Health check for the orchestrator, non-root user, input size cap.

  • Authentication in front of /triage, and the tenant taken from the authenticated caller, not from the request body. (Omitted above to keep the sample short; it's a Stop item for production.)

  • Roll out gradually: a small share of traffic on the new version, compare traces and eval results, then go wider. Keep the previous prompt and model ID ready for rollback.


Part 5: Claude API vs Amazon Bedrock vs Google Cloud

The same models are offered on several platforms. The request body is nearly the same; what changes is who bills you, how you authenticate, where data is processed, and which features exist.

Claude APIAmazon BedrockGoogle Cloud (Google managed, formerly "Vertex AI")
Who operates and billsAnthropicAWSGoogle Cloud
TypeScript clientAnthropic from @anthropic-ai/sdkAnthropicBedrockMantle from @anthropic-ai/bedrock-sdkAnthropicVertex from @anthropic-ai/vertex-sdk
AuthAPI key (or workload identity federation)AWS IAM credentials (SigV4), or a Bedrock bearer tokenGoogle Application Default Credentials
Model IDclaude-opus-5-5anthropic.claude-opus-5-5claude-opus-5-5
Location choiceOptional geography controls (inference_geo)Global or regional endpoints; regional costs 10% moreGlobal, multi-region (us, eu) or regional; multi-region and regional cost 10% more
Not available (as of 2026-11-25)(Reference platform)Message Batches, Files API, URL image/document sources, server tools (code execution, web search, web fetch), MCP connector, Agent Skills, server-side fallback, Managed AgentsMessage Batches, Files API, URL sources, code execution, web fetch, MCP connector, Agent Skills, server-side fallback, Managed Agents

Notes on the table:

  • Bedrock's Messages API endpoint (bedrock-mantle) is what AnthropicBedrockMantle calls. The older bedrock-runtime endpoint (InvokeModel / Converse) is a separate path, and some models (Claude Fable 5.2) are only served there. Check before relying on it: which endpoint serves your model.

  • Google Cloud now has two Claude offerings: "Google managed" (the Vertex AI path, AnthropicVertex) and "Anthropic managed" (AnthropicGoogleCloud from @anthropic-ai/google-cloud-sdk), which has more Anthropic features. There is also Claude Platform on AWS, operated by Anthropic and billed through AWS Marketplace, and Microsoft Foundry. Check before relying on it: these are newer offerings, so read each platform's page for current features.

  • Rate limits and quotas on partner platforms are managed by that cloud, not by your Anthropic tier.

  • Always check feature availability per platform before you depend on a feature. Our M2 batch job and our M4 server-side fallback both need a different plan on Bedrock or Google Cloud (Google managed).

Switching providers through config

TypeScript
// packages/triage/src/providers.ts
import Anthropic from "@anthropic-ai/sdk";
import { AnthropicBedrockMantle } from "@anthropic-ai/bedrock-sdk";
import { AnthropicVertex } from "@anthropic-ai/vertex-sdk";

export type CreateMessage = (p: Anthropic.MessageCreateParamsNonStreaming) => Promise<Anthropic.Message>;

export function makeCreate(provider = "anthropic"): { create: CreateMessage; model: (id: string) => string } {
  switch (provider) {
    case "anthropic": {
      const c = new Anthropic();
      return { create: (p) => c.messages.create(p), model: (id) => id };
    }
    case "bedrock": {
      const c = new AnthropicBedrockMantle({ awsRegion: process.env.AWS_REGION });
      return { create: (p) => c.messages.create(p), model: (id) => `anthropic.${id}` };
    }
    case "vertex": {
      const c = new AnthropicVertex({ projectId: process.env.GCP_PROJECT_ID, region: "global" });
      return { create: (p) => c.messages.create(p), model: (id) => id };
    }
    default:
      throw new Error(`Unknown CLAUDE_PROVIDER: ${provider}`);
  }
}

Each client uses its own platform's credentials, so no Anthropic key is needed on Bedrock or Google Cloud. Model ID mapping is in one place. Check before relying on it: the three clients' TypeScript types line up in current SDK versions, but if your installed versions differ, a cast at this one boundary is the place to fix it.

How I choose, in one line: if your company already runs on one cloud and needs its billing, IAM and data boundary, use that cloud's offering and accept the feature gaps; otherwise start on the Claude API, which gets new features first.


Part 6: Trust boundaries on one page

Draw every place where data crosses from one level of trust to another. Each arrow that crosses a boundary gets a check.

Text
 Customer ──ticket, attachments──▶ [1] Help-desk API ──session tenant──▶ Triage service
 (untrusted)                        authN, size limits                   │
                                                                         │ prompt with <ticket> as data
                                                                         ▼
                                                                  Claude (model output = untrusted)
                                                                         │ tool_use requests
                                                                         ▼
                                                    [2] Tool layer: tenant set by server,
                                                        read-only, schema-validated
                                                                         │
                                                                         ▼
                                                    [3] Tenant DB (row-level security by tenant_id)
                                                                         
 Model output ──▶ [4] Output checks (schema, amounts vs invoices, links stripped, HTML escaped)
              ──▶ [5] Human approver ──▶ Customer
CrossingCheckFrom module
Customer → our APIAuthentication, size limits, tenant from the sessionM5
Our code → modelUntrusted data in tags; no secrets or other tenants' data in contextM1, M4
Model → toolsStrict schemas; tenant and limits set by the server; least privilegeM2, M3
Tools → databaseTenant filter enforced in the database too (row-level security), not just in codeM3
Model → our outputStructured output, re-validated; amounts checked; output escapedM2, M4
Our output → customerHuman approval for replies and refundsM4
Claude Code → repoPermission rules, hooks, no push to mainM3

Two principles make the diagram work: treat everything the model produces as untrusted input (it may have been steered by the ticket), and put enforcement at the layer that can't be talked out of it (the database, the tool code, a human), not only in the prompt.


Part 7: Contributing back

Team B finds a bug: Hinglish tickets ("payment fail ho gaya, please check") are classified as other. Instead of patching their copy, they contribute back:

  1. An eval case first, which fails on the current version.

  2. The fix: a new prompt file triage.v4.md with two Hinglish examples, plus any code change.

  3. The full eval run: 41/42, up from 39/41, with no regressions.

  4. A changelog entry: 3.2.0: Hinglish tickets classified correctly (eval +2). Prompt triage.v4.

  5. A pull request using a template that requires the eval result:

Markdown
<!-- .github/pull_request_template.md -->
## What changed
## Eval result (before → after)
## Prompt / model / schema version bumped?
## New eval cases added for this change

Every team gets the fix with npm update. The eval case stops the bug from coming back.

Sharing Claude Code gates as a plugin

The hooks, skill and subagent from Module 3 are reusable too. Package them as a Claude Code plugin: a folder with a .claude-plugin/plugin.json manifest (only name is required) and the components beside it. Publish it through a plugin marketplace, so other repos install it with /plugin install <plugin>@<marketplace> and get the same tenant-SQL guard and secret-file guard. Check before relying on it: the exact folder layout for plugin hooks and the marketplace commands, in the current plugin docs.


Common mistakes and how to spot them

MistakeHow to spot itFix
Copy-pasted Claude code across teamsThe same bug fixed three times; prompts drift apartOne package with a stable interface
The library creates its own client and reads the keyTeams can't add tracing, retries or another providerThe caller passes the client or create function
Prompts edited in place"It changed and nobody knows when"Versioned prompt files + changelog
Model ID hard-coded in many filesA model migration touches 20 filesOne config value per environment
No eval in CI for prompt changesRegressions found by customersPath-filtered eval job with its own low-limit key
Key baked into the Docker imageKey visible in image layersSecret store at runtime
Tenant taken from the request bodyOne caller can read another tenant's ticketsTenant from the authenticated caller
Assuming every feature exists on every platformBatch job or fallback fails after a move to BedrockCheck each platform's feature list first
Using first-party model IDs on BedrockModel-not-found errorsMap IDs in one place (anthropic. prefix on Bedrock)
Trusting model output because "it's our model"Injected links or amounts reach customersTreat output as untrusted; validate and escape
Enforcing tenancy only in the promptRare cross-tenant answersEnforce in tools and in the database
Fixing another team's bug only in your copyThe bug returns elsewhereEval case + fix + changelog + PR upstream

Remember

  1. Copy-paste is not reuse: one package, typed input and output, client passed in.

  2. Prompts are versioned files; model IDs are config; changes get changelog entries.

  3. Semver by behaviour: eval-moving prompt change = minor, schema change = major.

  4. The eval runs in CI on prompt, schema and model changes, with its own low-limit key.

  5. Requirements say what the feature never does; that list becomes your Stop items.

  6. Re-run evals on a new model ID before switching; retire old credentials and prompts.

  7. Containers take all config from the environment and the key from a secret store.

  8. Bedrock: AnthropicBedrockMantle, IAM auth, anthropic. model IDs; Google Cloud (Google managed): AnthropicVertex, ADC.

  9. Check feature availability per platform: batches and server-side fallback aren't on Bedrock or Google Cloud (Google managed).

  10. Draw trust boundaries; every crossing gets a check, and model output is untrusted.


Practice: mcq/module-05.md · Previous: Module 4 · Mock exam: mcq/mock-exam.md · Course home: README.md

↑ ↓ navigate · ↵ select · esc close