Use Claude Code
使唤它的窍门
使唤它的窍门 这一页讲的,就是 使唤它的窍门 这件事在 Claude Code 里到底怎么用。
页面信息
这页不是官方原文,而是顺着官方文档结构做的中文解释版。命令、参数、配置名这些硬东西尽量保留,解释部分则尽量讲成人能照着做的话。
如果你碰到特别敏感的配置、权限或企业环境差异,最好顺手点上面的“查看原始文档”再核一遍。
这一页先讲明白
这一页讲怎么把 Claude Code 用顺手,而不是用成一锅粥。
核心就是目标清楚、范围清楚、验收清楚。
好帮手也怕遇到糊涂指令。你话说得越具体,它越少返工。
这页不是新功能,而是把前面那些能力用得更稳的经验。
任务要具体,最好带上范围、限制、验收标准。
上下文别太杂。不同活别硬塞同一会话,不然它会把东家的锄头拿去修西家的墙。
Documentation Index
这里不是让你背"Documentation Index"这个词,而是让你看它真干活时怎么使。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Give Claude a way to verify its work
这里不是让你背"Give Claude a way to verify its work"这个词,而是让你看它真干活时怎么使。
Explore first, then plan, then code
看到这里,就把"Explore first, then plan, then code"当成一件真要上手的活来看。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Explore first, then plan, then code 1
先看下面这块原始片段,等会儿再回头看解释会顺得多。
read /src/auth and understand how we handle sessions and login.
also look at how we manage environment variables for secrets. Explore first, then plan, then code 2
先看下面这块原始片段,等会儿再回头看解释会顺得多。
I want to add Google OAuth. What files need to change?
What's the session flow? Create a plan. Explore first, then plan, then code 3
先看下面这块原始片段,等会儿再回头看解释会顺得多。
implement the OAuth flow from your plan. write tests for the
callback handler, run the test suite and fix any failures. Provide specific context in your prompts
别把这段只当成标题看,它其实是在给"Provide specific context in your prompts"划边界。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Provide rich content
这一段是在说怎么用 @ 去做 reference files, paste screenshots/images, or pipe data directly.。看这种内容,光知道名字没用,还是得落到手上。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Configure your environment
这里讲怎么把某个开关拧对。重点不是概念,而是你该在哪儿改、改完怎么确认生效。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Write an effective CLAUDE.md
这一段是在把 /init to generate a starter CLAUDE.md file based on your current project structure, then refine over time. 真跑起来。别只看命令长什么样,还得看跑完该出现什么。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Write an effective CLAUDE.md 1
这一段要真抓重点,通常就抓下面这块原文。
# Code style
- Use ES modules (import/export) syntax, not CommonJS (require)
- Destructure imports when possible (eg. import { foo } from 'bar')
# Workflow
- Be sure to typecheck when you're done making a series of code changes
- Prefer running single tests, and not the whole test suite, for performance Write an effective CLAUDE.md 2
这会儿轮到改配置了,字段名和关键字别自己乱换。
See @README.md for project overview and @package.json for available npm commands.
# Additional Instructions
- Git workflow: @docs/git-instructions.md
- Personal overrides: @~/.claude/my-project-instructions.md Configure permissions
这一段主要是在拧开关,地方和顺序都别搞错。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Use CLI tools
这里不是让你背"Use CLI tools"这个词,而是让你看它真干活时怎么使。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Connect MCP servers
这一段是在把 claude mcp add to connect external tools like Notion, Figma, or your database. 真跑起来。别只看命令长什么样,还得看跑完该出现什么。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Set up hooks
这里是上手准备活,通常会告诉你前提条件、落地点和最稳的起步顺序。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Create skills
这一段是在教你把 SKILL.md files in .claude/skills/ to give Claude domain knowledge and reusable workflows. 真正建出来。文件放哪儿、字段怎么写、建完怎么验,都得跟着看。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Create skills 1
光知道意思还不够,这里得把规矩落进配置里,下面这块照着填。
---
name: api-conventions
description: REST API design conventions for our services
---
# API Conventions
- Use kebab-case for URL paths
- Use camelCase for JSON properties
- Always include pagination for list endpoints
- Version APIs in the URL path (/v1/, /v2/) Create skills 2
光知道意思还不够,这里得把规矩落进配置里,下面这块照着填。
---
name: fix-issue
description: Fix a GitHub issue
disable-model-invocation: true
---
Analyze and fix the GitHub issue: $ARGUMENTS.
1. Use `gh issue view` to get the issue details
2. Understand the problem described in the issue
3. Search the codebase for relevant files
4. Implement the necessary changes to fix the issue
5. Write and run tests to verify the fix
6. Ensure code passes linting and type checking
7. Create a descriptive commit message
8. Push and create a PR Create custom subagents
看到这里,就把"Create custom subagents"当成一件真要上手的活来看。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Create custom subagents
这一段说完,最后还得写到配置里才算真的生效。
---
name: security-reviewer
description: Reviews code for security vulnerabilities
tools: Read, Grep, Glob, Bash
model: opus
---
You are a senior security engineer. Review code for:
- Injection vulnerabilities (SQL, XSS, command injection)
- Authentication and authorization flaws
- Secrets or credentials in code
- Insecure data handling
Provide specific line references and suggested fixes. Install plugins
这段就是手把手操作,照顺序来最稳。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Communicate effectively
别把这段只当成标题看,它其实是在给"Communicate effectively"划边界。
Ask codebase questions
这一段主要是在把"Ask codebase questions"讲实,不是只摆个标题给你看。
Let Claude interview you
这一块主要是在说"Let Claude interview you"真到手上该怎么用,哪里最容易踩坑。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Let Claude interview you
"Let Claude interview you"这一段里最要紧的原始写法在下面,先看它怎么落地。
I want to build [brief description]. Interview me in detail using the AskUserQuestion tool.
Ask about technical implementation, UI/UX, edge cases, concerns, and tradeoffs. Don't ask obvious questions, dig into the hard parts I might not have considered.
Keep interviewing until we've covered everything, then write a complete spec to SPEC.md. Manage your session
看到这类标题,就把它当成日常管摊子的规矩。
Course-correct early and often
这一段主要是在把"Course-correct early and often"讲实,不是只摆个标题给你看。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Manage context aggressively
这段主要是在说平时怎么管,不是光教你怎么开。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Use subagents for investigation
这一段主要是在把"Use subagents for investigation"讲实,不是只摆个标题给你看。
看这段时要特别盯工具和权限边界,别为了省事一把全开。
Use subagents for investigation
这一段要真抓重点,通常就抓下面这块原文。
Use subagents to investigate how our authentication system handles token
refresh, and whether we have any existing OAuth utilities I should reuse. Rewind with checkpoints
这一段主要是在把"Rewind with checkpoints"讲实,不是只摆个标题给你看。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Resume conversations
看到这里,就把"Resume conversations"当成一件真要上手的活来看。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Automate and scale
看到这里,就把"Automate and scale"当成一件真要上手的活来看。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Run non-interactive mode
这一段主要是在把"Run non-interactive mode"讲实,不是只摆个标题给你看。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Run non-interactive mode
先别急着往下翻,下面这条命令跑完,心里才有底。
# One-off queries
claude -p "Explain what this project does"
# Structured output for scripts
claude -p "List all API endpoints" --output-format json
# Streaming for real-time processing
claude -p "Analyze this log file" --output-format stream-json Run multiple Claude sessions
这一段是在把 multiple Claude sessions in parallel to speed up development, run isolated experiments, or start complex workflows. 真跑起来。别只看命令长什么样,还得看跑完该出现什么。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Fan out across files
看到这里,就把"Fan out across files"当成一件真要上手的活来看。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Fan out across files 1
这一段不是只让你理解意思,下面这条命令就是现在要跑的。
for file in $(cat files.txt); do
claude -p "Migrate $file from React to Vue. Return OK or FAIL." \
--allowedTools "Edit,Bash(git commit *)"
done Fan out across files 2
这一段不是只让你理解意思,下面这条命令就是现在要跑的。
claude -p "<your prompt>" --output-format json | your_command Run autonomously with auto mode
这里不是让你背"Run autonomously with auto mode"这个词,而是让你看它真干活时怎么使。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Run autonomously with auto mode
真到动手的时候了,下面这条直接敲一遍,看它回什么。
claude --permission-mode auto -p "fix all lint errors" Avoid common failure patterns
这一块主要是在说"Avoid common failure patterns"真到手上该怎么用,哪里最容易踩坑。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
Develop your intuition
这一段不只是挂个标题,它是在说明"Develop your intuition"这一块到底负责什么。
Related resources
这一段主要是在把"Related resources"讲实,不是只摆个标题给你看。
这里还牵扯作用域,意思就是这条规则到底管当前项目、你个人,还是只管这一趟会话。
照着做一遍
这页属于“使唤它的窍门”这类活,最稳的办法还是一小步一小步来。
下面这三步不一定华丽,但通常最不容易绕晕。
第 1 步:先起步
任务要具体,最好带上范围、限制、验收标准。
第 2 步:边做边看
上下文别太杂。不同活别硬塞同一会话,不然它会把东家的锄头拿去修西家的墙。
一眼看懂这一页
这页的作用,就是把原本偏专业的话题,拆成能直接照着走的明白话。
使唤它的窍门
|
v
使唤它的窍门 这一页讲的,就是 使唤它的窍门 这件事在 Claude Code 里到底怎么用。
|
v
照着步骤去做 文末提醒
这站会按官方 docs 的导航和内容变化继续重生成,原站加页、删页、改页时,这里会跟着更新。
人话解释会尽量顺着原页往下讲,但命令、参数名、配置名这些硬东西还是保留原样,免得你抄过去跑不起来。