TruCMS Coding Conventions and Rules

The project's own guidelines, collected in one place. Follow them and your plugin will look like the bundled modules — which is the point.

Architecture rules

PHP style

The code is formatted with Laravel Pint (preset: laravel, one space around string concatenation). Run vendor/bin/pint --dirty (or vendor/bin/pint Modules/YourPlugin) before finishing any PHP change.

Naming conventions

ThingConventionExample
Module name / aliasStudlyCase name; lowercase kebab alias (2–64 chars)TruCommerce / trucommerce
Provider{Name}ServiceProviderBookingServiceProvider
Admin route namesadmin.{module}.{resource}.{action}admin.booking.services.store
Front route names{module}.{page}booking.services.index
PermissionsLowercase English phrases: manage x, create x, edit x, delete x, view xmanage booking services
Permission groupskebab-case, prefixed with the modulebooking-refunds
Setting keyssnake_case, prefixed with the module aliastrucommerce_page_shop
View namespacesModule aliasbooking::admin.dashboard
Translation keysnamespace::file.key for modules; file.key for corebooking::booking.services
Shortcode idskebab-case, module-prefixedbooking-services
Shortcode tags (Blade components)x-shortcode-{id}<x-shortcode-booking-services>
Widget registry keyskebab-case, module-prefixedtrucommerce-cart-mini
Dashboard item idsdotted {module}.{item}booking.counters
Facade container keyslowercase one-word stringsmenumanager, app-pages
Scheduled commands{module}:{verb}-{noun}booking:cleanup-payment-intents

Views and front-end

Database

Testing rules

Area-specific rules

A few areas carry decisions the code cannot express. In the source repository each has a rule file in .ai/rules/; the essence is below. Follow it whenever you change or override files in these areas:

Applies toRule fileEssence
app/Services/PageBuilder/Bindings/**bindings.mdCostly record fields are LazyValue so resolve() keeps a constant query count; extra baker markers (lists, counts, show-if, vars, attrs)
resources/themes/echo/page-templates/**page-templates.mdTheme colours only; layout CSS in sibling .css files (database), never in Echo Sass; motion layouts use the lm- prefix; dividers follow the site; data-bound markers
resources/themes/echo/assets/sass/components/_page-sections.scsscomponents.mdThe ui-* kit is compiled by npm run templates:kit, stored in template_assets, and output only for the classes a page uses
Echo header components, menus, _header.scss, _theme-options.scss, ThemeCssCompilerheader.mdMenus take colours from --bs-header-* tokens; header presets, aliases, and the CSS "fit" mechanism; top-bar HTML is sanitised
resources/themes/echo/assets/sass/**sass.mdStored page content makes Echo class names public API; check history before deleting a class
database/seeders/Niches/**niches.mdNiches supply data; palettes are derived from brand colours (NichePalette); presentation lives in NicheStyles
app/Services/WebsiteTemplates/**website-templates.mdTemplate packages are data only, never code; strict allow-lists and asset handling
scripts/capture-*scripts.mdScreenshot scripts use a scratch _previews database and must never run in parallel