javascript-patterns/SKILL.md
JavaScript design patterns for SaaS apps: Module, Observer, Factory, Strategy, Command, Mediator, Repository, and State patterns with practical web app examples. Use when structuring JavaScript code, implementing event-driven UI, decoupling...
npx skillsauth add peterbamuhigire/skills-web-dev javascript-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
javascript-patterns or would be better handled by a more specific companion skill.SKILL.md first, then load only the referenced deep-dive files that are necessary for the task.Production-grade patterns for structuring JavaScript in PHP-backed SaaS applications.
Core principle: Every feature is a module. Components communicate through events, not
direct references. Data access lives in repositories, not scattered fetch calls.
✅ Vanilla JS ✅ PHP SaaS ✅ ES2020+ ✅ No framework | ❌ React/Vue ❌ Node.js server-side
Each feature = one module. Private state lives in the closure; only the public API is exposed.
// assets/js/modules/invoice-form.js
const InvoiceForm = (() => {
// Private
let lineItems = [];
function calculateTotals() {
const subtotal = lineItems.reduce((sum, i) => sum + i.qty * i.price, 0);
const tax = subtotal * 0.16;
return { subtotal, tax, total: subtotal + tax };
}
function updateUI(totals) {
document.getElementById('subtotal').textContent = formatCurrency(totals.subtotal);
document.getElementById('tax').textContent = formatCurrency(totals.tax);
document.getElementById('total').textContent = formatCurrency(totals.total);
}
// Public API
return {
addItem(item) { lineItems.push(item); updateUI(calculateTotals()); },
removeItem(idx) { lineItems.splice(idx, 1); updateUI(calculateTotals()); },
getItems() { return [...lineItems]; } // copy, not reference
};
})();
Rule: Never leak private functions. Return only what callers need. Replace the IIFE with export when bundling.
Extended guidance for javascript-patterns was moved to references/skill-deep-dive.md to keep this entrypoint compact and fast to load.
Use that deep dive for:
Pattern 2 — Observer / EventBus (PubSub)Pattern 3 — FactoryPattern 4 — StrategyPattern 5 — Command (+ Undo/Redo)Pattern 6 — Repository (Frontend Data Layer)Pattern 7 — MediatorPattern 8 — State MachinePattern 9 — Singleton (Careful Use)Pattern 10 — DecoratorPattern 11 — Async Performance PatternsPattern Selection GuideAnti-Patterns to Avoiddata-ai
Use when adding AI-powered analytics to a SaaS platform — semantic search over business data, natural language queries, trend detection, anomaly alerts, and AI-generated insights for dashboards. Covers embeddings, NL2SQL, and per-tenant analytics...
data-ai
Design AI-powered analytics dashboards — what metrics to show, how to display AI predictions and confidence, drill-down patterns, KPI cards, trend visualisation, AI Insights panels, export design, and role-based dashboard variants. Invoke when...
development
Use when designing, building, reviewing, or upgrading production software systems that must be secure, performant, maintainable, scalable, and user-centered. Apply before writing specs, code, architecture, APIs, databases, mobile apps, SaaS platforms, or ERP systems.
development
Professional web app UI using commercial templates (Tabler/Bootstrap 5) with strong frontend design direction when needed. Use for CRUD interfaces, dashboards, admin panels with SweetAlert2, DataTables, Flatpickr. Clone seeder-page.php, use...