bricks_delete_global_variable

Phase 2BeginnerDestructiveComplexity: 2/10
Delete a CSS variable

Overview

Permanently deletes a global CSS variable by ID. Any elements, global classes, or theme styles that reference this variable via var(--name) will lose their value and fall back to the browser default or inherited style.

This is a destructive operation. Before deleting, consider whether any part of the site relies on this variable. Use bricks_get_global_variables to verify the variable exists and confirm its name before deletion.

Key Features

Permanent Removal
Completely removes the variable from the Bricks design system. The var(--name) reference will no longer resolve to any value.
ID-Based Deletion
Uses the variable ID (not name) for precise targeting, preventing accidental deletion of the wrong variable.

When to Use

Removing an obsolete or unused design token from the system
Cleaning up duplicate variables after a design system audit
Removing variables from a previous design that no longer applies
As part of a design system refactor when replacing old tokens with new ones
Prerequisites
The variable must exist. You need the variable_id from bricks_get_global_variables. Ensure no critical elements depend on this variable before deleting.

When NOT to Use

When you want to change a variable value — use bricks_update_global_variable instead
When the variable is actively referenced by elements — update those elements first
When you want to rename a variable — use bricks_update_global_variable which handles global rename

Parameters

1 Total Parameters1 Required
variable_idstringREQUIRED
The unique ID of the variable to delete. Obtain this from bricks_get_global_variables.

Code Examples

Delete an Unused Variable

Remove an obsolete variable after confirming it is no longer referenced.

JSON
// Step 1: List variables and identify the one to delete
bricks_get_global_variables({})
// Find: { id: "v_old123", name: "old-spacing-xl", value: "40px" }

// Step 2: Delete it
bricks_delete_global_variable({
  variable_id: "v_old123"
})
Response
{"success": true, "message": "Variable deleted successfully"}

Common Mistakes

Deleting a variable that is still referenced by elements, causing broken styles.
Before deleting, search your site for var(--variable-name) references. Update or remove those references first, then delete the variable.
Wrong
// Deleting without checking references
bricks_delete_global_variable({ variable_id: "v1a2b3" })
// Elements using var(--spacing-lg) now have no value!
Correct
// First check for usage
bricks_search_content({ query: "var(--spacing-lg)" })
// If references exist, update them to use a different variable
// Then safely delete
bricks_delete_global_variable({ variable_id: "v1a2b3" })
Deleting spacing scale variables that are part of the mandatory design system.
Never delete variables from the spacing scale (xs through 5xl) unless you are replacing the entire scale with new values. These are foundational design tokens.
Wrong
bricks_delete_global_variable({ variable_id: "spacing_md_id" })
// Now all elements using var(--spacing-md) break!
Correct
// Update the value instead of deleting
bricks_update_global_variable({ variable_id: "spacing_md_id", value: "18px" })

Tips & Warnings

Tips & Warnings

Warning: Destructive operation. Deleted variables cannot be recovered. Any element using var(--deleted-name) will render with no value (browser default or inherited style).

Check references first: Use bricks_search_content to search for the variable name across all pages and templates before deleting.

Consider updating instead: If you want to change a variable, bricks_update_global_variable is safer than delete + recreate, as it preserves the ID and can rename references automatically.

Return Values

FieldTypeDescription
successbooleanWhether the variable was deleted successfully.
messagestringConfirmation message or error details.

Related Tools

Technical Details

Tool ID
bricks_delete_global_variable
API Endpoint
/bricks-mcp/v1/design-system/variables/{variable_id}
HTTP Method
DELETE
Namespace
design-system
Source File
design-system/variables.ts
Version
1.0
Min Bricks Version
1.9
Requires Auth
Yes

Changelog

v1.0
Initial release
20250101