/component-creator:add-prop Optional component namefrom component-creator
Add or sync a prop on an existing component (.tsx + story + test + yaml deps). Stops at the source boundary; /publish-all handles registry/build/publish.
Ships in component-creator. Installing the plugin adds it to Claude Code.
You are adding (or syncing) a single prop on an existing myOperator UI component. You handle source-side edits only — .tsx, .stories.tsx, .test.tsx, and (when a new npm import appears) the dependencies array in packages/cli/components.yaml. You DO NOT run integrity-snapshot, registry generation, prefix validation, version bump, npm publish, git commit, or git push — those belong to /publish-all.
There are two flows:
.tsx and just wants the story + test (and yaml deps if needed) updated to match.If $ARGUMENTS is non-empty, treat its trimmed value as the component name. Otherwise, ask:
If the user picks "Show me the list", ls src/components/ui/*.tsx and ls -d src/components/custom/*/ and present a Glob-trimmed list. Then re-ask with concrete options (max 4 — use Other for the rest).
Search in this order:
src/components/ui/<name>.tsxsrc/components/custom/<name>/<name>.tsx (single-file custom)src/components/custom/<name>/*.tsx (multi-file custom)If multiple matches or no match, ask the user to disambiguate.
For multi-file custom components (isMultiFile: true in components.yaml), ask which file the prop belongs to:
.tsx files in the directoryRead all three:
.tsx (and its types.ts if it's a custom multi-file component)*.stories.tsx__tests__/<name>.test.tsxKeep them in context — every subsequent edit must match the existing patterns in these files (CVA structure, story conventions, test style).
Ask:
If "Create new prop" → continue to Phase 3 (Flow A). If "Sync existing code" → skip to Phase 5 (Flow B).
Ask:
Ask the user for:
/^[a-z][a-zA-Z0-9]*$/. Reject names starting with uppercase or containing _/-.If CVA variant group:
tone).info, warning, danger).If Boolean flag:
false is the conventional default).true, optionally one for false).If String / enum:
If ReactNode slot:
Any Tailwind classes the user supplies must use semantic tokens. Reject and re-prompt if you see:
#XXXXXX)bg-gray-*, text-white, bg-black, text-gray-*bg-[#...])Confirm tokens exist:
grep -E "(--semantic-|--color-)" src/index.css
If a token the user named isn't found, suggest the closest match and ask before proceeding.
The new prop MUST be optional or have a default in the destructure. Refuse if the user wants a required prop with no default — this would break npm run api:check at commit time. Explain and ask them to make it optional.
Edit in this order. Use the Edit tool, not Write.
<component>.tsxFor CVA variant group:
cva(...) call. Add the new key inside variants: { ... } with all options as Tailwind class strings.defaultVariants: { ... } with the user's chosen default.VariantProps<typeof <component>Variants> typing picks it up automatically — do NOT manually edit the Props interface for CVA additions....props — no edit needed unless the prop drives conditional render.For Boolean / String / ReactNode prop:
Props interface with the new field, including /** JSDoc */. Place it in the right slot:
Lint rules to enforce while editing:
<p> MUST include m-0 (or be inside a CVA base string with m-0). The pre-commit check-bootstrap-compat.js will block otherwise.bg-gray-*, no text-white. Semantic tokens only.After editing, read the file back and confirm the change is syntactically clean.
<component>.stories.tsxAdd an argTypes entry. Control type matrix:
| Prop kind | argTypes shape |
|---|---|
| CVA variant | control: "select", options: [<all options>], description: "<JSDoc>" |
| Boolean | control: "boolean", description: "<JSDoc>" |
| String (enum) | control: "select", options: [...], description: "..." |
| String (free) | control: "text", description: "..." |
| ReactNode | control: "boolean", mapping: { true: <PlaceholderIcon />, false: undefined }, description: "..." |
Add a dedicated story for the prop:
export const <PascalCasePropName>: Story = {
args: {
<propName>: <representativeValue>,
children: "Example",
},
};
For CVA variants, also extend the existing comparison story (commonly named AllVariants, ButtonKinds, Sizes, etc.) by adding the new option(s) inline:
// existing render
<Component variant="default">Default</Component>
<Component variant="primary">Primary</Component>
// + new
<Component variant="<newOption>">{"<newOption>"}</Component>
Only update the parameters.docs.description.component Design Tokens table if the prop introduces a NEW token row (e.g., a tone="warning" that uses --semantic-warning-* for the first time). Do not pad it otherwise.
__tests__/<component>.test.tsxMatch the existing test style.
For CVA variant group — extend the it.each([...]) block:
it.each([
["existing", "existing-class"],
["<newOption>", "<representativeClass>"],
] as const)("renders %s variant", (variant, expectedClass) => {
render(<Component variant={variant}>Test</Component>);
expect(screen.getByRole("...")).toHaveClass(expectedClass);
});
For Boolean prop — add positive + negative cases:
it("applies <propName> when true", () => {
render(<Component <propName>>Test</Component>);
expect(/* effect */).toBe(/* ... */);
});
it("does not apply <propName> when false (default)", () => {
render(<Component>Test</Component>);
expect(/* effect */).not.toBe(/* ... */);
});
For ReactNode slot:
it("renders <propName> slot", () => {
render(
<Component <propName>={<span data-testid="slot">x</span>}>
Test
</Component>
);
expect(screen.getByTestId("slot")).toBeInTheDocument();
expect(screen.getByText("Test")).toBeInTheDocument();
});
Bootstrap compat: if the component renders any <p>, ensure the test imports and calls:
import { assertNoBootstrapMarginBleed } from "./utils/bootstrap-compat";
// inside a render test:
assertNoBootstrapMarginBleed(container);
Do not duplicate this if it's already present.
Run:
git diff -- src/components/ui/<name>.tsx src/components/custom/<name>/
If the diff is non-empty:
variants: { ... }, new fields in the Props interface, or new entries in the forwardRef destructure.If the diff is empty (file already committed):
Show the user what you detected and ask to confirm:
<name> (kind: <kind>, default: <default>). Correct?"If "No", fall back to the Flow A Phase 3 questions to gather the spec, but skip the .tsx edit in Phase 4 Step 1 — the user has already written it.
Run Phase 4 Step 2 (story) and Phase 4 Step 3 (test) exactly as in Flow A.
DO NOT re-edit the .tsx. The user owns it in this flow.
Compare the post-edit .tsx import list against the pre-edit version:
git diff -- src/components/ui/<name>.tsx | grep '^+import'
For each new bare-package import (e.g., @radix-ui/react-tooltip, NOT relative imports like ./button or ../../lib/utils):
dependencies: block in packages/cli/components.yaml. If yes, skip.package.json:
grep '"@radix-ui/react-tooltip"' package.json
<pkg>@^<version>. Add to components.yaml under <component> → dependencies?"packages/cli/components.yaml — locate the component's dependencies: array and add the new entry. Maintain alphabetical order. Use caret range (^X.Y.Z).If no new bare-package imports appeared, skip this phase silently.
Animation classes special case: if the user added animate-in, animate-out, fade-in-*, zoom-in-*, or slide-in-from-* classes and tailwindcss-animate is not in the component's deps, propose adding it.
Run, in order:
npm run lint -- --fix src/components/ui/<name>.tsx src/components/ui/<name>.stories.tsx src/components/ui/__tests__/<name>.test.tsx
Then:
npm run test:smart
If test:smart fails:
toHaveClass because you guessed the class instead of reading it from the component), fix the test and re-run once.If test:smart reports "no changed components" (because the user staged nothing), fall back to:
npx vitest run src/components/ui/__tests__/<name>.test.tsx
Print a summary table:
| File | Change |
|------|--------|
| src/components/ui/<name>.tsx | [Flow A only] added prop `<propName>` (`<kind>`) |
| src/components/ui/<name>.stories.tsx | argTypes entry, `<PascalCase>` story, extended comparison render |
| src/components/ui/__tests__/<name>.test.tsx | added `it.each` row / `it()` block(s) |
| packages/cli/components.yaml | added dependency `<pkg>@^<version>` *(only if applicable)* |
Then print the boundary reminder verbatim:
Source edits done. Run
/publish-allwhen you're ready to beta-publish. This command does not run integrity-snapshot, registry generation, prefix validation, version bump, or publish — those belong to/publish-all.
You MUST NOT run any of these:
cd packages/cli && npm run integrity:snapshotnode scripts/check-integrity.js verify ...npm run generate-registrynpm run validate:prefixnpm run build (root or packages/cli)npm versionnpm publish (with or without MYOPERATOR_PUBLISH_ALLOWED=1)git add, git commit, git pushnode scripts/sync-mcp-metadata.jspackages/cli/src/registry-*.ts (auto-generated)packages/cli/components.yaml is the only CLI-adjacent file you may write to, and only its dependencies: array, only when a real new bare-package import appeared in Phase 6.
.tsx. Never guess class names.bg-gray-*, text-white, arbitrary color values. Use semantic-* tokens; verify in src/index.css.<p> rule. Every <p> in component files needs m-0 (or mb-0/my-0).api:check.@/lib/utils, sibling ./<name>. Custom components: ../../../lib/utils, ../../ui/<name>. Never @/components/ui/... in custom components./** ... */ immediately above the field in the Props interface./publish-all, leave it for /publish-all.Files this command reads when invoked
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
2 commands in this plugin
2 plugins ship this exact command · first indexed Apr 28, 2026
npx claudepluginhub ankish8/myoperator-plugins --plugin component-creator