CC吊炸天的秘密找到了!舊金山初創(chuàng)CEO自曝?cái)?shù)月研究:CC主控制僅1個循環(huán),大量使用小模型,驚呼:簡單到爆,肝一份深度復(fù)刻指南
原創(chuàng) 精選編輯 | 云昭
出品 | 51CTO技術(shù)棧(微信號:blog51cto)
世界上最好用的編程工具,Claude Code,又被人深度研究了!
它背后,竟然只保留了一個主控制循環(huán),系統(tǒng)邏輯竟然簡單到爆。
管AI代理如此復(fù)雜,但這款最令人愉悅的AI編程工具,卻保持了極其簡單的方式。
“我高度懷疑:大多數(shù)應(yīng)用可能真不需要多 Agent 系統(tǒng)?!?/p>
近日,CC 的一家重度用戶,MinusX 團(tuán)隊(duì)經(jīng)過煞費(fèi)苦心的研究,終于發(fā)現(xiàn)了背后的秘密。
事情是這樣?jì)饍旱摹?/p>
MinusX 是一家去年成立的、位于美國舊金山的初創(chuàng)公司,核心愿景就是打造一款“AI數(shù)據(jù)科學(xué)家”, 讓 AI 能像人一樣,在用戶熟悉的數(shù)據(jù)工具里(如 Jupyter、Metabase、Grafana、Tableau等),通過點(diǎn)擊和輸入幫助用戶自主完成數(shù)據(jù)分析。(沒錯,又是一款 Agent!)
近日,他們的聯(lián)合創(chuàng)始人兼 CEO Vivek Aithal 對于自家團(tuán)隊(duì)使用 CC 打造 Agent 的經(jīng)歷頗有感觸,并突然發(fā)現(xiàn):值得學(xué)習(xí)的對象,遠(yuǎn)在天邊,近在眼前。
Claude Code 本身就是一款超級無敵好用的 AI Agent!
于是他們?yōu)榱烁闱宄?CC 為什么如此好用,幾月前專門搭建了一個日志工具,攔截每一次網(wǎng)絡(luò)請求,并分析了數(shù)月的使用數(shù)據(jù)。
圖片
結(jié)果,他們團(tuán)隊(duì)發(fā)現(xiàn)了很多反常識的真相。
- 50% 的 Claude Code 調(diào)用使用了更便宜的 Haiku 模型:不僅用于簡單任務(wù),還包括讀取大型文件、解析 git 歷史,甚至是生成你看到的那些一詞式處理標(biāo)簽。
- “Edit” 是使用最頻繁的工具(占 35%),其次是 “Read”(22%)和 “TodoWrite”(18%)。
圖片
- 沒有任何多 Agent 的交接。盡管外界炒得很熱,Claude Code 實(shí)際上只用一條主線程,最多帶一個分支。
- 工具描述竟然超過 9400 個 token ——他們在工具提示上的投入比大多數(shù)人整個系統(tǒng)提示還要多。
- LLM 搜索 >>> RAG 搜索。
最令人吃驚的是,在外界充斥各種 AI Agent 復(fù)雜性的同時,這款世界上最好用的編程 AI 卻選擇了一條極致簡潔的路徑:
一個循環(huán)、一份消息歷史、清晰的工具設(shè)計(jì)、大量示例。
Vivek 為此大為觸動,很細(xì)致地將這次 CC 的逆天研究也分享了出來,當(dāng)然全面解析 CC 的開發(fā)設(shè)計(jì)哲學(xué)并不是最終目的,目的還是告訴大家如何打造一款叫好且叫座的 Agent 產(chǎn)品!
網(wǎng)友看罷,直呼過癮。
圖片
話不多說,全文邏輯非常清晰,請各位大佬系好安全帶,咱們這就發(fā)車!
一、CC 擊敗了 Cursor,為什么它如此讓人省心、開心
Claude Code 是迄今為止我用過最讓人愉快的 AI agent/工作流。
它不僅能做定向修改,而且在“甩手寫點(diǎn)小工具”的場景下,也不那么煩人。更重要的是,用 Claude Code 的過程本身就讓我開心。它的自主性剛剛好——既能做出有趣的事,又不會像其他工具那樣帶來強(qiáng)烈的“失控”感。
客觀地說,即使它們底層模型相同,Claude Code 也要比 Cursor 或 Github Copilot agents 更省心。
PS:當(dāng)然,大部分硬活兒還是得靠 Claude 4 新模型(尤其是 interleaved thinking)撐著。
那問題來了,Claude Code 到底為什么這么好用?如果你邊讀邊點(diǎn)頭,我會嘗試給你一些答案。
注意,這里不會像市面上那樣再去搞一篇 CC 架構(gòu)的剖析文章,而是基于我過去幾個月使用和試驗(yàn) CC 的經(jīng)驗(yàn)(加上我們攔截并分析的日志),寫的一份“如何打造讓人叫好的 LLM agent”指南。
多說一嘴,如果各位想直接看干貨,可以跳到 TL;DR 部分。
二、Claude Code 的妙處
CC 之所以好用,是因?yàn)樗熬褪悄芘芷饋怼薄?/p>
CC 的設(shè)計(jì)從根本上理解了 LLM 擅長什么、糟糕在哪。它的 prompts 和工具能幫模型彌補(bǔ)短板,同時放大強(qiáng)項(xiàng)。而且,其控制循環(huán)極其簡單,容易跟蹤和調(diào)試。
我們在 MinusX 一發(fā)布就開始用了 CC。為了探底,Sreejith 寫了個 logger,能攔截并記錄每一個網(wǎng)絡(luò)請求。
以下分析就是我過去幾個月的大量使用總結(jié)。
本文的核心問題是——“Claude Code 為什么好用?你又如何在自己的對話式 LLM agent 里實(shí)現(xiàn) CC 式體驗(yàn)?”我們已經(jīng)在 MinusX 吸收了大部分經(jīng)驗(yàn),希望你也能做到!
三、重點(diǎn)來了:如何打造一個像 Claude Code 的 Agent
如果只記住一句話,那就是——保持簡單,傻瓜(Keep Things Simple, Dummy)。
LLM 本來就夠難調(diào)試和評估了,你加的每一層復(fù)雜度(多 Agent、交接鏈、復(fù)雜 RAG 檢索算法)都會讓調(diào)試難度翻十倍。就算能跑起來,你之后也會害怕去改它。
所以,把所有邏輯放在一個文件里,避免無謂的腳手架,每隔一陣子就全部推倒重來幾次 :)
先來給大家看一個省流版,后面詳細(xì)為大家奉上各個 CC 的細(xì)節(jié)。
1)Control Loop
- 保持一個主循環(huán)(最多一條分支)+ 一份消息歷史。
- 大量使用小模型。所有場景。所有時間。
2)Prompts
- 用 claude.md 模式協(xié)作并記錄用戶偏好
- 使用特殊的 XML 標(biāo)簽、Markdown、大量示例
3)Tools
- LLM 搜索 >>> RAG 搜索
- 工具設(shè)計(jì)的高低抽象取舍(High vs Low level)
- 讓 Agent 自己管理 todo list
4)Steerability(可控性)
- 語氣和風(fēng)格
- 很遺憾,“PLEASE THIS IS IMPORTANT” ,仍然是 SOTA
- 寫出算法,附帶啟發(fā)式和示例
Claude Code 在每個環(huán)節(jié)都選擇架構(gòu)上的簡潔:一個主循環(huán)、簡單的搜索、簡單的 todo 列表……要抵抗“過度工程化”的沖動,給模型搭個好舞臺,讓它自由發(fā)揮。是不是又回到了“端到端自動駕駛”的老梗?是的,苦澀教訓(xùn)依然成立。
1.Control Loop 設(shè)計(jì)
1)保持單一主循環(huán)
記住,可調(diào)試性 >>> 花哨的多 Agent 拼圖。
盡管多 Agent 系統(tǒng)很火,但 CC 只有一個主線程。它會定期用不同提示詞總結(jié) git 歷史、壓縮消息歷史、生成一些有趣的交互元素。但除此之外,它就是一份簡單的消息列表。處理層級任務(wù)時,CC 會“克隆”自己作為子 agent,但子 agent 無法再繼續(xù)派生,最多一層。執(zhí)行結(jié)果作為“tool response”并回到主循環(huán)。
簡單任務(wù)靠迭代工具調(diào)用即可,復(fù)雜任務(wù)才會觸發(fā)“最多一條分支”的子 agent + todo list 機(jī)制。這樣既能拆解問題,又不會偏離最終目標(biāo)。

我高度懷疑大多數(shù)應(yīng)用真的需要多 Agent 系統(tǒng)。每加一層抽象,系統(tǒng)更難 debug,更重要的是,你也偏離了“靠模型本身不斷進(jìn)化”的大趨勢。
2)小模型無處不在
CC 超過 50% 的重要調(diào)用都是給 claude-3-5-haiku 的。它用來讀大文件、解析網(wǎng)頁、處理 git 歷史、總結(jié)長對話,甚至給每個擊鍵生成一字標(biāo)簽。小模型比大模型(Sonnet 4、GPT-4.1)便宜 70-80%,該用就用,別心疼。
2.Prompts
Claude Code 的提示詞非常復(fù)雜,充滿啟發(fā)式、示例和“重要提醒”。系統(tǒng) prompt ~2800 tokens,工具 prompt 高達(dá) 9400 tokens。
用戶請求里總是包含 claude.md 文件(1000-2000 tokens)。系統(tǒng)提示里還有語氣風(fēng)格、主動性、任務(wù)管理、工具使用策略、當(dāng)前目錄、平臺/OS 信息、最近提交等。
一定要去讀完整提示!這里,小編索性幫大家扒下來了 CC 的系統(tǒng)提示詞和工具提示詞。大家可以拷貝研究下。
You are Claude Code, Anthropic's official CLI for Claude.
You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
IMPORTANT: Assist with defensive security tasks only. Refuse to create, modify, or improve code that may be used maliciously. Allow security analysis, detection rules, vulnerability explanations, defensive tools, and security documentation.
IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.
If the user asks for help or wants to give feedback inform them of the following:
- /help: Get help with using Claude Code
- To give feedback, users should report the issue at https://github.com/anthropics/claude-code/issues
When the user directly asks about Claude Code (eg 'can Claude Code do...', 'does Claude Code have...') or asks in second person (eg 'are you able...', 'can you do...'), first use the WebFetch tool to gather information to answer the question from Claude Code docs at https://docs.anthropic.com/en/docs/claude-code.
- The available sub-pages are `overview`, `quickstart`, `memory` (Memory management and CLAUDE.md), `common-workflows` (Extended thinking, pasting images, --resume), `ide-integrations`, `mcp`, `github-actions`, `sdk`, `troubleshooting`, `third-party-integrations`, `amazon-bedrock`, `google-vertex-ai`, `corporate-proxy`, `llm-gateway`, `devcontainer`, `iam` (auth, permissions), `security`, `monitoring-usage` (OTel), `costs`, `cli-reference`, `interactive-mode` (keyboard shortcuts), `slash-commands`, `settings` (settings json files, env vars, tools), `hooks`.
- Example: https://docs.anthropic.com/en/docs/claude-code/cli-usage
# Tone and style
You should be concise, direct, and to the point.
You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail.
IMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.
IMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.
Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did.
Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is <answer>.", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...". Here are some examples to demonstrate appropriate verbosity:
<example>
user: 2 + 2
assistant: 4
</example>
<example>
user: what is 2+2?
assistant: 4
</example>
<example>
user: is 11 a prime number?
assistant: Yes
</example>
<example>
user: what command should I run to list files in the current directory?
assistant: ls
</example>
<example>
user: what command should I run to watch files in the current directory?
assistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]
npm run dev
</example>
<example>
user: How many golf balls fit inside a jetta?
assistant: 150000
</example>
<example>
user: what files are in the directory src/?
assistant: [runs ls and sees foo.c, bar.c, baz.c]
user: which file contains the implementation of foo?
assistant: src/foo.c
</example>
When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).
Remember that your output will be displayed on a command line interface. Your responses can use Github-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.
If you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences.
Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
IMPORTANT: Keep your responses short, since they will be displayed on a command line interface.
# Proactiveness
You are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:
- Doing the right thing when asked, including taking actions and follow-up actions
- Not surprising the user with actions you take without asking
For example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.
# Following conventions
When making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.
- NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language).
- When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.
- When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the given change in a way that is most idiomatic.
- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.
# Code style
- IMPORTANT: DO NOT ADD ***ANY*** COMMENTS unless asked
# Task Management
You have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.
It is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.
Examples:
<example>
user: Run the build and fix any type errors
assistant: I'm going to use the TodoWrite tool to write the following items to the todo list:
- Run the build
- Fix any type errors
I'm now going to run the build using Bash.
Looks like I found 10 type errors. I'm going to use the TodoWrite tool to write 10 items to the todo list.
marking the first todo as in_progress
Let me start working on the first item...
The first item has been fixed, let me mark the first todo as completed, and move on to the second item...
..
..
</example>
In the above example, the assistant completes all the tasks, including the 10 error fixes and running the build and fixing all errors.
<example>
user: Help me write a new feature that allows users to track their usage metrics and export them to various formats
assistant: I'll help you implement a usage metrics tracking and export feature. Let me first use the TodoWrite tool to plan this task.
Adding the following todos to the todo list:
1. Research existing metrics tracking in the codebase
2. Design the metrics collection system
3. Implement core metrics tracking functionality
4. Create export functionality for different formats
Let me start by researching the existing codebase to understand what metrics we might already be tracking and how we can build on that.
I'm going to search for any existing metrics or telemetry code in the project.
I've found some existing telemetry code. Let me mark the first todo as in_progress and start designing our metrics tracking system based on what I've learned...
[Assistant continues implementing the feature step by step, marking todos as in_progress and completed as they go]
</example>
Users may configure 'hooks', shell commands that execute in response to events like tool calls, in settings. Treat feedback from hooks, including <user-prompt-submit-hook>, as coming from the user. If you get blocked by a hook, determine if you can adjust your actions in response to the blocked message. If not, ask the user to check their hooks configuration.
# Doing tasks
The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
- Use the TodoWrite tool to plan the task if required
- Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.
- Implement the solution using all tools available to you
- Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach.
- VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (eg. npm run lint, npm run typecheck, ruff, etc.) with Bash if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to CLAUDE.md so that you will know to run it next time.
NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
- Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result.
# Tool usage policy
- When doing file search, prefer to use the Task tool in order to reduce context usage.
- You should proactively use the Task tool with specialized agents when the task at hand matches the agent's description.
- When WebFetch returns a message about a redirect to a different host, you should immediately make a new WebFetch request with the redirect URL provided in the response.
- You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel.
You can use the following tools without requiring user approval: Bash(npm run build:*)
Here is useful information about the environment you are running in:
<env>
Working directory: <working directory>
Is directory a git repo: Yes
Platform: darwin
OS Version: Darwin 23.6.0
Today's date: 2025-08-19
</env>
You are powered by the model named Sonnet 4. The exact model ID is claude-sonnet-4-20250514.
Assistant knowledge cutoff is January 2025.
IMPORTANT: Assist with defensive security tasks only. Refuse to create, modify, or improve code that may be used maliciously. Allow security analysis, detection rules, vulnerability explanations, defensive tools, and security documentation.
IMPORTANT: Always use the TodoWrite tool to plan and track tasks throughout the conversation.
# Code References
When referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location.
<example>
user: Where are errors from the client handled?
assistant: Clients are marked as failed in the `connectToServer` function in src/services/process.ts:712.
</example>
gitStatus: This is the git status at the start of the conversation. Note that this status is a snapshot in time, and will not update during the conversation.
Current branch: atlas-bugfixes
Main branch (you will usually use this for PRs): main
Status:
(clean)
Recent commits:
<list of commits>1)claude.md:共享上下文與偏好
幾乎所有 Coding Agent 都有 context 文件(Cursor Rules / claude.md / agent.md)。有無 claude.md,Claude Code 的表現(xiàn)判若兩人。它能傳遞代碼庫之外的上下文,固化用戶偏好。例如,強(qiáng)制跳過某些目錄、指定使用特定庫。CC 每次請求都會附帶完整 claude.md。
我們在 MinusX 也搞了 minusx.md,正在成為默認(rèn)的團(tuán)隊(duì)/用戶偏好配置。
2)特殊 XML 標(biāo)簽、Markdown、示例
CC 廣泛使用 XML 標(biāo)簽和 Markdown 來組織 prompt。常見標(biāo)簽有:
- <system-reminder>:提醒 LLM 某些狀態(tài),但不要顯式告訴用戶
示例:
<system-reminder>This is a reminder that your todo list is currently empty. DO NOT mention this to the user explicitly because they are already aware. If you are working on tasks that would benefit from a todo list please use the TodoWrite tool to create one. If not, please feel free to ignore. Again do not mention this message to the user.</system-reminder>
<system-reminder>這是一個提醒:你的待辦列表目前是空的。請不要向用戶明確提及這一點(diǎn),因?yàn)樗麄円呀?jīng)知道。如果你正在處理的任務(wù)適合使用待辦列表,請使用 TodoWrite 工具創(chuàng)建一個。如果不是,請忽略此提醒。再次強(qiáng)調(diào),不要向用戶提及此消息。</system-reminder>- <good-example> / <bad-example>:對比式示例,明確“走哪條路才對”
示例:
Try to maintain your current working directory throughout the session by using absolute paths and avoiding usage of `cd`. You may use `cd` if the User explicitly requests it.
<good-example>
pytest /foo/bar/tests
</good-example>
<bad-example>
cd /foo/bar && pytest tests
</bad-example>
請盡量在整個會話中保持你當(dāng)前的工作目錄,方法是使用絕對路徑并避免使用 cd。只有在用戶明確要求時,你才可以使用 cd。
<good-example>
pytest /foo/bar/tests
</good-example>
<bad-example>
cd /foo/bar && pytest tests
</bad-example>Markdown 用于分割系統(tǒng)提示的部分:Tone、Style、Code style、Task Management、Tools 等。
3.Tools
正如前文所說,CC 的工具 prompt 多達(dá) 9400 tokens。
1)LLM 搜索 >> RAG 搜索
CC 和大多數(shù) agent 不同,它不依賴 RAG,而是像人一樣搜索代碼庫,利用復(fù)雜的 ripgrep、jq、find 命令。因?yàn)?LLM 本身理解代碼,能用高級正則定位任意片段,有時直接用小模型讀完整文件。
RAG 理論上好,但引入了大量隱藏失敗模式:相似度函數(shù)、reranker、chunk 策略、大 JSON 如何處理……而 LLM Search 就像你自己翻文件一樣,看看幾行再決定要不要讀更多。更重要的是,這是可 RL 學(xué)習(xí)的方向,未來大廠會重點(diǎn)發(fā)力。
2)工具設(shè)計(jì):高 vs 低抽象
工具到底給“泛用能力”還是“低層級操作”?答案是——都要有。
CC 有低層(Bash、Read、Write)、中層(Edit、Grep、Glob)、高層(Task、WebFetch、ExitPlanMode)。例如,雖然能直接用 bash grep,但因?yàn)?grep/glob 用得太多,單獨(dú)做成工具更穩(wěn)。WebFetch 這種高層工具則高度確定性,避免 LLM 瞎折騰低級操作。
工具描述里有大量示例,系統(tǒng) prompt 也寫明“什么時候用哪個工具”。
3)讓 Agent 自己管理 todo list
長時間跑 Agent 的一個常見問題就是: context rot(上下文腐化):一開始熱情滿滿,后面漸漸跑偏變垃圾。
常見方案:
- 專門的 todo 生成/執(zhí)行模型
- 多 Agent 接力(PM -> 實(shí)現(xiàn) -> QA)
但我們知道多 Agent 接力很糟糕。CC 的做法是——todo list 由模型自己維護(hù)。模型被強(qiáng)烈提示要頻繁參考 todo list,同時也能隨時調(diào)整,丟掉或插入新的事項(xiàng)。這正好利用了 LLM 的 interleaved thinking 能力,既保持目標(biāo)感,又具備靈活性。
圖片
4.可控性
1)語氣與風(fēng)格
Claude Code(CC)會明確地嘗試控制代理的“審美行為”。在系統(tǒng)提示詞(system prompt)里有專門的語氣、風(fēng)格和主動性部分——充滿了規(guī)則和示例。這就是為什么 Claude Code 在評論和回應(yīng)中會顯得“有品味”而且“積極”的原因。我的建議是,直接把這部分大段內(nèi)容原封不動地抄到你的應(yīng)用里。
語氣與風(fēng)格的幾個示例:
- 重要: 除非用戶要求,否則不要加任何不必要的開頭或結(jié)尾(比如解釋你寫的代碼,或總結(jié)你采取的行動)。不要主動補(bǔ)充代碼解釋或總結(jié),除非用戶明確提出需求。
- 如果你不能或不打算幫助用戶完成某件事,請不要解釋原因,也不要講可能導(dǎo)致什么結(jié)果。因?yàn)檫@會顯得說教且令人煩躁。
- 只有在用戶明確要求時才使用表情符號。否則避免在任何交流中使用 emoji。
圖片
2)“THIS IS IMPORTANT” 依然是當(dāng)前的最佳實(shí)踐
很遺憾,Claude Code 在“讓模型不要做某件事”方面也沒有更好的辦法。用 IMPORTANT(重要)、VERY IMPORTANT(非常重要)、NEVER(絕不要)、ALWAYS(始終要) 仍然是最有效的手段。未來模型應(yīng)該會更容易被引導(dǎo),避免這種“粗暴”的做法。但在現(xiàn)階段,CC 大量使用了這種方式,你也應(yīng)該如此。
一些示例:
- IMPORTANT:不要添加任何注釋,除非用戶要求。
- VERY IMPORTANT:你必須避免使用 find 和 grep 這樣的搜索命令。替代方案是使用 Grep、Glob 或 Task 來搜索。你必須避免使用 cat、head、tail、ls 等命令來讀取文件,而要用 Read 和 LS 工具。如果你仍然覺得必須要運(yùn)行 grep,停下!始終要先用 ripgrep(rg)。
- IMPORTANT:絕對不要為用戶生成或猜測 URL,除非你非常確定這些 URL 是為了解決編程問題。你可以使用用戶在消息中提供的 URL,或者使用本地文件中的 URL。
圖片
3)寫出算法(帶啟發(fā)式規(guī)則和示例)
識別 LLM 需要執(zhí)行的最關(guān)鍵任務(wù),并為它寫出算法,這一點(diǎn)極其重要。
你可以嘗試“角色扮演”,把自己當(dāng)作 LLM,帶著示例一步步走流程,明確寫出所有決策點(diǎn)。
如果能做成流程圖會更好。這樣能幫助結(jié)構(gòu)化決策過程,并讓 LLM 更容易遵循。
要絕對避免的一點(diǎn)是:把提示寫成一大堆 “該做 / 不該做” 的雜亂集合。
- 這類規(guī)則很難管理和相互排斥;
- 一旦提示長度達(dá)到幾千 token,就必然會出現(xiàn)沖突;
- LLM 會因此變得非常脆弱,新的用例也很難加入。
Claude Code 的系統(tǒng)提示里,在 任務(wù)管理(Task Management)、執(zhí)行任務(wù)(Doing Tasks) 和 工具使用策略(Tool Usage Policy) 部分,都明確列出了要遵循的算法。這些部分還包含了大量啟發(fā)式規(guī)則和各種情境下的示例。
四、為什么要關(guān)注大廠的提示詞?
在 LLM 的“可控性”設(shè)計(jì)里,很多工作其實(shí)是在逆向工程它們后訓(xùn)練 / RLHF 的數(shù)據(jù)分布。
- 你應(yīng)該用 JSON 還是 XML?
- 工具描述要放在系統(tǒng)提示里,還是放在工具列表里?
- 要不要包含應(yīng)用的當(dāng)前狀態(tài)?
觀察大廠在它們自家應(yīng)用里的做法,可以給你很好的參考。Claude Code 的設(shè)計(jì)非常有“主見”,拿來借鑒,會幫你更快地確定方向。
五、CC風(fēng)格的Agent:簡單且強(qiáng)大
再強(qiáng)調(diào)一次:保持簡單。復(fù)雜的腳手架框架只會讓問題更多。
Claude Code 讓我真正相信,“Agent”其實(shí)可以既簡單又非常強(qiáng)大。我們已經(jīng)把其中很多經(jīng)驗(yàn)吸收到 MinusX 里了,還在持續(xù)加入更多。
所以,把自己的 LLM 代理“Claude 化”,也許是一條不錯的構(gòu)建和優(yōu)化路線!
如果你想要適用于 Metabase 的、可訓(xùn)練的 Claude Code 風(fēng)格的數(shù)據(jù)代理,可以看看 MinusX,或者直接約個 demo。
祝你玩得開心(Claude 風(fēng)格的編程快樂)!
好了文章到這里就結(jié)束了,這里小編想補(bǔ)充兩點(diǎn)。
一來,其實(shí) Claude Code 偶爾也會啟動并行的 agents,只是在有明確提示要求時,會做得更好。
二來,“claude.md 模式”是真的火,現(xiàn)在幾乎所有的 AI 工具都會在每次請求時附帶整個指令文件。據(jù)一位 Reddit 網(wǎng)友表示,這也不是 Claude Code 的新東西,幾乎可以肯定 GitHub Copilot 的指令文件早就一直是這么做的。
CC 為什么如此好用?除了簡單的循環(huán)控制邏輯、提示詞用法以外,還有哪些?評論區(qū)交給各位大佬們了。
參考鏈接:
https://minusx.ai/blog/decoding-claude-code/
https://www.reddit.com/r/ClaudeAI/comments/1myw74x/analyzed_months_of_claude_code_usage_logs_tell/





























