component-architecture
Skill3 starsChanged 6 months agoMITView on GitHub
Use when structuring React components in a SaaS app — composing shadcn/ui, cva variants, compound components, controlled vs uncontrolled state, and knowing when to abstract versus inline.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- yogvidwankhede/vishwakarmatheir own version, first seen Sep 26, 2026
- nahid-sparktales/agent-dispatchertheir own version, first seen Sep 21, 2026
- sanky369/vibe-building-skillstheir own version, first seen Jul 2, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- nahid-sparktales/agent-dispatcher★ 59same name
- sanky369/vibe-building-skills★ 30same name
- yogvidwankhede/vishwakarma★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository14 other files it gives its agents.
- accessible-componentsSkill
- auth-screensSkill
- billing-and-pricingSkill
- dashboard-layoutSkill
- data-tablesSkill
- design-tokens-themingSkill
- empty-and-loading-statesSkill
- forms-and-validationSkill
- modals-and-dialogsSkill
- navigation-patternsSkill
- notifications-and-toastsSkill
- onboarding-flowsSkill
- responsive-layoutSkill
- settings-pagesSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 79
Controlled: only when the parent needs the value (e.g.
- Distinctive: line 83
Follow the rule of three: inline the markup the first two times.
- Very specific: line 96
Boolean prop explosion: instead of a variant enum.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Component Architecture
Overview
shadcn/ui gives you owned components (copied into your repo, not imported from a package). That means architecture is your job: build a thin layer of app-specific components on top of the primitives, use cva for variants, and resist abstracting until a pattern repeats. Good structure keeps a SaaS UI consistent without a maze of props.
When to use
- Deciding how to structure or compose UI components.
- A component has grown a dozen boolean props.
- You're copy-pasting the same markup across pages.
Variants with cva, not boolean soup
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
const badge = cva(
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold",
{
variants: {
variant: {
default: "border-transparent bg-primary text-primary-foreground",
secondary: "border-transparent bg-muted text-muted-foreground",
success: "border-transparent bg-emerald-500/15 text-emerald-600",
destructive: "border-transparent bg-destructive/15 text-destructive",
},
},
defaultVariants: { variant: "default" },
},
);
export interface BadgeProps
extends React.HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badge> {}
export function Badge({ className, variant, ...props }: BadgeProps) {
return <span className={cn(badge({ variant }), className)} {...props} />;
}One variant prop scales better than isSuccess, isError, isMuted booleans that can contradict each other.
Compound components for related parts
Expose structure, not a config object, when parts vary:
<Card>
<CardHeader>
<CardTitle>Usage</CardTitle>
<CardDescription>This billing period</CardDescription>
</CardHeader>
<CardContent>{children}</CardContent>
<CardFooter><Button>Upgrade</Button></CardFooter>
</Card>This beats <Card title="…" description="…" footer={<Button/>} /> — consumers compose freely.
asChild to compose without wrapper soup
Radix's asChild merges props onto your element instead of rendering an extra node — great for making a link look like a button:
<Button asChild>
<Link href="/billing">Manage plan</Link>
</Button>Controlled vs uncontrolled
- Uncontrolled (component owns state) by default — simpler, less re-render.
- Controlled only when the parent needs the value (e.g. a filter that syncs to the URL). Support both like Radix: optional
value+onValueChange, with internal fallback state.
When to abstract
Follow the rule of three: inline the markup the first two times; extract a component on the third repetition, when the shared shape is clear. Premature abstractions calcify the wrong API.
File structure
components/
ui/ # shadcn primitives (owned)
<feature>/ # app components grouped by feature
lib/utils.ts # cn() + helpersPitfalls
- Boolean prop explosion instead of a
variantenum. - Mega-components taking a
configobject — prefer composition/children. - Abstracting too early — one usage is not a pattern.
- Editing shadcn primitives in place for app logic — wrap them instead, keep
ui/upgradeable. cn()not used — conditional class strings collide instead of merging.
Hand-off
A clean component layer that forms-and-validation, data-tables, and the SaaS-flow skills build their screens from.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

