AI Coding Agent — Master Mindset Guide (2026)
A bilingual master guide to AI coding agents in 2026 — the 5 layers of control (rules, permissions, commands, skills, sub-agents), local vs cloud, single-to-multi-agent progression, prompting, and cost/context management.
Prompts · Rules · Skills · Sub-agents · Agent Teams · Local vs Cloud. {Prompts · Rules · Skills · Sub-agents · Agent Teams · Local vs Cloud.}
Updated: May 2026 · Bilingual EN / {VN}
Table of Contents {Mục lục}
- The Core Mental Model {Mental model cốt lõi}
- 5 Layers of Agent Control {5 lớp điều khiển agent}
- When to Use Which {Khi nào dùng cái nào}
- Local vs Cloud Agents {Agent local vs cloud}
- Single Agent → Multi-agent Progression {Tiến trình từ single đến multi-agent}
- Prompt Engineering Principles {Nguyên tắc viết prompt}
- The Daily Workflow {Workflow hàng ngày}
- Cost & Context Management {Quản lý chi phí và context}
- Quick Reference Card {Bảng tham chiếu nhanh}
1. The Core Mental Model {Mental model cốt lõi}
EN
An AI agent is not autocomplete. It is a junior engineer you delegate to.
Your job is not to write prompts. Your job is to design the environment in which the agent operates:
- What it knows (Rules, docs)
- What it can do (Permissions, tools)
- What patterns it follows (Skills, sub-agents)
- What it produces (Output formats, validation)
The agent is only as good as the environment you build. A skilled developer with a bad environment ships bad code. Same for agents.
The shift in thinking:
Before: "How do I write a better prompt?"
After: "How do I build a better system around the agent?"
Every time the agent makes a mistake, the question is not “how do I rephrase?” but “what’s missing in the environment that allowed this mistake?”
{VN}
AI agent không phải autocomplete. Nó là một junior engineer mà bạn delegate cho.
Công việc của bạn không phải viết prompt. Công việc của bạn là thiết kế môi trường để agent hoạt động:
- Nó biết gì (Rules, docs)
- Nó được làm gì (Permissions, tools)
- Nó theo pattern nào (Skills, sub-agents)
- Nó produce gì (Output formats, validation)
Agent chỉ tốt bằng môi trường bạn xây. Developer giỏi với môi trường tệ vẫn ship code tệ. Agent cũng vậy.
Thay đổi tư duy:
Trước: "Làm sao viết prompt tốt hơn?"
Bây giờ: "Làm sao xây hệ thống xung quanh agent tốt hơn?"
Mỗi khi agent sai, câu hỏi không phải “tôi rephrase thế nào?” mà là “môi trường thiếu gì khiến sai lầm này xảy ra?“
2. The 5 Layers of Agent Control {5 lớp điều khiển agent}
EN
A mature agent setup has 5 layers. Each solves a different problem. Don’t skip layers.
┌─────────────────────────────────────────────────────────────┐
│ Layer 5: Multi-agent orchestration │
│ Sub-agents, Agent Teams │
│ "Delegate isolated work" │
├─────────────────────────────────────────────────────────────┤
│ Layer 4: Skills │
│ .claude/skills/*/SKILL.md │
│ "Procedural knowledge with scripts, auto-discovered" │
├─────────────────────────────────────────────────────────────┤
│ Layer 3: Commands │
│ .claude/commands/*.md │
│ "Quick prompt templates I trigger manually" │
├─────────────────────────────────────────────────────────────┤
│ Layer 2: Permissions + Hooks │
│ .claude/settings.json │
│ "Safety + automation" │
├─────────────────────────────────────────────────────────────┤
│ Layer 1: Rules (foundation) │
│ CLAUDE.md, .cursor/rules/*.mdc │
│ "Always-on behavior, conventions, constraints" │
└─────────────────────────────────────────────────────────────┘
Critical insight: These layers are not alternatives. They complement each other.
{VN}
Một agent setup hoàn chỉnh có 5 lớp. Mỗi lớp giải quyết vấn đề khác nhau. Đừng skip lớp.
┌─────────────────────────────────────────────────────────────┐
│ Lớp 5: Multi-agent orchestration │
│ Sub-agents, Agent Teams │
│ "Delegate công việc cô lập" │
├─────────────────────────────────────────────────────────────┤
│ Lớp 4: Skills │
│ .claude/skills/*/SKILL.md │
│ "Kiến thức quy trình + scripts, auto-discover" │
├─────────────────────────────────────────────────────────────┤
│ Lớp 3: Commands │
│ .claude/commands/*.md │
│ "Prompt template nhanh, gọi thủ công" │
├─────────────────────────────────────────────────────────────┤
│ Lớp 2: Permissions + Hooks │
│ .claude/settings.json │
│ "Safety + automation" │
├─────────────────────────────────────────────────────────────┤
│ Lớp 1: Rules (nền tảng) │
│ CLAUDE.md, .cursor/rules/*.mdc │
│ "Always-on behavior, conventions, constraints" │
└─────────────────────────────────────────────────────────────┘
Insight quan trọng: 5 lớp này KHÔNG phải alternatives. Chúng bổ sung cho nhau.
Layer 1 — Rules {Lớp 1 — Rules}
EN
- What: Behavioral guidelines that load into EVERY session/request
- Format:
CLAUDE.md(Claude Code) or.cursor/rules/*.mdc(Cursor) - Cost: Always in context — keep lean (<400 tokens)
- Use for: Naming conventions, stack constraints, “never do X” rules, code style
- Don’t use for: Procedural workflows, multi-step processes, scripts
Example rule that works:
Components: PascalCase filename → UserCard.tsx (NOT user-card.tsx)
Named exports only (except files in src/pages/)
NEVER store API data in Zustand → use React Query
Example rule that doesn’t work:
Write clean code ← too vague
Follow best practices ← unmeasurable
Be careful with types ← AI can't act on this
{VN}
- Là gì: Behavioral guidelines load vào MỌI session/request
- Format:
CLAUDE.md(Claude Code) hoặc.cursor/rules/*.mdc(Cursor) - Chi phí: Luôn trong context — giữ lean (<400 tokens)
- Dùng cho: Naming conventions, stack constraints, “never do X” rules, code style
- Đừng dùng cho: Procedural workflows, multi-step processes, scripts
Rule hoạt động:
Components: PascalCase filename → UserCard.tsx (KHÔNG user-card.tsx)
Named exports only (trừ files trong src/pages/)
NEVER store API data in Zustand → dùng React Query
Rule KHÔNG hoạt động:
Write clean code ← quá mơ hồ
Follow best practices ← không đo được
Be careful with types ← AI không action được
Layer 2 — Permissions + Hooks {Lớp 2 — Permissions + Hooks}
EN
- What: Safety boundaries + automatic actions
- Format:
.claude/settings.json - Cost: Zero token cost (system-level enforcement)
- Use for: Restricting dangerous commands, auto-running TypeScript check after edits, denying access to secrets
Example settings.json:
{
"permissions": {
"allow": [
"Bash(pnpm run *)",
"Bash(npx tsc --noEmit)",
"Read(./src/**)"
],
"deny": [
"Bash(git push *)",
"Bash(rm -rf *)",
"Read(./.env*)"
]
},
"hooks": {
"PostToolUse": [{
"matcher": "Write(./src/**/*.tsx)",
"hooks": [{
"type": "command",
"command": "npx tsc --noEmit 2>&1 | head -20"
}]
}]
}
}
{VN}
- Là gì: Safety boundaries + automatic actions
- Format:
.claude/settings.json - Chi phí: Zero token (system-level enforcement)
- Dùng cho: Restrict dangerous commands, auto-run TypeScript check sau edits, deny access secrets
The settings.json example above applies as-is.
{Ví dụ settings.json ở trên dùng nguyên xi.}
Layer 3 — Commands {Lớp 3 — Commands}
EN
- What: Reusable prompt templates triggered manually with
/command - Format:
.claude/commands/*.md - Cost: Loads when called (~200-500 tokens depending on template)
- Use for: Workflows you type the same prompt for repeatedly
- Don’t use for: Behavior that should auto-trigger (use Skills) or workflows needing isolated context (use Sub-agents)
Example /new-component:
Create React component: $ARGUMENTS
Steps:
1. Create folder src/components/$ARGUMENTS/
2. Create $ARGUMENTS.tsx with TypeScript, named export
3. Create $ARGUMENTS.module.scss
4. Create $ARGUMENTS.test.tsx
5. Create index.ts barrel export
Use AntD v4 components. Props interface: ${ARGUMENTS}Props in same file.
Usage: /new-component ProductCard
{VN}
- Là gì: Reusable prompt templates trigger thủ công bằng
/command - Format:
.claude/commands/*.md - Chi phí: Load khi gọi (~200-500 tokens tùy template)
- Dùng cho: Workflows bạn gõ cùng prompt lặp lại
- Đừng dùng cho: Behavior cần auto-trigger (dùng Skills) hoặc workflows cần isolated context (dùng Sub-agents)
The /new-component template above is the same in both languages.
{Template /new-component ở trên giống nhau ở cả hai ngôn ngữ.}
Layer 4 — Skills {Lớp 4 — Skills}
EN
- What: Procedural knowledge with optional scripts, auto-discovered by description
- Format:
.claude/skills/<name>/SKILL.md(with optional files) - Cost: ~100 tokens (metadata) until triggered, then loads body on-demand
- Key feature: Progressive disclosure — skill can have 50 files but Claude only loads what’s needed
- Use for: Multi-step workflows, knowledge with reference docs, scripts to execute
- Don’t use for: Simple style rules (use Rules), one-off prompts (just type them)
Example folder structure:
.claude/skills/handoff/
├── SKILL.md ← Entry point, YAML frontmatter
├── templates/
│ └── handoff-template.md
└── scripts/
├── collect-changes.sh
└── check-status.sh
SKILL.md anatomy:
---
name: handoff
description: |
Create HANDOFF.md when context > 60% or ending session.
Use when: save progress, wrap up, context full.
Triggers: handoff, save progress, end session.
---
# System prompt body
[Workflow instructions, templates, constraints]
Critical pattern: Use “MUST BE USED for X” in description — this significantly lifts auto-routing priority per Anthropic docs.
{VN}
- Là gì: Kiến thức quy trình với optional scripts, auto-discover bằng description
- Format:
.claude/skills/<name>/SKILL.md(với optional files) - Chi phí: ~100 tokens (metadata) đến khi trigger, sau đó load body on-demand
- Tính năng quan trọng: Progressive disclosure — skill có 50 files nhưng Claude chỉ load những gì cần
- Dùng cho: Multi-step workflows, knowledge với reference docs, scripts để execute
- Đừng dùng cho: Style rules đơn giản (dùng Rules), one-off prompts (cứ gõ trực tiếp)
The folder structure and SKILL.md anatomy above apply to both.
{Cấu trúc folder và anatomy SKILL.md ở trên áp dụng cho cả hai.}
Pattern quan trọng: Dùng “MUST BE USED for X” trong description — pattern này lift auto-routing priority đáng kể theo Anthropic docs.
Layer 5 — Sub-agents + Agent Teams {Lớp 5 — Sub-agents + Agent Teams}
EN
Sub-agents are specialized AI instances that handle specific tasks in isolated context windows.
- Format:
.claude/agents/<name>.md(YAML frontmatter + system prompt) - Cost: ~7x normal (each has own context) but worth it for context isolation
- Key insight: Exploration tasks pollute main context with 50K tokens of file reads. Run in sub-agent → main session only sees 500-token summary.
- Use for: Code review, research, parallel analysis, specialist work
- Don’t use for: Tasks under 3 files, one-off jobs
Sub-agent example:
---
name: code-reviewer
description: |
Expert code reviewer. MUST BE USED after code changes.
Use when: PR ready, before merge, quality check.
tools: Read, Grep, Glob, Bash
model: sonnet
---
You are a senior code reviewer.
[Workflow + output format]
Agent Teams (experimental, requires CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1):
- Multiple sub-agents that can communicate with each other
- Used for: agents that need to debate/collaborate in real-time
- Most use cases don’t need this — sub-agents are sufficient
3 Built-in sub-agents Claude provides:
- Explore (Haiku, read-only) — search/analyze codebase
- Plan (read-only) — research during plan mode
- General-purpose (full tools) — complex multi-step tasks
“If your work fits one of the built-ins, use it. Custom sub-agents are for when it doesn’t.” — Anthropic docs
{VN}
Sub-agents là specialized AI instances handle tasks cụ thể trong isolated context windows.
- Format:
.claude/agents/<name>.md(YAML frontmatter + system prompt) - Chi phí: ~7x bình thường (mỗi agent có context riêng) nhưng đáng giá vì context isolation
- Insight quan trọng: Exploration tasks pollute main context với 50K tokens. Chạy trong sub-agent → main session chỉ thấy 500-token summary.
- Dùng cho: Code review, research, parallel analysis, specialist work
- Đừng dùng cho: Tasks dưới 3 files, one-off jobs
The code-reviewer example above applies to both.
{Ví dụ code-reviewer ở trên áp dụng cho cả hai.}
Agent Teams (experimental): Multiple sub-agents giao tiếp với nhau real-time. Hầu hết use cases không cần — sub-agents đủ rồi.
3 Built-in sub-agents Claude có sẵn:
- Explore (Haiku, read-only) — search/analyze codebase
- Plan (read-only) — research trong plan mode
- General-purpose (full tools) — complex multi-step tasks
“Nếu công việc của bạn fit một trong built-in, dùng nó. Custom sub-agents chỉ cho khi không fit.” — Anthropic docs
3. When to Use Which {Khi nào dùng cái nào}
EN — Decision Tree
You have an AI coding task. What do you reach for?
Q1: Is this a one-time task you'll likely never repeat?
├── YES → Just write a prompt directly. Don't build infrastructure.
└── NO ↓
Q2: Will it pollute context with lots of file reads/exploration?
├── YES → Sub-agent (isolated context)
└── NO ↓
Q3: Is it primarily "how to behave" (style, naming, conventions)?
├── YES → Rule in CLAUDE.md
└── NO ↓
Q4: Does it need scripts, executables, or multi-file references?
├── YES → Skill (.claude/skills/)
└── NO ↓
Q5: Is it a prompt you type the same way 3+ times per week?
├── YES → Command (/cmd)
└── NO → Just write a prompt
{VN} — Decision Tree
Bạn có AI coding task. Dùng cái nào?
Q1: Đây là one-time task chắc không lặp lại?
├── CÓ → Chỉ cần viết prompt trực tiếp. Đừng build infrastructure.
└── KHÔNG ↓
Q2: Sẽ pollute context với nhiều file reads/exploration?
├── CÓ → Sub-agent (isolated context)
└── KHÔNG ↓
Q3: Chủ yếu là "behave thế nào" (style, naming, conventions)?
├── CÓ → Rule trong CLAUDE.md
└── KHÔNG ↓
Q4: Cần scripts, executables, hoặc multi-file references?
├── CÓ → Skill (.claude/skills/)
└── KHÔNG ↓
Q5: Prompt bạn gõ cùng kiểu 3+ lần/tuần?
├── CÓ → Command (/cmd)
└── KHÔNG → Chỉ cần viết prompt
EN — Quick Comparison Table
| Concern | Tool |
|---|---|
| ”Always follow this convention” | Rule |
| ”Never run this dangerous command” | Permission (settings.json) |
| “Auto-check TypeScript after edits” | Hook (settings.json) |
| “Quick template for new component” | Command |
| ”Multi-step workflow with scripts” | Skill |
| ”Don’t pollute my main context with research” | Sub-agent |
| ”Multiple specialists working in parallel” | Multiple sub-agents (fan-out) |
| “Builder + independent validator” | Validation chain (two sub-agents) |
| “Background tasks while I work elsewhere” | Cloud agent (see Section 4) |
{VN} — Bảng so sánh nhanh
The table above is universal — the concepts map 1:1 across languages. {Bảng trên mang tính phổ quát — các khái niệm ánh xạ 1:1 giữa hai ngôn ngữ.}
4. Local vs Cloud Agents {Agent local vs cloud}
EN
There are 4 mechanisms for letting AI agents work without you watching:
┌─────────────────────────────────────────────────────────────┐
│ 1. Local interactive (default) │
│ claude — terminal session you watch │
│ "Tight feedback loop, you approve each step" │
├─────────────────────────────────────────────────────────────┤
│ 2. Agent View (local background) │
│ claude agents — dashboard of background sessions │
│ "Multiple parallel local agents, you monitor" │
├─────────────────────────────────────────────────────────────┤
│ 3. Headless (CI/CD) │
│ claude -p — single-shot, no interaction │
│ "Scripts, automation, GitHub Actions" │
├─────────────────────────────────────────────────────────────┤
│ 4. Cloud agents │
│ Cursor Background Agents, Routines (claude.ai) │
│ "Runs on cloud VM, you check back later" │
└─────────────────────────────────────────────────────────────┘
{VN}
Có 4 cơ chế để AI agents làm việc mà không cần bạn nhìn:
┌─────────────────────────────────────────────────────────────┐
│ 1. Local interactive (mặc định) │
│ claude — phiên terminal bạn theo dõi │
│ "Feedback loop chặt, bạn duyệt từng bước" │
├─────────────────────────────────────────────────────────────┤
│ 2. Agent View (local background) │
│ claude agents — dashboard các phiên chạy nền │
│ "Nhiều agent local song song, bạn giám sát" │
├─────────────────────────────────────────────────────────────┤
│ 3. Headless (CI/CD) │
│ claude -p — chạy một phát, không tương tác │
│ "Scripts, automation, GitHub Actions" │
├─────────────────────────────────────────────────────────────┤
│ 4. Cloud agents │
│ Cursor Background Agents, Routines (claude.ai) │
│ "Chạy trên cloud VM, bạn quay lại check sau" │
└─────────────────────────────────────────────────────────────┘
Local Agents — When and Why {Local Agents — Khi nào và tại sao}
EN
Local = runs on your machine, accesses your local filesystem
✅ Use local when:
- Tight feedback loop needed (refactor, debug, exploration)
- Work with sensitive code that shouldn’t leave your machine
- You want to watch and intervene immediately
- Project requires local-only tools (specific DB, internal services)
- Cost-sensitive (uses your existing subscription, no extra cloud fees)
❌ Don’t use local when:
- You want to close laptop and have agent continue
- Need parallel browser-based UI testing
- Long-running task (hours) that you can’t supervise
Tools:
- Claude Code — terminal-native, local-first
- Cursor (editor mode) — IDE-integrated, local
{VN}
Local = chạy trên máy bạn, access local filesystem của bạn
✅ Dùng local khi:
- Cần tight feedback loop (refactor, debug, exploration)
- Làm việc với sensitive code không nên rời máy
- Muốn watch và intervene ngay
- Project cần local-only tools (DB cụ thể, internal services)
- Cost-sensitive (dùng subscription hiện có, không extra cloud fees)
❌ Đừng dùng local khi:
- Muốn đóng laptop và agent vẫn chạy tiếp
- Cần parallel browser-based UI testing
- Long-running task (hàng giờ) bạn không thể supervise
Tools:
- Claude Code — terminal-native, local-first
- Cursor (editor mode) — IDE-integrated, local
Cloud Agents — When and Why {Cloud Agents — Khi nào và tại sao}
EN
Cloud = runs on remote VM, fire-and-forget, check back later
✅ Use cloud when:
- Task takes hours and you want to do other work
- Need parallel agents (8+) without local resource constraints
- Browser-based testing (Cursor BG agents have full desktop env)
- Recurring scheduled tasks (Anthropic Routines)
- Async delegation (PRs from agent, you review later)
❌ Don’t use cloud when:
- Quick tasks (overhead of context handoff > benefit)
- Sensitive code that shouldn’t leave your infrastructure
- Need to intervene mid-task constantly
- Cost-sensitive (cloud agents add separate billing)
Tools:
- Cursor Background Agents — up to 8 parallel cloud VMs with desktop env
- Anthropic Routines (claude.ai) — recurring scheduled or trigger-based
- GitHub Copilot Cloud Agents — Claude/Codex agents in cloud, integrated with PR workflow
Pricing caveat: Starting June 2026, claude -p (headless) on subscription plans draws from a separate Agent SDK credit pool. Plan CI usage carefully.
{VN}
Cloud = chạy trên remote VM, fire-and-forget, quay lại check sau
✅ Dùng cloud khi:
- Task mất hàng giờ và bạn muốn làm việc khác
- Cần parallel agents (8+) không bị giới hạn local resource
- Browser-based testing (Cursor BG agents có full desktop env)
- Recurring scheduled tasks (Anthropic Routines)
- Async delegation (PRs từ agent, bạn review sau)
❌ Đừng dùng cloud khi:
- Quick tasks (overhead context handoff > benefit)
- Sensitive code không nên rời infrastructure
- Cần intervene giữa task liên tục
- Cost-sensitive (cloud agents add separate billing)
Tools:
- Cursor Background Agents — đến 8 parallel cloud VMs với desktop env
- Anthropic Routines (claude.ai) — recurring scheduled hoặc trigger-based
- GitHub Copilot Cloud Agents — Claude/Codex agents trên cloud, integrate với PR workflow
Pricing caveat: Từ tháng 6/2026, claude -p (headless) trên subscription plans dùng separate Agent SDK credit pool. Plan CI usage cẩn thận.
EN — The 2026 Production Stack
Most teams shipping fast in 2026 don’t pick one — they compose:
Claude Code (local) → craftsmanship, refactor, debug, sensitive work
Cursor Background (cloud) → parallelism, UI testing, async tasks
Claude Routines (cloud) → recurring jobs (security scans, doc audits)
Headless claude -p (CI) → automation pipelines
One API key, multiple execution surfaces.
{VN} — Production Stack 2026
Hầu hết teams ship nhanh năm 2026 không pick một — họ compose:
Claude Code (local) → craftsmanship, refactor, debug, sensitive work
Cursor Background (cloud) → parallelism, UI testing, async tasks
Claude Routines (cloud) → recurring jobs (security scans, doc audits)
Headless claude -p (CI) → automation pipelines
Một API key, nhiều execution surfaces.
5. Single Agent → Multi-agent Progression {Single → Multi-agent}
EN
Don’t jump to multi-agent setup on day 1. Progress through levels:
Level 1 — Single agent + Rules
- CLAUDE.md with 10-15 rules
- Permissions in settings.json
- You write prompts directly
Time investment: 1-2 hours setup
Returns: Consistent code style, no convention drift
Level 2 — Add Commands
- 3-5 commands for repeated workflows (/new-component, /handoff)
- Hooks for auto-TypeScript check
Time investment: +2-3 hours
Returns: 5-minute tasks become 30 seconds
Level 3 — Add Skills
- 2-3 skills for procedural workflows (handoff, codebase-auditor)
- First skill with scripts (capability uplift)
Time investment: +4-6 hours
Returns: Complex workflows become single-command
Level 4 — Add Sub-agents
- Code reviewer (read-only)
- Test writer (Haiku, cost-optimized)
- 2-3 specialists (frontend, state, API)
Time investment: +6-8 hours
Returns: Context isolation, parallel work, specialized quality
Level 5 — Multi-agent orchestration
- Builder + validator chains
- Cost pyramid (Opus orchestrate, Sonnet implement, Haiku search)
- Cloud agents for parallel work
Time investment: +10-15 hours
Returns: Ship features 3-5x faster, near-autonomous workflows
Don’t skip levels. Each level builds on what you learned from previous. Jumping to Level 5 without Level 1 = chaotic agent behavior.
{VN}
Đừng jump thẳng vào multi-agent setup ngày 1. Progress qua từng level:
Level 1 — Single agent + Rules
- CLAUDE.md với 10-15 rules
- Permissions trong settings.json
- Bạn viết prompts trực tiếp
Đầu tư: 1-2 giờ setup
Thu lại: Code style nhất quán, không drift convention
Level 2 — Thêm Commands
- 3-5 commands cho workflows lặp lại (/new-component, /handoff)
- Hooks cho auto-TypeScript check
Đầu tư: +2-3 giờ
Thu lại: Task 5 phút còn 30 giây
Level 3 — Thêm Skills
- 2-3 skills cho procedural workflows (handoff, codebase-auditor)
- Skill đầu tiên có scripts (nâng capability)
Đầu tư: +4-6 giờ
Thu lại: Workflow phức tạp thành single-command
Level 4 — Thêm Sub-agents
- Code reviewer (read-only)
- Test writer (Haiku, tối ưu chi phí)
- 2-3 specialists (frontend, state, API)
Đầu tư: +6-8 giờ
Thu lại: Context isolation, parallel work, chất lượng chuyên biệt
Level 5 — Multi-agent orchestration
- Builder + validator chains
- Cost pyramid (Opus orchestrate, Sonnet implement, Haiku search)
- Cloud agents cho parallel work
Đầu tư: +10-15 giờ
Thu lại: Ship features nhanh 3-5x, workflow gần như tự động
Đừng skip levels. Mỗi level build trên những gì bạn học từ level trước. Jump thẳng Level 5 mà không có Level 1 = chaotic agent behavior.
6. Prompt Engineering Principles {Nguyên tắc viết prompt}
EN
Even with all 5 layers in place, prompts still matter. The CARET framework:
C — Context What's the situation? What does the agent need to know?
A — Action What specifically should it do?
R — Result What should the output look like?
E — Examples Show good examples. Show what NOT to do (negative examples are powerful).
T — Test How do we know it's done correctly?
Bad vs Good Prompts
❌ Bad: “Write a function to handle user input”
✅ Good:
Context: Building a signup form. User input is email + password.
Action: Create validateSignupInput(input) function in src/utils/validation.ts
Result:
- Returns { valid: boolean, errors: string[] }
- Errors are user-facing messages (no technical jargon)
- Email validation: standard regex + max 254 chars
- Password: min 8 chars, must contain letter + number
Examples:
✅ Good: { valid: false, errors: ["Email is required", "Password must be at least 8 characters"] }
❌ Bad: { valid: false, errors: ["VALIDATION_EMAIL_EMPTY"] } ← technical codes
Test:
- Write tests in src/utils/validation.test.ts
- Cover: valid input, missing fields, invalid email format, short password
- All tests pass
Negative Examples Are Underrated
Telling the agent what NOT to do is often more effective than telling it what to do:
DON'T:
- Use `any` type
- Catch errors and silently swallow them
- Use index as React key in lists
- Hardcode API URLs
DO:
- Use `unknown` + type guard
- Log errors with context AND show user-friendly message
- Use stable IDs as keys
- Use environment variables (import.meta.env)
{VN}
Even với 5 layers đầy đủ, prompts vẫn quan trọng. Framework CARET:
C — Context Tình huống là gì? Agent cần biết gì?
A — Action Cụ thể làm gì?
R — Result Output trông như thế nào?
E — Examples Show good examples. Show NOT to do (negative examples mạnh hơn).
T — Test Làm sao biết đúng?
The Bad vs Good prompt example and DON’T/DO list above apply to both languages. {Ví dụ prompt Tệ vs Tốt và danh sách DON’T/DO ở trên áp dụng cho cả hai ngôn ngữ.}
Negative examples bị underrated. Nói cho agent biết KHÔNG làm gì thường effective hơn nói làm gì.
7. The Daily Workflow {Workflow hàng ngày}
EN — Starting a session
1. Open project: cd my-project && claude
2. Quick context: /status (see context %)
3. If resuming: "Read .claude/HANDOFF.md and continue from Next steps"
4. If new task: paste spec or describe task with CARET framework
EN — During work
- Watch context %: switch to new session at 60-70%
- Use sub-agents for exploration (don't pollute main context)
- Run /agents to see what sub-agents are available
- After every major task: verify (tsc --noEmit, tests pass)
EN — Ending session
1. Run handoff skill: "create handoff"
2. Skill writes .claude/HANDOFF.md with:
- Completed tasks
- In-progress work + exact resume point
- Key decisions + reasoning
- Files changed
- Next steps for new session
3. Commit code if appropriate
4. Close session
EN — When agent makes a mistake
Step 1: Don't just fix the output. Ask: "Why did the environment allow this?"
Step 2: Identify which layer failed:
- Convention wrong? → Update Rule
- Workflow wrong? → Update Skill or Command
- Wrong agent invoked? → Tighten description
- Code wrong despite good rules? → Add example/negative example
Step 3: Update the layer. Test that the fix works.
Step 4: Move on.
{VN} — Bắt đầu một phiên
1. Mở project: cd my-project && claude
2. Context nhanh: /status (xem context %)
3. Nếu resume: "Đọc .claude/HANDOFF.md và tiếp tục từ Next steps"
4. Nếu task mới: paste spec hoặc mô tả task bằng framework CARET
{VN} — Trong lúc làm
- Theo dõi context %: chuyển session mới ở mức 60-70%
- Dùng sub-agents cho exploration (đừng pollute main context)
- Chạy /agents để xem sub-agents nào có sẵn
- Sau mỗi task lớn: verify (tsc --noEmit, tests pass)
{VN} — Kết thúc phiên
1. Chạy handoff skill: "create handoff"
2. Skill ghi .claude/HANDOFF.md gồm:
- Tasks đã xong
- Việc đang làm + điểm resume chính xác
- Quyết định quan trọng + lý do
- Files đã đổi
- Next steps cho phiên mới
3. Commit code nếu phù hợp
4. Đóng session
{VN} — Khi agent mắc lỗi
Bước 1: Đừng chỉ fix output. Hỏi: "Tại sao môi trường cho phép điều này?"
Bước 2: Xác định layer nào fail:
- Sai convention? → Update Rule
- Sai workflow? → Update Skill hoặc Command
- Gọi nhầm agent? → Siết lại description
- Code sai dù rule tốt? → Thêm example/negative example
Bước 3: Update layer đó. Test rằng fix hoạt động.
Bước 4: Đi tiếp.
8. Cost & Context Management {Quản lý chi phí và context}
EN
Context window is your most valuable resource. Manage it like RAM.
Strategies:
1. Use the cost pyramid for model selection:
Haiku (~25x cheaper than Opus)
↑ search, summarize, simple read tasks
Sonnet (balanced)
↑ implementation, code review
Opus (most expensive)
↑ orchestration, architecture decisions
2. Sub-agents for context-heavy tasks:
- Searching across 50 files? → Sub-agent (Haiku, read-only)
- Code review of large PR? → Sub-agent (Sonnet, read-only)
- The findings come back as summary, not 50,000 tokens of file content
3. Skills don’t load until needed:
- Skill metadata: ~100 tokens
- Body loads only when triggered
- Linked files load only when SKILL.md references them
- A skill with 50 files can stay “installed” without context cost
4. /clear between unrelated tasks:
- Long sessions accumulate dead-end exploration history
- Each turn resends all of it
- /clear cuts per-message cost 30-50%
5. Stop idle agents:
- Background agents/sub-agents idle = still consuming quota
- /stop when task complete
- An idle Opus session is not free
6. Handoff before context full:
- Quality degrades after 70% context usage
- Auto-compact loses information
- Run handoff skill at 60% → start fresh session
{VN}
Context window là resource quý nhất. Quản lý nó như RAM.
Chiến lược:
1. Dùng cost pyramid để chọn model:
Haiku (~25x rẻ hơn Opus)
↑ search, summarize, read tasks đơn giản
Sonnet (cân bằng)
↑ implementation, code review
Opus (đắt nhất)
↑ orchestration, quyết định architecture
2. Sub-agents cho task nặng context:
- Search qua 50 files? → Sub-agent (Haiku, read-only)
- Code review PR lớn? → Sub-agent (Sonnet, read-only)
- Kết quả trả về dạng summary, không phải 50.000 tokens nội dung file
3. Skills không load đến khi cần:
- Skill metadata: ~100 tokens
- Body chỉ load khi trigger
- Linked files chỉ load khi SKILL.md reference tới
- Skill 50 files có thể “installed” mà không tốn context
4. /clear giữa các task không liên quan:
- Session dài tích lũy lịch sử exploration ngõ cụt
- Mỗi lượt gửi lại toàn bộ
- /clear cắt 30-50% chi phí mỗi message
5. Stop idle agents:
- Background agents/sub-agents idle = vẫn tốn quota
- /stop khi task xong
- Một phiên Opus idle không miễn phí
6. Handoff trước khi context đầy:
- Chất lượng giảm sau 70% context
- Auto-compact mất thông tin
- Chạy handoff skill ở 60% → bắt đầu session mới
9. Quick Reference Card {Bảng tham chiếu nhanh}
EN — File Locations
project-root/
├── .claude/
│ ├── CLAUDE.md ← Rules (always-on, commit git)
│ ├── CLAUDE.local.md ← Personal rules (gitignore)
│ ├── settings.json ← Permissions + hooks (commit)
│ ├── settings.local.json ← Personal overrides (gitignore)
│ ├── commands/ ← Slash commands (commit)
│ │ ├── new-component.md ← /new-component
│ │ └── handoff.md ← /handoff
│ ├── agents/ ← Sub-agents (commit)
│ │ ├── code-reviewer.md
│ │ └── test-writer.md
│ └── skills/ ← Skills (commit)
│ ├── handoff/
│ │ ├── SKILL.md
│ │ ├── templates/
│ │ └── scripts/
│ └── codebase-auditor/
│
├── .cursor/
│ └── rules/ ← Cursor rules (commit)
│ ├── base.mdc ← alwaysApply
│ ├── react-components.mdc ← glob match
│ └── personal.mdc ← gitignore
│
├── .mcp.json ← MCP servers (commit)
│
├── docs/ ← Documentation referenced by rules
│ ├── ARCHITECTURE.md
│ ├── COMPONENT_GUIDE.md
│ ├── STATE_MANAGEMENT.md
│ └── API_PATTERNS.md
│
└── ~/.claude/ ← Global (user-level, not committed)
├── CLAUDE.md ← Personal cross-project rules
├── agents/ ← Personal sub-agents
└── skills/ ← Personal skills
EN — Commands Cheatsheet
# Session management
claude # start session
claude agents # agent view (dashboard)
claude -p "task" # headless (single-shot)
/clear # clear context within session
/status # see context %, model, etc.
/agents # list available sub-agents
/handoff # if you've installed handoff skill
exit # end session
# Cost management
/cost # session cost so far
/usage # quota stats
/stop # stop a sub-agent
# Model selection
claude --model claude-opus-4-7 # use Opus
export CLAUDE_CODE_SUBAGENT_MODEL= # default for sub-agents
"claude-sonnet-4-5"
EN — Rule of Thumb Decisions
| Situation | Action |
|---|---|
| Repeated task this week | Make it a Command |
| Procedural workflow with scripts | Make it a Skill |
| Pollutes context with file reads | Make it a Sub-agent |
| Convention violated repeatedly | Add Rule + negative example |
| Risky command needed | Add to settings.json allow/deny |
| Auto-check after edits | Add Hook |
| Long-running async work | Cloud agent |
| Quick refactor with feedback | Local agent |
| Context > 60% | Handoff + new session |
| Task < 3 files | Don’t orchestrate, single agent |
| Task > 5 files across domains | Sub-agent specialists |
{VN}
The file layout, commands cheatsheet, and rule-of-thumb table above are language-neutral — use them as-is. {Bố cục file, cheatsheet lệnh, và bảng rule-of-thumb ở trên trung lập ngôn ngữ — dùng nguyên xi.}
Closing Thoughts {Suy nghĩ cuối}
EN
The hardest mindset shift in 2026 isn’t learning new tools. It’s learning that:
- Your job is environment design, not prompt writing
- Mistakes are signals about your environment, not the agent
- Layers compound — Rules + Commands + Skills + Sub-agents > sum of parts
- Don’t over-engineer — Skip layers you don’t need yet
- Iterate — Setup is never “done”, it evolves with codebase
Teams shipping fastest in 2026 invested 20-40 hours in their agent infrastructure. That’s 1 week of work for a permanent multiplier on every future task.
The mindset: Treat your agent setup like product code. Version control it, review it, refactor it, test it.
{VN}
Sự thay đổi mindset khó nhất năm 2026 không phải học tools mới. Đó là học rằng:
- Công việc của bạn là environment design, không phải prompt writing
- Mistakes là signals về environment, không phải về agent
- Layers compound — Rules + Commands + Skills + Sub-agents > tổng các phần
- Đừng over-engineer — Skip layers chưa cần
- Iterate — Setup không bao giờ “xong”, nó evolve theo codebase
Teams ship nhanh nhất năm 2026 đầu tư 20-40 giờ vào agent infrastructure. Đó là 1 tuần làm việc để có permanent multiplier cho mọi task tương lai.
Mindset: Treat agent setup như product code. Version control, review, refactor, test.
Sources: Anthropic Engineering blog · code.claude.com/docs · Cursor changelog · verified May 2026.