Teaching Agents to Build Your SaaS: Inside Cornerstone
How a modular Rails 8 foundation uses explicit LLM instructions and swappable provider adapters to end the era of "clone and forget" boilerplates.
- Cornerstone leverages a dedicated file to instruct autonomous agents on its architecture, preventing AI hallucinations during feature generation.
- A provider abstraction layer routes services through a central configuration file, eliminating vendor lock-in for billing and emails.
- The template brings the ShadCN UI philosophy to the Rails ecosystem using ViewComponent and a helper-first approach.
- Strict multi-tenancy is enforced by default using a scoping concern to safely isolate database queries across organizations.
The Codebase as an API for Agents
The era of the "clone and forget" boilerplate is dead. Cornerstone is interesting not just because it is a modern Rails template, but because it is designed specifically for the AI era. By treating the codebase as a living, modular framework and explicitly documenting its architecture for LLMs via a dedicated markdown file, Cornerstone shifts the paradigm. It is a foundation built to be manipulated by autonomous coding agents as much as by human engineers.
A Rails 8 SaaS template foundation with modern UI, authentication, and multi-tenancy. Built for rapid development with a clean, modular architecture.
The Provider Abstraction Engine
The core logic for billing, email, and AI adapters lives in a dedicated library directory intended to be highly swappable. Instead of hardcoding a specific payment processor, the system is designed around a generic gateway interface. This allows the template to support different vendors by simply swapping the adapter in a central configuration file.
Multi-Tenancy by Default
The core data model revolves around the Account, User, and Membership triad. This allows a single user to belong to multiple organizations with different roles. The project uses a dedicated concern to handle automatic database scoping and a current attributes singleton to track the active account and user throughout the request lifecycle, ensuring data does not leak across tenants.
Bringing ShadCN to Ruby
The project implements a robust design system using ViewComponent, bringing the highly successful ShadCN "copy-paste" component philosophy into the Rails ecosystem. A base component provides a helper to safely merge custom utility classes with default component styles. It uses a "Helper-First" approach, making the components accessible to developers who might find standard component rendering syntax verbose.
The Weight of Opinionated Boilerplates
Compared to established commercial templates, Cornerstone fills a niche for developers seeking a lightweight, unopinionated foundation. While heavy templates offer more out-of-the-box features, Cornerstone's modular approach is better suited for developers who want a starting point rather than a straightjacket.
| Feature | Cornerstone | Bullet Train | Jumpstart Pro |
|---|---|---|---|
| Architecture Style | Modular Foundation | Super-Scaffolding | Commercial Engine |
| AI Readiness | First-class agent docs | Ad-hoc | Ad-hoc |
| UI Paradigm | ViewComponent/ShadCN | Custom Helpers | Custom Helpers |
| Upstream Drift | Managed via upgrade script | High | Managed via gem updates |