请问HN:使用AI辅助构建前端的最佳实践是什么?

1作者: sukit8 个月前原帖
嗨,HN, 我是一名后端开发者,最近开始构建全栈应用,主要使用 Next.js 和 shadcn-ui。鉴于人工智能编码工具最近变得非常强大,我一直依赖它们来帮助我弥补前端技能的不足。 在大多数情况下,这种方法效果很好——尤其是当我可以直接组合现有的 shadcn-ui 组件时。我描述我想要的布局和功能,AI 帮助我将这些元素组合在一起。 然而,当遇到以下情况时,我就会遇到困难: - 组件的外观不符合我的预期,需要进行自定义; - 我需要的组件在库中不存在; - 我需要微调 CSS/样式; 在这些情况下,事情就变得更加复杂。我对 CSS 或前端设计系统并不太熟悉,有时 AI 生成的代码并不能完全符合我的想法。结果我不得不花费过多的时间来调试样式,或者试图更好地解释我想要的内容——通常并不成功。 所以我现在在想: 这是否意味着我需要投入更多时间深入学习前端开发(特别是样式和布局)? 还是说我只是没有以正确的方式与 AI 协作——例如,我的提示写得不好,或者我缺少一些工具或技巧,使这个过程更加顺畅?
查看原文
Hi HN,<p>I&#x27;m a backend developer who recently started building full-stack apps, mostly using Next.js + shadcn-ui. Given how capable AI coding tools have become lately, I&#x27;ve been relying on them to help me bridge the gap in my frontend skills.<p>For the most part, this has been working great — especially when I can just compose existing shadcn-ui components. I describe the layout and functionality I want, and AI helps me glue things together.<p>However, I&#x27;m running into trouble when:<p>The components don’t look quite the way I want and need customization;<p>The component I need doesn’t exist in the library;<p>I need to fine-tune the CSS&#x2F;styling;<p>In those cases, things get a lot harder. I&#x27;m not very fluent with CSS or frontend design systems, and sometimes AI-generated code doesn&#x27;t fully match what I had in mind. Then I end up spending too much time debugging styles or trying to explain better what I want — often unsuccessfully.<p>So now I’m wondering:<p>Is this a signal that I need to invest more time into deeply learning frontend development (especially styling and layout)?<p>Or am I just not collaborating with AI in the right way — e.g., are my prompts poorly written, or am I missing some tools or techniques that make this process smoother?