pythonic生物人

使用Cursor进行编程的黄金法则

Cursor是一款专为AI辅助编码设计的智能代码编辑器,集成了强大的AI助手,支持自动补全、错误修复和代码优化,适用于快速开发、调试与协作,特别适合数据科学、Web开发及AI应用开发,提高编程效率。

Image

分享最近火爆的Cursor进行编程的15条黄金法则:

  1. Start from a template: Begin your project by cloning a template from GitHub or another source to provide a solid foundation (On Cursor, Start from Repo, and paste this link to build a Next.js app that is prebuilt with AI features, database, and authorization: https://github.com/ansh/template-2).
    从模板开始:在 GitHub 或其他平台上找到合适的模板,克隆并作为项目起点,以建立稳固的基础。

  2. Use agent mode: Utilize Cursor’s agent mode (not normal mode) to create, edit, and manage files through natural language commands.
    使用代理模式:在 Cursor 中启用 代理模式(而不是普通模式),通过自然语言命令来创建、编辑和管理文件,提高开发效率。

  3. Use Perplexity: Use Perplexity to find new designs and APIs from the web. Say that you are creating a Next.js project, and that you want to create a certain feature, and it will provide instructions and code examples.
    善用 Perplexity 搜索:利用 Perplexity 查找最新的 API 和设计方案。例如,当你开发 Next.js 项目时,直接说明你要实现 某个功能,然后让它提供详细的代码示例和使用说明。

  4. Create new chats in Composer: Open a new Composer chat for each distinct task. Keep agent chats short.
    为不同任务开启新的 Composer 聊天:一个任务对应一个对话,保持对话内容简洁高效,避免信息混乱。

  5. Run locally, test frequently: Use built-in servers to run your app locally and test often to catch issues early.
    本地运行,持续测试:使用本地服务器频繁运行和测试代码,尽早发现并解决问题。

  6. Iterate and refine: Embrace rapid iteration—don’t worry about perfect designs initially; improve them step by step.
    快速迭代,逐步优化:不要一开始就追求完美,先完成核心功能,再不断优化,逐步提升代码质量。

  7. Utilize voice-to-text: Use tools likeWhispr Flowfor faster input, and just vibe.
    使用语音输入加快开发:借助 Whispr Flow 等语音转文字工具,提高输入效率,让开发更流畅。

  8. Clone and fork wisely: Use GitHub repos as starting templates to accelerate development, or to find inspiration, then customize them to fit your vision.
    灵活克隆和 Fork 代码:在 GitHub 上寻找优秀的开源项目,既可以加速开发,也能汲取灵感,然后根据自己的需求进行调整和优化。

  9. Copy errors and paste into Composer agent: When errors occur, copy error messages from your console and paste them into the Composer agent, and more often than not, they will be fixed. When dealing with errors, over-explain the issue if it’s not fixed the first time.
    遇到错误,直接复制粘贴到 Composer 代理:如果代码报错,复制错误信息并粘贴到 Composer 代理,它通常能快速帮你解决。如果问题未解决,尝试提供更详细的上下文信息。

  10. Don’t forget you can restore previous Composer chats: Save your work frequently so you can revert to an earlier state if needed.
    学会恢复历史版本:Composer 支持回溯历史对话,养成定期保存的习惯,以便在需要时回滚到之前的状态。

  11. Secure your secrets: Always store API keys and sensitive data in environment files rather than hard-coding them.
    保护敏感信息:API Key、数据库密码等敏感数据必须存放在环境变量文件 .env 中,绝对不要硬编码到代码里,以防泄露。

  12. Commit often: Push your progress to GitHub regularly to track changes and safeguard your work. Cursor can do this for you, just ask the agent.
    频繁提交代码:养成良好的代码管理习惯,定期将代码提交到 GitHub,确保版本可追溯、数据不丢失。Cursor 代理也可以帮你完成这项任务。

  13. Deploy early: Use platforms like Vercel to deploy your app early, to make sure there are no errors on deployment.
    尽早部署:尽早使用 Vercel 或其他平台部署项目,及时发现线上环境中的潜在问题,避免发布后才紧急修复。

  14. Keep a record of the prompts that work best; reuse them often: Document your most effective prompts to make future development and debugging easier.
    整理并复用高效的提示词(Prompt):记录下最有效的 AI 提示词,以便在未来开发和调试时直接复用,提高开发效率。

  15. Enjoy the process—just vibe: Embrace the creative journey of vibe coding, experiment, learn, and have fun along the way. Just vibe.
    享受编程过程,保持愉悦的心态:Vibe 编程不仅仅是写代码,更是一次充满创意和探索的旅程。大胆尝试、不断学习,在这个过程中找到乐趣!

ref:https://x.com/rileybrown_ai/status/1889832939216941100>


-END-

推荐阅读:

👉Python matplotlib保姆级教程
👉Python seaborn保姆级教程

交流学习

图片