/htmx-php-builder:php-patternsfrom htmx-php-builder
Enforces a feature-oriented Page Controller pattern for PHP applications: procedural PDO queries, full-page + partial templates, and five standard HTMX response patterns. Read before writing or editing any PHP file in this plugin's apps.
Ships in htmx-php-builder. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Every application uses the feature-oriented Page Controller pattern defined in references/pattern-guide.md — read it before writing PHP. This SKILL.md is the enforcement summary plus the plugin-integration rules.
| Responsibility | Implementation |
|---|---|
| Controller | Small procedural PHP endpoint under /var/www/html/{feature}/ (the Apache DocumentRoot on Ubuntu 24.04) |
| Data access | Procedural functions taking PDO as first param, in app/features/{feature}/queries.php |
| Full-page view | app/views/{feature}/page.php (wrapped by app/views/layout.php) |
| Fragment view | app/views/{feature}/partials/*.php |
| Infrastructure | app/bootstrap.php, app/db.php, app/http.php |
Vertical slices: one feature = one /var/www/html/{feature}/ endpoint set + one /var/www/app/features/{feature}/queries.php + one /var/www/app/views/{feature}/ view set. The web root is html/ under the application root — /srv/apps/<key>/html for an application of the Business OS (the kernel's installer puts the repository at /srv/apps/<key> and renders the vhost), /var/www/html for a standalone product on a bare Ubuntu 24.04 host — build the application there, not in a public/ directory; app/ and config/ sit beside html/, outside the DocumentRoot, and must never be placed inside it. Configuration is config/.env (env()), the file the kernel's installer writes; config/application.php holds defaults and maps env keys onto them. No classes for controllers, repositories, services, DTOs, or entities — extract shared procedural helpers only when duplication becomes substantial.
bootstrap → authenticate/authorize → read input → validate
→ query functions → log activity → render page or partial
require_post(); verify_csrf();.$_GET/$_POST, HTMX, HTTP codes, or templates.| Pattern | Use for |
|---|---|
| A — dedicated fragment endpoint | Dropdown options, search results, table bodies, dashboard widgets — and the record picker's rows (html/pick/index.php over app/pickers.php; design-system record-picker.md) |
B — dual full-page/partial endpoint (is_htmx_request() + Vary: HX-Request) | Index/list screens, pagination, filters, sortable tables — the default for navigable screens |
C — replace nearest component (hx-target="closest tr") | Row delete, status toggle, inline edit, expanding details |
D — server-triggered refresh (HX-Trigger event + listening region) | Cross-component updates after saves — the default over manual targeting |
E — out-of-band swaps (hx-swap-oob) | Sparingly: counts, toasts, nav badges alongside a primary update |
Responses return the smallest meaningful component (a whole badge, row, or form container — never a bare text fragment). Keep conventional href/method/action attributes alongside hx-* for progressive enhancement.
db(): PDO (static singleton, env-config DSN, ERRMODE_EXCEPTION, FETCH_ASSOC, real prepares) · view(string $template, array $data): string (path-confined to app/views, template names never from request input) · e(mixed): string (escape every dynamic value) · is_htmx_request(): bool · require_post(): void · request_integer(string): ?int · csrf_token() / verify_csrf().
Writes use SQL RETURNING; multi-operation actions use explicit beginTransaction/commit/rollBack; a lone INSERT/UPDATE/DELETE does not.
Escape everything dynamic with e(); prepared statements for values; allowlists for SQL identifiers (ORDER BY columns etc. — placeholders can't parameterize identifiers); POST + CSRF for all state changes; authorization checked in every endpoint (HX-Request is never an authorization signal); no database exception details to users; validate/constrain ids, sort fields, limits, search strings.
#page-content (Pattern B endpoints with hx-push-url set to an explicit canonical URL — never hx-push-url="true", which pushes the partial's fetch path and breaks relative URLs). The guide's in-page editor aside and form-replaces-itself flow (Patterns A + D) is the standard for secondary inline editing where a full navigation would be heavy — validation errors still re-render the form partial in place in both flows.hx-confirm guards destructive actions (delete, irreversible state changes), exactly as the pattern guide shows. The no-modal rule applies to forms and display pages, not confirmations.verify_csrf() accepts the hidden field or the X-CSRF-Token header stamped by the shell's htmx:configRequest listener (see php-session-auth). Both are the same session token.customer-row-{id}, per design-decisions.md) — that's the change-request vocabulary and the hook for cross-component targets (Patterns D/E). For element-local operations, still prefer closest targeting so components stay uncoupled from their own ids.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub maludb/maludb-os-htmx-php-guidelines --plugin htmx-php-builder10 skills in this plugin
/chat-actionsThe voice-first chat command bar that ships on every screen of every application — natural language in (typically dictated via a tool like Wispr Flow), application actions and navigation out, powered by an LLM router activating MCP tools. Use when building or extending the assistant command bar, the actions MCP server, the action manifest, chat-driven navigation, or voice-to-data capture./design-systemThe mandatory UI design system for applications built with this plugin — Bootstrap 5.3 admin template (nxl theme) with fixed layout, component patterns, and mobile-first rules. Use before generating or editing ANY page, screen, partial, or HTML in an application built with this plugin, and when the user mentions look and feel, styling, layout, or UI consistency./malumail-sendSend transactional email through the MaluMail API (api.malumail.com) and integrate MaluMail sending into an application. Use when an app needs to send email programmatically — welcome/verification/receipt/notification/password-reset messages, alerts, or any outbound mail — through MaluMail; when wiring up MaluMail sending; when managing a MaluMail suppression list; or when debugging MaluMail send failures (401/403/429/502, verified sending domains, API keys, Bearer auth). Triggers on "send email via MaluMail", "MaluMail API", "api.malumail.com", "transactional email", "suppression list"./mcp-serversDesign and build the two MCP servers every application ships — the record-memory server over PostgreSQL 17 and the activity-memory server over MaluDB — in Python with FastMCP, exposed to the app's AMA agent and to clients' own AI tools. Use during Phase 1 (tool-surface design) and when implementing, deploying, or extending an application's MCP servers./memory-first-planningBackground context for planning or brainstorming a new application or SaaS product — memory-first design, the ask-me-anything view of applications, SaaS Plus+ data sovereignty, and the default technical stack (PostgreSQL 17 + MaluDB, Apache/PHP/Bootstrap 5.3/HTMX). Provides answers and direction, not a workflow to run./new-appStart building a new HTMX + PHP + Bootstrap 5.3 application. Use when the user says "new app", "start a new application", "build an app", "begin the project", or invokes /new-app. Enforces the fixed build order — full database + memory design first, then authentication + app shell, then vertical feature slices — on the standard stack (Ubuntu 24.04, PostgreSQL 17 + MaluDB, Apache, PHP, HTMX).Other plugins' skills for the same job