如何高效使用 AI 编程工具,有什么经验可以分享啊

55 天前
 maladaxia

我在网上看到有人使用 cursor, 一天可以写 1 万行有效代码, 这效率也太高了.
我自愧不如.

大家有什么经验可以分享吗

2062 次点击
所在节点    程序员
14 条回复
Abbeyok
55 天前
多写备注,让 ai 知道你想干嘛,然后让 ai 自动生成代码
2han9wen71an
55 天前
让他补充测试用例和文档,然后基于测试用例进行重构优化
ZeekChatCom
55 天前
@Abbeyok 不是多写提示词?
name1991
55 天前
感觉最近我遇到瓶颈了,一开始有 cursor 的帮助干劲十足,想做个之前一直想做的 http server ,但是做了一段时间之后,就没有兴趣了,想找一个新的项目来做,但是做找不到什么目标。。。迷茫中。。。
Abbeyok
55 天前
@ZeekChatCom 我是直接写备注
CCSundy
55 天前
这个 规则很好用 https://pastebin.com/clone/hLRexhqB
爱不释手
maladaxia
55 天前
@name1991 AI 辅助编程适合 idea 特别多的人
monosolo1on1
55 天前
## 1. 启动阶段让 AI 多想想再开始写:
You are about to work with me in an interactive coding process.
Your role is to propose solutions, ask clarifying questions, and discuss ideas collaboratively.

You may proceed to write code only after receiving explicit approval⚠️.
Act with caution and deliberation — do not rush into implementation or shift direction without strong justification.

Follow the steps below in order:
1. Understand the task: Describe your understanding of the task, highlight areas that require extra care, and consider both best practices and the specific context of this project.
2. Understand the codebase: Describe your understanding of the project by using any available methods to gather information (file structure, key configs, code, etc.).
3. Outline your approach: Present your proposed solution and implementation steps. Include key code snippets (each no more than 50 lines). Avoid diving into full implementation details.
4. Evaluate dependencies: If your approach involves new packages, explain their necessity and compare them to alternative options.
5. Request approval: If anything is unclear, ask. Do not start coding until the plan is fully confirmed.

## 2. 追问过程中让 ai 继续保持思考,让我确认再写代码:
This is the **drafting stage**. Focus on analyzing the problem, evaluating options, and outlining a clear plan.
Avoid all implementation for now. Do **not** begin coding, editing, or executing any part of the solution.

Use short code fragments (≤ 50 lines) only if necessary to support discussion or clarify ideas.
Keep the conversation at the planning level until implementation is explicitly requested.

## 3. 告诉 AI 之前的讨论方案 OK ,现在可以开始写代码了:
You are now authorized to implement the confirmed solution(s).
Write code strictly based on the previously discussed and approved solution.
Do not introduce new ideas, restructure the logic, or make assumptions beyond the agreed scope⚠️.
If you encounter uncertainties, pause and ask questions before proceeding.

## 4. 告诉 AI 我修改了代码,先读取最新的代码再开始写:
I’ve made substantial changes to the codebase.
**Before continuing any work, carefully re-read all affected code files** to fully understand the latest logic and structure.
Ensure your upcoming work is based on this updated version—failure to do so may result in conflicts, overwritten work, or critical bugs.

## 5. 让 AI 重构代码文件,模块化,不要改其它的东西
Refactor this file by breaking it down into smaller, decoupled internal modules to improve readability and maintainability.

Requirements:
1. Do not alter any existing functionality, styles, or behaviors.
2. Update documentation and comments as needed to reflect the new structure.
3. You may only edit this file. Creating or modifying any other files is strictly prohibited.

以上是我每天在用的,设置了快捷键一键输入(可以用 raycast),不然我也不可能一个一个敲出来回复你。

我觉得 AI 写代码最大的瓶颈在于“沟通”,只要把话说清楚背景捋清楚,它总能写得比我自己又快又好。
我并不觉得我得沟通能力差,只是很多时候我懒得说/懒得打那么多字。
所以我做了两个尝试:
1. 把经常要说的提示词用快捷键输入。虽然有 cursorrules 等文件,但是它经常忽略。而我明确在聊天框说的字,它是不会忽略的;
2. 让它尽可能和我交互,多问我问题,我再简单回答。比我自己上来要铺垫很多信息要更轻松,也更精准。
maladaxia
55 天前
@CCSundy 感谢, 之前在 cusor 论坛看到过. 还没有试
maladaxia
55 天前
@monosolo1on1
感谢分享.

1. curosr 现在有 project rule, 你可以引用规则 @rule.
2. 另外可以在一次 agent 请求中, 让他向你询问, 这样可以省钱. 我也是在 V2EX 上刚看到的.
比如写个 shell 脚本 ask.sh
```bash
#!/bin/bash
echo "🤖 问题: $1"
echo "💬 请输入回复:"
response=$(cat)
echo "💬 回复:"
echo "$response"
```
name1991
55 天前
@monosolo1on1 #8 这些可以放在 rules 里面吗? user rules
maladaxia
55 天前
@name1991 可以每个规则写一个文件, 用的时候 @出来. 应该跟 raycast 差不多
monosolo1on1
55 天前
确实,写到文件里面然后聊天框里面引用,也是一个方法~

但我还有些定制聊天规则的 prompt ,用在 chatgpt 聊天框的。所以定制为快捷键可能更便捷一点。

我还有一些 in-zh ,in-en ,in-short ,的快捷键,指定回复语言和风格的。各种快捷键可以很方便组合~

@maladaxia
monosolo1on1
55 天前
我一开始也是用 rules 文件,但他经常忽略我的 rules 。有另外一位兄弟建议可以 @ rules 文件来强调,或许可以试一试。但这样的话和输入一次快捷键的操作成本差不多了~

@name1991

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://ex.noerr.eu.org/t/1137350

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX