Claude Certified Developer · आधारभूत
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.
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:
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.)
// 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
createfunction). 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 asclaude-opus-5-5are pinned snapshots, so the model doesn't change under you; moving to a new model is a deliberate change.Semantic versioning, applied to behaviour:
| Change | Version bump | Why |
|---|---|---|
| Typo or wording fix with no eval change | Patch (3.1.0 → 3.1.1) | Same behaviour |
| Prompt change that moves the eval score, or a new default model | Minor (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:
# .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 limitGive 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:
# 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_humanrate 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:
// 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));# 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
.envfiles 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 API | Amazon Bedrock | Google Cloud (Google managed, formerly "Vertex AI") | |
|---|---|---|---|
| Who operates and bills | Anthropic | AWS | Google Cloud |
| TypeScript client | Anthropic from @anthropic-ai/sdk | AnthropicBedrockMantle from @anthropic-ai/bedrock-sdk | AnthropicVertex from @anthropic-ai/vertex-sdk |
| Auth | API key (or workload identity federation) | AWS IAM credentials (SigV4), or a Bedrock bearer token | Google Application Default Credentials |
| Model ID | claude-opus-5-5 | anthropic.claude-opus-5-5 | claude-opus-5-5 |
| Location choice | Optional geography controls (inference_geo) | Global or regional endpoints; regional costs 10% more | Global, 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 Agents | Message 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 whatAnthropicBedrockMantlecalls. The olderbedrock-runtimeendpoint (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" (AnthropicGoogleCloudfrom@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
// 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.
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| Crossing | Check | From module |
|---|---|---|
| Customer → our API | Authentication, size limits, tenant from the session | M5 |
| Our code → model | Untrusted data in tags; no secrets or other tenants' data in context | M1, M4 |
| Model → tools | Strict schemas; tenant and limits set by the server; least privilege | M2, M3 |
| Tools → database | Tenant filter enforced in the database too (row-level security), not just in code | M3 |
| Model → our output | Structured output, re-validated; amounts checked; output escaped | M2, M4 |
| Our output → customer | Human approval for replies and refunds | M4 |
| Claude Code → repo | Permission rules, hooks, no push to main | M3 |
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:
An eval case first, which fails on the current version.
The fix: a new prompt file
triage.v4.mdwith two Hinglish examples, plus any code change.The full eval run: 41/42, up from 39/41, with no regressions.
A changelog entry:
3.2.0: Hinglish tickets classified correctly (eval +2). Prompt triage.v4.A pull request using a template that requires the eval result:
<!-- .github/pull_request_template.md -->
## What changed
## Eval result (before → after)
## Prompt / model / schema version bumped?
## New eval cases added for this changeEvery 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
| Mistake | How to spot it | Fix |
|---|---|---|
| Copy-pasted Claude code across teams | The same bug fixed three times; prompts drift apart | One package with a stable interface |
| The library creates its own client and reads the key | Teams can't add tracing, retries or another provider | The 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 files | A model migration touches 20 files | One config value per environment |
| No eval in CI for prompt changes | Regressions found by customers | Path-filtered eval job with its own low-limit key |
| Key baked into the Docker image | Key visible in image layers | Secret store at runtime |
| Tenant taken from the request body | One caller can read another tenant's tickets | Tenant from the authenticated caller |
| Assuming every feature exists on every platform | Batch job or fallback fails after a move to Bedrock | Check each platform's feature list first |
| Using first-party model IDs on Bedrock | Model-not-found errors | Map IDs in one place (anthropic. prefix on Bedrock) |
| Trusting model output because "it's our model" | Injected links or amounts reach customers | Treat output as untrusted; validate and escape |
| Enforcing tenancy only in the prompt | Rare cross-tenant answers | Enforce in tools and in the database |
| Fixing another team's bug only in your copy | The bug returns elsewhere | Eval case + fix + changelog + PR upstream |
Remember
Copy-paste is not reuse: one package, typed input and output, client passed in.
Prompts are versioned files; model IDs are config; changes get changelog entries.
Semver by behaviour: eval-moving prompt change = minor, schema change = major.
The eval runs in CI on prompt, schema and model changes, with its own low-limit key.
Requirements say what the feature never does; that list becomes your Stop items.
Re-run evals on a new model ID before switching; retire old credentials and prompts.
Containers take all config from the environment and the key from a secret store.
Bedrock:
AnthropicBedrockMantle, IAM auth,anthropic.model IDs; Google Cloud (Google managed):AnthropicVertex, ADC.Check feature availability per platform: batches and server-side fallback aren't on Bedrock or Google Cloud (Google managed).
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