create-ds-component
Skill0 starsChanged 56 days agoMITView on GitHub
Build a reusable component inside packages/design_system — directory layout, barrel exports, named-constructor variants, shared base widgets, token-only styling, and the app-vs-design-system placement decision. Use when adding or changing a widget in the design system package, or deciding whether a widget belongs there at all.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- omardoucoure/claude-skillstheir own version, first seen Apr 4, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- omardoucoure/claude-skills★ 0same 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 repository18 other files it gives its agents.
- payload/AGENTS.mdAGENTS.md
- add-design-tokenSkill
- add-localizationSkill
- add-platform-channelSkill
- add-routeSkill
- create-adrSkill
- create-api-providerSkill
- create-dtoSkill
- create-featureSkill
- create-pageSkill
- create-storeSkill
- create-use-caseSkill
- handle-errorsSkill
- plan-featureSkill
- qa-featureSkill
- triage-bug-reportSkill
- write-maestro-flowSkill
- write-testsSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 93
No raw Color(0x…), no TextStyle(…) composite, no hand-assembled BoxShadow list — in the package either.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Create a design-system component
Governed by ADR-0014 (package boundary) and ADR-0013 (tokens only). Visual spec: DESIGN.md.
Concepts behind this playbook: performance-guide.
Does it belong here?
| Widget | Home |
| Generic, app-agnostic, no feature knowledge — button, input, avatar, modal chrome | packages/design_system/lib/src/components/ |
Reused across features but app-specific — knows a store, a route, a LocaleKey | lib/core/ui/ |
| Used by one feature only | lib/features/{feature}/components/ |
The test: could another app use this unchanged? If it imports anything from lib/, the answer is no and it does not go in the package.
Layout
packages/design_system/lib/
design_system.dart the only public entry — everything is exported here
src/
components/
components.dart barrel
src/
{component}/ one directory per non-trivial component
{component}.dart barrel
src/ implementation parts + shared base widgets
core/src/constants/ kSpacingNpx, kBorderRadiusNpx …
theme/src/ GeistTheme, GeistTextStyles, GeistRadius, GeistDuration
gen/ GENERATED assets/colors/fonts — never editNaming: *_widget.dart or the descriptive name (primary_button.dart), *_theme.dart, *_constants.dart, *_utils.dart.
A component is exported from its own barrel → components.dart → design_system.dart. A component not reachable from design_system.dart does not exist as far as lib/ is concerned.
Variants are named constructors, not booleans
enum _ButtonType { filled, text }
class PrimaryButton extends HookWidget {
const PrimaryButton.largeFilled({
super.key,
required this.onPressed,
required this.child,
this.leftIcon,
this.rightIcon,
this.isLoading = false,
this.isDisabled = false,
}) : _size = ButtonSize.large,
_type = _ButtonType.filled;
final VoidCallback? onPressed;
final Widget child;
final Widget? leftIcon;
final Widget? rightIcon;
final bool isLoading;
final bool isDisabled;
final ButtonSize _size;
final _ButtonType _type;
@override
Widget build(BuildContext context) => switch (_type) {
_ButtonType.filled => MyFilledButton(/* … */),
_ButtonType.text => MyTextButton(/* … */),
};
}- Named constructors per variant —
PrimaryButton.largeFilled(), notPrimaryButton(size: …, type: …). The call site reads as the design, and an invalid combination becomes unrepresentable. - Private enums for type and size; the variant is fixed by the constructor, not passed in.
- Shared behaviour lives in a base widget (
MyFilledButton) undersrc/; the public component only picks one. constconstructors wherever the widget allows it.- Optional parameters get sensible defaults so the common case is one line.
Styling
Tokens only. A component inside the package reads the same tokens app code does, and it reads colours through the theme, so an app that overrides GeistTheme restyles the component too:
- Colours →
context.geist.*, read once at the top ofbuild - Text →
GeistTextStyles.*, colour applied with.copyWith(color: …)at the use site - Radii →
GeistRadius.*· Durations →GeistDuration.* - Spacing →
kSpacingNpxfor padding;Gap(kSpacingNpx)between siblings in aRoworColumn, neverSizedBox - Shadows → the composed stacks on
GeistTheme(cardShadow,ringShadow)
No raw Color(0x…), no TextStyle(…) composite, no hand-assembled BoxShadow list — in the package either.
When a token is missing, decide its kind before adding it: does it need a different value in dark mode? If yes, it is a theme-aware field on GeistTheme with a light and a dark value — never a constant, because a constant renders the light value in dark mode. If no, it is a static constant (GeistRadius, GeistDuration, GeistTextStyles, spacing). The dark value of a theme-aware token is not optional, and forgetting it is not always a compile error: if the extension is missing from one theme, context.geist silently falls back to the light values at runtime. Full steps: add-design-token.
Local state inside a component
Components in the package default to useValueNotifier, not useState (ADR-0019). A design-system widget is used everywhere, so a whole-widget rebuild on every toggle multiplies across the app. Scope the rebuild with a ValueListenableBuilder around the part that changes, cache anything built in build() with useMemoized, and never write a Widget _buildX() method: extract a private widget class instead (ADR-0018).
The six states
A component is unfinished until default, pressed, hover, focus, disabled and loading are all defined — see DESIGN.md §12. Loading keeps the control the same size; disabled stays readable (≥ 3:1) rather than washing out.
Accessibility and testability
- Interactive components take an optional
semanticsLabeland wrap inSemantics. The label text comes from the caller —LocaleKeyslives inlib/, so the package never hardcodes copy. - Touch targets ≥ 44×44 pt, expanded with padding rather than by growing the glyph.
- The component passes
keythrough (super.key) so callers can tag it withTestIdfor E2E (ADR-0015).
Codegen
Assets, brand colours (assets/colors/colors.xml → AppColors) and fonts under packages/design_system/lib/gen/ are generated, and so is the Tailor CustomTheme mixin. After adding or changing any of them, re-run the design-system codegen:
melos run build:design_systemThen melos run build:app if the app uses the changed type, or melos run build to run everything in order (ADR-0014). Never edit gen/ or *.tailor.dart by hand. GeistTheme and the static token classes are hand-written and need no codegen.
Checklist
- Belongs in the package — imports nothing from
lib/ - Own directory with a barrel, exported through
design_system.dart - Variants are named constructors; type and size are private
- Local state uses
useValueNotifier; noWidget _buildX()methods - Shared behaviour extracted to a base widget under
src/ - Tokens only — no raw colour, text style, radius, duration or shadow stack
- New token: theme-aware (light and dark on
GeistTheme) if it differs in dark mode, static constant otherwise - Sibling spacing is
Gap(kSpacingNpx) melos run build:design_systemrun after an asset, font or brand-colour change- All six states defined; light and dark both correct at WCAG AA
super.keypassed through;semanticsLabelaccepted for interactive componentsDESIGN.mdupdated if this introduces a new visual pattern
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.

