Class Merge Helper
Combine conditional classes in one place so the last one written actually wins.
What it adds
A single helper every component uses to resolve base, conditional, and caller-supplied classes into one final list.
What your agent is told to do
5
What your agent is told to do
5-
1
Find every component that currently builds a class string by hand and route all of them through one helper, so the resolution rules are identical everywhere.
-
2
Define the precedence plainly: the component's own base classes lose to its variant classes, and both lose to whatever the caller passed in. A caller that supplies a class expects it to take effect.
-
3
Accept the shapes calling code actually produces rather than forcing every call site to normalise first, and make the behaviour for absent and empty values explicit rather than incidental.
-
4
Detect and collapse conflicting utilities that set the same property, keeping the last one, so a caller adjusting one aspect of a component does not have to fight a base class that is still present.
-
5
Do not let this helper decide policy. Which utilities are permitted and when a pattern should be extracted belong to Utility Class Conventions; this helper only resolves what it is given.
Edge cases it handles
6
Edge cases it handles
6- A caller passing a class to change one property must win over the component's own class for that property. If the base class survives, the override silently does nothing and the caller will reach for importance flags instead.
- Values arriving as lists, as objects keyed by condition, and as absent or empty entries must all be handled without special-casing at the call site, and must never contribute stray separators or empty entries to the output.
- Conflicts between classes belonging to different systems — a utility framework class against a hand-written or component class targeting the same property — cannot be resolved by name matching alone. Define the resolution rule and state its limits.
- An invalid or misspelled class name must survive to the output unchanged rather than being quietly dropped, because a helper that swallows typos turns a visible styling bug into an invisible one.
- The helper runs on every render of every component, so its cost is multiplied by the size of the tree and must stay proportionate to the classes it is given.
- Ordering must be stable: the same inputs must produce the same output string every time, or server-rendered and client-rendered markup will disagree.
Definition of done
8
Definition of done
8- Every component composes classes through the single helper, with no hand-built class strings remaining.
- Caller-supplied classes reliably override the component's own classes for the same property.
- Lists, condition maps, and absent values are all accepted and produce no empty or duplicated entries.
- Conflicting utilities setting the same property collapse to the last one given.
- Unrecognised class names pass through unchanged.
- The same inputs always produce the same output string.
- The feature matches the existing design system.
- No existing functionality is broken.
Related features
CSS Module Boundaries
CSS Module Boundaries
Keep each component's styles its own, and make the shared parts deliberate.
What it does
A boundary around each component's styles, exposing only a named set of hooks that callers are permitted to style through.
How it works
- 1 Identify the primitives the rest of the app builds on — button, field, card, menu, table — and treat everything inside them as private unless it is deliberately published.
- 2 For each primitive, publish an explicit surface: the variants it accepts, the slots a caller may target, and the custom properties it reads. Anything not on that list is internal and may change without notice.
- 3 Find the places where product screens currently reach into a primitive's internals and rewrite them to use the published surface, adding a variant or a slot where the need is legitimate.
Copy the prompt
No account needed
Add this feature to my app:
https://addthisfeature.com/x/css-module-boundaries
Tokenized Inline Styles
Tokenized Inline Styles
Allow styles computed at runtime without letting arbitrary values escape the design system.
What it does
A constrained path for dynamically computed styles, where every value is either a design token or a number clamped to an approved range.
How it works
- 1 Find every place the app already sets a style value at runtime — progress widths, chart bar heights, avatar colours, drag positions, user-chosen accent colours — and sort them into two groups: values that must come from the token set, and values that are genuinely continuous numbers.
- 2 For the first group, accept only token names and resolve them to values at the boundary. A caller passing a raw colour or a raw pixel value should be rejected loudly in development rather than quietly rendered.
- 3 For the second group, clamp to a documented minimum and maximum and round to a sensible precision, so a percentage of 4000 or a width of 0.3847291 pixels never reaches the DOM.
Copy the prompt
No account needed
Add this feature to my app:
https://addthisfeature.com/x/tokenized-inline-styles
CSS Layer Strategy
CSS Layer Strategy
Give the stylesheet an explicit order of precedence instead of one decided by accident.
What it does
An ordered set of cascade layers — reset, tokens, base, components, utilities, overrides — that every stylesheet is assigned to.
How it works
- 1 Define the layer order once, in one file, and have every other stylesheet declare which layer it belongs to rather than relying on the order the bundler happens to emit.
- 2 Assign the existing stylesheets to layers before changing any of them. The map from current file to intended layer is the whole design decision, and it should be reviewable on its own.
- 3 Migrate in stages: place everything currently unlayered into a defined position relative to the new layers, then move files into their proper layer one at a time, checking the rendered result after each move.
Copy the prompt
No account needed
Add this feature to my app:
https://addthisfeature.com/x/css-layer-strategy
How it works
-
1
Copy the link
Grab the Markdown instruction URL for this feature.
-
2
Give it to your AI
Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.
-
3
It inspects, then implements
Your agent reads your existing app first, then adds the feature to fit it.
Works with your stack
These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.
Need it tighter than that? Customize the feature and tell it exactly what you're running.