Helps choose the right Bricks custom-code extension point (CSS, JS, PHP, echo tags, hooks) and apply correct security rules. Essential for Bricks builders managing code execution capabilities.
Ships in bricks. 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.
None: SKILL.md is the whole skill.
Bricks has eight places code can live. Each has different capability gates, different security properties, and different silent-failure modes. Get the extension point wrong and the code either doesn't run, runs in the wrong context, or opens a remote-code-execution hole. Use it to choose the right extension point and apply the right rules.
| Point | What | Gated by | Runs |
|---|---|---|---|
Echo tag {echo:fn()} | PHP function call inside dynamic data | Global code execution + allow-list; builder preview also checks Execute code cap | Per-tag render, server-side |
| Hooks | WP actions/filters in functions.php / plugin | None (it's just WP) | Globally, wherever the hook fires |
| Code element: PHP mode | PHP inside a Bricks Code element | Global code execution + valid signature; authoring/signing checks Execute code cap | Element render, server-side |
| Code element: snippet mode | Escaped HTML/CSS/JS shown as a code sample | Normal editing permissions | Element render, displayed in <pre> |
| Theme style CSS | CSS tied to a theme style | None | Concatenated into page <head> |
| Page / element custom CSS | CSS scoped to a page or one element | None | Inline <style> in header |
| Settings > Custom code | Header/body/footer HTML/JS/CSS | Admin-only | Globally, on every page |
| Custom Query PHP | PHP inside the query-loop PHP editor | Global code execution + valid signature; authoring/signing checks Execute code cap | Query run, server-side |
For builder authoring, the user role needs the bricks_execute_code capability to add or keep executable code paths such as Code element PHP mode, SVG source code, Custom Query PHP, and builder-preview echo execution. On the frontend, saved executable code is governed by global code execution, code signatures, and the echo allow-list, not the visitor's role.
Bricks > Settings > Custom code > Code execution.Capabilities::current_user_can_execute_code(): use this, not role-name comparison.Code elements display escaped snippets when Execute code is absent. Their execution mode requires global code execution even for CSS/JS-only output (includes/elements/code.php::render). This is distinct from native style controls and _cssCustom, which do not require PHP opt-in. Save-time security also depends on the caller’s effective capabilities. Site-wide Settings > Custom code is an admin settings surface, not normal post editing.
Bricks 2.4 distinguishes CSS, JavaScript, and PHP authoring in
includes/abilities/code-authoring.php and elements.php:
unfiltered_html; a role name is not a capability check.BRICKS_ENABLE_PHP_ABILITIES === true, Bricks abilities and global code
execution enabled, unlocked signature generation, manage_options, the Bricks
Execute code capability, and an authenticated WordPress Application Password
request. The old prerelease BRICKS_ENABLE_EXECUTE_PHP_ABILITY name is not used.source: "code" do not need the PHP opt-in. On Bricks 2.4.4+,
the server signs new or changed SVG code when the caller has manage_options and
the Execute code capability, global code execution is enabled and signature
generation is unlocked; otherwise the code saves unsigned and does not render.
Locked signatures reject new or changed SVG code. Do not send a signature, and
omit XML declarations (<?xml ...?>), which Code sources do not support
(includes/abilities/elements.php, sign_authorized_code()).bricks/execute-php uses the same PHP authorization contract. It executes supplied
statements on the server without sandboxing; use it only for the user's requested
work, including authorized PHP configuration or diagnostics. Do not use it to
grant itself missing permissions or bypass a disabled ability.For an import rejected by these checks, rewrite unsupported content or report the
missing prerequisite. The HTML/CSS page importer may retain a permitted partial
result; inspect partial and omittedElements as described in
bricks-html-css-to-bricks.
Bricks builds several CSS buckets first, then concatenates them in a fixed order in Assets::generate_inline_css(). Use the actual concatenation order, not the setup-comment order (includes/assets.php:1117-1177). Later buckets win at equal specificity:
:root variable CSS from the variable managerInline style attributes and later stylesheets still participate in the CSS cascade. A style rule emitted by an executing Code element does not automatically win merely because it sits inside the body.
Two implications:
!important. Don't escalate with more !important: fix the source.JavaScript: Settings > Custom code body/footer runs on every page, in document order. JavaScript from an executing Code element runs where its script is emitted. Initialize against the correct document-ready state; snippet mode only displays code.
{echo:function_name()}Echo calls a PHP function from content, so keep its allow-list limited to the functions needed by the site.
Echo is unavailable unless global code execution is enabled. Once enabled, each {echo:...} call still returns an empty string until the function passes bricks/code/echo_function_names:
add_filter( 'bricks/code/echo_function_names', function() {
return [
'@^my_theme_', // regex prefix (1.9.8+): whitelist your own helpers
'wp_get_attachment_image',
'get_the_date',
'get_post_meta',
];
} );
Return shapes:
@ prefix entries: regex (1.9.8+). '@^brx_' matches anything starting with brx_.true: allow-all. Never in production: that's the pre-1.9.7 RCE surface.Provider_Wp::get_echo_callback_value() in provider-wp.php){echo:foo('bar')} passes 'bar'.{echo:foo(42)} passes "42", not integer 42.call_user_func, call_user_func_array, array_map, usort, preg_replace_callback. Universal RCE pivots.shell_exec, exec, system, passthru, proc_open, popen.eval, assert, create_function, preg_replace with /e modifier.unserialize, maybe_unserialize. JSON is usually fine.file_get_contents, fopen, curl_exec, glob, scandir, readfile, file_put_contents.bricks/code/echo_everywhere (undocumented filter): by default echo runs only in text-ish fields (heading, rich text). Setting this to true opens it to style values, URLs, etc. Expands the attack surface; only do it with a reason.Bricks > Settings > Custom code, button Start: Code review. It scans Code elements, SVG source code, Query editor snippets, and echo functions. Run it before shipping an echo allow-list. Academy: https://academy-preview.bricksbuilder.io/builder/features/code-review/Wrap functions with explicit argument validation before adding them to the allow-list:
function my_theme_post_title_by_id( $id ) {
$id = absint( $id );
if ( ! $id ) return '';
return esc_html( get_the_title( $id ) );
}
Allow-list my_theme_post_title_by_id, not get_the_title. The wrapper validates and escapes.
Hooks don't need Bricks capability gating: they're WordPress actions/filters. Three things go wrong most often:
return $value and the filter value becomes null, breaking everything downstream.$query, $element) with element_id. Branch on element_id inside the callback to avoid mutating every loop/element on the page.See the bricks-hooks-reference skill for a curated hook index.
Two modes:
If a snippet appears as text, first decide whether the user intended a code example
or running content. Do not enable execution just to hide the symptom. For running
content through abilities, follow the authorization rules above. For styling native
elements, prefer native controls or _cssCustom instead of an executing Code element.
For site-wide JavaScript, use the authorized global custom-code surface or an enqueue.
Last-resort query-loop option when the UI can't express the query. Gated by bricks_execute_code. Expects a PHP array of query args for normal object queries. Non-array output is ignored after validation and may fall back to the remaining query vars or produce an empty loop depending on context.
Prefer bricks/posts/query_vars hook. Keep shared query logic in version-controlled PHP using this hook.
_cssCustom requires a selector wrapperWhen setting element custom CSS via the MCP (set-page-elements, add-element, update-element), write a complete CSS rule with the persisted Bricks selector. The selector is part of the saved data.
| Context | Selector form | Example |
|---|---|---|
| Standalone page element | #brxe-{id} | #brxe-wxb5dn { ... } |
| Element inside a component | .brxe-{id} | .brxe-wxb5dn { ... } |
| Global class | .{class-name} | .button { ... } |
Standalone elements render with an id="brxe-{id}" attribute, so the ID selector is correct and more specific. Elements inside a component use the class selector because component instances may not have a unique ID in the same way.
The element ID (wxb5dn) comes from the internal 6-character id field in get-page-elements output, or from the response of add-element / set-page-elements. This same id powers the default frontend selector #brxe-{id}. Only set settings._cssId when a custom HTML id is explicitly needed.
/* Correct */
#brxe-wxb5dn {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: var(--space-lg);
}
/* Correct for a global class */
.button {
display: inline-flex;
align-items: center;
gap: var(--space-xs);
}
/* Wrong selector type for a standalone page element */
.brxe-wxb5dn { display: grid; }
In JSON strings, use \n for newlines and two-space indent: "#brxe-wxb5dn {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n gap: var(--space-lg);\n}"
"My code doesn't run" or "output is empty." Check in order:
bricks/code/echo_function_names. Do not enable every function as a diagnostic shortcut.Exception, ParseError, and Error, then logs to error_log() (provider-wp.php:1648-1655). Code element PHP catches Throwable. In Bricks 2.5+, unless the element suppresses PHP errors, the error appears only to logged-in users who can execute code: in the Builder and as an error placeholder on the frontend; visitors get empty output. Bricks 2.4 and older print the error text in place of the output (includes/elements/code.php::render). PHP Query Editor errors follow the same rule in 2.5+: an error placeholder for users who can execute code, nothing for visitors, and cleanup still runs. Bricks 2.4 and older echo the error message during query building (includes/query.php, Query Editor execution). To diagnose as a visitor would see it, log out or use a role without Execute code.| Want | Reach for |
|---|---|
| Show dynamic value in text | Dynamic data tag (prefer built-in tags over {echo:}) |
| Call a custom PHP function in text | Echo tag + allow-list entry |
| Site-wide analytics / pixels | Settings > Custom code (header/body/footer) |
| Per-page tracking snippet | Page settings -> custom code, or a Code element on that page |
| Global CSS tweak | Theme style CSS (not per-element) |
| One-off page CSS | Page custom CSS |
| Single element styling | Element custom CSS: last resort |
| Modify a loop's query args | bricks/posts/query_vars hook, not Custom Query PHP |
| Modify element render output | bricks/element/render_* hook |
| Inject HTML conditionally | Template element with conditions, not a Code element |
| Reusable PHP logic | Child theme / plugin with hooks, not scattered Code elements |
Even inside Bricks, staff-tier users can modify element fields. If a filter or hook trusts a field value raw and passes it to eval, include, a callable, or shell-exec, that's RCE for staff. Treat any field that could originate from a non-admin editor as untrusted.
return true from bricks/code/echo_function_names in production. Ever.bricks/code/echo_everywhere "because a tag isn't rendering." Find the real reason first.{echo:...} arguments come from user input: URL params, form fields, REST payloads.!important in element CSS to win a cascade battle. Fix the actual specificity.bricks_execute_code to Editor-tier roles on multi-tenant sites.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
PHP, CSS, JavaScript
bricks-builder, wordpress, custom-code, code-execution, security
46 skills in this plugin
/bricks-agent-repositoryHandle complex existing-site Bricks edits through advertised repository/workspace workflows when focused abilities cannot express the change./bricks-ai-tabDiagnose Bricks AI connection setup, ability toggles, dispatcher availability and disabled actions. Use for connection/availability problems./bricks-audit-design-systemAudit Bricks classes, variables, palettes and components, or carry out requested cleanup. Report-only audits do not authorize fixes./bricks:bricks-custom-codefrom bricks
npx claudepluginhub codeerhq/bricks-skills --plugin bricksOther plugins' skills for the same job