bricks_get_class_usage
Overview
Returns usage statistics for a specific global class, showing which pages use it and how many elements reference it. This is essential for impact analysis before modifying or deleting a class.
Use this tool to understand how widely a class is used across the site. It helps decide whether a class is safe to delete, rename, or modify, and identifies which pages would be affected by changes.
Key Features
When to Use
Before renaming or significantly modifying a class — understand the impact
When auditing the design system to find unused classes that can be cleaned up
When consolidating duplicate classes — check which one is more widely used
When NOT to Use
When you want to check usage of all classes at once — call this per class individually
Parameters
class_idstringREQUIREDCode Examples
Check usage before modifying a class
Checks how many pages and elements use btn-primary before changing its background color. Shows the class is used on 5 pages with 18 elements.
// Check usage of btn-primary class before modifying it
bricks_get_class_usage({
class_id: "d4e5f6"
}){
"class_id": "d4e5f6",
"class_name": "btn-primary",
"total_pages": 5,
"total_elements": 18,
"pages": [
{ "page_id": 33, "title": "Home", "element_count": 4 },
{ "page_id": 45, "title": "About", "element_count": 2 },
{ "page_id": 56, "title": "Services", "element_count": 6 },
{ "page_id": 67, "title": "Contact", "element_count": 3 },
{ "page_id": 78, "title": "Pricing", "element_count": 3 }
]
}Find unused classes for cleanup
Checks if an old class is still referenced anywhere. Returns 0 pages/elements, indicating it is safe to delete.
// Check if an old class is still in use (cleanup audit)
bricks_get_class_usage({
class_id: "old123"
}){
"class_id": "old123",
"class_name": "old-button-style",
"total_pages": 0,
"total_elements": 0,
"pages": []
}
// Safe to delete — not used anywhereCommon Mistakes
// Deleting without checking impact
bricks_delete_global_class({ class_id: "abc123", force: true })
// Oops — 50 elements just lost their styling!// Check impact first
bricks_get_class_usage({ class_id: "abc123" })
// Returns: 5 pages, 50 elements
// Decision: update the class instead of deleting
bricks_update_global_class({ class_id: "abc123", settings: { ... } })Tips & Warnings
Best practice: Call this tool before any destructive action on a class (delete, major rename, or significant style change). The per-page breakdown helps you understand the blast radius of your changes.
Design system audit: Periodically check usage of all classes to identify unused ones that can be cleaned up, keeping the design system lean and maintainable.
Tip: If a class has 0 usage and was created recently, it might be unused because elements have not been assigned to it yet. Check if it was part of Phase 2 setup before deleting.