CCA-F Knowledge Map
Cấu trúc và giải thích từng knowledge area theo domain
Domain 1 · Agentic Architecture & Orchestration
Autonomous task execution, multi-agent patterns, hooks, session management
27%
1.1 Agentic Loop
Core concept
K1
stop_reason là signal duy nhất để control loop
Mỗi API response trả về
stop_reason. Đây là cơ chế duy nhất đáng tin cậy:"tool_use" → model muốn gọi tool → execute tool, append result vào history, gửi lại"end_turn" → model hoàn thành → show result cho user"max_tokens" → bị cắt → tăng limit hoặc xử lý tiếp"stop_sequence" → hit stop sequence → xử lý theo logic app
while True:
response = claude.messages.create(
model="claude-sonnet-4-6",
messages=messages,
tools=tools
)
if response.stop_reason == "end_turn":
break # Task hoàn thành
if response.stop_reason == "tool_use":
tool_result = execute_tool(response)
messages.append(tool_result) # Append vào history, loop tiếp
Anti-pattern: Parse text của assistant để detect completion ("Task completed", "Done") — KHÔNG đáng tin. Signal duy nhất là
stop_reason == "end_turn".
K2
Full conversation history phải gửi lại mỗi request
Claude API stateless — model không nhớ gì giữa các call. Phải gửi toàn bộ
messages[] history (bao gồm tool results đã append) trong mỗi request để model có context đủ để reason về bước tiếp theo.
Tip: Tool result phải có role
user với type: "tool_result" và tool_use_id matching với call trước đó. Nếu thiếu ID này → API error.
K3
Model-driven vs. pre-configured decision trees
Model-driven (agentic): Claude quyết định tool nào gọi tiếp theo dựa trên context và prior results. Linh hoạt, xử lý được edge cases không ngờ tới.
Pre-configured decision tree: action sequence hardcoded. Predictable nhưng rigid, không xử lý được variations.
Pre-configured decision tree: action sequence hardcoded. Predictable nhưng rigid, không xử lý được variations.
Exam hint: Khi câu hỏi hỏi về "unpredictable user requests" hoặc "varying workflows" → model-driven approach là đáp án.
1.2 Multi-Agent Hub-and-Spoke
Architecture
K4
Coordinator responsibilities
Coordinator agent chịu trách nhiệm toàn bộ:
• Decompose tasks thành subtasks
• Delegate cho subagents phù hợp
• Aggregate results từ nhiều subagents
• Route errors và re-delegate nếu cần
• Synthesize final output
Tất cả inter-agent communication ĐI QUA coordinator — subagents không communicate trực tiếp với nhau.
• Decompose tasks thành subtasks
• Delegate cho subagents phù hợp
• Aggregate results từ nhiều subagents
• Route errors và re-delegate nếu cần
• Synthesize final output
Tất cả inter-agent communication ĐI QUA coordinator — subagents không communicate trực tiếp với nhau.
K5
Subagents KHÔNG kế thừa context — bao giờ hết
Mỗi subagent có isolated context. Không có shared memory, không có automatic history propagation từ coordinator. Mọi thứ subagent cần phải được pass explicitly trong prompt của nó.
# SAI — subagent không tự biết web_agent đã tìm được gì
synthesis_agent.run("Synthesize the research findings")
# ĐÚNG — pass findings explicitly
synthesis_agent.run(f"""
Synthesize these research findings:
{web_agent_results}
{doc_agent_results}
""")
Exam trap: "Synthesis agent cần kết quả từ web search agent" → đáp án đúng là pass findings trực tiếp trong prompt, KHÔNG phải shared memory, event bus, hay database.
K6
Task tool và parallel spawning
Dùng
Parallel subagents: emit multiple Task calls trong một single coordinator response → chạy đồng thời.
fork_session: tạo independent branches từ shared baseline để explore divergent approaches.
Task tool để spawn subagents từ coordinator. allowedTools của coordinator PHẢI include "Task" nếu không sẽ không spawn được.Parallel subagents: emit multiple Task calls trong một single coordinator response → chạy đồng thời.
fork_session: tạo independent branches từ shared baseline để explore divergent approaches.
coordinator = AgentDefinition(
name="research_coordinator",
allowed_tools=["Task", "get_sources", "synthesize"],
# "Task" bắt buộc để spawn subagents
)
1.3 Hooks & Programmatic Enforcement
Thường ra đề
K7
Programmatic vs. Prompt-based enforcement
Prompt instructions có non-zero failure rate (probabilistic). Khi có financial/compliance consequence → PHẢI dùng programmatic enforcement (code, hooks, prerequisites).
"Khi lỗi có financial consequence, rely on LLM to 'usually' follow instructions là KHÔNG phải valid architecture."
"Khi lỗi có financial consequence, rely on LLM to 'usually' follow instructions là KHÔNG phải valid architecture."
Mental model: Prompt = "model thường làm đúng". Code = "model buộc phải làm đúng". Compliance-critical → dùng code.
K8
3 loại hooks và use cases
PostToolUse hooks: chạy sau khi tool trả về kết quả. Normalize heterogeneous formats (timestamps, status codes, currency units) trước khi model process.
Tool call interception hooks: chạy trước khi execute. Block policy violations. Ví dụ: intercept
Prerequisite gates: block tool B cho đến khi tool A đã chạy thành công. Ví dụ: block
Tool call interception hooks: chạy trước khi execute. Block policy violations. Ví dụ: intercept
process_refund nếu amount > $500 → redirect sang escalate_to_human.Prerequisite gates: block tool B cho đến khi tool A đã chạy thành công. Ví dụ: block
process_refund cho đến khi get_customer trả về verified customer ID.
Key insight: Hooks = deterministic guarantees. Prompts = probabilistic compliance. Khi đề hỏi "make it reliable" → hooks/programmatic.
1.4 Task Decomposition & Session Management
Patterns
K9
Prompt chaining vs. Dynamic decomposition
Prompt chaining: predictable fixed sequential steps → dùng cho multi-aspect code reviews, known pipelines với steps xác định trước.
Dynamic decomposition: open-ended investigation, model tự quyết định steps tiếp theo → dùng cho legacy codebase exploration, research tasks có scope rộng.
Dynamic decomposition: open-ended investigation, model tự quyết định steps tiếp theo → dùng cho legacy codebase exploration, research tasks có scope rộng.
K10
Session commands
--resume <session-name>: tiếp tục một named session đã lưu trước đó.fork_session: tạo independent branches từ shared analysis baseline để explore approaches khác nhau mà không ảnh hưởng baseline.
Tip: Fresh session với structured summary thường reliable hơn resume khi prior tool results đã stale hoặc context cũ không còn relevant.
Domain 2 · Tool Design & MCP Integration
MCP servers, tool descriptions, scoping, boundaries, JSON schema
18%
2.1 Tool Description Design
Thường ra đề
K1
Description là routing mechanism chính của LLM
LLM chọn tool dựa trên description — không phải function name, không phải system prompt. Description tệ → model đoán mò khi có 2 tools overlap về chức năng.
Description tốt phải include:
• Cụ thể tool làm gì và trả về gì
• Input formats và example values
• Edge cases và constraints
• Khi nào dùng cái này vs. cái tương tự
Description tốt phải include:
• Cụ thể tool làm gì và trả về gì
• Input formats và example values
• Edge cases và constraints
• Khi nào dùng cái này vs. cái tương tự
# BAD — quá ngắn, model không biết khi nào dùng
"description": "Get customer info"
# GOOD — đủ context để route đúng
"description": "Finds a customer by email or ID. Returns profile,
order history, and account status. Use BEFORE lookup_order to
verify customer identity. Accepts: email (user@domain.com)
or numeric customer_id."
Exam trap: "Agent hay chọn built-in Read tool thay vì MCP tool của mình" → fix bằng cách strengthen MCP tool description (highlight unique data/capabilities), KHÔNG phải đổi system prompt.
K2
Tránh overlapping descriptions
Nếu
Fix: Rename tools để eliminate overlap. Highlight concrete advantages và unique data của từng tool. Explicit boundaries: "Use this for X, use analyze_document for Y".
analyze_content và analyze_document có descriptions gần giống nhau → model sẽ confuse và chọn sai thường xuyên.Fix: Rename tools để eliminate overlap. Highlight concrete advantages và unique data của từng tool. Explicit boundaries: "Use this for X, use analyze_document for Y".
2.2 MCP Server Architecture
Architecture
K3
MCP server types: stdio vs. SSE/HTTP
stdio (local): chạy trên máy local, communicate qua stdin/stdout. Dùng cho local development, tools cần filesystem access, personal tools.
SSE/HTTP (remote): server chạy remote, communicate qua HTTP. Dùng cho production environments, shared tools giữa nhiều agents và nhiều users.
SSE/HTTP (remote): server chạy remote, communicate qua HTTP. Dùng cho production environments, shared tools giữa nhiều agents và nhiều users.
K4
Tool scoping & 4–5 tools/agent rule
Mỗi agent chỉ expose tools thuộc role của nó. Tool boundaries ngăn reasoning overload.
Rule: 4–5 tools/agent là optimal. Với 18 tools → selection reliability giảm mạnh → model chọn sai tools thường xuyên hơn.
Rule: 4–5 tools/agent là optimal. Với 18 tools → selection reliability giảm mạnh → model chọn sai tools thường xuyên hơn.
Pattern: Coordinator = Task + 2–3 high-level tools. Mỗi subagent = 3–5 specialized tools cho domain của nó. Tổng tools trong system có thể nhiều nhưng mỗi agent chỉ thấy phần của mình.
K5
tool_choice parameter
"auto": model tự quyết định (default cho hầu hết cases)"any": model PHẢI gọi một tool nào đó → dùng khi cần guaranteed structured output{"type":"tool","name":"X"}: force gọi tool cụ thể → dùng khi cần forced first step
# Force extract_metadata chạy đầu tiên
response = claude.messages.create(
tool_choice={"type": "tool", "name": "extract_metadata"},
tools=[extract_metadata, enrich_data, validate],
...
)
2.3 JSON Schema cho Structured Output
Technical
K6
Schema guarantees syntax, NOT semantics
tool_use + JSON schema đảm bảo JSON syntactically valid, required fields có mặt. KHÔNG đảm bảo values đúng nghĩa (semantic correctness). Cần validation + retry loops để xử lý semantic errors.
{
"type": "object",
"properties": {
"category": {
"type": "string",
"enum": ["bug", "feature", "docs", "unclear", "other"]
// "unclear" và "other" quan trọng — tránh hallucination
},
"severity": {"type": "string", "enum": ["critical","high","medium","low"]},
"confidence": {"type": "number", "minimum": 0, "maximum": 1},
"notes": {"type": ["string", "null"]}
// nullable = model trả null thay vì hallucinate
},
"required": ["category", "severity"]
// optional fields không trong required
}
Schema design rules: (1) Dùng
["string","null"] cho optional fields. (2) Thêm "other" + detail field vào enum để không mất data. (3) "unclear" trong enum để model honest khi không chắc — tốt hơn là chọn sai.
Domain 3 · Claude Code Configuration & Workflows
CLAUDE.md hierarchy, .claude/rules/, skills, slash commands, CI/CD
20%
3.1 CLAUDE.md Hierarchy
Thường ra đề
K1
3 cấp CLAUDE.md và override rules
Project-level (
User-level (
System-level: enterprise policies, override tất cả bên dưới.
Override order: system > project > user
./CLAUDE.md hoặc .claude/): rules cho project cụ thể, committed vào repo, áp dụng cho cả team.User-level (
~/.claude/CLAUDE.md): personal preferences của từng developer, không committed, không ảnh hưởng người khác.System-level: enterprise policies, override tất cả bên dưới.
Override order: system > project > user
Exam question dạng: "TypeScript frontend + Python backend + Terraform infra — configure conventions theo file type" → đáp án:
.claude/rules/ với glob patterns trong YAML frontmatter. KHÔNG phải một CLAUDE.md duy nhất với sections, KHÔNG phải separate CLAUDE.md trong subdirectories.
K2
.claude/rules/ với glob patterns
Conditional rule loading dựa trên file path/extension. Chỉ load rules khi làm việc với file type cụ thể → giữ context clean, focused, không bị overload.
# .claude/rules/typescript.md
---
globs: ["**/*.ts", "**/*.tsx"]
---
Use strict TypeScript. No `any` types. 4-space indent.
Prefer const over let. Use functional components.
# .claude/rules/python.md
---
globs: ["**/*.py"]
---
Follow PEP 8. Type hints required on all functions.
Use ruff for linting. Prefer dataclasses over dicts.
# .claude/rules/terraform.md
---
globs: ["**/*.tf", "**/*.tfvars"]
---
Use snake_case for resource names. Tag all resources.
3.2 Skills & Slash Commands
Technical
K3
SKILL.md frontmatter structure
Skills nằm trong
.claude/skills/. Mỗi skill có YAML frontmatter định nghĩa khi nào Claude sẽ tự động dùng skill đó.
# .claude/skills/run-tests.md
---
name: run-tests
description: Run test suite with coverage reporting
trigger: explicit # explicit = chỉ khi user yêu cầu
# automatic = Claude tự trigger khi phù hợp
---
## Instructions
Run: `npm test -- --coverage`
Ensure coverage >= 80% before reporting success.
If coverage drops, highlight which files lost coverage.
K4
Custom slash commands
Tạo trong
Commands hay xuất hiện trong exam (QA context):
Commands đặc biệt hữu ích cho CI/CD automation vì có thể gọi từ command line.
.claude/commands/. Standardize workflows across team.Commands hay xuất hiện trong exam (QA context):
/cf-orchestrate-convert — convert Cypress tests sang Playwright/cf-orchestrate-new-test — generate test mới từ spec/descriptionCommands đặc biệt hữu ích cho CI/CD automation vì có thể gọi từ command line.
3.3 CI/CD Integration (headless mode)
Technical
K5
Non-interactive (headless) mode flags
Claude Code trong CI/CD chạy headless — không có interactive prompt. Các flags quan trọng:
claude --print \
--allowedTools "Read,Grep,Glob" \
--output-format json \
--no-permissions-prompt \
"Review this PR for security vulnerabilities"
# --print : single-turn, print output và exit
# --allowedTools : restrict tools (safety trong CI)
# --output-format : json | text (json cho downstream parsing)
# --no-permissions-prompt : skip interactive confirmations
Tip: Trong code review CI/CD, thường restrict về
Read, Grep, Glob only — no Write, no Bash. Đảm bảo review mode không thay đổi code tự động.
K6
Built-in tools trong Claude Code
Read — đọc file contentWrite — ghi/tạo fileBash — chạy shell commandsGrep — search patterns trong filesGlob — find files theo patternWebFetch — fetch URL contentClaude Code tự ưu tiên built-in tools khi descriptions overlap → cần strengthen MCP tool descriptions nếu muốn Claude dùng MCP thay vì built-in.
Domain 4 · Prompt Engineering & Structured Output
Few-shot, validation loops, enforcement patterns, escalation routing
20%
4.1 Few-shot Prompting
Core
K1
Few-shot dùng cho gì và KHÔNG dùng cho gì
Dùng tốt:
• Format và tone của output
• Xử lý non-standard measurement units ("a pinch", "handful")
• Style extraction và edge case handling
• Demonstrate ambiguous category classification
KHÔNG dùng để:
• Enforce tool ordering / calling sequence
• Guarantee compliance với critical business rules
• Prevent model từ bỏ qua steps quan trọng
• Format và tone của output
• Xử lý non-standard measurement units ("a pinch", "handful")
• Style extraction và edge case handling
• Demonstrate ambiguous category classification
KHÔNG dùng để:
• Enforce tool ordering / calling sequence
• Guarantee compliance với critical business rules
• Prevent model từ bỏ qua steps quan trọng
# Good use of few-shot — format guidance:
"""
Extract measurements from recipe text. Examples:
Input: "add 2 tbsp olive oil" → {"amount": 2, "unit": "tbsp"}
Input: "a pinch of salt" → {"amount": 1, "unit": "pinch"}
Input: "juice of half a lemon" → {"amount": 0.5, "unit": "lemon"}
Now extract: {user_input}
"""
Exam trap: "Agent bỏ qua get_customer 12% thời gian → thêm few-shot examples để enforce sequence" — SAI. Đây là compliance issue → cần programmatic prerequisite, không phải few-shot.
4.2 Validation & Retry Loops
Reliability
K2
Defense in depth — 3 lớp cho reliable structured output
Layer 1 — Schema: JSON schema enforce structure (syntax guarantee — no invalid JSON)
Layer 2 — Few-shot: examples guide format, edge cases, ambiguous inputs
Layer 3 — Validation + retry: code validate semantic correctness, retry với error feedback nếu fail
Layer 2 — Few-shot: examples guide format, edge cases, ambiguous inputs
Layer 3 — Validation + retry: code validate semantic correctness, retry với error feedback nếu fail
result = claude.extract(schema=MY_SCHEMA, few_shot=EXAMPLES)
errors = validate_semantics(result)
if errors:
result = claude.extract(
schema=MY_SCHEMA,
few_shot=EXAMPLES,
additional_context=f"Previous attempt had errors: {errors}. Please fix."
)
K3
Independent review instances
Model giữ reasoning context từ generation nên ít question quyết định của chính nó (self-review limitation). Independent review instance (fresh session, không có prior reasoning context) hiệu quả hơn cho catching subtle issues.
Ứng dụng: dùng second independent Claude instance để review generated code, không phải ask cùng instance tự review.
Ứng dụng: dùng second independent Claude instance để review generated code, không phải ask cùng instance tự review.
4.3 Escalation & Confidence Routing
Thường ra đề
K4
Self-reported confidence KHÔNG đáng tin
LLM confidence score tự báo cáo (self-reported) kém calibrated — model tự tin nhất khi sai nhất. KHÔNG dùng self-reported confidence để route escalation decisions.
Thay bằng: external validation signals, explicit trigger conditions trong code (amount > $500, customer explicitly requests human, error rate vượt threshold).
Thay bằng: external validation signals, explicit trigger conditions trong code (amount > $500, customer explicitly requests human, error rate vượt threshold).
Exam trap: "Add confidence field vào JSON schema để route escalation" → anti-pattern. Dùng explicit conditions trong code.
K5
Prompt chaining cho multi-step extraction
Với complex extraction tasks, không nhồi hết vào một prompt. Chia thành steps:
Step 1 → Extract raw entities
Step 2 → Normalize và validate
Step 3 → Enrich với additional context
Mỗi step focused → accuracy cao hơn nhiều so với một mega-prompt.
Step 1 → Extract raw entities
Step 2 → Normalize và validate
Step 3 → Enrich với additional context
Mỗi step focused → accuracy cao hơn nhiều so với một mega-prompt.
Domain 5 · Context Management & Reliability
Long context strategies, handoff patterns, Batch API, error handling
15%
5.1 Lost-in-the-Middle Effect
Critical
K1
Cách model xử lý long context
Model xử lý reliable ở đầu và cuối input. Content ở GIỮA thường bị miss hoặc underweighted. Đây là design constraint thật, không phải bug — phải design xung quanh nó.
Anti-pattern: "Tăng context window để fix attention dilution" — context window size ≠ attention quality. Cần split thành focused passes, không phải throw more tokens at it.
K2
Strategies để mitigate
• Đặt key summaries và critical info ở ĐẦU aggregated input
• Dùng explicit section headers để guide attention
• Trim verbose tool outputs trước khi accumulate trong context
• Per-file analysis passes thay vì dump tất cả files vào một context
• Cross-file integration pass riêng biệt sau per-file passes
• Dùng explicit section headers để guide attention
• Trim verbose tool outputs trước khi accumulate trong context
• Per-file analysis passes thay vì dump tất cả files vào một context
• Cross-file integration pass riêng biệt sau per-file passes
# Per-file passes (ĐÚNG)
for file in files:
findings[file] = claude.review(
f"Review ONLY {file} for local issues:\n{file_content}"
)
# Separate integration pass
final = claude.synthesize(
f"## Key findings summary\n{summarize(findings)}\n\n"
f"Now identify cross-file integration issues."
)
# Single massive context (SAI — attention dilution)
# claude.review(f"Review all {len(files)} files: {all_files}")
5.2 Batch API vs. Real-time API
Thường ra đề
K3
Khi nào dùng Batch API và khi nào KHÔNG
Batch API tiết kiệm 50% cost nhưng có up-to-24h processing window, không có SLA.
Dùng Batch: overnight reports, weekly audits, bulk extraction jobs, non-blocking analytics, scheduled tasks.
KHÔNG dùng Batch: blocking workflows, user-facing requests, real-time agent loops, anything cần response ngay lập tức.
Dùng Batch: overnight reports, weekly audits, bulk extraction jobs, non-blocking analytics, scheduled tasks.
KHÔNG dùng Batch: blocking workflows, user-facing requests, real-time agent loops, anything cần response ngay lập tức.
Exam trap: "Route tất cả sang Batch API để tiết kiệm cost" → SAI. Đây là latency decision, không phải cost decision. Blocking workflow → real-time API bắt buộc.
5.3 Handoff Patterns & Error Handling
Patterns
K4
Required handoff summary fields
Khi handoff giữa agents hoặc escalate to human, summary bắt buộc phải có đủ:
• Customer ID (đã verified)
• Root cause của issue
• Refund amount (nếu applicable)
• Recommended action tiếp theo
Thiếu bất kỳ field nào → incomplete handoff → downstream không có context để xử lý.
• Customer ID (đã verified)
• Root cause của issue
• Refund amount (nếu applicable)
• Recommended action tiếp theo
Thiếu bất kỳ field nào → incomplete handoff → downstream không có context để xử lý.
K5
KHÔNG suppress errors silently
Khi subagent fail, KHÔNG return empty results. PHẢI return structured error context để coordinator có thể recover và re-delegate đúng cách.
# SAI — silent suppression
except Exception:
return [] # coordinator không biết gì đã xảy ra
# ĐÚNG — structured error context
except Exception as e:
return {
"error": str(e),
"error_type": "timeout",
"attempted_query": query,
"partial_results": partial,
"retry_recommended": True
}
Pattern: Coordinator nhận structured error → quyết định retry với different params, re-delegate sang different subagent, hoặc escalate to human với đủ context.
K6
Progressive summarization risks
Khi compress long conversation history, numeric values, percentages và dates thường bị vague hóa ("about 30%", "a few days ago", "roughly $500"). Cần explicit preservation strategy cho critical numbers trong summaries.
Design rule: Khi summarize, extract và preserve exact numbers riêng biệt trước khi tóm tắt prose. Đừng để model paraphrase con số tự nhiên.