Section 1: The Real Pain Points Managers Face
Our team took over a legacy system that has been running for eight years. The original core developers have long since left, the code has almost no comments, and the documentation is stuck in a half-finished state from three years ago. New team members take weeks on average before they can independently modify a single module—and every change risks setting off a chain reaction, because no one can clearly explain the dependencies between modules.
As a manager, the problem I face isn't "is the code well written or not," but three process-level problems:
- Knowledge is concentrated in the heads of a few veteran employees—when one of them goes on vacation, the iteration grinds to a halt.
- Change risk assessment is guesswork—with no architecture documentation, everyone in review meetings can only estimate the impact scope from memory.
- The cost of onboarding new people is high—bringing someone up to speed effectively means having them read the entire codebase from scratch, which is pure waste.
Everyone knows that adding comments and writing architecture docs should be done, but it never makes it into the iteration plan. Because it's "important but not urgent," and the workload is enormous and tedious—nobody wants to do it. This is exactly the kind of scenario AI should take over.
Section 2: How We Turned This into a Process
Feeding the entire codebase to AI directly is unrealistic. We broke it down into four steps, each with a human review checkpoint—this is the key to risk control.
Step 1: Split by module, feed to AI in batches. We split by directory and process only one module at a time, to avoid exceeding context limits and to make acceptance easier. When connecting to the model, we went through a unified gateway (for platform access pricing, refer to the official pricing page), which makes it easy to control usage and account for costs per module.
Step 2: AI generates, humans set format standards. We have the AI output according to a unified template: module responsibilities, external interfaces, dependencies, key business rules, and potential risk points. With a standardized format, the outputs can later be compiled into a searchable documentation library.
Step 3: Veteran employees do fact-checking. AI-generated comments and descriptions may "look right but be fabricated," especially the business rules sections. We assign people familiar with the system to only do verification, not writing—the workload drops from "writing documentation" to "editing documentation," which veterans readily accept.
Step 4: Archive into the knowledge base and integrate into the review process. The generated architecture documentation becomes required reading for code reviews and new requirement assessments. Documentation is no longer a one-off deliverable, but part of the process.
Section 3: The Core Prompt Template
This is the module-level analysis prompt we actually use—you can copy and modify it directly:
你是一位资深架构师,请分析我提供的代码模块,输出中文文档,严格按以下结构:
# 模块名:<根据代码推断>
1. 模块职责:用3句话以内概括这个模块解决什么业务问题
2. 对外接口:列出主要公开函数/类,说明输入、输出、副作用
3. 依赖关系:它依赖哪些模块、被哪些模块依赖(从import和调用推断)
4. 核心业务规则:提炼代码中隐含的业务逻辑,标注对应的代码位置
5. 潜在风险点:指出可能有问题的地方,如硬编码、隐藏副作用、边界缺失
6. 给新人的导读:建议的阅读顺序和理解要点
要求:
- 不确定的内容明确标注「推测」,不要编造业务背景
- 涉及外部调用(数据库、接口、消息队列)请单独列出
代码如下:
<粘贴模块代码>The instruction "mark speculation as speculation, don't fabricate" was a hard-learned lesson—our early version didn't include it, and the AI would produce plausible-sounding explanations for business contexts that didn't exist.
Section 4: Before and After AI
Before the transformation:
- New hires needed about one to two weeks to get familiar with a module, mostly by grinding through the code on their own.
- Change reviews relied on veteran employees' memory; impact assessments had oversights, which once caused a production rollback.
- No one was responsible for documentation updates—written once, then left to rot.
After the transformation:
- New hires first read the AI-generated, human-verified module documentation, which noticeably shortens the onboarding cycle. Deep understanding still requires reading the code, but the starting point is much higher.
- Before every change, we check the dependency list first. Review meetings now discuss "which items on the list are affected," instead of "does anyone remember who else calls this?"
- Documentation maintenance is split into two lightweight steps—"AI generation + human verification"—and can be triggered on demand. For example, after a major refactoring, we simply re-run the module analysis.
To be honest: what AI fills in is not "all the knowledge." Those historical decisions that truly live only in people's heads (like "why it was designed this way back then") still require interviews with veteran employees to supplement. What AI does is automate "the parts that can be read from the code"—which accounts for the bulk of the overall knowledge gap.
Section 5: Three Risk Reminders for Managers
- Don't skip the human verification step. If AI-generated comments are wrong, they're more harmful than no comments at all—they will mislead future readers with a tone of certainty.
- Control cost and pace. Batch processing and billing through a unified gateway prevent one-time token consumption from spiraling out of control, and make it easier to report ROI to management.
- Embed the deliverables into the process. If the documentation doesn't enter the review process, it turns into a pile of outdated waste paper again in three months.
If you also want to try out this kind of AI capability at low cost, you can start with a unified access platform and run small, module-by-module: https://api.thistoken.ai/register
---
Every example in this post runs with a single API key — get yours at https://api.thistoken.ai/register and start in minutes.
Bạn muốn thử Token.AI?
Tạo API Key cấp dự án, bật kênh trong bảng điều khiển và định cấu hình định tuyến, ngân sách và nhật ký kiểm tra.
注册 ThisToken.AI 并获取 API Key