AI Coding at Scale: Rewriting 100K Lines in Six Months With 300K Lines of Output

    A first-hand account of an aggressive legacy rewrite carried out solo in six months using AI coding tools. It covers why technical debt compounds in inherited codebases, how context engineering shapes output quality, how to split work into machine-verifiable units, why automated validation becomes the real bottleneck once generation is cheap, and how to manage cost and a sustainable pace. The core takeaway: as generation costs approach zero, engineering discipline matters more, not less.

    1. The Real Cost Behind an Aggressive Commitment

    Seven years of production development experience, one developer, six months, and a rewrite of roughly 100,000 lines of legacy code — that combination would almost certainly be challenged in any schedule review. But once intelligent coding tools can absorb large volumes of boilerplate and repetitive refactoring, an aggressive timeline becomes something you can actually discuss on engineering terms.

    The other side of the story is equally real. Six months later, the codebase had grown from about 100,000 lines to somewhere between 300,000 and 400,000 lines, monthly tool subscriptions came to roughly 1,400 RMB, and the author’s own conclusion was that it “may have cost me five years of my life.”

    This is not a story about deifying tools. It is a case study in what happens to the bottleneck after output capacity is amplified — and understanding that matters more than memorizing any tool trick.

    2. Where the Legacy System Actually Started: Debt Compounds

    The web application in question had a tangled pedigree: originally written by an intern, then derived seven years ago from another intern project. The typical symptoms:

    • Layering was a mess, with business logic scattered across routes and templates;
    • Type definitions were missing or effectively useless, so nothing could be statically verified during refactoring;
    • Implicit state and global variables were intertwined, so one change triggered regressions in several places;
    • There were no tests, so every modification could only be confirmed by clicking through the app manually.

    Intelligent coding tools are extremely valuable in this kind of situation — but only if you first give them verifiable boundaries. Otherwise they will simply produce more unmaintainable code at very high speed.

    3. Using the Tools Correctly: Context Engineering Determines Output Quality

    The author spent about $200 a month on a high-tier plan. What actually made the difference was not the quota but how context was organized. Four reusable principles:

    1. Maintain a project-level rules file: put the tech stack, directory conventions, naming rules, and prohibited practices into a context configuration at the repository root so every session loads it automatically.
    2. Layer the context: progress from global rules to module descriptions to single-file comments, avoiding a single dump of large amounts of irrelevant information.
    3. Read before writing: require the tool to first output its understanding of the existing implementation and an impact analysis, and only then start changing code.
    4. Commit in small steps: solve one verifiable goal at a time so the diff stays readable.

    An example rules file structure:

    1. # Project Context
    2. - Language and version: TypeScript strict mode
    3. - Layers: api / service / domain / infra
    4. - Prohibited: accessing the data access layer directly across layers
    5. - Every change must include unit tests
    6. - Commit message format: type(scope): summary

    4. Task Decomposition: AI Handles Breadth, Humans Handle Depth

    The 300,000 lines were not generated in one pass; they were broken into thousands of verifiable units. Effective ways to split the work included module boundaries, data migration stages, and the smallest closed loop that tests can cover. The principle is that the acceptance criteria for every task must be machine-decidable — it compiles, it passes tests, it matches the interface contract.

    By contrast, vague instructions like “help me optimize this module” tend to produce large blocks of code that look reasonable but cannot be merged.

    5. The Automated Validation Loop Is the Real Source of Efficiency

    AI generates far faster than a human can review, so the bottleneck necessarily shifts from writing to verifying. You have to build the loop:

    1. # Type check -> static analysis -> unit tests -> build
    2. tsc --noEmit && eslint ./src --max-warnings=0 && npm test && npm run build

    Wire those commands into a pre-commit hook and the CI pipeline so tool-generated code clears the machine gate first, and humans review only what machines cannot judge: business semantics, boundary conditions, and security implications. Get this step right and a doubling of efficiency holds up. Get it wrong and the only thing that increases is overtime.

    6. Cost, Health, and a Sustainable Pace

    A monthly spend of about 1,400 RMB is only worthwhile if it reduces rework and shortens delivery cycles. The physical cost deserves equal attention: long stretches of high-intensity flow can mask fatigue signals. Practical constraints include a fixed end-of-day time, handing mechanical tasks entirely to automation, and replacing manual watchkeeping with monitoring, alerting, and log services.

    If elastic compute or managed environments are needed, general-purpose cloud capabilities can carry the load: a container platform to run build jobs, object storage to hold artifacts, a message queue to decouple long-running tasks, and logging and monitoring services to observe pipeline health. Baidu AI Cloud offers the same category of general-purpose infrastructure capabilities for this kind of scenario.

    7. Conclusion

    The real lesson here is not that “AI can write 300,000 lines of code.” It is that when the cost of generation approaches zero, the value of engineering discipline is amplified. Context engineering, task decomposition, automated validation, and pace management — miss any one of the four, and the stronger your tools are, the faster debt accumulates.