一些关于AI Coding的经验
一些关于AI Coding的经验
Attention
- "写代码"的门槛非常低, 收益非常的可观 Anthropic是怎么使用Claude Code
- 写代码 != 产出高质量软件
- 需求的实现成本/难度 下降?
- 不要为LLM的发展焦虑, 但不要做 coding义和团
基座模型
基本性能要求
一行代码约 10 Token Token 计算器
-
上下文: 128K+ (最好能够到200K) Token
- 成本
- 输出的速度/质量
-
输出速度: 60 Token/s
-
智力水平: SWE-Bench 70% (With Thinking) 60% (Low Think / No Think)
-
其他特性:
- ToolUse / Function Call
- Token Cache
- Reasoning
主流的模型
美国: Anthropic / OpenAI / Google Gemini /
Grok中国: Qwen / GLM / Kimi / MiniMax / DeepSeek
Anthropic (地域黑/权限狗)
对中国用户不友好 , 挂VPN也能封号, 策略最严格 之 <<封号斗罗>>
目前最强的Agent Model:
- 旗舰 Opus
- 次旗舰 Sonnet : 主要使用的Coding模型, 全能的模型
- 狗屎 Haiku
OpenAI (CloseAI)
gpt-5-codex : 修改准确, 调查充分, 但是耗时过长, 非常适合修复BUG
Gemini (Google大善人)
Gemini 3 : 虽然还没有公布发布时间, 但是我们几乎可以认为gemini 3 会平息2025最佳模型的争论
Gemini 2.5 pro : 除了写代码之外最好的大模型, Product Planning / Chat 的最佳模型, AI Studio几乎免费用
Qwen (真正的OpenAI)
qwen3 Max : 中国特色gemini 2.5 pro
qwen3 coder plus : 狗都不用, 但是必要的时候可以当狗
GLM Kimi MiniMax (整挺好)
glm4.6 : 能力很好, Coding Plan也很好, 但是最近在降智
DeepSeek (我卡呢?)
大家举起双手把力量借给DeepSeek 👐👐👐
主流的AI Coding工具
我们可以按照交互的形式主要分为三类
- VsCode-Fork: GUI Local, Fork VsCode 的发行版 , 使用 OpenVSX 作为插件来源 , 集成AI能力增强代码编写体验
- CLI: 在命令行中与Agent进行交互, 对运行环境有最好的支持, 一般能够轻易的在CICD 中集成, 配合前后端分离的架构可以配合VSCode插件使用
- Web/Remote Agent: 提供最开箱即用的能力, 开发环境完全托管远程, 控制能力较弱, 价格较贵
VsCode-Fork
赞美VsCode, 你是IDE的终点, 你是AIDE的起点. GUI > CLI !!!
V门
大部分耳熟能详的AI IDE都是基于VsCode来做, 包括但不限于:
- ***Cursor*** : 最流行的AI Coding工具, 开箱即用, 最好的complete功能, 定价变化大
- Windsurf: 无功无过
- Trae: 字节出品, 做的不错, 重新设计过UI, 有SOLO模式, 创新不大
- Qoder: 阿里出品
- CodeBuddy: 腾讯出品
- 开源: Void(不再维护了)
- 开源Coding插件: Cline / Roo Code / Kilo Code / continue.dev
最大的优势是: 用户习惯迁移非常方便. 缺点是: 同质化非常严重
Auto Complete
快速自动补全是所有的AI IDE的最基本功能之一, 由此演变来的功能一般还有:
当然了, 有开源的项目提供了类似的能力, 一般支持FIM的小模型都能够顾胜任此工作
Commit Message
根据代码变更自动生成Commit Message

Coding Agent
这部分的实现和交互和CLI Agent比较类似, 会在下一个大节详细描述
CLI
CLI交互天生就有一种严肃性, 同时CLI也有最广泛的适用性
- Cluade Code : 目前最强大 特性最丰富 普适性最强的的Coding工具
- Codex CLI : 功能非常简陋, 纯靠模型能力硬顶
- ***iflow*** : 国产CC
- gemini cli : 做的也很简陋, 但是更新迭代快, 配合gemini2.5pro的1M上下文非常的爽!
- auggie / cursor cli: 狗屎
Web/Remote Agnt
非专业开发人员的福音:
- 几乎没有环境依赖
- 一般配有 在线预览 + 快速部署的功能
- 非常适合做DEMO验证
个人使用经验
提升AI Coding质量的最有效方法:
- 提供高质量 高相关度的上下文, 至少是包含相关的上下文
- 合理的划分任务, 每次专注于一个任务
CLAUDE.md / AGENTS.md
CLAUDE.md 和 AGENTS.md本质上都是注入到Context里的提示词, 在claude code的实现中, 会将 User / Project 的CLAUDE.md 都插入到Context中.
实现原理
<system-reminder>
As you answer the user's questions, you can use the following context:
# claudeMd
Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.
...
</system-reminder>

如何使用?
- 使用
/init初始化Claude.md - 使用
# content添加到Claude.md
记录什么东西
- DO NOT xxx, because xxx
- Always use xxx to do xxx
{项目概况: 名称/技术栈/架构}
## 核心技术栈
## 项目架构
## 开发命令
## 关键配置
## 开发注意事项
Chat more before coding
这是最简单的最推荐的提升AI Coding质量的方法, 多聊几轮
如果有Plan模式, 那么先使用Plan模式, 直到AI能够彻底理解你的需求, 并且给出了合理的方案
或者说 并不是 "Chat More" 而是 "先调查, 再规划, 再写代码"


SOP Coding
重复自己是最无聊的事情
如果在堆积业务代码, 非常推荐整理出一个SOP, 后续再开发的时候 让AI Follow 这个SOP进行编程.
有两种办法:
- 在commit之前, 让AI总结操作步骤, 并且写入到项目的文档目录中, 做持久化管理
- 使用recorder 自动记录你的操作行为成日志, 生成操作文档
Option Coding
在Claude Code的 2.0.21的更新中, 引入了一个新的功能: interactive question tool
简单来说: AI可以主动向你发文, 你可以做选项回复.

对于懒得打字的朋友们来说, 简直是福音.
做选择题, 总是要比做填空题爽是不是?
一般来说在plan模式下, 会更加主动的调用AskUserQuestion这个工具, 来让用户进行选择.
所以, Enjoy yourself
llmdoc
文档系统在AI Coding中只会越来越重要.
LLM没有长期记忆, 全部依赖于Context, 文档系统本质上就是外挂了一个持久化数据层.
帮助AI快速获取充分的信息.
我这里以我们后端系统的文档建设举例.

当然了, 全部都是AI生成的, by cc-plugin
MCP

寻找MCP
现在几乎所有主流的AI SaaS服务都有提供MCP, 如果你感兴趣可以在这里主流的平台中寻找MCP:
常用MCP
-
chrome-devtools-mcp: Browser use, 谷歌出品, 调用浏览器, 获取Console/网络请求 日志
-
K8S: 注意要使用 readonly模式%20(default%20%22table%22)-,%2D%2Dread%2Donly,-If%20set%2C%20the)
-
ref: 提供准确的文档, Better than context7 贵的东西的缺点只有贵 :(
-
context7: 虽然我认为用处不大, 但是推荐尝试
-
***figma*** : 尽管我几乎不使用figma, 但是由于figma巨大的影响力, 还是加上, 防止有些人竟然不知道
不要使用的MCP
- serena: 太多的重复功能, 不稳定的LSP, 你不会需要这个的.
- 所有超过10个tools的MCP, 只会让你的Coding Agent变成
笨蛋
不要使用MCP

使用Tools是有代价的, Tools并不是LLM天生就会的事情.
从ReAct开始, 工具调用能力被认为是提升Agent解决问题的能力重要组成部分, 在2025年, 号称是 "?Agent元年", 几乎所有的模型都在强调工具调用能力, 就像是人使用手一样
MCP带来的最重要的进步: 一个更容易接入,实现更自由的, 平台框架解耦的Function Call / Tools
但是MCP是有代价的, 而且是昂贵的代价, 每一个MCP Tools都占用一个昂贵的Tool的位置, Claude Code为了能够强化其ToolUse的能力, 在System提示词中做了巨大的强调 (530 Token, 约25%)
# 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.
- A custom slash command is a user-defined operation that starts with /, like /commit. When executed, the slash command gets expanded to a full prompt. Use the Skill tool to execute them. IMPORTANT: Only use Skill for commands listed in its Available Commands section - do not guess or use built-in CLI commands.
- 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 can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency. However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.
- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks. For example, if you need to launch multiple agents in parallel, send a single message with multiple Task tool calls.
- Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools: Read for reading files instead of cat/head/tail, Edit for editing instead of sed/awk, and Write for creating files instead of cat with heredoc or echo redirection. Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead.
- VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the Task tool with subagent_type=Explore instead of running search commands directly.
<example>
user: Where are errors from the client handled?
assistant: [Uses the Task tool with subagent_type=Explore to find the files that handle client errors instead of using Glob or Grep directly]
</example>
<example>
user: What is the codebase structure?
assistant: [Uses the Task tool with subagent_type=Explore]
</example>
又是policy, 又是few shot, 然后一个 mcp add 引入了20个额外的tools + 巨大的无聊的Description , 完全没有经过设计的Response, context 已经完全不够用了!!!!
我建议你只使用0-2个MCP, 在不需要的时候及时关掉
唯一推荐的使用方式是, 在支持多Agent的工具中, 为每个Agent开启一个MCP, 例如Claude Code Subagent.
下图为我在CherryStudio中使用MCP, 尽量让一个Agent做一件事情, 专注于使用一类工具.

MCP是灾难, 调休也是.
我还使用哪些AI工具
- ***Cherry Studio*** : 桌面AI工具, 好用, 强烈推荐
- ***Gemini*** : 我是Gemini的付费Pro会员, 强烈推荐
- ***AIHubMix*** : AI代理提供商, 提供几乎所有的主流模型, 强烈推荐
- ***notebooklm*** : Google出品, 我一般用来做知识库使用, 强烈推荐
- Dify: 懒得写代码的时候我会直接用Dify接一些简单的功能, 比如说简单的Chat之类的工作. 比如说这里的 面试官小工具
- zread / deepwiki: LLM帮你分析开源repo
上下文工程
这里要讲的东西有点太多了, 根本说不完.
这里给出我认为非常适合学习的材料, 感兴趣的可以自行阅读
结构化提示词 : 一个入门教程
AI代理的上下文工程:构建Manus的经验教训 : Agent必吃榜第一
Manus AI Agent 分享PPT : Agent必吃榜第二
Context Rot: More Input, More Stupid
评估LLM的上下文能力: 1M上下文是童话故事
- Anthropic | How we built our multi-agent research system
- Anthropic | Effective context engineering for AI agents
- Anthropic | Building agents with the Claude Agent SDK
- Anthropic | Writing effective tools for agents — with agents
- Anthropic | How we built our multi-agent research system
- Anthropic | Building effective agents
- Cognition | Don’t Build Multi-Agents
- Letta | Anatomy of a Context Window: A Guide to Context Engineering
- Letta | Agent Memory: How to Build Agents that Learn and Remember
- Letta | Memory Blocks: The Key to Agentic Context Management
- Letta | RAG is not Agent Memory
- LangChain | The rise of "context engineering"
- LangChain | Context Engineering
- LangChain | Agent Middleware
- LangChain | Context Engineering for Agents
- Github | Context Engineering Resources
- Github | 12 Factor Agents: Principles for building reliable LLM applications
- Context Engineering for Agents
- Context Engineering Guide
- Context Rot: How Increasing Input Tokens Impacts LLM Performance
- How to Fix Your Context
- What is Context Engineering and How It Differs from Prompt Engineering
- Context Engineering with Agents using LangGraph: A Guide for Modern AI Development
- Context Engineering Skills
- Context Engineering - What it is, and techniques to consider
- Andrej Karpathy on X: "+1 for "context engineering" over "prompt engineering"
- Tobi Lutke tweet
- Free ~14 minute talk on Context Engineering tips & tricks
- Windsurf: Windsurf’s context retrieval
- CodeRabbit: Context Engineering
- Context engineering, clearly explained!
- Context Engineering for PMs
- How to build a context engineering workflow
- Context Engineering for Agents - Lance Martin, LangChain
- Context Engineering with DSPy - the fully hands-on Basics to Pro course