通过手动重打大模型生成的代码,来避免认知债务。
Prevent cognitive debt by manually retyping LLM-generated code

原始链接: https://ankursethi.com/blog/prevent-cognitive-debt-by-manually-retyping-llm-generated-code/

作者拒绝在个人项目中使用现代“AI生成、人工审核”的工作流程,认为将整个编码过程外包会造成巨大的认知负债,并剥夺开发的乐趣。与其允许 AI 直接修改文件,作者采用了一种“手动录入”的工作流:在聊天中请求代码片段,并手动将其键入编辑器。 尽管这种方法不如全自动化高效,但作者认为它更具价值。手动转录代码会强制放慢节奏,这有助于理解代码、构建代码库的空间心智模型,并更容易发现幻觉内容或糟糕的设计选择。通过将大语言模型视为交互式文档而非自主代理,作者保持了自己的主导权,并确保对工作有深刻的个人理解。归根结底,作者更看重长期的代码掌握能力和构建过程,而非 AI 驱动的原始生产速度,并警告称,行业目前对自动化“垃圾内容”的依赖,可能会导致未来开发者不再理解自己的基础设施。

最近的一场 Hacker News 讨论探讨了手动重写大模型(LLM)生成的代码以避免“认知债务”的做法。 支持者认为,直接复制粘贴代码会导致“理解漏洞”,即开发者无法内化逻辑或识别潜在假设,从而增加后续调试的难度。通过手动重写,开发者被迫放慢速度,分析语法,并思考代码如何融入更广泛的架构。这种习惯类似于从教科书中学习:输入的动作强迫开发者保持专注,从而建立更扎实的思维模型。 然而,这种方法仍具争议。怀疑者指出,手动输入会显著降低开发速度,使个人项目变成苦差事,并可能阻碍职业生产力。另一些人则认为,大模型现在产出的代码往往优于人类,使得手动过程看起来像是一种不必要的负担,或者对于难以适应新技术的人来说,只是一种“形式主义的仪式”。 归根结底,共识在于:重写的价值取决于开发者的目标——追求速度的人偏好自动化,而追求深度学习和长期代码掌握能力的人,则认为手动重写是避免技术停滞的宝贵习惯。
相关文章

原文

Despite what I said in April, I'm still using coding assistants on my personal projects.

Using them to one-shot entire features leaves me unsatisfied and disoriented, but I do enjoy using them to fast-forward through the boring parts of my projects.

However, allowing my coding assistant to roam free in my projects leaves me with a colossal amount of cognitive debt. I might hate the idea of poring over the Django documentation to figure out how to add tagging to my website, but I still fundamentally want to understand how it works. Just because a problem is boring doesn't mean I want to fully offload my understanding of the solution to a machine.

Of course, I could review every single line of code the LLM produces. That's what most developers are expected to do in this cursed year of 2026. Robots raise PRs, humans review them. It's a brave new world.

But I don't enjoy reviewing AI-generated PRs. Poring over hundreds of lines of overly-defensive, badly-commented, subtly incorrect code is not fun. I might grudgingly do it for an employer—while making sure said employer becomes an ex-employer as soon as possible—but I'm sure as hell not doing it for my personal projects. Personal projects must be fun above all else. The joy of working on personal projects comes from the process, not from the outcome.

So what's a boy to do? How do I offload the boring work to LLMs without ceding control of my own work and cognition to the slop machine?

I've come up with a solution that's grossly inefficient and perhaps slightly comical: I ask my coding assistant to generate code in the chat, then manually make all the edits myself.

I have these instructions in all the agents files in my personal projects:

I want to understand every line of code that goes into this project. Never create, edit, move, rename, or delete project files unless I explicitly ask you to do so. Instead, show me every proposed edit in the chat so I can type it in manually.

Do not run commands that modify project files, install dependencies, or change repository state unless I explicitly request that action. Instead, show me those commands in the chat so I can run them manually.

I'm an experienced developer. Do not explain syntax, APIs, programming concepts, or implementation details unless explicitly asked.

Using LLMs this way allows me to work faster than not using LLMs at all, but I'm still slower than those who are willing to allow the machine to think for them. Instead of being 10x faster, I'm probably only 2x faster. But what I lose out on in terms of speed, I gain in terms of a deeper understanding of my code.

As I manually type every single line of LLM generated code into my editor, I build up a mental model of how it works and fits into my existing codebase. If I don't understand an API or algorithm, I can stop to look it up, or just ask the LLM to explain it.

Typing the code myself forces me to slow down, which means I'm more likely to detect hallucinations or bad design choices the LLM might have made. I can clean up the code as I go, reorganizing it, refactoring it, adding comments, and generally adapting it to my own taste.

Most importantly, this workflow allows me to build a spatial map of my codebase. I know where every bit of functionality lives in the codebase. When I need to make a change, I know exactly where I need to make it. It not only helps me work faster within my projects, it also makes it easier for me to better prompt and instruct the LLM in the future.

When I was learning to code as a teenager, experienced programmers would often tell me to never copy and paste code into my projects. If I was learning from a book, I was advised to copy all the examples into my computer and make sure I could run them. If I was learning from a blog post or forum answer, I was advised to type it out and adapt it to my codebase so I understood it completely.

Manually typing LLM-generated into my codebase feels like the exact same learning process. It might not be the most efficient way to work with an LLM, but I value comprehension over productivity. I've been doing this for a few months now, and it's been working well for me. I plan to continue using this workflow for as long as I can.

I fear the software industry is taking on a large amount of cognitive debt that we'll have to pay back very soon. There will come a time when we no longer understand how large parts of our digital infrastructure are put together. I might not personally be able to change the course of the entire industry, but I can at least make sure I completely understand the software I put out into the world. Anything else would be professional malpractice.

联系我们 contact @ memedata.com