零重力瓦力 25-07-07 16:45
微博认证:AI博主

Claude Code 的编程能力十分强大,但要真正用好这款工具,还是有不少门道的。AI 技术达人 Alex Finn 分享了八个超级实用的技巧,不仅能大幅提升 Claude Code 的使用体验,对其他各种 Vibe Coding 方式也同样适用。

1. Claude Code 有个很特别的功能,就是支持自定义规则。只要在项目里加个 CLAUDE.md,把你希望遵循的开发规范写进去,Claude 后续的每一步都会按照你的要求来。比如,你可以要求它把任务细分到最小单元,每一步都让你确认,并且自动归档历史变更。这样一来,你的思路会更清晰,代码质量和协作效率也能明显提升。

2. 很多人习惯直接让 Claude 写代码,其实先用 Plan 模式梳理一下需求和步骤,会让 Claude 的方案更完善,出错概率也更低。你甚至可以为每个环节都单独做个规划,有点像画流程图再动手。虽然看起来慢点,但能大幅减少返工,尤其适合复杂需求。顺便说一句,建议规划时用能力强的 Opus 模型,执行时切回 Sonnet,这样既保证效果又省钱。

3. 有经验的开发者都知道,保存进度和随时 “撤回” 有多重要。Claude Code 虽然没有像 Cursor Agent 那样的一键回退功能,但你可以用 GitHub 做自己的 “检查点” 系统。每完成一步就提交一次代码,不用担心提交太频繁。这样哪怕出错,也能随时回到任意历史节点,再也不怕 AI 写错导致进度丢失。这其实也是传统开发中非常好的实践。

4. Claude Code 不只理解文本,还能直接分析图片。比如想参考某个应用的 UI,直接截图拖进去,让 Claude 按照图片样式搭界面。遇到 bug 或报错,也能截图提交,Claude 会帮你定位和解决问题。无论是头脑风暴还是问题排查,有图片输入效率都高很多。其实,这种“多模态” 输入已成为新一代 AI 工具的标配,用了就知道有多方便。

5. 很多人容易忽略 /clear 命令。每完成一个阶段,记得清理上下文,不仅能减少 AI 出错和“胡编乱造” 的概率,还能节省大量 Token 费用。尤其是长时间对话和大项目,非常建议定期清空。道理很简单,信息越新、越聚焦,Claude 的回答就越靠谱。

6. AI 生成代码虽然省事,但安全性参差不齐,像 API 密钥、敏感信息这些很容易被无意暴露。每次开发新功能,都要让 Claude 做一遍安全检查,比如有没有敏感信息泄漏、是否符合安全最佳实践、有没有明显漏洞。可以把安全检查的提示词固定下来,每次开发都用,习惯成自然,安全有保障。

7. 有些新手觉得 AI 会写,自己懂不懂无所谓,其实这样很容易陷入 “黑盒” 操作。反过来,每次都让 Claude 解释一下代码和实现思路,哪怕一开始没看懂,坚持下来进步会很快。理解背后的原理和数据流,之后再提需求就更有针对性,Claude 用起来也会越来越顺手。

8. 最后一个小建议,等 Claude 写代码时别刷手机、看短视频,不妨趁机和 Claude 聊天,头脑风暴或反思下当前方案。这样 “无缝切换” 能极大提升专注力,让等待时间变得更有价值。开发效率,很多时候就是这么一点点积累出来的。善用碎片时间,灵感和效率都能大幅提升。

总的来说,Claude Code 不只是一个自动写代码的工具,更像是一个可以深度协作的 “编程拍档”。用好 “规则、规划、检查点、多模态输入、安全检视、学习机制和节奏管理”,每个人都能从中获得极大的提升。

以下是视频中提到的 4 个重要的 Claude 提示

【CLAUDE.md】
1. First think through the problem, read the codebase for relevant files, and write a plan to tasks/todo.md.
2. The plan should have a list of todo items that you can check off as you complete them
3. Before you begin working, check in with me and I will verify the plan.
4. Then, begin working on the todo items, marking them as complete as you go.
5. Please every step of the way just give me a high level explanation of what changes you made
6. Make every task and code change you do as simple as possible. We want to avoid making any massive or complex changes. Every change should impact as little code as possible. Everything is about simplicity.
7. Finally, add a review section to the [todo.md](http://t.cn/A6DsjkHq) file with a summary of the changes you made and any other relevant information.

【让 Claude 检测代码安全性】
Please check through all the code you just wrote and make sure it follows security best practices. make sure there are no sensitive information in the front and and there are no vulnerabilities that can be exploited

【让 Claude 解释它生成的代码】
Please explain the functionality and code you just built out in detail. Walk me through wehat you changed and how it works. Act like you’re a senior engineer teaching me code

【在 Claude 编码过程中高效利用时间】
When I am coding with AI there are long breaks into between me giving me commands to the AI. Typically I spend that time doom scrolling which distracts me and pu†s me in a bad mental state. I'd like to use that time now to chat with you and generate new ideas, and also reflect on my other ideas and businesses and content. I'm not sure how I'd like to use this chat or what role I'd like you to play, but I think ti could be much more useful than me doom scrolling. What do you think? What could be the best way for us to use this chat?

#AI技术[超话]##AI编程##claude##AI创造营# http://t.cn/A6DsYVpW

发布于 上海