Case study - AI code migration using local models
This article was written without AI help. The code however was 100% generated by AI.
One of the very good reasons why you might want to use local model instead of cloud hosted models is privacy, and your personal or companies source code is definitely something that should be private and guarded. More about that later.
A lot of organizations have mountains of legacy code, dating back years, often even decades. Modernization of that code is often times not really a worthwhile effort, because it takes a lot of time and engineering resources that isn't really justified. As this code ages together with the employees that wrote it years ago, the pressure to modernize code and systems, however grows.
There is an interesting use case for these organizations using locally hosted AI models and automated code translation from one language to another without uploading it to the Internet.
wg-mesh source code conversion
For my own business, I have been using a utility called wg-mesh. You can find the Github repository here: https://github.com/k4yt3x/wg-meshconf/tree/master
I'm thankful for their contribution and helping me understand both Wireguard and AI better.
wg-mesh is a Python utility that manages a WireGuard peer peer mesh network. It's a fairly simple tool for a problem that grows exponentially in complexity in real life. Keep in mind that in a peer to peer mesh network the number of connections is N * (N -1) ÷ 2.
As you can see, managing this complexity manually isn't really something that system administrators want to sign up for. That's why this tool exists, it makes the creation and management of these keys easy, but it does not address the problem of distributing these keys.
That's something that I always wanted to add to wg-mesh. Unfortunately, the author of this tool has moved on to other things, and therefore the repository has stayed stale for a number of years. Being a system administrator myself, and having the need to create an overlay network for my own infrastructure I had ideas to extend the tool and integrate Ansible in order to automate the rollout of these keys. We'll leave the improvement and a management of the Ansible-based key rollout for another article and focus on the conversion to my preferred programming language for now, which is Golang.
wg-mesh is not a proprietary piece of software, it is freely available on the Internet and I'm using this just as an example of what you could do with your own private source code that you do not want to upload to the Internet.
Never, ever, ever !
As Greg Kroah-Hartman, Linux security guru said in his talk "Kernel Recipes 2026 - Security in the LLM age" : "Local models are good enough ... run local for free... Never ever, ever upload anything non-public because at that point in time [it] is considered public. ... Do not upload anything you don’t wanna see on the web - just like normal stuff on the web. People don’t realize that is the same thing."
I have a number of machines available locally that are powerful enough to run large language models, specifically LLM's that are optimized for coding and tool calling. Both Apple Mac Mini's and Intel-based servers.
A modest proposal
For this project, I want to show you how you can use a fairly modest desktop PC with an Intel B50 GPU with 16 GB of VRAM and 16 GB of RAM to convert this Python utility to Golang completely locally within an hour and a half. That is something I don't think a human could do in that amount of time. I certainly can not.
In order to do this, you need only a few tools:
- First, an AI harness. These are tools that orchestrate external tools and perform certain functions, for example, calling compilers, linters or other development tools. None of these AI harnesses currently are what I would call stable or easy to use. They are in a varying degree of software quality, ranging from catastrophic (early OpenClaw) to somewhat stable to "This looks pretty nice!". I have personally used Hermes, OpenCode and most recently pi.dev. My recommendation is to skip both Hermes and Opencode and start with pi.dev. It is very fast, designed to be minimal but offers extensibility when needed. For this project, I didn't need to extend it. Everything worked out of the box. You can add agents and customize it to be a software factory if you want.
- Second, you'll need a LLM that can write code and call tools. Selecting such an LLM is a task you will likely have to learn, just like I did (or you could hire me as a consultant...). The combination of available hardware and your requirements is most likely the biggest hurdle to success. I've found that the restrictions I gave myself were really just a stimulation to make this work. As the old adage goes, "Necessity is the mother of invention". I've spent a lot of time on this, you don't have to.
- Third, a project you want to convert. In my case, it's wg-mesh, converting from Python to Go.
Below below is a screenshot that shows the beginning of the process:
In order to keep things simple, I created a markup document that contained the instructions for the tool. It simply read :
"In directory wg-meshcon-master is a Python tool you convert to GoLang". Then I hit enter and answered a few questions.
The conversion process
After a few minutes, it came back with the following:
I have reviewed the Python source code. Here is a summary of the tool's functionality:
This is a tool for managing WireGuard peer configurations in a mesh or point-to-point network. It manages a "database" (a CSV file) of peers and their configurations and can generate the actual .conf files used by WireGuard.The model correctly identified the core functionality and proposed a conversion plan, which it performed iteratively.
During that conversion, the model realized that some libraries had version dependencies that needed to be resolved and it did it without a hitch:
Another example is during the compilation the model tripped over fully qualified, path names when trying to write the source code to disk. However, it also realized that it made a mistake and figured out a way to correct it itself. Take a look at this validation error:
Moments later it had fixed it:
Another highlight: The level of precision this local model offers. It noticed that there is a functional discrepancy between the libraries used:
The Python version uses the rich library to create a colored table. The Go version currently uses a simple fmt.Printf table. While it doesn't match the "look" exactly, it provides the same data. If you'd like, I can integrate the github.com/olekukonko/tablewriter library to better match the Python output.I told it to use tablewriter and it simply did - that is impressive, at least to me! Mind you this is a cosmetic issue, not a functional one.
Finally, it offered to write the Go tests. I'll skip the boring testing output here and close with this:
One hour, seventeen minutes start to finish
As you can see by the timestamps, the conversion process started at 5:21pm and finished with a fully tested 100% compatible version at 6:38pm:
Of course I immediately tested the code and found it to be working without an issue. You'll have to agree - that's pretty neat!
I'd love to hear about your experience and questions. I'm here to assist in your local projects as technical and strategic advisor that can lead both the hardware and software stack from the bottom-up. These are fun projects and I'd like to help you. Check out my website at https://thegoodguyai.com for more information and contact.