He was an expert but not in a discipline

He was an expert but not in a discipline that anyone could fully appreciate. He knew how to hold the cone just right so that the soft server ice-cream fell into it at the precise angle to form a perfect cone each and every time. It had taken years to perfect and he could now do it without even putting any thought behind it.

Why did the developer bring a flashlight to the legacy codebase? Because every time they tried to refactor it, they found more bugs hiding in the dark corners.

The thing is, working with legacy code can also be bad—worse than that joke even! Whether you’ve inherited a decades-old codebase or are revisiting your own past work, working with a legacy codebase can be a time-consuming and overwhelming process—especially if there’s no documentation.

Having well-documented code, legacy or otherwise, is critical for maintaining software quality and informing future development work. This is where GitHub Copilot can help. While conversations around Copilot often focus on writing new code, it’s equally valuable for making sense of existing code. By using its natural language processing capabilities, you can work with Copilot to document complex logic, explain obscure functions, and even suggest improvements to enhance readability.

In this blog post, we’ll explore practical tips and examples for using GitHub Copilot to document and explain legacy code effectively—and all these features are available in our Copilot Free tier plan, which is included with every personal GitHub account.

Whether you’re dealing with a monolithic application, cryptic comments, or no documentation at all, these techniques will help you bring clarity to your codebase and set it up for long-term success. Oh, and if you’re curious, I powered GitHub Copilot with Anthropic’s Claude 3.5 Sonnet model to run the examples below—but you can also use models from OpenAI, too.