Workshop

Behind the Build

Published on: 2025-04-09

By: Ian McCutcheon & AI Assistant for polish

Behind the Build: AI Pair Programming the Python SSG

In a previous post, I detailed the features and workflow of the simple Python Static Site Generator (SSG) that powers this digital workshop. I mentioned its rapid development – roughly 5-6 hours of hands-on coding time spanning less than two days. But how exactly did that happen? How does one go from zero to a functional SSG, including templating, frontmatter parsing, asset handling, and deployment integration, so quickly?

The secret sauce wasn't some hidden coding superpower; it was intensive pair programming with an AI assistant. This post delves into that process, starting with the very seed that kicked it all off.

The Starting Point: Defining the Destination

Before writing a single line of Python, the crucial first step was defining what needed to be built. Instead of just jumping into code, I drafted a clear "seed document." This wasn't just a vague idea; it was a structured plan outlining:

  1. Overall Goals: What the SSG should achieve at a high level.
  2. Core Philosophy: Simplicity, control, using familiar tools.
  3. Step-by-Step Milestones: Breaking the project into manageable, tangible steps, each building upon the last. This is vital for iterative development and provides clear checkpoints.
  4. Core Tools: Identifying the likely technologies involved.
  5. Potential Future Features: Listing desired add-ons to keep them in mind, even if not implemented immediately (like Jinja2, which we decided to use from the start).

The goal of this document was twofold: first, to clarify my own thinking, and second, to provide a sufficiently detailed brief for an AI coding assistant. Giving the AI a clear roadmap is far more effective than vague instructions.

The Seed Document / Initial Prompt

Here is the exact document I prepared in VS Code and then fed into the AI assistant (specifically, Google's AI model via the Cursor editor) to initiate the project:

```markdown Summary of the SSG Goals:

The objective is to build a lightweight, personal SSG using Python and Git. This system will allow you to:

  1. Write content locally using Markdown in VS Code.
  2. Organize content logically within a folder structure.
  3. Automate the conversion of Markdown files into complete HTML pages using a defined template.
  4. Generate a static website structure (HTML, CSS, potentially JS, images) in a designated output folder.
  5. Preview the generated site locally using a simple Python web server.
  6. Leverage Git for version control of content and code, with the future possibility of triggering deployment.

The core philosophy is simplicity, developer control, and using familiar tools.

Step-by-Step Implementation Plan with Motivational Milestones:

This plan breaks down the development into manageable stages, each providing a visible, working result.

Milestone 1: The Simplest Possible Conversion

Milestone 2: Basic Templating

Milestone 3: Processing Multiple Files & Basic Structure

Milestone 4: Local Preview Server & Basic Styling

Core Tools Recap:


Appendix: Potential Add-on Features (Post-Core Implementation)

We like the below and so please consider them all as to be part of the project even though they are not as fleshed out. Jinja2 is a good example of a templating engine that we should consider out of the gate.

(Note: The full details of the appendix items were included in the actual prompt but abbreviated here for brevity in the blog post.)

The Workflow: Pair Programming with AI

With this plan loaded into Cursor, my AI-aware editor, I essentially pointed the AI (Google's model) at the document and said, "Let's get started on Milestone 1."

What followed was remarkable velocity:

  1. Rapid Generation: The AI immediately started scaffolding the project structure and generating the initial generate.py script based on Milestone 1's steps.
  2. Review and Refine: My role shifted primarily to reviewing the generated code, testing it (python generate.py), verifying the output, and providing corrective feedback or asking for the next step ("Okay, looks good. Now let's implement Milestone 2 using Jinja2 instead of basic string replacement.").
  3. Iterative Progression: We moved through the milestones rapidly. The AI handled the boilerplate and implemented the core logic for file walking (os.walk), Markdown conversion, Jinja2 integration, frontmatter parsing (PyYAML), and asset copying (shutil).
  4. Problem Solving: When unexpected issues arose (like ensuring relative image paths worked correctly), I described the problem, and the AI often proposed solutions (like using BeautifulSoup4 to parse and rewrite <img> tags post-conversion), which we then refined together.
  5. Minimal Typing: I wrote very little code from scratch. Most of my interaction involved reading, testing, prompting, and occasionally tweaking the AI's output. As I mentioned, there were points where I felt I could barely keep up with the pace of generation and the need to review and integrate.

This iterative loop – Prompt -> Generate -> Test -> Refine -> Prompt Next – continued through the core features outlined in the first blog post. Features like the config file (config.yaml), specific handling for home.md, drafts/hidden posts, and even the structure of the deployment script were built using this same collaborative process, guided by the initial plan and subsequent conversational prompts.

Reflections on the Process

This experience solidified several thoughts about AI-assisted development:

Conclusion

So, that's the story behind the build. The Python SSG wasn't conjured out of thin air but meticulously planned and then rapidly executed through a tight feedback loop with an AI coding assistant. It started with the "seed document" above and grew through guided, iterative development. For solo projects or rapid prototyping, this approach proved incredibly effective, turning a multi-day project into something achievable in just a few focused hours.

Wait there's more.

Here's the really interesting part. I used an AI to generate the seed document!