January 18, 2026
5 min read
By Cruz Morales

Docs as Code: The Unsung Hero of Our Refactor

DocumentationMarkdownZenflowRefactoringAgile

The Most Important Files in Our Refactor Weren't Code

When we talk about a major refactoring effort, we usually think about code. We picture ourselves deep in the weeds of Dart files, untangling complex logic and restructuring classes. But in our recent bug-fixing sprint on the Plugged Flutter app, the most important files weren't .dart files; they were .md files. The spec.md, plan.md, and report.md documents, all managed within our Zenflow task, were the unsung heroes of the project. They were the scaffolding that allowed us to execute a complex refactor with confidence and clarity.

The Build: A Trinity of Documentation

Our documentation-as-code approach was built on a simple but powerful trinity of Markdown files, each serving a distinct purpose in the project lifecycle.

  1. The Specification (spec.md): This was our blueprint. Before we wrote a single line of code, we used an AI assistant to analyze the codebase and generate a detailed technical specification. This document identified all the failing tests, diagnosed the root causes, and proposed a clear implementation strategy. It was a moment of pure planning, a chance to step back and think strategically before diving into the tactical work. This document ensured that we were all aligned on the 'what' and the 'why' before we started worrying about the 'how'.

  2. The Plan (plan.md): This was our roadmap. We translated the high-level strategy from the spec.md into a concrete, step-by-step plan. Each step was a checkbox, a small, verifiable unit of work. 'Fix the 5 failing tests in auth_bloc_test.dart.' 'Fix the use_build_context_synchronously warning.' This plan transformed a daunting project into a series of manageable tasks. It provided a real-time view of our progress and kept the entire team on the same page. It was the antidote to the chaos that can so often derail a complex refactor.

  3. The Report (report.md): This was our story. After all the work was done, we used the AI assistant to generate a comprehensive completion report. This document summarized what was implemented, detailed how the solution was tested, and explained the issues that were encountered and resolved along the way. It was a complete, transparent record of the project, a story of how we went from a sea of red tests to a stable, production-ready application. This report is now a permanent part of the project's history, a valuable resource for any developer who works on the codebase in the future.

Key Insights

  • Think, Then Do: The spec.md forced us to think critically about the problem before we started writing code. This upfront investment in planning paid off tenfold by preventing us from going down the wrong path.
  • Clarity is Kindness: The plan.md provided a level of clarity that is essential for effective teamwork. Everyone knew what needed to be done, who was doing it, and what the definition of 'done' was. This is the foundation of a healthy, high-functioning team.
  • Document Your Wins: The report.md is more than just a summary; it's a celebration of the work. It's a chance to reflect on the challenges you overcame and the value you delivered. This is a powerful way to build team morale and create a culture of excellence.

Results: A Refactor Guided by a Narrative

By embracing a docs-as-code approach, we were able to execute a complex refactoring project with a level of clarity, confidence, and transparency that would have been impossible otherwise. The documentation wasn't an afterthought; it was an integral part of the development process itself. It was the narrative that guided our work, the script that we followed from the opening scene to the final credits. The result was a project that was not only technically successful but also a model of effective project management.

Takeaway

Treat your documentation like you treat your code. Give it the same level of care, attention, and respect. Use tools like Zenflow and AI to integrate documentation directly into your development workflow. For your next project, try creating a spec.md, a plan.md, and a report.md. You'll be amazed at how much clarity and focus it brings to your work. It's a simple change that can have a profound impact on your ability to deliver high-quality software. At TresPies, this is what we mean by 'craft': it's not just about the code, it's about the entire process of building beautiful, reliable software.

Cruz Morales

Cruz Morales

Freelance developer specializing in AI integration and multi-stack development. Based in Madison, WI.

More Insights