问 HN:如何提高使用 AI 进行编程的能力?

4作者: lemonlime2276 天前
最近我一直在做一个个人项目,将一个旧的 jQuery + Django 项目重写成 SvelteKit。主要工作是将 UI 模板翻译成地道的 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?