Adil Khan

Back
CSS architecture Code refactoring Documentation

Comax

When working CSS isn’t necessarily good CSS.

Comax was developing a more customised component library for their Blazor applications. The project was already well underway, but the team needed additional expertise to review and improve the CSS behind it.

Much of the existing styling had been written with the help of AI. While it worked, there hadn’t been a clear strategy or architecture guiding how the CSS should be structured, either for the developers or the AI tools they were using.

Over time, this had resulted in a codebase that was difficult to read, understand and maintain.

I joined the project for a one-week sprint to help get things back on track.

Comax

Photo by Maik Jonietz on Unsplash

Finding the structure behind the code

My first step was reviewing the existing CSS to understand how it was organised and where the main problems were.

The challenge wasn’t necessarily that individual styles were incorrect. It was that there was no consistent approach to writing and organising them. Without shared conventions, the code had become increasingly difficult to work with.

I focused on defining a CSS strategy and architecture that would fit the project, along with the tooling and conventions needed to support it.

The goal was to create a foundation that developers could understand and maintain, while also providing clear guidelines for future AI-assisted development.

Refactoring with AI, not relying on it

With the new approach in place, I used AI to help refactor the existing CSS codebase.

Rather than letting AI decide how the code should be structured, I defined the architecture, conventions and requirements it needed to follow. This made it possible to work through the codebase much faster while keeping the changes aligned with a consistent strategy.

AI can write CSS. That doesn’t mean it knows how your CSS should be written.

Without a clear strategy, even working code can quickly become difficult to maintain.

Leaving more than cleaner code

Alongside the refactoring, I documented the CSS architecture, development conventions and fundamental CSS principles to help the team understand and continue working with the new structure.

By the end of the sprint, the existing CSS codebase had been refactored around a more consistent architecture, supported by documentation and clearer development guidelines.

The team now had a defined approach to CSS that could be followed by both developers and AI tools, rather than relying on individual decisions made along the way.

For me, this project was a good example of where experience makes a difference when working with AI. The tools can help with the heavy lifting, but understanding the technology is what allows you to guide them towards a result that’s actually useful.

The goal wasn’t to write less CSS. It was to make the CSS easier to work with.

A good foundation should help the next developer understand what they’re looking at, whether the code was written by a person or an AI agent.


Work