Practical Observations on Using AI Coding Agents to Reverse-Engineer and Rewrite Legacy Software

    This article shares hands-on lessons from using an intelligent coding agent to rewrite a long-running legacy application whose source code was lost. It covers why legacy software rewrites are a good testing ground for AI agents, how to structure a phased delivery pipeline, how to reverse-engineer undocumented proprietary file formats, and how to handle licensing, compliance, and human-in-the-loop quality control. It concludes that an agent's real value depends less on raw code generation and more on disciplined engineering governance.

    1. Background: Why Legacy Software Rewrites Are a Good Testing Ground

    When a long-lived software product has lost its source code but the binary is still running, a rewrite faces three core challenges. First, the original architecture and module boundaries can only be inferred from behavior. Second, proprietary file formats, network protocols, and resource containers have no public documentation. Third, the old code relies on historical conventions and “magic constants,” so even a successful disassembly rarely translates into a maintainable new codebase.

    These conditions are exactly what stress-tests an intelligent coding agent’s real capabilities. The agent does more than generate scaffolding code: it can read binary analysis output, infer format patterns, draft parsers, add test cases, and iterate based on continuous feedback. That said, this is far from a “one-click rewrite.” The more realistic positioning is to treat the agent as a high-intensity exploratory engineering assistant, while humans own goal definition, compliance judgment, architectural trade-offs, and acceptance criteria.

    The experiment followed a phased plan: a pre-Alpha phase for the UI and foundational framework, an Alpha phase for the combat system, and a Beta phase for online play and matchmaking lobbies. At peak, iteration ran at roughly 400 commits per day. High-frequency commits surface problems quickly, but they also create review bottlenecks, so automated quality gates and behavioral regression tests are mandatory—you cannot rely on humans reading every line.

    2. Phase Breakdown and the Automation Pipeline

    The key to a legacy rewrite is not “let the agent keep writing” but decomposing the big goal into small, verifiable loops. A reusable pipeline can be abstracted as:

    1. Scan the repository and build artifacts
    2. -> Automated build
    3. -> Run unit tests and behavioral regression
    4. -> Compare output differences between old and new programs
    5. -> Generate patch suggestions
    6. -> Static analysis and license scanning
    7. -> Manual spot checks on high-risk modules
    8. -> Merge commits

    Within this pipeline, agents are well suited to repetitive tasks with clear feedback: generating resource parser skeletons, filling in boundary-condition tests, migrating data structures, and writing debugging tools. For high-risk modules such as core combat logic, network synchronization, and save-file compatibility, humans should define the interface contracts and acceptance samples first, then let the agent implement within a controlled scope.

    High-frequency commits also demand a rollback-capable process: keep each commit small, keep commit messages traceable, and snapshot key paths for comparison. Otherwise, when behavior drifts, it becomes very hard to pinpoint which generation introduced the bug.

    3. Reverse-Engineering Proprietary Formats: Samples, Differencing, and Specification

    One of the most time-consuming parts of the experiment was dealing with numerous ancient proprietary formats. They often have no usable parsing library, unclear field semantics, and constants of unknown origin. The agent had to experiment repeatedly against sample files to infer byte layouts, compression schemes, index structures, and resource reference relationships. This kind of work consumes a lot of inference budget and easily produces constants that “seem to work” but cannot be explained.

    A more reliable approach is to formalize the reverse-engineering results first, rather than piling on code immediately:

    1. Build a sample set covering different versions, resource types, and malformed files.
    2. Write differencing tools that correlate field changes with program behavior changes.
    3. Record the provenance of every constant: each magic constant needs evidence from samples or an experimental explanation.
    4. Generate format documentation: fields, offsets, types, constraints, and error-tolerance strategies.
    5. Use golden samples for regression: parse results must be reproducible and comparable.

    Without public references, an agent may spend a long time guessing. In this experiment, the agent repeatedly experimented to infer one proprietary video container format. A far more efficient approach is to supply explicit experiment scripts, sample comparisons, and acceptance criteria, so the agent converges in an observable environment instead of generating blindly.

    4. Licensing and Dependency Governance: Speed Does Not Replace Compliance

    Intelligent coding agents are generally sensitive to licensing. In this experiment, the project used a permissive license, while a candidate open-source implementation was weak copyleft and involved static linking—so it could not be adopted directly, and a decoder was built in-house instead. This illustrates that agents can help identify license risks, but they cannot replace an organization’s compliance process.

    Recommended governance rules to set up early in the project:

    • Maintain a whitelist of acceptable licenses.
    • For each candidate dependency, determine the implications of static linking, dynamic linking, and distribution methods.
    • Generate a software bill of materials (SBOM) and scan it continuously.
    • Run similarity detection on agent-generated code.
    • State explicitly in prompts: “Do not copy restricted implementations; reference interface ideas only and implement independently.”
    • Keep design records and alternative approaches for critical algorithms.

    Additionally, do not try to circumvent the agent’s safety policies through fabricated identities or misrepresented authorization. In production, provide genuine authorization statements, compliance boundaries, and auditable task descriptions so the agent operates within legitimate bounds.

    5. Human–Agent Collaboration and Quality Control

    When commits arrive at high frequency, humans cannot review every line and must rely more on outcome-based acceptance. But “it runs” is not the same as “it is maintainable.” Quality control therefore needs to shift left:

    First, define interface contracts and behavioral tests so the agent writes implementations around tests. Second, establish golden samples and fuzz testing to cover abnormal inputs. Third, set baselines for performance, memory, and determinism. Fourth, mandate human review for high-risk modules. Fifth, require the agent to state its assumptions, open questions, and verification methods in each commit message.

    Agents can also exhibit “prompt-sensitive” behavior: they may refuse when explicitly asked to copy an implementation, yet lean toward mimicking one when hints of a public implementation appear in the prompt. You should not rely on model self-discipline alone—enforce engineering constraints through prompt standards, code similarity detection, and license scanning.

    6. Scope, Limits, and Conclusions

    Based on this case, the value of intelligent coding agents in legacy software rewrites lies mainly in accelerating format exploration, generating parser drafts, filling in tests, migrating glue code, and sustaining high-frequency iteration. They are not suitable for independent decision-making on core logic that is safety-critical, lacks authorization, or lacks acceptance criteria. Intellectual property, the legality of reverse engineering, trademarks, and resource copyrights must all be assessed before the project starts.

    The reusable methodology comes down to five steps: first, conduct feasibility and compliance assessment; second, build sample and test sets; third, formalize proprietary formats and interfaces into specifications; fourth, drive phased delivery with an automated pipeline; finally, release and maintain in a rollback-capable, auditable manner.

    The conclusion: an intelligent coding agent can genuinely be a powerful assistant in legacy system rewrites, but success or failure ultimately depends on engineering governance. Only when the agent is embedded in a system with tests, license boundaries, rollback mechanisms, and a clear human–machine division of labor can it turn “looks impressive” into “actually deliverable.”