Learn > Claude > Claude Platform 101

Claude Platform 101

Build app trên Claude Developer Platform từ first-principles: API request, agent loop, tool use, built-in tools/Skills/MCP, managed agents & deployment.

  • Claude Developer Platform là hạ tầng giúp tương tác với Claude lập trình qua API, SDK thay vì chat giao diện web.
  • Hệ thống gồm 3 lớp xếp chồng: Primitives (Messages API, tool, MCP), Infrastructure (managed agents, observability) và Controls (evals, dashboards).
  • Giúp dịch chuyển tư duy từ một chatbot đơn thuần ('hỏi Claude') sang tích hợp sâu AI như một component của sản phẩm ('Claude là một phần của sản phẩm').

TL;DR — Claude Developer Platform là hạ tầng lập trình của Anthropic. Công thức vận hành cốt lõi: build với primitives, scale trên infrastructure, run với control. Nền tảng giúp lập trình viên dịch chuyển từ việc hỏi đáp đơn thuần sang tích hợp sâu AI như một thành phần (component) cốt lõi của sản phẩm.


1. Claude Developer Platform là gì?

Claude Developer Platform là hạ tầng của Anthropic dành cho việc lập trình và tích hợp các mô hình Claude vào mã nguồn (programmatically). Thay vì trò chuyện thủ công với Claude trên giao diện trình duyệt web, tôi gửi các structured requests (yêu cầu có cấu trúc) từ code của mình và nhận về structured responses (phản hồi có cấu trúc) từ hệ thống.

Phương thức này mang lại quyền kiểm soát tuyệt đối trên từng chi tiết của request:

  • Model: Quyết định chính xác mô hình nào sẽ xử lý tác vụ (ví dụ: dòng Haiku cho tác vụ nhanh, rẻ; Sonnet cho đa tác vụ và suy luận sâu; Opus cho các bài toán cực kỳ phức tạp).
  • Token budget: Giới hạn số token tối đa được chi tiêu (max_tokens).
  • Tool use: Khai báo các công cụ (hàm, API ngoài) Claude được phép gọi.
  • System instructions: Thiết lập chỉ thị hệ thống định hình hành vi, vai trò cốt lõi của trợ lý.

Các thành phần cấu thành

Nền tảng bao gồm:

  1. REST API: Có thể gọi từ bất kỳ ngôn ngữ lập trình nào hỗ trợ HTTP request.
  2. SDKs (Software Development Kits): Thư viện chính thức cho Python, TypeScript/JavaScript, Go... giúp viết code nhanh và chuẩn hóa.
  3. Command Line Interfaces (CLIs): Công cụ dòng lệnh hỗ trợ lập trình viên tương tác nhanh từ terminal.
  4. Claude Console (console.anthropic.com): Nơi quản lý API keys, giám sát usage (lượng token tiêu thụ), cấu hình và deploy các managed agents, đồng thời test prompt nhanh qua công cụ Workbench.

2. Ba lớp của Claude Platform (The Three Layers)

Một cách trực quan nhất để hình dung về Claude Developer Platform là cấu trúc 3 lớp xếp chồng lên nhau:

Ba lớp của Claude Developer Platform ① BUILD Primitives khối cơ bản Messages API · Tool Use · Files · Web Search Code Execution · MCP Servers · Skills ② SCALE Infrastructure hạ tầng chạy ngầm Managed Agents · Retries · Queues Observability · Prompt Caching · Memory ③ RUN Controls bộ kiểm soát Dashboards · Evaluations (Evals) · Workspaces Usage & Spend Limits · Request Logs
Build với primitives · scale trên infrastructure · run với controls.
Lớp Thành phần Mô tả thực tế
Primitives (Khối cơ bản) Messages API, Tool Use, Files, Web Search, Code Execution, MCP Servers, Skills. Các viên gạch nền tảng mà tôi trực tiếp gọi trong code để thực thi tác vụ. Đây là nơi logic ứng dụng bắt đầu giao tiếp với LLM.
Infrastructure (Hạ tầng) Managed Agents, Retries, Queues, Observability, Prompt Caching, Memory. Hệ thống ống nước chạy ngầm giúp hệ thống scale từ một bản prototype đơn giản lên hệ thống phục vụ hàng ngàn người dùng thực tế mà không bị nghẽn mạng hay mất mát dữ liệu.
Controls (Bộ kiểm soát) Dashboards, Evaluations (Evals), Workspaces, Usage & Spend Limits, Request Logs. Các núm xoay, bảng điều khiển giúp team vận hành giám sát chi phí, kiểm thử chất lượng, phân quyền và lưu vết hệ thống.

💡 Slogan tóm gọn: Build với primitives, scale trên infrastructure, run với control (xây dựng bằng khối cơ bản, scale trên hạ tầng vững chắc, vận hành dưới sự kiểm soát chặt chẽ).


3. Ví dụ thực tế: Soạn phản hồi hỗ trợ khách hàng (Help Desk)

Giả sử tôi đang quản lý một phần mềm Help Desk và muốn thêm tính năng: tự động soạn câu trả lời nháp dựa trên nội dung ticket hỗ trợ, đảm bảo tuân thủ giọng điệu và cẩm nang của công ty. Tính năng này được kích hoạt khi nhân viên nhấn nút "Draft reply with Claude" trên giao diện.

Đây là kịch bản hoàn hảo cho Messages API với flow xử lý cơ bản:

import anthropic

client = anthropic.Anthropic()

response = client.messages.create(
    model="claude-haiku-4-5",       # Haiku: tối ưu chi phí và tốc độ cho tác vụ soạn thảo đơn giản
    max_tokens=1024,                # Giới hạn độ dài câu trả lời nháp
    system=TONE_AND_GUIDELINES,     # Truyền cẩm nang giọng điệu vào system prompt
    messages=[
        {"role": "user", "content": ticket_content} # Đưa nội dung ticket của khách hàng vào messages
    ],
)

draft = response.content[0].text

Phân tích tham số:

  • model: Chọn mô hình xử lý. Ở đây dùng Haiku 4.5 vì tác vụ soạn thảo thư nháp không quá phức tạp, cần ưu tiên tốc độ nhanh và chi phí rẻ.
  • max_tokens: Chặn trần độ dài câu trả lời để tránh lãng phí chi phí.
  • system: Đặt vai trò và quy tắc. Cẩm nang ứng xử và tone giọng viết email của công ty sẽ nằm ở đây.
  • messages: Lịch sử hội thoại. Đóng vai trò truyền nội dung ticket khách hàng viết để Claude phân tích.

Sau khi API trả response, code sẽ trích xuất phần text và đưa thẳng vào khung soạn thảo để nhân viên xem xét, chỉnh sửa trước khi nhấn Send.


4. Cuộc gọi API đầu tiên của bạn (Your first API call)

Để thực hiện cuộc gọi API đầu tiên bằng Node.js / JavaScript, quy trình thiết lập và triển khai gồm các bước sau:

Thiết lập môi trường (Setup)

  1. Lấy API Key: Tạo key mới tại console.anthropic.com. Lưu ý copy key ngay khi tạo vì nó chỉ hiển thị một lần.
  2. Lưu trữ key bảo mật: Tạo file .env.local ở thư mục gốc của dự án JavaScript và lưu key:
    ANTHROPIC_API_KEY="your-api-key-here"
    
    Quan trọng: Luôn thêm file .env.local vào .gitignore để tránh đẩy key lên các kho lưu trữ công cộng như GitHub.
  3. Cài đặt thư viện (SDK):
    npm install @anthropic-ai/sdk dotenv
    

Code gọi API đầu tiên

import Anthropic from '@anthropic-ai/sdk';
import 'dotenv/config'; // Nạp các biến môi trường từ .env.local

const anthropic = new Anthropic(); // Tự động đọc ANTHROPIC_API_KEY từ process.env

const response = await anthropic.messages.create({
  model: 'claude-sonnet-5',      // Dùng alias model hiện hành — model ID có ngày (dạng claude-x-y-2024xxxx) sẽ lỗi thời và bị retire
  max_tokens: 300,
  messages: [
    { role: 'user', content: 'What is quantum computing? Answer in one sentence' }
  ]
});

// Trích xuất text phản hồi từ response object
console.log(response.content[0].text);

Anatomy of a Request (Giải phẫu Request)

Mọi cuộc gọi API đều đi qua hàm messages.create(). Ở dạng cơ bản nhất, bạn cần chỉ định:

  • Model: Tên mô hình xử lý.
  • Max tokens: Giới hạn trần độ dài câu trả lời của mô hình (không phải mục tiêu bắt viết đủ).
  • Messages list: Một mảng (array) các object chứa lịch sử đối thoại dưới dạng { role, content }.

5. Chọn dòng mô hình phù hợp (Choosing the right model)

Khi đưa ứng dụng lên production, việc chọn đúng dòng mô hình sẽ giúp tối ưu hóa cả chi phítốc độ phản hồi (latency).

Các dòng mô hình chính (Model Tiers)

  1. Claude Fable: Dòng mô hình cực kỳ mạnh mẽ, xếp trên Opus, dành cho các thử thách khó khăn và phức tạp nhất. Chi phí rất cao, chỉ nên sử dụng khi độ phức tạp bài toán thực sự xứng đáng.
  2. Claude Opus: Dòng mô hình thông minh nhất của 3 họ truyền thống, sâu sắc, xử lý logic phức tạp tốt nhưng tốc độ chậm và chi phí cao nhất. Phù hợp cho deep reasoning, complex analysis và multi-step coding.
  3. Claude Sonnet: Điểm ngọt (sweet spot) cân bằng hoàn hảo giữa trí tuệ, tốc độ và chi phí, là sự lựa chọn mặc định tốt nhất cho hầu hết ứng dụng production.
  4. Claude Haiku: Dòng mô hình nhanh nhất và rẻ nhất, tối ưu hiệu suất, phù hợp với các tác vụ khối lượng lớn và độ phức tạp thấp như classification, extraction và routing.

Quy trình đánh giá đơn giản (Simple Evaluation)

Đừng mặc định chọn dòng mô hình thông minh nhất. Hãy thiết lập một eval nhỏ trước khi code:

  1. Chuẩn bị tập dữ liệu mẫu gồm 20–30 ví dụ đại diện cho công việc thực tế của ứng dụng.
  2. Chạy thử tập mẫu trên Haiku trước. Nếu chất lượng đạt chuẩn, bạn đã hoàn tất đánh giá và tiết kiệm được rất nhiều tiền.
  3. Nếu Haiku không đạt, nâng cấp thử nghiệm lên Sonnet.
  4. Chỉ dùng đến Opus / Fable khi tác vụ thực sự đòi hỏi khả năng suy luận vượt trội mà Sonnet không đáp ứng nổi.

Đây không phải lý thuyết suông: khi đánh giá prompt trả lời review khách hàng cho một dự án tại công ty, tôi cũng chạy đúng quy trình này — gom tập review thật, chạy qua từng model, chấm điểm theo tiêu chí cố định rồi mới chốt cấu hình. Nhờ vậy quyết định chọn model có số liệu chống lưng thay vì cảm tính "đọc thử vài câu thấy ổn".

Định tuyến động (Dynamic Routing) trong ứng dụng

Trong production thực tế, một hệ thống chuyên nghiệp nên định tuyến các tác vụ khác nhau đến các mô hình khác nhau:

  • Mọi file gửi lên → Phân loại (classification) bằng Haiku.
  • Các bản cập nhật thông tin khách hàng → Soạn thảo bản nháp bằng Sonnet.
  • Các phản hồi tài liệu đấu thầu phức tạp (RFP) → Định tuyến tới Opus.

Bạn có thể theo dõi lượng token tiêu thụ của từng model qua trường response.usage để kiểm soát hóa đơn API.


6. Dịch chuyển tư duy: Từ "Hỏi Claude" đến "AI là một phần của sản phẩm"

Bản chất của ví dụ trên cho thấy: tôi không cần phải xây một chatbot từ con số 0. Thay vào đó, tôi đang tích hợp Claude vào một sản phẩm đã có sẵn, biến nó thành một component hoạt động trơn tru trong pipeline của mình.

Đó là cốt lõi của việc chuyển từ:

"Hỏi Claude một câu hỏi" (Chatbot giao diện) ➡️ "Claude là một phần của sản phẩm" (Lập trình tích hợp)

Và khi sản phẩm tiến hóa cần đến các tác nhân tự trị (agents), platform không chỉ đơn thuần cung cấp model cho tôi tự xử lý logic, mà với managed agents, Anthropic sẽ đảm nhận việc vận hành, duy trì trạng thái và thực thi các agent đó cho tôi.


7. Agent loop — trái tim của agentic workflow

🧭 Đọc trước kẻo lú — Agent loop KHÔNG phải API mới. Nếu bạn từng học "gọi Claude như một LLM: request → response liên tục tới kết quả cuối", thì agent loop chính là cái đó. Vẫn cùng client.messages.create() bạn đã biết, không đổi. Chỉ khác: lượt trả lời ở giữa do CODE điền (bằng tool result) thay vì con người gõ, và dừng khi stop_reason == "end_turn". Vòng while chỉ là tự động lặp lại messages.create thay vì bạn gọi tay từng lượt.

Ba tầng cho khỏi lẫn:

Tầng Cách gọi Ai cầm vòng lặp?
1. LLM thuần messages.create (1 lần) Không có loop
2. Agent loop (bài này) messages.create trong while + tools Bạn (code)
3. Managed agent (section 14–15) beta.agents/sessions/eventskhông còn messages.create Anthropic

Còn client.**beta**.messages.create (ở bài Skills, MCP) vẫn là Messages API đó, chỉ bật thêm một feature còn beta qua betas=[...]; ra chính thức thì bỏ chữ beta. Đừng nhầm nó với client.beta.**agents**.create — cái sau mới là API khác (Managed Agents).

Một cuộc gọi API chỉ trả về một response rồi kết thúc. Để tự động hoá một quy trình, Claude cần lặp lại chu trình: hành động → nhìn kết quả → quyết định bước kế → làm tiếp. Đó chính là cái người ta gọi là agentic workflow.

Agent là gì: một phiên bản Claude autonomous (tự trị), tự chạy cả hai phía của messaging loop mà không có người ở giữa. Agent nhận một task, chọn một tool, và execute trong một vòng lặp cho tới khi chính Claude quyết định là đã xong.

Agent loop — 5 bước

  1. Gửi message tới Claude kèm tools (các công cụ có sẵn).
  2. Claude trả về một trong hai: câu trả lời cuối cùng, HOẶC một yêu cầu dùng tool (tool_use).
  3. Code của tôi thực thi tool đó (Claude không tự chạy).
  4. Tôi gửi kết quả tool trở lại cho Claude.
  5. Lặp lại cho tới khi stop_reason == "end_turn".

Coi như một cuộc hội thoại luân phiên: user khởi động → agent gọi tool → tool trả kết quả → agent đọc rồi đi tiếp, tới khi có câu trả lời.

Ví dụ tối giản: "Mặc gì ở Austin hôm nay?"

Wire một tool giả get_weather. Claude không tự biết thời tiết → buộc phải gọi tool, đọc kết quả, rồi mới trả lời.

tools = [{
    "name": "get_weather",
    "description": "Get the current weather for a city.",
    "input_schema": {                 # input_schema là một JSON Schema
        "type": "object",
        "properties": {"city": {"type": "string", "description": "The city to get weather for"}},
        "required": ["city"],
    },
}]

def run_tool(name, tool_input):        # trong app thật: hit DB / API / v.v.
    if name == "get_weather":
        return f"Weather in {tool_input['city']}: 95F, sunny"

messages = [{"role": "user", "content": "What should I wear in Austin today?"}]

while True:
    response = client.messages.create(
        model="claude-sonnet-4-6", max_tokens=1024, tools=tools, messages=messages,
    )
    if response.stop_reason == "end_turn":          # Claude xong → in text rồi break
        for block in response.content:
            if block.type == "text": print(block.text)
        break
    if response.stop_reason == "tool_use":          # Claude xin gọi tool
        tool_results = []
        for block in response.content:
            if block.type == "tool_use":
                result = run_tool(block.name, block.input)
                tool_results.append({
                    "type": "tool_result",
                    "tool_use_id": block.id,         # ghép kết quả ↔ đúng yêu cầu
                    "content": result,
                })
        messages.append({"role": "assistant", "content": response.content})   # (1) nguyên response Claude
        messages.append({"role": "user", "content": tool_results})            # (2) kết quả tool, role = user

Chạy ra 2 turn: turn 1 stop_reason = tool_use (Claude xin get_weather cho Austin), turn 2 stop_reason = end_turn (Claude bảo mặc đồ mỏng, thoáng). Tổng cộng: 2 API calls · 1 tool execution · 1 câu trả lời cuối — đó là toàn bộ vòng lặp.

⚠️ Bốn điểm cực dễ nhầm

  • tool_result gửi dưới role: "user", KHÔNG phải "tool" hay "assistant". API chỉ có 2 role: userassistant.
  • Claude KHÔNG tự chạy tool — nó chỉ yêu cầu (tool_use). Việc execute là code của tôi. Đây là ý nghĩa "you own the loop and the tools; Claude owns the reasoning".
  • Mỗi vòng phải append đủ 2 message, đúng thứ tự: (1) assistant = nguyên response.content (chứa block tool_use), rồi (2) user = danh sách tool_result.
  • tool_use_id dùng để ghép đôi mỗi tool_result với đúng yêu cầu tool_use tương ứng (quan trọng khi một turn có nhiều tool).

Cùng loop đó trong production

Cùng khung vòng lặp này vận hành một auto-review endpoint: compliance agent đọc structural report, tra building codes qua tool, ghi từng risk finding vào DB khi làm. Hình dạng loop y hệt — chỉ khác: tool thật (thay mock), kết quả stream về UI qua server-sent events, và findings được persist vào bảng risk-finding. Khi không muốn tự ôm vòng lặp → managed agents chạy chính xác loop này giùm trên hạ tầng Anthropic.


8. Tool use đi sâu: mô tả tốt · nhiều tool · tool runner

Tool là một function tôi định nghĩa và expose cho Claude: tôi mô tả nó làm gì + nhận input gì, Claude quyết định khi nào gọi, code của tôi execute. Định nghĩa tool = JSON schema 3 phần (name · description · input_schema), truyền qua mảng tools.

description là thứ Claude ĐỌC để chọn tool

Đây là điểm quan trọng nhất của cả bài: Claude đọc description để quyết định có gọi tool hay không, và gọi tool nào. Viết mô tả mơ hồ → tool use tệ. Mô tả lờ mờ là lý do SỐ 1 khiến agent bắn trượt (misfire) hoặc không nắm lấy tool đang có.Be specific.

{
  "name": "lookup_building_code",
  "description": "Look up a specific building code section by its identifier. Returns the full text of that code section.",
  "input_schema": {
    "type": "object",
    "properties": { "section": { "type": "string", "description": "The building code section to look up" } },
    "required": ["section"]
  }
}

Nhiều tool — để Claude tự chọn

Khai báo nhiều tool, Claude đọc description → map prompt → chọn đúng tool cho từng việc. Ví dụ chuyến đi Denver 3 ngày: khai báo get_weather (hôm nay) + get_forecast (mấy ngày tới). Vòng lặp y hệt agent loop cũ, chỉ thêm một hàm runTool dispatch theo tên tool bằng switch:

function runTool(name, input) {
  switch (name) {
    case "get_weather":  return getWeather(input.city);
    case "get_forecast": return getForecast(input.city);
  }
}
// ... trong loop: filter block type === "tool_use" → map sang tool_result (type, tool_use_id, content)

Claude sẽ gọi get_weather rồi get_forecast — có khi cùng turn, có khi lần lượt. Thêm tool thứ 3 = thêm vào mảng tools + thêm một case. (Lưu ý: name để code dispatch; description để Claude chọn — đừng lẫn.)

Tool runner — bỏ boilerplate

Loop tay có 2 nhược điểm: (1) nhiều code cho vài lookup đơn giản; (2) phải tự tay viết JSON schema cho mọi function (như viết code hai lần). Tool runner giải quyết cả hai — có sẵn trong Claude SDK cho TypeScript, Python, Ruby. Nó nhận chính các function thật của tôi, tự đọc types/docs để dựng schema, và tự xử lý toàn bộ vòng lặp tool_use / tool_result bên trong.

const runner = client.beta.messages.toolRunner({
  model: "claude-sonnet-4-6", max_tokens: 1024,
  messages: [{ role: "user", content: "I'm packing for a three-day trip to Denver. What's the weather today and over the next few days?" }],
  tools: [getWeather, getForecast],     // truyền thẳng function — KHÔNG viết schema
});
const finalMessage = await runner.untilDone();   // trả về assistant message CUỐI sau khi tool ping-pong xong

Code teo lại còn: mô tả tool → gửi prompt → chờ kết quả. Không while loop, không switch stop_reason, không tự push tool_result, không tự viết schema.

Tool thật bọc code sẵn có: trong thực tế tool chỉ là thin wrapper quanh function đã có (vd lookup_building_code, search_building_code) — truyền thẳng vào tool runner là agent trích dẫn được đúng code section trong mỗi finding.

📐 Phổ mức độ "buông tay": tự chạy loopgiao loop cho tool runner (SDK lo schema + loop, vẫn hạ tầng của tôi) → xa nhất: giao cả agent cho managed agents (Anthropic chạy trên hạ tầng của họ). Tool runner ≠ managed agents — khác cấp độ ủy thác.


9. Extended thinking — cho Claude suy luận trước khi trả lời

Có những task cần hơn một câu trả lời nhanh. Extended thinking cho Claude reason từng bước trước khi ra final response. Khi bật, Claude sinh internal reasoning tokens — gọi là chain of thought — rồi mới trả lời. Quan trọng: reasoning hiển thị ngay trong response (visible, không bị giấu). Nó tránh đúng failure mode: hỏi câu nhiều bước mà bắt trả lời ngay → model tự tin trả lời sai.

Adaptive thinking trên Opus 4.8

Với Opus 4.8, thinking là adaptive: không phải chọn token budget — chỉ bật lên, Claude tự quyết khi nào nghĩ và nghĩ bao nhiêu.

Điều chỉnh độ sâu bằng effort. ⚠️ Gotcha: effort nằm trong output_config, KHÔNG đặt cạnh block thinking. Năm mức: low · medium · high (mặc định) · xhigh (extra high) · max.

response = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=16000,
    thinking={"type": "adaptive"},       # bật adaptive thinking — không cần token budget
    output_config={"effort": "high"},    # effort ở ĐÂY: low | medium | high | xhigh | max
    tools=[weather_tool],
    messages=[{"role": "user", "content": "Plan a road trip out of San Francisco with two stops, weighing weather and drive time."}],
)

Khi nào dùng — và khi nào bỏ qua

  • Dùng cho: toán & multi-step logic · debug code · regulatory analysis · bất cứ việc gì có trade-off / so sánh phương án.
  • Bỏ qua với: classification đơn giản, extraction, boilerplate → thinking chỉ thêm latency + chi phí mà không cải thiện kết quả.

Chạy ví dụ road trip, output có: thinking block (Claude cân trade-off) → tool call kiểm tra từng city → text block khuyến nghị cuối. Reasoning nhìn thấy được — đó chính là mục đích.

Vì sao quan trọng trong production

Đây là khác biệt giữa agent "tìm lỗi từng cái" và agent "nối các lỗi lại". Trong compliance review app, bật adaptive thinking cho auto-review call giúp agent reason xuyên các section — bắt được ví dụ wind load spec ở section 3 mâu thuẫn với material spec ở chỗ khác trong tài liệu.


10. Built-in tools — Anthropic ship sẵn (server tools & client tools)

Tôi tự viết custom tool được, nhưng vài năng lực phổ biến tới mức Anthropic ship sẵn: tôi không viết code, không host sandbox — chỉ declare tool, Anthropic chạy giùm.

Server tools — tôi khai báo, Anthropic chạy

Server tools chạy trên hạ tầng của Anthropic. Tôi KHÔNG execute chúng → không cần agent loop: Claude tự gọi tool, kết quả trả về ngay trong cùng response. Ba cái chính:

  • Web search — tìm internet, trả kết quả kèm citations.
  • Code execution — Claude viết + chạy Python trong sandbox.
  • Web fetch — lấy full nội dung từ URL.
# Web search — Anthropic chạy search server-side
resp = client.messages.create(
    model="claude-opus-4-8", max_tokens=1024,
    tools=[{"type": "web_search_20260209", "name": "web_search"}],   # type có hậu tố ngày (versioned)
    messages=[{"role": "user", "content": "What is Anthropic's latest model release? Answer in one sentence."}],
)
for block in resp.content:
    if block.type == "server_tool_use":   # block type MỚI: lệnh gọi server tool
        print(block.name, block.input)
    elif block.type == "text":
        print(block.text)

# Code execution — Claude viết + chạy Python trong sandbox
resp = client.messages.create(
    model="claude-opus-4-8", max_tokens=1024,
    tools=[{"type": "code_execution_20260120", "name": "code_execution"}],
    messages=[{"role": "user", "content": "Calculate the mean and standard deviation of [1..10]"}],
)
for block in resp.content:
    if block.type == "bash_code_execution_tool_result":   # kết quả sandbox
        print(block.content.stdout)

Hai điều đáng chú ý: (1) không có agent loop — không switch stop_reason, không push tool result về; Anthropic chạy server-side nên response đã chứa sẵn kết quả. (2) response có block type mới: server_tool_use (lệnh gọi) + code execution tool result block (bash_code_execution_tool_resultcontent.stdout) + text như thường. Không phải dựng crawler, không phải chạy Python sandbox — declare 2 tool là có cả hai, free.

Client tools — chạy nơi code của tôi chạy

Client tools chạy ở phía code của tôi, nhưng được ship trong Claude SDK nên tôi không phải tự định nghĩa schema. Cùng hình dạng custom tool, nhưng SDK cho sẵn schema + runner. Hai ví dụ:

  • Memory — Claude đọc/ghi memory xuyên các session.
  • Bash — một persistent bash shell để Claude chạy lệnh.

Vì sao quan trọng & một lời nhắc

Đây là đường ngắn nhất tới các feature vốn tốn hàng tuần: web search có thể vận hành một fact-check endpoint kiểm mọi con số / claim quy định trong bản nháp so với web trực tiếp. ⚠️ Nhắc: cái gì "validated trên internet" không có nghĩa là đúng — luôn double-check kết quả của Claude.

🧩 Bức tranh lớn: ý "hosted by Anthropic" nống dần theo cấp: một tool (server tool) → cả vòng lặp (tool runner) → cả agent (managed agents).


11. Skills — đóng gói quy trình của bạn cho Claude

Skillsfolder chứa instructions, scripts, resources mà Claude load động để làm tốt các task chuyên biệt. Lõi của mọi Skill là file SKILL.md — bộ hướng dẫn đóng gói, upload một lần rồi attach vào bất kỳ call messages.create nào. Bản chất: tôi dạy Claude CÁCH tôi làm một việc (format báo cáo, checklist review, release notes) → Claude đọc, làm theo procedure, cho output đúng khuôn của tôi.

Skills vs Tools — hai bài toán khác nhau

  • Tools nối Claude tới data & actions ("tra code section", "gửi email") — Claude gọi tool, thứ khác chạy.
  • Skills dạy Claude một procedure ("tạo status report theo template này") — một playbook Claude đọc và làm theo, đôi khi tự chạy script đóng kèm.
  • 🔑 Tools = Claude LÀM ĐƯỢC GÌ (what); Skills = tôi muốn nó LÀM THẾ NÀO (how).

Progressive loading (nạp dần)

Skill KHÔNG nạp full vào context lúc khởi động. Ban đầu chỉ name + description được nạp; khi agent thấy Skill liên quan → mới nạp full vào context. Nhờ vậy context gọn nhẹ kể cả khi có rất nhiều Skill.

Upload một lần, tham chiếu bằng ID

skill = client.beta.skills.create(
    display_title="Status Report Generator",
    files=files_from_dir("status-report-skill"),   # folder chứa SKILL.md
)
print(skill.id)   # dùng lại ID này trong các request sau

Attach vào request qua container.skills

response = client.beta.messages.create(   # bản beta — KHÔNG phải create thường
    model="claude-sonnet-4-5", max_tokens=4096,
    betas=["skills-2025-10-02", "code-execution-2025-08-25"],   # bật qua beta header
    container={"skills": [{"type": "custom", "skill_id": skill.id, "version": "latest"}]},
    tools=[{"type": "code_execution_20250825", "name": "code_execution"}],
    messages=[{"role": "user", "content": f"Generate the daily status report from this activity log:\n\n{activity_log}"}],
)

Ba điểm: (1) gọi client.beta.messages.create + bật qua beta headerSkills còn là beta. (2) container.skillsmột listlayer nhiều Skill lên một call. (3) thường pair với code execution vì procedure của Skill có thể làm việc thật (chạy script trong terminal).

Vì sao quan trọng

Đây là cách chuẩn hoá output cho cả team/feature: mọi PM nhận cùng cấu trúc, tone, section, thứ tự — không ai phải copy-paste template vào prompt. Prompt người dùng chỉ 1 dòng; procedure sống trong Skill. → Reach for a Skill khi cái "how" quan trọng ngang cái "what".


12. MCP — nối Claude tới service bên thứ ba (ai maintain integration?)

Vì sao MCP tồn tại khi đã có tools/skills/connectors? Câu trả lời nằm ở ai maintain code tích hợp.

Bài toán maintenance: agent cần kéo task từ Asana, xem Google Calendar, tìm Slack → với custom tool tôi phải viết 3 integration, rồi maintain chúng mỗi lần một service đổi API (rất thường xuyên). Kết cục: è cổ bảo trì một đống third-party API wrapper.

MCP dời gánh maintenance sang chính nhà cung cấp: Asana publish một MCP server, Slack/Google cũng vậy. Mỗi server tự expose tool của nó — kèm description, schema, authentication — qua một protocol chuẩn. API của họ đổi → họ update server, tôi không đổi gì.

Tools vs Skills vs MCP

Feature Dùng cho Ai maintain
Tools Hệ thống nội bộ của tôi (DB, tracker, API riêng) Tôi
Skills Quy trình của tôi (template, checklist) — instructions, không phải integration Tôi
MCP Service bên thứ ba Nhà cung cấp

🔑 Câu ngắn gọn: tools = đồ của tôi · skills = quy trình của tôi · MCP = đồ của người khác.

Kết nối tới MCP server — hai mảnh phối hợp

  • mcp_servers: khai báo kết nốitype, url, name, tùy chọn authorization_token.
  • một tool type: "mcp_toolset": cấu hình tool nào Claude được dùng từ server đó (mặc định = tất cả).
response = client.beta.messages.create(
    model="claude-opus-4-8", max_tokens=1000,
    messages=[{"role":"user","content":"What tools do you have available?"}],
    mcp_servers=[{"type":"url","url":"https://mcp.linear.app/mcp","name":"linear",
                  "authorization_token": os.environ["LINEAR_MCP_TOKEN"]}],
    tools=[{"type":"mcp_toolset","mcp_server_name":"linear"}],
    betas=["mcp-client-2025-11-20"],   # MCP connector còn beta
)

🔑 Không viết một dòng tool schema nào. Claude introspect (tự dò) server → nhận danh sách tool + schema → tự chọn cái đúng cho prompt. Không viết Linear client — Linear maintain nó.

Lọc tool nào Claude được dùng (read-only pattern)

MCP server thường expose rất nhiều tool; không phải lúc nào cũng muốn cho dùng hết (không muốn quyền write, hoặc tránh cả đống schema ngốn context). Cách: tắt hết mặc định, bật đúng cái cần:

tools=[{"type":"mcp_toolset","mcp_server_name":"slack",
        "default_config":{"enabled": False},           # tắt tất cả
        "configs":{"search_messages":{"enabled":True},  # bật đúng 2 tool đọc
                   "list_channels":{"enabled":True}}}]

→ Claude search + list được, nhưng không post/delete — hữu ích khi tin service ở mức đọc nhưng không muốn Claude ghi nhầm thay mình. Danh sách server: modelcontextprotocol.io.


13. Context management — ở trong window mà không mất thứ quan trọng

Mỗi request có một context window. 1 triệu token nghe to nhưng hết nhanh hơn tưởng khi ship agent thật. Context management = cách ở trong window mà không mất thứ quan trọng.

Cái gì tính là context

Mọi thứ Claude thấy trong một turn — và là input của MỌI API call:

  • System prompt · Message history · Tool definitions + tool results · Attached files + skills · Thinking blocks

Trả tiền cả lượt vào lẫn lượt ra; window đầy → request FAIL. Mục tiêu không phải nhét hết vào, mà nhét đúng thứ cần. Anthropic có 4 pattern — 3 là API feature, 1 là design pattern:

Pattern 1 — Just-in-time context (design pattern)

Đừng nạp hết upfront. Nạp cái cần bây giờ, để agent tự kéo thêm qua tool khi hỏi. Compliance agent không nhồi cả cuốn building code vào system prompt — nó gọi lookup_building_code khi cần section cụ thể. Không có gì đặc biệt trong API — chỉ là lựa chọn có chủ đích: nạp gì, khi nào.

Pattern 2 — Server-side compaction (API feature)

Hội thoại dài → server Anthropic tóm tắt các turn cũ thành một block. Opt-in bằng key context_management chứa edits type "compact":

response = client.messages.create(
    model="claude-sonnet-4-5", max_tokens=1024,
    context_management={"edits": [{"type": "compact"}]},
    messages=messages,
)

API tự tóm tắt khi input vượt trigger threshold — khỏi tự theo dõi độ dài hội thoại.

Pattern 3 — Prompt caching (API feature)

Đánh dấu phần ổn định (system prompt, tool definitions, tài liệu dài) → tái dùng qua nhiều call với chi phí bằng một phần nhỏ. Toán quan trọng hơn vẻ ngoài: system prompt 4.000 token × 100 call/giờ → caching là khác biệt giữa hoá đơn xài đượccú điện thoại từ phòng tài chính.

Pattern 4 — Memory tool (API feature)

Vài context cần sống sót xuyên session (user preferences, ghi chú agent, tuần trước chốt gì):

  • Claude đọc/ghi một memory directory qua tool call.
  • Tôi tự implement storage backend phía client — file system, database, encrypted store, tuỳ.
  • Anthropic tự inject một system instruction bảo Claude check memory directory trước khi bắt đầu việc.

Layer cả 4

Production thường xài đồng thời cả 4: compliance agent cache system prompt + tool definitions, kéo building code section just-in-time. Mỗi pattern trị một failure mode: cost · window size · statelessness. Chọn cái khớp thứ đang vỡ. Managed agents ship sẵn caching + compaction bật mặc định.

Pattern Loại Trị failure mode
Just-in-time context Design pattern Nạp gì / khi nào
Server-side compaction API feature Window size
Prompt caching API feature Cost
Memory tool API feature Statelessness (xuyên session)

14. Managed agents — agent loop được Anthropic host, ở quy mô lớn

Claude Managed Agents là một suite of APIs để build + deploy agent ở quy mô lớn, chạy trên hạ tầng Anthropic. Tôi: (1) định nghĩa agent (tools, personas, capabilities); (2) cấu hình sandbox environment (packages + network controls); (3) fire session từ chính app của mình → Claude làm việc trong isolated containerfile system access, bash execution, và web search.

Bản chất vẫn là agent loop (reason → call tool → read result → lặp tới khi xong) — nhưng hosted for you, không phải tự chạy loop. Nằm ở section riêng trong Claude Console.

Ba ví dụ mở khoá ý tưởng

  • Kanban tự làm việc: kéo ticket → auto fire session → environment cài sẵn Lighthouse/Puppeteer, mount GitHub repo → Claude chạy theo rubric ("done" = Lighthouse >90, không render-blocking, ảnh lazy-load). Tool call stream real-time về board qua event stream. Một grader riêng (context window riêng) chấm output → Claude sửa & resubmit tới khi đạt (demo lên 96). Kéo ticket thứ 2 → 2 session, 2 container, song song.
  • Research agent định kỳ có memory: web search giá → cost analysis Python trong sandbox → Excel skill + executive summary → post Slack + tạo Asana task qua MCP. Đọc/ghi memory store → báo cáo nói được "compute cost giảm 15% so với tuần trước" thay vì lặp data tĩnh.
  • Incident response nhiều agent: alert → custom tool đẩy payload vào session dưới dạng tool resultcoordinator agent delegate cho 3 specialist (mỗi specialist context window riêng trên shared file system) → coordinator synthesize thành incident summary. Permissions policy chặn: bản nháp Slack chờ human approve rồi mới gửi. Memory flag pattern từ incident cũ ("giống lỗi DNS 2 tuần trước do TTL sai").

8 building blocks

Block Là gì
Agents Definitions: tools, personas, capabilities
Sessions Lần chạy riêng, fire từ app của tôi (chạy song song được)
Environments Sandbox: đúng packages + network controls
Tools Gồm cả custom tool ở back end
MCP Kết nối service (Slack, Asana…)
Memory Store agent đọc trước khi bắt đầu, ghi khi xong
Outcomes Rubrics + graders định nghĩa & kiểm "done"
Multi-agent coordination Coordinator delegate cho specialists

🧭 Cả khoá trong một câu: từ "hỏi Claude một câu" (chatbot) → "Claude là component" (API) → "giao cả đội agent tự vận hành có QC, memory, human-approval" (managed agents). Tôi định nghĩa thế nào là XONG (rubric); Claude cày tới khi đạt.


15. Xây managed agent đầu tiên — 4 primitives & event stream

Khi nào nên delegate loop? Loop tay đúng cho nhiều feature, nhưng khi loop chạy rất lâu (phút→giờ), qua nhiều tool, có state phải giữ, file phải ghi, cần resume sau network hiccup → đừng chạy trên server của mình nữa → delegate. Đó là managed agents: agent loop chạy trên hạ tầng Anthropic. Mô tả agent một lần, cho environment, start session; Anthropic chạy loop, tôi chỉ stream event ra. Bật mặc định cho mọi API account — không cần special access.

Bốn primitives (theo thứ tự)

# Primitive Là gì Đặc trưng
1 Agent persona: model + system prompt + toolset Tái dùng qua nhiều run
2 Environment nơi agent chạy: cloud/local, networking config container template
3 Session một lần chạy của agent trong environment unit of work
4 Events message vào/ra: actions, tool calls, results, replies cách mọi thứ "chảy"

🔑 Chuyển dịch tư duy: không chạy while loop nữa — gửi event và đọc event.

Managed agent nhỏ nhất (tạo file → đếm dòng → báo cáo)

Dùng agent toolset — bộ file/bash/web tool đóng gói sẵn của Anthropic, khỏi tự define tool.

# B1 — Agent (tái dùng: tạo 1 lần, chạy nhiều session)
agent = client.beta.agents.create(
    name="Line Counter", model="claude-opus-4-8",
    system="You are a helpful agent that completes small file tasks.",
    tools=[{"type": "agent_toolset_20260401", "default_config": {"enabled": True}}],
)
# B2 — Environment (container template)
environment = client.beta.environments.create(
    name="line-counter-env", config={"type": "cloud", "networking": {"type": "unrestricted"}},
)
# B3 — Session (agent + environment) = unit of work
session = client.beta.sessions.create(
    agent=agent.id, environment_id=environment.id, title="Count lines demo",
)
# B4 — MỞ STREAM TRƯỚC, rồi mới gửi kickoff (stream chỉ giao event xảy ra SAU khi mở)
with client.beta.sessions.events.stream(session_id=session.id) as stream:
    client.beta.sessions.events.send(                # 'events' — số nhiều
        session_id=session.id,
        events=[{"type": "user.message",
                 "content": [{"type": "text", "text": "Create a file..., count its lines, and report back."}]}],
    )
# B5 — consume stream: 3 event type quan trọng
    for event in stream:
        if event.type == "agent.message":            # text của Claude
            ...
        elif event.type == "agent.tool_use":         # Claude chọn tool gì
            ...
        elif event.type == "session.status_idle":    # agent XONG → break
            break

Cái trade

Thay vì tự cầm loop + sandbox + resumability, tôi giao hết và chỉ consume event stream. Production: dạng task chạy dài, đụng file, "đi dọn giùm tôi" — ví dụ fileshare cleanup: đọc spec cấu trúc thư mục, đi qua folder bừa bộn, move file đúng chỗ, archive file trùng/rác 0-byte, flag cái không chắc — một session chạy vài phút với hàng ngàn file. Reach for managed agents khi loop chạy quá lâu / làm quá nhiều / cần sống sót qua hiccup; reach for manual loop khi cần toàn quyền kiểm soát.


16. Building with Claude Code — để Claude tự viết integration

Viết code gọi Claude API bằng tay thì ổn, nhưng có đường nhanh hơn: để Claude tự viết. Dùng Claude Code điền một API integration từ một file stub (khung rỗng), bằng chính các primitive đã học suốt khoá.

Bắt đầu từ stub

Một file TypeScript lấy thời tiết, 2 stub: getWeather (city → nhiệt độ + điều kiện) và run (phải dùng tool runner + Claude TypeScript SDK). Nhớ: tool runner lo tool calling + agent loop giùm — khỏi tự đấu dây.

Claude API skill

Claude Code có built-in skill tên Claude API: gọi thẳng bằng /claude-api, hoặc tự gọi khi phát hiện TypeScript SDK. Chưa thấy skill thì thêm từ marketplace:

/plugin marketplace add AnthropicsSkills

⚠️ Để ý chữ s cuối "Anthropics" — dễ sót.

Một prompt, code chạy được

Prompt tốt làm 3 việc: (1) nêu tên file muốn sửa · (2) nêu pattern muốn dùng · (3) nêu end state mong đợi. Claude Code rồi: điền getWeather + run khớp types, append lời gọi ở cuối file, chạy script, báo output; nếu lỗi thì đọc error và vá tại chỗ. Lần chạy demo: nó tạo một Zod tool parse input & trả output theo kiểu city, dựng tool runner + run, in kết quả cuối của agent loop.

Pattern cần nhớ

Hầu hết code viết với Claude API có cùng khuôn:

  1. Define a tool.
  2. Hand it to a runner.
  3. Return the result.

Không cần gõ thuộc lòng mỗi lần — stub file → giao Claude Code → review diff. (Claude Code là một agent biết sửa file + chạy lệnh trong terminal, và bạn vẫn là người duyệt diff.)


Góc Delivery Manager. Nhìn từ góc độ quản lý dự án và vận hành hệ thống thực tế, mô hình 3 lớp của Claude Platform giải quyết đúng những bài toán nhức nhối khi đưa AI vào sản phẩm doanh nghiệp:

  1. Primitives không phải là tất cả: Nhiều đội ngũ kỹ thuật chỉ tập trung vào lớp đầu tiên (Primitives) — viết prompt, gọi API, thiết lập tool. Tuy nhiên, prototype chạy tốt trên máy local không có nghĩa là sẽ chạy ổn khi golive.
  2. Bức tường Infrastructure: Khi sản phẩm tăng trưởng, một hành động của người dùng có thể kích hoạt chuỗi tác vụ gọi API liên tục (agent loop). Lúc này, nếu không có lớp Infrastructure gánh (xử lý hàng đợi Queues khi chạm rate limit, tự động Retries khi mạng lỗi, và giám sát Observability để biết bước nào trong chuỗi agent bị lỗi), hệ thống sẽ đổ vỡ ngay lập tức. Đặc biệt, việc bật Prompt Caching là bắt buộc để giảm độ trễ (latency) và tối ưu hóa chi phí khi truyền đi lượng lớn tài liệu ngữ cảnh lặp đi lặp lại.
  3. Controls là chốt chặn an toàn: Để chạy thực tế dài hạn, ta bắt buộc phải có các chốt chặn về ngân sách (Usage & Spend Limits) để tránh kịch bản vòng lặp vô hạn của agent đốt sạch tài khoản trong một đêm. Quan trọng hơn, quy trình đánh giá chất lượng (Evaluations - Evals) phải được thiết lập tự động. Khi Anthropic ra mắt model mới hoặc nâng cấp phiên bản (ví dụ từ Haiku 4.5 lên Haiku 4.6), tôi không thể cảm tính "đọc thử vài câu thấy ổn" để deploy; tôi cần chạy bộ dữ liệu thử nghiệm (eval dataset) qua pipeline đánh giá để đảm bảo độ chính xác không bị suy giảm (regression).

Từ khoá cần thuộc

🔴 Core: REST API · SDKs · Claude Console · Primitives · Infrastructure · Controls · Messages API · Managed Agents · Observability · System instructions · max_tokens · model · messages · role: "user" vs role: "assistant" · Agent loop · stop_reason (tool_use / end_turn) · tool_use · tool_result (role: "user") · tool_use_id · tools array (name · description · input_schema).

🟡 Important: Workbench · Prompt Caching · Prompt Evaluation (Evals) · Usage and spend limits · Request logs · Help desk reply usecase · Claude Haiku (tốc độ/chi phí) · Prefilling / Structured output · Agentic workflow · Autonomous agent · JSON Schema (input_schema) · Server-sent events (stream tool result về UI) · description = thứ Claude đọc để chọn tool (vague desc = lý do #1 misfire) · Tool runner (toolRunner · untilDone() · TypeScript/Python/Ruby) · runTool switch dispatch (theo name).

🔴 Core (Extended thinking): Extended thinking · Chain of thought (reasoning tokens, visible) · Adaptive thinking (thinking: {"type": "adaptive"} — KHÔNG cần token budget) · effort nằm TRONG output_config (không cạnh thinking) · 5 mức low · medium · high (mặc định) · xhigh · max.

🔴 Core (Built-in tools): Server tools (Anthropic chạy, KHÔNG cần agent loop, kết quả trong cùng response): Web search (kèm citations) · Code execution (Python trong sandbox) · Web fetch · block server_tool_use · Client tools (chạy phía code mình, SDK ship schema+runner): Memory (xuyên session) · Bash (persistent shell) · "hosted by Anthropic": tool → loop → agent.

🔴 Core (Skills): Skill = folder instructions/scripts/resources · lõi SKILL.md · Tools = what · Skills = how · Progressive loading (đầu chỉ name+description, full nạp khi cần) · upload client.beta.skills.createskill_id · attach qua container.skills (list, layer nhiều Skill; skill_id+version) · beta (client.beta.messages.create + betas=[...]) · pair với code execution.

🔴 Core (MCP): MCP (Model Context Protocol) = nối service bên thứ ba, nhà cung cấp maintain integration (API họ đổi → mình không đổi gì) · tools = đồ của tôi · skills = quy trình của tôi · MCP = đồ của người khác · khai báo mcp_servers (type/url/name/authorization_token) + cấp quyền mcp_toolset trong tools (mặc định = tất cả tool) · Claude introspect server → không viết schema · read-only: default_config:{enabled:False} + bật lẻ trong configs · beta mcp-client-2025-11-20 · modelcontextprotocol.io.

🔴 Core (Context management): Context window (đầy → request FAIL; trả tiền cả in lẫn out) · context gồm 5 thứ: system prompt · message history · tool definitions/results · files & skills · thinking blocks · 4 pattern (3 API feature + 1 design pattern): Just-in-time context (design pattern) · Server-side compaction (context_management/edits/{type:"compact"}, tự trigger — trị window size) · Prompt caching (mark phần ổn định — trị cost) · Memory tool (đọc/ghi memory directory, backend do mình giữ client-side, Anthropic auto-inject instruction — trị statelessness xuyên session) · managed agents mặc định bật caching + compaction.

🔴 Core (Managed agents): Managed Agents = suite of APIs build/deploy agent ở quy mô lớn, agent loop được Anthropic host trong isolated container (file system access · bash execution · web search) · 8 building blocks: Agents · Sessions (chạy song song, stream real-time qua event stream) · Environments (sandbox + network controls) · Tools (gồm custom back-end) · MCP · Memory (đọc trước/ghi sau) · Outcomes (rubrics + grader chạy context window riêng) · Multi-agent coordination (coordinator → specialists, mỗi specialist context riêng nhưng shared file system) · Permissions policy (hành động nhạy cảm chờ human approve) · "tôi định nghĩa done, Claude cày tới khi đạt".

🔴 Core (Build managed agent): 4 primitives theo thứ tự: Agent (persona: model+system+toolset, tái dùng) → Environment (nơi chạy: cloud/local, networking) → Session (một lần chạy = unit of work) → Events (message vào/ra) · tư duy: gửi/đọc event, KHÔNG while loop · MỞ STREAM TRƯỚC rồi mới gửi kickoff (stream chỉ giao event xảy ra sau khi mở) · 3 event demo: agent.message · agent.tool_use · session.status_idle (xong) · agent toolset (file/bash/web bundled, agent_toolset_...) · bật mặc định mọi account · client.beta.agents/environments/sessions.create + sessions.events.stream/.send.

🟡 Important (Build with Claude Code): Claude Code = agent sửa file + chạy lệnh trong terminal · built-in skill Claude API (/claude-api hoặc tự kích hoạt khi phát hiện TypeScript SDK) · marketplace: /plugin marketplace add AnthropicsSkills (nhớ chữ s) · prompt tốt nêu 3 thứ: file · pattern · end state · khuôn Claude API: define a tool → hand to a runner → return the result · quy trình: stub → delegate → review diff · Zod tool · tool runner lo tool calling + agent loop.

🟢 Good-to-know: CLI · Retries · Queues · Workspaces · Skilljar certificates · get_weather demo (2 calls · 1 tool exec) · Thin wrapper quanh function sẵn có · Phổ ủy thác: loop tay → tool runner → managed agents · Thinking dùng cho trade-off/multi-step, bỏ qua cho classification/extraction.


Nguồn: Claude Platform 101 (Anthropic Academy) — Copyright Anthropic. Phần đề thi thử cho khoá này nằm ở tab "Đề thi thử".

Câu hỏi thường gặp

Claude Developer Platform là gì?
Là hạ tầng của Anthropic giúp lập trình viên xây dựng ứng dụng với Claude thông qua việc gửi request có cấu trúc và nhận response có cấu trúc, kiểm soát chi tiết về model, token, system prompt và tool use.
Ba lớp của Claude Platform gồm những gì?
Gồm Primitives (khối xây dựng cơ bản như Messages API, tool use, MCP), Infrastructure (hạ tầng vận hành như managed agents, retries, observability) và Controls (công cụ kiểm soát như dashboards, evals, limits).
Sự khác biệt giữa việc dùng chatbot thông thường và dùng API là gì?
Dùng chatbot thông thường là tương tác thủ công trên trình duyệt. Dùng API giúp tích hợp Claude vào sản phẩm hiện có để tự động hoá quy trình (như soạn email phản hồi ticket tự động khi nhấn nút).
Nên chọn Claude Haiku, Sonnet hay Opus cho ứng dụng production?
Đừng mặc định chọn model mạnh nhất. Chạy 20-30 mẫu dữ liệu thật trên Haiku trước (rẻ và nhanh nhất); nếu chất lượng không đạt mới nâng lên Sonnet, và chỉ dùng Opus/Fable khi tác vụ thực sự cần suy luận sâu. Hệ thống production tốt thường định tuyến động: tác vụ phân loại đi Haiku, soạn thảo đi Sonnet, phân tích phức tạp đi Opus.

Đề thi thử (99 câu)

Đề thi thử tự biên soạn, bám sát đề thi chứng chỉ thật — trích 20 câu đầu dưới đây. Bản tương tác — chấm điểm, đáp án & giải thích từng câu — nằm ở tab “Đề thi thử” trên trang.

  1. Platform Architecture Which of the following belongs to the 'Primitives' layer of the Claude Developer Platform?

    • A. Evaluations (Evals) and Dashboards
    • B. Managed Agents, Retries, and Queues
    • C. Messages API, Tool Use, and Model Context Protocol (MCP)
    • D. Usage limits and spend alerts
  2. Platform Architecture A delivery manager wants to set up automated prompt testing to prevent quality regression when switching models. Under which layer of the Claude Platform does this capability fall?

    • A. Primitives
    • B. Infrastructure
    • C. Controls
    • D. Hardware
  3. Platform Architecture What is the primary role of the 'Infrastructure' layer in the Claude Platform?

    • A. Defining the core prompt guidelines and templates for developers
    • B. Providing the necessary systems (managed agents, retries, queues, prompt caching) to scale agentic applications past the prototype phase
    • C. Restricting API key usage and monitoring billing graphs
    • D. Rendering UI components like HTML and Markdown in the client application
  4. Developer Tools Which tool in the Claude Console allows developers to interactively test prompts, adjust temperature, and view token usage without writing code?

    • A. CLI
    • B. Workbench
    • C. Managed Agents dashboard
    • D. Activity Log
  5. API & Integration In the help desk app example, which Claude model is recommended for drafting support replies due to its optimal speed and cost?

    • A. Claude 3 Opus
    • B. Claude 3.5 Sonnet
    • C. Claude 4.5 Haiku
    • D. Claude 3.5 Opus
  6. API & Integration When calling client.messages.create(), where should you place guidelines about the tone and formatting rules for the response?

    • A. In the 'model' parameter
    • B. In the 'max_tokens' parameter
    • C. In the 'system' parameter
    • D. As the first dictionary inside the 'messages' array with the role 'assistant'
  7. Platform Philosophy What is the core transition in developer mindset when moving from a consumer chatbot to the Claude Developer Platform?

    • A. Moving from 'asking Claude questions' to 'making Claude a component of your product'
    • B. Replacing frontend developers entirely with AI agents
    • C. Using larger prompt context windows instead of databases
    • D. Running all code locally on the client's device instead of the cloud
  8. Developer Tools Which of the following is NOT a component of the Claude Developer Platform?

    • A. REST API
    • B. Command Line Interface (CLI)
    • C. Managed Agent Hosting
    • D. Anthropic Search Engine
  9. API & Integration What is the purpose of the 'max_tokens' parameter in the Messages API request?

    • A. It forces the model to write exactly that number of tokens
    • B. It acts as a safety cap to limit the length of Claude's generated response
    • C. It determines the size of the input context window
    • D. It sets the price tier for the API request
  10. Platform Architecture To prevent an autonomous agent loop from generating excessive API costs due to an infinite loop, which feature in the 'Controls' layer should be configured?

    • A. Prompt Caching
    • B. Evaluations (Evals)
    • C. Usage & Spend Limits
    • D. Web Search integration
  11. Developer Tools Which of the following tasks is typically performed within the Claude Console rather than via the REST API or SDKs?

    • A. Sending user prompt messages and streaming the generated text response
    • B. Managing API keys, monitoring usage analytics, and testing prompts in the Workbench
    • C. Defining JSON schemas for tools that Claude can use during a session
    • D. Parsing the response content of the model programmatically
  12. API & Integration When implementing the Help Desk reply drafter in the provided example, why is 'claude-haiku-4-5' selected instead of a larger model like Claude Sonnet?

    • A. Because Haiku is the only model that supports the 'system' parameter
    • B. Because Haiku has a larger context window than Sonnet
    • C. Because drafting a simple support reply is a low-complexity task, making Haiku a good fit due to its speed and cost-efficiency
    • D. Because Haiku does not charge for input tokens
  13. API Keys & Security To prevent API keys from being leaked on public repositories like GitHub, what is the best practice recommended in the course?

    • A. Obfuscate the API key inside client-side JavaScript files
    • B. Store the API key in a `.env.local` file and ensure it is added to `.gitignore`
    • C. Hardcode the API key in source files and restrict repository access
    • D. Retrieve the key dynamically from an unauthenticated public HTTP endpoint
  14. Developer Tools Which command is used to install the official Anthropic SDK for Node.js / JavaScript projects?

    • A. npm install anthropic-api
    • B. npm install @anthropic-ai/sdk
    • C. npm install claude-sdk
    • D. npm install @anthropic/messages
  15. Choosing a Model When designing a simple evaluation (eval) to choose the right model for a production task, what is the recommended workflow?

    • A. Start with Opus to get the best baseline, and never test other models
    • B. Run 20 to 30 representative examples through Haiku first, stepping up to Sonnet or Opus only if the quality does not hold
    • C. Randomly distribute test prompts across all models and average the results
    • D. Always use Fable regardless of the quality-to-cost ratio
  16. Choosing a Model How is a developer billed for their usage of the Claude API?

    • A. A flat monthly subscription fee regardless of volume
    • B. Based on the input and output token counts reported in response.usage
    • C. Based strictly on the value of the max_tokens parameter set in the request
    • D. A fixed charge per API call made to the messages endpoint
  17. Agent Loop In the agent loop, which stop_reason value tells your code to break out of the loop because Claude has produced its final answer?

    • A. tool_use
    • B. max_tokens
    • C. end_turn
    • D. stop_sequence
  18. Agent Loop When you send a tool's output back to Claude in the next turn, which role must the message carrying the tool_result use?

    • A. role: "tool"
    • B. role: "assistant"
    • C. role: "user"
    • D. role: "system"
  19. Agent Loop In the agent loop, who is responsible for actually executing the tool that Claude requests?

    • A. Claude executes the tool automatically on Anthropic's servers
    • B. Your own code runs the tool; Claude only requests it
    • C. The Workbench executes it during the request
    • D. The tool_result block executes itself when appended
  20. Agent Loop Which field on a tool_result block is used to match the result back to the specific tool_use request Claude made?

    • A. name
    • B. tool_use_id
    • C. input_schema
    • D. stop_reason

…và 79 câu nữa trong bản đề thi thử đầy đủ (99 câu) — mở tab “Đề thi thử” trên trang để làm toàn bộ, có chấm điểm & giải thích.