如果人工智能编码正在降低你的代码质量,说明你的质量管理方式不对。
If AI coding is lowering your code quality, you're not managing quality right

原始链接: https://www.i-kh.net/p/if-ai-coding-is-lowering-your-code

尽管有些人担心 AI 编程代理会以牺牲质量为代价换取速度,但采取分层防御的方法实际上可以将开发者的产出提高 2-3 倍,同时减少错误。关键在于将 AI 融入开发生命周期的每一个阶段: * **规范驱动开发:** 在开始编码之前,利用 AI 主动识别边缘情况和需求差距。 * **测试驱动开发 (TDD):** 利用代理在实现功能前编写全面的测试套件,以确保高覆盖率。 * **自动化审查流程:** 利用 AI 进行安全性检查、代码规范检查 (linting) 和重构,以保持代码标准并消除“AI 味”。 * **分层验证:** 在自动化 PR 审查的基础上,辅以针对复杂逻辑的人工抽查。 * **可观测性:** 使用 AI 驱动的日志和错误跟踪工具,自动诊断并修复生产环境中的错误。 通过将 AI 视为质量控制的引擎而不仅仅是代码生成器,团队可以实施比以往更深入、更频繁的检查。这种策略确保了更快的交付不会损害可靠性,使开发者能够在保持高标准的同时显著加快工作流程。

这篇来自 Hacker News 的讨论探讨了围绕 AI 辅助编程及其对软件质量影响的争议。 核心争论在于:是 AI 降低了质量,还是用户未能正确使用它。AI 的支持者认为,它是一种强大的工具,而非工程的替代品;如果开发者实施严格的护栏措施(如广泛的测试、模块化架构设计和彻底的人工代码审查),就能产出高质量的代码。 然而,批评者认为,AI 生成的代码往往会引入“垃圾内容”,且 AI 产生的大量代码使得有效的审查变得不可能,从而导致系统脆弱且难以维护。许多参与者强调,无论使用何种工具,代码的责任始终在于开发者。一些人指出,所谓的“AI 编程危机”实际上是管理上的失败,即公司将速度置于工艺之上。 最终,大家的共识倾向于:AI 有效地放大了开发者现有的习惯。那些重视质量和严格标准的人利用 AI 来扩展其专业能力,而那些追求速度或缺乏自律的人则利用 AI 更快地生产出有缺陷的代码。
相关文章

原文

One common take on the coding agents that I see goes something like this: “Sure, AI helps you output more code, but won’t the quality suffer?”

It certainly will if you just blindly merge the PRs and send them off to prod. But if you take a thoughtful, layered approach to managing quality, I find that it’s possible to not just keep the number of bugs stable but actually reduce it—while still increasing the output by 2-2x.

Many of these defensive layers are pretty much the same as before Claude/Copilot/Codex/etc. (though they’re made easier now by AI), while others are new. Here’s a defensive setup that I’ve seen successfully used in practice, both on my team and elsewhere.

One of the biggest surprises after I started using spec-driven development was the drop in bugs in the freshly written code. Before spec-driven development, when building, e.g., a new feature, the teams I was on often spent up to a third of the total effort on the post-development “polishing,” i.e., discovering and fixing various bugs. Many of these bugs occurred either because we didn’t foresee certain interactions and edge cases, or because the developer was tired that day and didn’t put in enough thought, or because the designer or PM didn’t think through certain scenarios. Some of these bugs were missed and ended up in production.

After I started using spec-driven development, the number of these bugs in my code sharply dropped, and I’ve seen the same drop for some (but not all) of my teammates. As far as I can tell, the main cause of this drop is one specific step in the process: having the AI review the requirements or the tech design and find any gaps, edge cases, unexpected interactions with the existing code, or other similar problems.

The AI doesn’t get tired and, when prompted right, is a lot less likely to give up hunting for potential issues. If anything, it can sometimes be overzealous, and I have to carefully review its proposed edits to the requirements to make sure that it doesn’t invent any issues that aren’t there.

Coding agents now make test-driven development (TDD) trivial to the point where there’s no reason not to do it. However, it needs to be done right: you don’t want the agent to blindly write passing tests for any bugs it just added to the code. So the best planning and implementation skills I’ve seen usually follow this pattern:

  • Instruct the agent to think through the test scenarios and test cases based on the requirements,

  • Write the test cases,

  • Write the implementation,

  • Test the implementation against the test cases and fix any issues that come up,

  • Maybe backfill any remaining coverage gaps—but again, keeping the requirements in mind.

Also, with the agents writing the tests, there’s no excuse not to shoot for near-universal coverage or to wait on backfilling any missing unit tests.

There’s still no substitute for a human (you, QA, PM, or someone else) actually trying out the feature, going through all the edge cases, and seeing whether everything works as expected or whether you need to make changes.

These manual tests can take a while, especially if the test scenarios take some effort to set up. This is one of the steps that so far has seen only modest gains in productivity, and it’s the main reason that my output has increased only 2-3x instead of something like 10x. Though now that I think about it, there may be a few opportunities for automation here that I’ve missed.

End-to-end (E2E) tests are arguably the most important tests in the codebase because they verify that new changes haven’t broken any existing functionality as experienced by the end user. Ideally, they’d run on the PRs, in the test/stage environments, and in production after every deployment. Ideally, they’d also be maintained by the same developers who write regular code, but I understand that some organizations aren’t really set up for that.

AI does make it easier to write E2E tests, but to do that effectively, it needs access to the tools or MCP servers that let it debug test failures—e.g., a browser tool or MCP access to the logs. However, it’s important to keep in mind that E2E tests aren’t a substitute for manual testing because they’re just a rough, incomplete check that nothing important broke.

I find that coding agents aren’t great at following complex instructions in AGENTS.md or CLAUDE.md. But they do pretty well if you add a separate pass to find and fix specific issues. These can be:

  • Security issues,

  • Finding overcomplicated or duplicated code,

  • Compliance with naming, file organization, or formatting rules,

  • A general code review pass to find any issues with the logic,

  • Overly long comments written in AI-ese instead of regular English,

  • Any other specific things that you’d like to find and fix.

If added to the planning or implementation skills, these can be pretty much “free” additions, adding maybe 5-15 min to the implementation time with no additional attention required.

They can be also added to the PR reviews if you prefer to take a look at the comments before applying any fixes.

I think I’m becoming convinced that for minor tweaks and simple bug fixes, human reviews can become optional. Provided that other defensive layers are still in place.

But for complex changes, I find that it’s still necessary to review AI-written code. I still regularly find big-picture mistakes, missed adverse interactions with other features, overcomplicated or suboptimal implementations, and other problems. Not to mention weird word choices like “mint” instead of “generate” or “stamp” instead of “set.”

AI code reviews have also been a really great addition. On my current team, we run both Claude and Cursor reviews on the PRs, and surprisingly, each of them finds different problems. You can also add other custom reviews from various angles, like security, efficiency, interactions with other repos, and so on, though be aware that AI can be overly nitpicky in its reviews, so it’s important to also have a pass where another agent prunes the proposed AI-generated PR comments that aren’t actually meaningful.

Once the code is in production, at a minimum, it’s good to have someone periodically scroll through the logs or watch any user recordings in something like Fullstory, or review various dashboards that track error rates, latencies, and other issues.

Even better would be an error tracking service like Sentry or GCP’s Error Reporting that detects and deduplicates errors.

The best approach, however, would be to then have Claude/Cursor/whatever auto-diagnose these errors, figure out the root cause, and make PRs with the proposed fix.

I’m sure I’ve missed other important components of maintaining high quality, but the main idea is that with the right set of defensive layers, the increased output doesn’t have to come at the cost of reliability. If anything, coding agents now make it cheaper to add more and deeper checks than before: more tests, more review passes, faster diagnosis of production issues.

So if you’re sufficiently focused on quality, I think it’s entirely possible to double the delivery speed while keeping the bugs under control. Or maybe even reducing them.

联系我们 contact @ memedata.com