bricks_delete_global_class

Phase 2BeginnerDestructiveComplexity: 3/10
Delete a global class with usage check

Overview

Deletes a global CSS class from the Bricks design system. By default, the tool performs a safety check to see if the class is currently used on any pages and returns a warning with usage details. Use force=true to delete even when the class is in use.

Deleted classes are moved to a 30-day retention trash, providing a safety net against accidental deletion. Elements that referenced the deleted class will lose that styling until a replacement is assigned.

Key Features

Usage Safety Check
By default, checks if the class is used on any pages and returns a warning with usage count. Only deletes if unused or force=true.
30-Day Retention
Deleted classes are moved to trash with 30-day retention, providing a safety net against accidental deletion.
Force Delete Option
Set force=true to bypass the usage check and delete the class even when elements reference it.

When to Use

To remove an obsolete or duplicate class from the design system
During design system cleanup when consolidating similar classes
When a class was created with the wrong name and you want to start fresh
After confirming no elements use the class (via bricks_get_class_usage)
Prerequisites
The class must exist. Use bricks_get_global_classes to find the class_id. Recommended: call bricks_get_class_usage first to understand impact before deleting.

When NOT to Use

When the class is actively used and you want to modify it — use bricks_update_global_class instead
When you want to rename a class — use bricks_update_global_class with the name parameter
When you are unsure about usage — call bricks_get_class_usage first to check

Parameters

2 Total Parameters1 Required1 Optional
class_idstringREQUIRED
ID of the global class to delete. Get this from bricks_get_global_classes.
forcebooleanoptional
Force delete even if the class is currently in use. Elements referencing this class will lose its styling.
Default: false

Code Examples

Delete an unused class safely

Deletes a class that is no longer referenced by any elements. The default safety check passes.

JSON
// Safely delete an unused class
bricks_delete_global_class({
  class_id: "abc123"
})
Response
{
  "message": "Global class 'old-button' deleted successfully. Moved to 30-day trash."
}

Force delete a class in use

First attempts a safe delete (returns warning), then force-deletes. Elements lose the class reference.

JSON
// Attempt to delete a class that is in use (safety check)
bricks_delete_global_class({
  class_id: "def456"
})
// Returns warning — then force if intended:
bricks_delete_global_class({
  class_id: "def456",
  force: true
})
Response
// First call (no force):
{
  "message": "Class 'btn-primary' is in use on 3 pages (12 elements). Set force=true to delete anyway.",
  "usage": { "pages": 3, "elements": 12 }
}
// Second call (force=true):
{
  "message": "Global class 'btn-primary' force-deleted. 12 elements on 3 pages lost this class reference."
}

Common Mistakes

Force-deleting a widely used class without first checking usage or creating a replacement.
Always call bricks_get_class_usage first. If the class is heavily used, create a replacement class and update elements before deleting the old one.
Wrong
// Force delete without checking impact
bricks_delete_global_class({ class_id: "abc123", force: true })
// 50 elements just lost their styling!
Correct
// Check usage first
bricks_get_class_usage({ class_id: "abc123" })
// Returns: 50 elements on 8 pages
// Create replacement, then update elements, then delete
bricks_create_global_class({ name: "btn-new", settings: { ... } })
// ... update elements via bricks_update_element ...
bricks_delete_global_class({ class_id: "abc123" })

Tips & Warnings

Tips & Warnings

Safety first: Always attempt deletion without force=true first. The tool will tell you exactly how many pages and elements are affected. Only use force=true after confirming the impact is acceptable.

30-day trash: Deleted classes are recoverable for 30 days, but elements that referenced them will lose styling immediately upon deletion.

Best practice: Before deleting a class, check if it should be renamed or updated instead (bricks_update_global_class). Deletion is usually only needed for duplicates or obsolete classes.

Return Values

FieldTypeDescription
messagestringSuccess confirmation or warning message about class usage.
usageobjectWhen the class is in use and force=false, returns usage details (page count, element count).

Related Tools

Technical Details

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

Changelog

v1.0
Initial release with usage safety check, force delete, and 30-day trash retention.
20250101