, , ,

Sep 5, 2025 | 4 Minute Read

How AI Helps Refactor A Monolithic Site Studio Setup

Table of Contents

Introduction

Organizations are under increasing pressure to deliver scalable digital experiences without compromising speed or stability. The complexity of platforms is rising, and with it, the cost of inefficiencies hidden deep in legacy configurations. Yet, hidden within these technical constraints lies an opportunity: how can AI be strategically leveraged not as a curiosity, but as a performance multiplier?

In a recent platform engagement, we were presented with a significant engineering constraint, an unscalable Site Studio setup with over 1,500 files crammed into a single, flat directory. The configuration included components, helpers, styles, and settings with no meaningful separation or logical organization. It wasn’t a failure of code. It was a failure of structure, and it was slowing everything down: onboarding, enhancements, quality assurance, and overall delivery confidence.

Rather than approaching this as a slow, manual re-architecture effort, we made a decision: to operationalize AI as an architectural enabler. Using Cline AI, a code-native LLM integrated into our development environment, we restructured the entire configuration in half the time, and with higher structural integrity than would have been possible manually.

The Legacy Configuration: Where Complexity Became Chaos

The configuration we inherited was massive and disorganized. There was no structure, no grouping, and no distinction between helper logic, components, or site-level settings. YAML files, stylesheets, category definitions, layout configurations, and even assets like images and PDFs were all dumped into a single, flat directory.

Among this clutter were 357 helper files, 111 components, and hundreds of related assets, amounting to over 1,500 files. There was no logical hierarchy or folder separation. Everything was tightly coupled, manually configured, and inherently fragile.

This structure made onboarding painful, change tracking unreliable, and refactoring high-risk. We were stuck in a brittle ecosystem with no clear path forward.

Using AI To Reimagine Configuration Architecture

Recognizing that a manual restructure would take weeks and still risk errors, we explored how AI could help us modularize and refactor this configuration at scale.

We used Cline AI, a Visual Studio Code plugin built on the Sonnet 4 LLM, which is optimized for code transformation. To make the most of it, we started with detailed prompt engineering in ChatGPT. We framed our problem precisely: we needed logical packages for components, helpers, categories, and site settings. We defined clear patterns, naming conventions, and expected outcomes.

Once the prompt logic was finalized, we executed it inside VS Code, where Cline AI processed the structure locally. The model parsed the dependencies, reorganized files, and separated the configuration into clean, reusable modules, dramatically faster than a human could.

Refactoring Blueprint: From Flat To Functional

The AI followed a clear strategy for modularization that echoed Atomic Design principles. It grouped files by type and function into well-labeled directories:

  • Helper logic and styles went into pack_hlp_*
  • Components with templates and styles into pack_cpt_*
  • Site-level settings into pack_site_*
  • Visual categories and layout definitions into pack_cat_*

More than just reshuffling files, the AI:

  • Applied consistent, readable naming conventions
  • Cleaned up redundant references and unused dependencies
  • Improved overall clarity and cohesion of the codebase

What we ended up with was not just modular, but scalable. Future changes could be isolated and verified easily. It enabled clean commits, better testing, and faster onboarding.

Reintegrating with Site Studio: Testing, Validating, And Iterating

With the packages restructured, the next step was importing them back into Site Studio. We created a centralized manifest file, site_studio.packages.yml, to specify all package paths. Then we used Drush to trigger the import:

ddev drush sitestudio:multi-import --path=config/site_studio_sync/site_studio.packages.yml

While the AI handled 80% of the heavy lifting, our team performed a full manual validation after import. We checked that all component relationships held up, that no helpers were broken, and that every style or asset was properly linked. A few misgrouped files and redundant inclusions had to be manually fixed, but these were minor compared to the overall time saved.

The Outcome: A Tangible Productivity Boost

Had we gone the manual route, this cleanup would have consumed weeks of developer time and introduced significant risk. Thanks to the AI-assisted workflow, we:

  • Cut the total effort required by 50%
  • Reduced risk of error through consistent, automated bundling
  • Improved modularity, version control hygiene, and team velocity
  • Enabled parallel workstreams by breaking apart the monolith
  • Created a future-ready configuration that is easier to maintain and scale

It wasn’t just about fixing the past; it was about unlocking the future.

Where AI Needed Help And Why Human Review Was Non-Negotiable

As powerful as Cline AI was, it wasn’t flawless. It made assumptions based on file names and code structure, which occasionally led to misplaced dependencies or unnecessary duplication.

We found helper functions dropped into the wrong packages. Some image assets were repeated across modules. These mistakes didn’t break the system, but they reminded us why AI still needs human judgment to guide, review, and refine its work.

The lesson? AI can massively accelerate delivery, but only when used with structured oversight and a clear architectural strategy.

Advice For Engineering Leaders Considering AI Refactors

If you're leading a platform or engineering team and considering AI-powered restructuring, here’s what we recommend:

  • Clarify the outcome you want before writing prompts. AI needs rules.
  • Use code-native LLMs like Sonnet 4 or Copilot for deep structural changes.
  • Isolate logical units (helpers, components, etc.) for version control clarity.
  • Manually validate output, especially when dependencies are complex.
  • Never skip post-import testing in environments like Site Studio.

And remember: this isn’t a hands-off process. Think of AI not as a magic fix, but as a fast, skilled assistant who still needs guidance.

This Is What Augmented Engineering Looks Like

This use case wasn’t about innovation for innovation’s sake. It was about solving a real, painful delivery bottleneck using modern tools that extend the capability of our engineering team.

AI helped us move faster. But the win went much beyond achieving speed; it brought structure, clarity, and maintainability. The experience proved that the best outcomes happen when human insight and machine intelligence work together.

As digital platforms become more complex and modularity becomes non-negotiable, engineering teams need to rethink how they build and maintain systems. This project gave us a blueprint for doing exactly that.

If your platform configuration is slowing down your delivery, it’s time to modularize, strategically, and intelligently. Let’s talk.

 

About the Author
Shakil Ahmad, Software Engineer

Shakil Ahmad, Software Engineer

Shakil likes to learn and stay updated about all the latest technologies. Away from work, he explores places rich with natural beauty. His life’s essential values? Health and commitment to goals.


Leave us a comment

Back to Top