问HN:我该如何提高使用人工智能进行编程的能力?

4作者: lemonlime2271 天前原帖
最近我在进行一个个人项目,将一个旧的 jQuery + Django 项目重写为 SvelteKit。主要工作是将用户界面模板翻译成符合 SvelteKit 习惯的格式,同时保持原有的样式。这包括使用语义化的 HTML,而不是随意使用 div,避免将 div 嵌套在 div 中,以及用简化版的 Tailwind 替代 Bootstrap。还涉及一些逻辑重构,以保持原有功能,但重写以避免多年的代码债务。例如,用可组合的 Svelte 组件替换使用布尔标志的多个视图模板。 我在进行这项工作时有一个相对稳定的流程:查看 Django 中定义的每个路由,构建我的 `+page.server.ts`,然后将页面的每个主要部分拆分为一个 Svelte 组件,并为其创建相应的 Storybook 故事。这样做需要花费大量时间,因为我必须确保不是简单地复制模板,而是以更符合习惯的风格重新创建它。 这种工作似乎是 AI 辅助编程的一个很好的用例,但我未能有效利用它。最多,我只能让 Claude Code 生成一些稍微不那么混乱的 Svelte 代码。简单的提示无法让 AI 的代码质量达到我手动编写代码的 90%。理想情况下,AI 应该能将代码生成到我可以在 15-20 分钟内手动审查的程度,这将大大加快我在这个项目上花费的时间(目前我需要 1-2 小时才能正确翻译一个路由)。 你们有什么建议或技巧可以帮助我提高使用 AI 的效率和代码质量吗?
查看原文
I&#x27;ve been working on a personal project recently, rewriting an old jQuery + Django project into SvelteKit. The main work is translating the UI templates into idiomatic SvelteKit while maintaining the original styling. This includes things like using semantic HTML instead of div-spamming, not wrapping divs in divs in divs, and replacing bootstrap with minimal tailwind. It also includes some logic refactors, to maintain the original functionality but rewritten to avoid years of code debt. Things like replacing templates using boolean flags for multiple views with composable Svelte components.<p>I&#x27;ve had a fairly steady process for doing this: look at each route defined in Django, build out my `+page.server.ts`, and then split each major section of the page into a Svelte component with a matching Storybook story. It takes a lot of time to do this, since I have to ensure I&#x27;m not just copying the template but rather recreating it in a more idiomatic style.<p>This kind of work seems like a great use case for AI assisted programming, but I&#x27;ve failed to use it effectively. At most, I can only get Claude Code to recreate some slightly less spaghetti code in Svelte. Simple prompting just isn&#x27;t able to get AI&#x27;s code quality within 90% of what I&#x27;d write by hand. Ideally, AI could get it&#x27;s code to something I could review manually in 15-20 minutes, which would massively speed up the time spent on this project (right now it takes me 1-2 hours to properly translate a route).<p>Do you guys have tips or suggestions on how to improve my efficiency and code quality with AI?