AI 写代码快过发布速度,用 Feature Flags 灰度上线更稳妥
agent 一小时生成的代码比你敢上线的还多,这篇把 feature flags 加金丝雀发布的完整流程讲得很清楚,还给了 LaunchDarkly 这个现成方案。
当 AI 编程助手让写代码的速度超过发布速度,部署流程就成了瓶颈。作者建议用 feature flags 把部署和功能启用分成两个独立决策:代码先带开关上线、默认关闭。随后对一小批用户开启开关并监控报错情况,逐步扩大范围,这就是 canary release(金丝雀发布)。出问题时只需关闭开关即可止损,无需回滚部署。文中提到的 LaunchDarkly 提供托管方案,支持免重新部署开关功能、发布期间监控指标和自动回滚。
People are now writing code faster than they can roll it out to their users.
You need a plan for rolling out new features and updates. This is not optional anymore.
I've made so many mistakes deploying updates to software I've built that I could write an encyclopedia about everything you should and shouldn't do.
One of the most important lessons I've learned:
Never rush new code in front of all your users, especially now that agents generate so much of our code.
You need a way to decide what goes live, who gets it first, and when it's ready for more people.
This is how I usually implement this:
1. I have a new feature I want to release. I put it behind a switch in the code so I can turn it on or off. We call this "feature flags."
2. After I test the code, I deploy it with the flag off. Nobody has access to it at first. I want the deployment and the feature to become two separate decisions.
3. I then turn the flag on for a small group of users while everyone else keeps using the existing version.
4. I monitor what happens with the feature. Does it work as I expected? Are there any errors?
5. I gradually let more people use the new feature until I'm comfortable removing the flag.
6. If something breaks, I can turn the flag off for everyone and stop the problem until I fix it.
I call these gradual rollouts "canary releases". They're easy to implement with feature flags.
Feature flags don't replace code reviews or testing. They just give you another layer of control.
You don't have to build a feature flags system yourself. @LaunchDarkly manages the whole thing for you:
• Add flags to your code • Choose who gets the feature • Increase the group over time • Turn flags on or off without redeploying • Implement guarded rollouts to watch metrics during a release • Use automatic rollbacks
Here is a link to get started: https://t.co/05lTKSAm26
Agentic coding is amazing, but it's only worth it if you can confidently put working software in front of your users.
Thanks to the LaunchDarkly team for partnering with me on this post.