Skip to content

A visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.

fix(cli): correct agent priority order to match official docs (#98) (#100)

Luong NGUYENe43872e9bdd8
diff --git a/.claude/skills/lesson-quiz/references/question-bank.md b/.claude/skills/lesson-quiz/references/question-bank.md
index 8d13a9d..6ed86b6 100644
--- a/.claude/skills/lesson-quiz/references/question-bank.md
+++ b/.claude/skills/lesson-quiz/references/question-bank.md
@@ -813,9 +813,9 @@
### Q7
- **Category**: conceptual
- **Question**: What is the agent definition priority order?
-- **Options**: A) Project > User > CLI | B) CLI > User > Project | C) User > CLI > Project | D) All are equal priority
+- **Options**: A) Project > User > CLI | B) CLI > Project > User | C) User > CLI > Project | D) All are equal priority
- **Correct**: B
-- **Explanation**: CLI-defined agents (--agents flag) have highest priority, then User-level (~/.claude/agents/), then Project-level (.claude/agents/).
+- **Explanation**: CLI-defined agents (--agents flag) have highest priority, then Project-level (.claude/agents/), then User-level (~/.claude/agents/).
- **Review**: Agents configuration section
### Q8
diff --git a/10-cli/README.md b/10-cli/README.md
index 21e39d3..a394aee 100644
--- a/10-cli/README.md
+++ b/10-cli/README.md
@@ -435,10 +435,10 @@ claude -p --agents "$(cat agents.json)" --model sonnet "analyze performance"
When multiple agent definitions exist, they are loaded in this priority order:
1. **CLI-defined** (`--agents` flag) - Session-specific
-2. **User-level** (`~/.claude/agents/`) - All projects
-3. **Project-level** (`.claude/agents/`) - Current project
+2. **Project-level** (`.claude/agents/`) - Current project
+3. **User-level** (`~/.claude/agents/`) - All projects
-CLI-defined agents override both user and project agents for the session.
+CLI-defined agents override both project and user agents for the session. Project-level agents override user-level agents when their names collide. See [Lesson 04 — Subagents](../04-subagents/README.md#file-locations) for the full priority table including plugin-level agents.
---