一份实用的 Claude 代码指南,包含清晰的思维模型和复制粘贴示例 — 设置、提示工程、斜杠命令、技能、钩子、子代理、代理团队
一份实用的 Claude 代码指南,包含清晰的思维模型和复制粘贴示例 — 设置、提示工程、斜杠命令、技能、钩子、子代理、代理团队
From first prompt to agent teams — one guide.
A practical guide to Claude Code — from your first prompt to multi-agent automation, hooks, MCP, and team workflows. Built around clear mental models and real examples, not marketing.
npm install -g @anthropic-ai/claude-code
Who this is for: Developers using (or about to use) Claude Code. Beginners get a guided path; power users get depth on Skills, Hooks, MCP, and Agent Teams.
| You are… | Start here | Time |
|---|---|---|
| New to Claude Code | Setup → Prompt Engineering → Your First Skill | ~15 min |
| ⚡ Already using it, want depth | Skills · Hooks · MCP | ~30 min each |
| Building teams or automation | Dynamic Workflows · Agent Teams · BMAD | varies |
The five extension points in Claude Code, side by side:
| Tool | Use when… | Skip if… | Lives in |
|---|---|---|---|
| Skills (slash commands) | You repeat the same prompt or workflow ≥3 times | One-off task | .claude/commands/*.md |
| Hooks | You want code to run automatically on tool use, session start, etc. | You only want manual triggers | .claude/settings.json |
| Subagents | A subtask is big enough to need its own isolated context | The task fits in your main session | .claude/agents/*.md |
| Workflows | The job needs more agents than one conversation can coordinate | A couple of subagents would do | .claude/workflows/*.js |
| MCP servers | You need Claude to use external tools (browsers, DBs, APIs) | All your data is in local files | Configured per project |
These five compose. Most polished setups combine 2–3.
Fundamentals — What is Claude Code? · Setup · Prompt Engineering
Workflow extensions — Slash Commands · Skills · Hooks
Multi-agent & integration — Subagents · Dynamic Workflows · Agent Teams · Automation surface · MCP
Productivity & frameworks — Effort levels · Fast Mode · Super Claude · BMAD Method
Reference — Slash Command Cheatsheet · Effort levels · Workflows · Agent Teams · Skills · FAQ · Updates & Deprecations · Further Reading
Claude Code is Anthropic's official CLI for working with Claude from your terminal. You point it at a project; it reads the code, plans, edits files, runs commands, and commits — all from the prompt line.
Three things it does that a chat UI can't:
grep, follows imports, and grounds answers in real context.pytest/vitest/go test on the spot to verify the change.If you've used Copilot or Cursor, think of Claude Code as their "agent in your terminal" peer — same idea, different surface, no editor lock-in.
claude # start a session in the current repo
> explain what this codebase does
> fix the failing test in src/api.test.ts
> open a PR with the changes
Three launches landed in quick succession this summer: Claude Opus 4.8 (May 28, 2026) took over as the Opus-tier flagship, Claude Fable 5 and its restricted sibling Claude Mythos 5 (June 9, 2026) opened a new Mythos-class tier above Opus, and Claude Sonnet 5 (June 30, 2026) became Claude Code's default model. 1M-token context is now standard across current Opus, Sonnet, and Fable models — no beta flag, no long-context surcharge — with 128K max output.
Choosing a model — quick guide:
| Model | Reach for it when… |
|---|---|
| Sonnet 5 (default) | Everyday coding — most tasks live here. Intro pricing $2/$10 per MTok through Aug 31, 2026 (then $3/$15) |
| Opus 4.8 | Complex reasoning, large refactors, orchestrating agents — $5/$25, unchanged from 4.7 |
| Fable 5 | Genuinely hard problems — Mythos-class capability above Opus at $10/$50 |
| Haiku 4.5 | Fast, lightweight tasks — quick questions, doc updates ($1/$5, 200K context) |
Opus 4.7 / 4.6 and Sonnet 4.6 are now legacy models (still available via API and
/model); Opus 4.1 retires August 5, 2026. Mythos 5 is the same underlying model as Fable 5 with fewer safeguards — invitation-only for approved organizations via Project Glasswing.→ Full specs, capabilities, and pricing in
docs/reference/models.md
⏱️ 5-minute setup. Get from zero to your first AI-assisted commit.
npm install -g @anthropic-ai/claude-code
Requires Node.js 18+. For other install methods (Homebrew, curl, native binary), see the official install guide.
claude
On first run, Claude Code opens a browser to sign in with your Anthropic account (Pro, Max, or API key all work). After that, you can re-authenticate any time with /login (and sign out with /logout) inside a session, or claude auth login|status|logout from your shell.
From any project directory:
cd ~/your-project
claude
Once Claude Code is running, try one of these:
explain what this codebase does — Claude reads your repo and summarizes.add a README section about installation — generates content based on your project.find and fix the failing test in src/api.test.ts — diagnoses and edits in place.CLAUDE.md/init
Creates a project-level instruction file that Claude reads on every session — your project's "house rules." More on this in Prompt Engineering Deep Dive.
This repo's .claude/ directory is a working, runnable Claude Code project — one of each extension point, not screenshots of one. Every path below is something you can copy into your own project today:
| Path | What you get | Copy it when… |
|---|---|---|
.claude/commands/ |
7 slash skills — /pr, /review, /tdd, /test, /five, /ux, /todo |
You want PR hygiene and review rigor without writing the prompts |
.claude/skills/ |
An Agent Skill — /claude-md-review audits a CLAUDE.md for vagueness, dead paths, and bloat |
You want a worked example of the frontmatter contract |
.claude/agents/ |
5 subagents, plus 10 more role prompts in specialized-agents/ |
You want specialists without authoring role prompts — they double as Agent Teams teammates |
.claude/workflows/ |
A dynamic workflow — /stale-docs-audit fans agents across your docs, then refutes its own findings |
You want a real script to read before writing your own |
.claude/hooks/ |
Python hooks — post_tool_use.py, notification.py, stop.py, subagent_stop.py |
You want lifecycle automation (needs uv) |
.claude/settings.json |
Permissions + hook wiring | You're copying the hooks — swap the hardcoded uv path for $(which uv) |
git clone --depth 1 https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know /tmp/cc-guide
cp -r /tmp/cc-guide/.claude/commands/pr.md your-project/.claude/commands/ # take what you want
⚠️ Read before you copy. Skills, hooks, agents, and workflows are executable instructions that run with your permissions — including from this repo. Copy file by file and read each one, the same way you'd review a shell script before sourcing it. Don't
cp -ra whole.claude/you haven't opened.
Next: Claude Skills to build your own in 3 minutes.
** Claude Initialization** Run the
/initcommand to automatically generate aCLAUDE.mdfile. YourCLAUDE.mdfiles become part of Claude's prompts, so they should be refined like any frequently used prompt. A common mistake is adding extensive content without iterating on its effectiveness. Take time to experiment and determine what produces the best instruction following from the model.
Versatile workflow for complex problems.
"think", "think hard", "think harder", or "ultrathink" to nudge depth in the prompt — see Effort levels for the full reasoning dial. Optionally save the plan for future reference. Plan Mode and Accept Edits Mode. You can toggle between them using the Shift + Tab keys.** Pro Tip:** Research & planning first significantly improves performance for complex tasks.
Ideal for changes verifiable with unit/integration tests.
Clear targets (tests, mocks) improve iteration efficiency.
Iteration significantly improves output quality (2-3 rounds usually enough).
→ Full guide in docs/reference/effort-levels.md
Mental model: Effort is a behavioural dial, not a token budget — it shifts thinking depth, tool-call appetite, response length, and how persistently Claude pushes through multi-step work. Higher ≠ smarter; context quality often matters more.
The API knows 5 levels (low → max, default high); Claude Code adds a sixth:
| Level | Reach for it when… |
|---|---|
low |
Fast interactive queries you're steering — file renames, simple greps |
medium |
Gener |
暂无开放 Issues,或尚未同步最近议题。