1. ¿Qué es Claude Code?
Claude Code is a CLI AI coding assistant by Anthropic that runs directly in your terminal — reading/writing files, executing commands, managing Git. Not just code completion, but a true AI development agent.
Ingresos anuales estimados de $2.5 billion, siendo la herramienta de desarrollo AI de más rápido crecimiento. Supports parallel Sub-agents, complete Hooks system, CLAUDE.md persistent memory, and Command → Agent → Skill orchestration workflow.
vs Otras Herramientas
- Full terminal access
- Parallel Sub-agents
- Complete Hooks system
- CLAUDE.md memory
- $2.5B revenue (est.)
- IDE inline completion
- Inline code suggestions
- No agent capabilities
- No custom Hooks
- No memory system
- Graphical IDE interface
- Built-in AI chat
- Limited agent features
- 無 Hooks 系統
- No native orchestration
2. Arquitectura Central: Las Tres Cs
Claude Code's extensibility is built on three components: Agents, Commands, and Skills.
Agents
- Custom models & tools
- Background execution mode
- Hooks lifecycle
- Git Worktree isolation
- Skill preloading
Commands
- /slash command trigger
- Context fork isolation
- Model & effort override
- Tool permission control
- Shell script embedding
Skills
- Path-matching auto-load
- Agent preloading
- Independent fork execution
- simplify / batch / debug
- loop scheduled repeat
🤖 Agents — 16 Frontmatter Fields
| Campo | Tipo | Descripción |
|---|---|---|
| name | string | Unique identifier (lowercase + hyphens) |
| description | string | When to invoke. Use "PROACTIVELY" for auto-invocation |
| tools | string/list | Tool allowlist, supports Agent(type) syntax |
| disallowedTools | string/list | Tools removed from inherited list |
| model | string | haiku、sonnet、opus 或 inherit |
| permissionMode | string | default、acceptEdits、dontAsk、bypassPermissions、plan |
| maxTurns | integer | Maximum agentic turns |
| skills | list | Skill names preloaded at startup |
| mcpServers | list | MCP server connections |
| hooks | object | Lifecycle Hooks |
| memory | string | Memory scope: user、project、local |
| background | boolean | Set to true for background task execution |
| effort | string | low、medium、high、max |
| isolation | string | Set "worktree" to run in temporary git worktree |
| initialPrompt | string | First prompt auto-submitted when running as main agent |
| color | string | CLI output color (e.g. green、magenta) |
6 Official Built-in Agents
| # | Agent | Modelo | Herramientas | Propósito |
|---|---|---|---|---|
| 1 | general-purpose | inherit | All | 複雜多步驟任務 — 預Set 代理類型 |
| 2 | Explore | haiku | Read-only | Fast code search and exploration |
| 3 | Plan | inherit | Read-only | Pre-implementation planning |
| 4 | Bash | inherit | Bash | Execute terminal commands in separate context |
| 5 | statusline-setup | sonnet | Read, Edit | Set 定狀態列 |
| 6 | claude-code-guide | haiku | Glob, Grep, Read, WebFetch, WebSearch | Answer Claude Code feature questions |
⌨️ Commands — 13 Frontmatter Fields
| Campo | Tipo | Descripción |
|---|---|---|
| name | string | Display name and /slash-command ID |
| description | string | Description shown in autocomplete |
| argument-hint | string | Argument hint for autocomplete |
| disable-model-invocation | boolean | Prevent Claude from auto-invoking this command |
| user-invocable | boolean | Set false to hide from menu |
| paths | string/list | Glob patterns to limit loading |
| allowed-tools | string | Tools allowed without permission prompts |
| model | string | Model used when running |
| effort | string | Override effort level |
| context | string | Set fork to run in isolated subagent |
| agent | string | Subagent type when context: fork |
| shell | string | bash(預Set )或 powershell |
| hooks | object | Lifecycle hooks scoped to this command |
64 Official Commands (by Category)
| # | Comando | Categoría | Descripción |
|---|---|---|---|
| 1-3 | /login /logout /upgrade | Auth | Account login, logout, upgrade plan |
| 4-15 | /color /config /keybindings /permissions /privacy-settings /sandbox /statusline /stickers /terminal-setup /theme /vim /voice | Config | 主題、按鍵、權限、沙盒、語音等Set 定 |
| 16-22 | /context /cost /extra-usage /insights /stats /status /usage | Context | Context visualization, token usage, analytics |
| 23-27 | /doctor /feedback /help /release-notes /tasks | Debug | Diagnostics, bug reports, background tasks |
| 28-29 | /copy /export | Export | Copiar response to clipboard, export conversation |
| 30-37 | /agents /chrome /hooks /ide /mcp /plugin /reload-plugins /skills | Extensions | Agent, MCP, Plugin, Hooks management |
| 38 | /memory | Memory | 編輯 CLAUDE.md memory檔、管理 auto-memory |
| 39-43 | /effort /fast /model /passes /plan | Modelo | Model switching, effort adjustment, Plan mode |
| 44-49 | /add-dir /diff /init /pr-comments /review /security-review | Project | Working directory, Diff viewer, PR, security review |
| 50-56 | /desktop /install-github-app /install-slack-app /mobile /remote-control /remote-env /schedule | Remote | Desktop App, Slack, GitHub, remote control, cloud scheduling |
| 57-64 | /branch /btw /clear /compact /exit /rename /resume /rewind | Session | Branch, compact, rewind, Session management |
🧩 Skills — 13 Frontmatter Fields
| Campo | Tipo | Descripción |
|---|---|---|
| name | string | Display name and /slash-command ID |
| description | string | Description for auto-discovery |
| argument-hint | string | Argument hint for autocomplete |
| disable-model-invocation | boolean | Prevent Claude from auto-invoking |
| user-invocable | boolean | Set false to hide (agent preload only) |
| allowed-tools | string | Tools allowed without permission prompts |
| model | string | Model used when running |
| effort | string | Override effort level |
| context | string | Set fork to run in isolated subagent |
| agent | string | Subagent type when context: fork |
| hooks | object | Lifecycle hooks scoped to this skill |
| paths | string/list | Glob patterns to limit auto-loading |
| shell | string | bash(預Set )或 powershell |
5 Official Built-in Skills
| # | Skill | Propósito |
|---|---|---|
| 1 | simplify | Review changed code — refactor to eliminate duplication, improve quality |
| 2 | batch | Run commands across multiple files in bulk |
| 3 | debug | Debug failing commands or code issues |
| 4 | loop | Run prompts on a recurring schedule (up to 3 days) |
| 5 | claude-api | Build apps with Claude API / Anthropic SDK |
3. Sistema de Memoria
CLAUDE.md is Claude Code's persistent memory — loaded on every startup, letting Claude remember your project conventions, preferences, and workflows.
Writing a Good CLAUDE.md
CLAUDE.md is the most impactful way to improve Claude Code output:
- Project structure
- Code style conventions
- Common commands & paths
- Test & deploy workflows
- Personal preferences via CLAUDE.local.md
Three-Layer Loading
Claude Code loads memory in two directions:
- Ancestor loading (UP) — walks up from cwd at startup, loads all CLAUDE.md files
- Descendant loading (DOWN) — subdirectory files only load when accessed
- Global — ~/.claude/CLAUDE.md applies to all sessions
- Sibling directoriesnever load
Monorepo Structure Example
├── CLAUDE.md ← 根層共用(啟動即 load)
├── frontend/
│ └── CLAUDE.md ← before端專屬(讀取時才 load)
├── backend/
│ └── CLAUDE.md ← after端專屬(讀取時才 load)
└── api/
└── CLAUDE.md ← API 專屬(讀取時才 load)
從 /mymonorepo/frontend/ Starting from here:
✅ /mymonorepo/CLAUDE.md — 祖先目錄,啟動即 load
✅ frontend/CLAUDE.md — 當before目錄,啟動即 load
❌ backend/CLAUDE.md — 不同分支,不 load
❌ api/CLAUDE.md — 不同分支,不 load
4. Hooks: Barreras Determinísticas
Hooks are deterministic scripts that run outside the agentic loop — triggered on specific events, providing safety guardrails and automation.
Hooks trigger after tool operationscompletetriggers (PostToolUse), not before.PreToolUse is the exception — it can intercept before execution.
6 Hook Types Supported by Agents
PreToolUse
Triggersbeforetool execution. Can block, modify, or log pending operations.
PostToolUse
Triggersaftertool execution. Validate output, run linters, send notifications.
Notification
Triggers when Claude needs user attention. Connect to sounds, desktop notifications.
Stop
Triggers when agent completes a turn. Run final checks or cleanup.
SubagentStop
Triggers when subagent stops. Collect child agent results.
HTTP Hooks
Trigger external webhooks via HTTP POST with JSON payload.
Set 定範例
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "npx eslint --fix $CLAUDE_FILE_PATHS"
}
]
}
],
"Notification": [
{
"hooks": [
{
"type": "command",
"command": "afplay /System/Library/Sounds/Glass.aiff"
}
]
}
]
}
}
5. Flujo de Orquestación
Command → Agent → Skill is Claude Code's core orchestration pattern. A Command starts the flow, Agent handles execution, Skill provides domain knowledge.
Ejemplo: Sistema Meteorológico
| Componente | Rol | Ejemplo |
|---|---|---|
| Comando | Entry point, user interaction | /weather-orchestrator |
| Agent | Fetch data with preloaded skill | weather-agent(preloaded weather-fetcher) |
| Skill | Independent visual output | weather-svg-creator |
Flujo de Ejecución
// User input
/weather-orchestrator
// Step 1: Command asks user preference
├─ AskUser: "Celsius or Fahrenheit?"
│ └─ User: "Celsius"
// Step 2: Command invokes agent via Agent tool
├─ Agent tool → weather-agent
│ ├─ Preloaded Skill: weather-fetcher(domain knowledge)
│ ├─ Fetches from Open-Meteo API → 26°C
│ └─ Returns temperature to Command
// Step 3: Command invokes skill via Skill tool
├─ Skill tool → weather-svg-creator
│ ├─ Output → weather.svg(weather card)
│ └─ Output → output.md(summary)
// Done
└─ Display results to user
Agent Skill(預載): Injected via agent's skills field as domain knowledge.
Skill(獨立): Invoked independently via Skill tool, produces output directly.
6. Consejos Prácticos
Practical tips for everyday Claude Code usage to boost your productivity.
/context — Context Visualization
查看當before context 使用量的彩色格狀圖。顯示哪些工具佔用最多空間,建議如何優化。
context: fork
在 command 或 skill 中Set context: fork,讓它 to run in isolated subagent,不污染主對話。
paths Pattern Matching
用 paths 欄位Set 定 glob 模式,讓 skill 只在操作特定檔案時自動 load。
Auto Mode
用 claude --enable-auto-mode to start. Background safety classifier replaces manual permission prompts.
effort Adjustment
/effort low|medium|high|max to adjust thinking depth.max requires Opus 4.6.
/compact — Compress Conversation
When context is nearly full, use /compact to compress. Add focus:/compact keep API content
Flags CLI Comunes
| Flag | Abrev. | Descripción |
|---|---|---|
| --continue | -c | Continue most recent conversation |
| --resume | -r | Resume specific session |
| --model <NAME> | Specify model (sonnet, opus, haiku) | |
| -p | Non-interactive output (headless / SDK) | |
| --permission-mode | default、plan、acceptEdits、bypassPermissions | |
| --allowedTools | Tools allowed without permission prompts清單 | |
| --add-dir <path> | Add working directory to session | |
| --worktree | Run in git worktree | |
| --enable-auto-mode | Enable Auto Mode (beta) |
7. Instalación y Primeros Pasos
Tres pasos para empezar a usar Claude Code.
# 1. Install Claude Code
npm install -g @anthropic-ai/claude-code
# 2. Navigate to your project
cd your-project
# 3. Start Claude Code
claude
Referencia Rápida
🚀 Operaciones Básicas
claude # Start interactive mode
claude -c # Continue last conversation
claude -r # Resume specific session
claude -p "問題" # One-shot Q&A
claude /init # Initialize CLAUDE.md
⚙️ Operaciones Avanzadas
claude --model opus # Specify model
claude --worktree # Git worktree isolation
claude --enable-auto-mode # Auto Mode
/context # Check context usage
/compact # Compress conversation
/effort max # Maximum thinking depth
First time? Run claude /init to create CLAUDE.md and write your project conventions in it.
This is the highest ROI step — Claude remembers your preferences, making every conversation more precise.