用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/coinbase/cds --skill components-best-practices命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
USE THIS when writing or reviewing Jetpack Compose / Kotlin code in packages/cds-android or apps/android-app - @Composable APIs, Modifier parameters, CompositionLocal, state hoisting, or naming. Not for React or React Native work.
Deprecates a CDS component, hook, or other exported symbol with consistent JSDoc, version tags, and docsite metadata across every public export path (web, mobile, common, visualization), not only the original package. Use whenever the user asks to deprecate a CDS component or API, mark something as deprecated, add @deprecated / @deprecationExpectedRemoval, or update deprecation warnings in apps/docs metadata under components or hooks (webMetadata.json / mobileMetadata.json / metadata.json). Also use when replacing a component or hook and sunsetting the old one. Always finish by running `yarn nx run <project>:lint` on modified packages so `internal/deprecated-jsdoc-has-removal-version` passes.
Audits how often deprecated CDS exports are actively used in customer codebases using Sourcegraph MCP search tools. Use this skill whenever asked to assess removal readiness for deprecated CDS APIs, investigate the blast radius of removing a deprecated component or hook, check Sourcegraph for customer usage of deprecated exports, or help the team decide which deprecated APIs are safe to remove in the next major version. Always invoke when asked to "audit deprecated APIs", "check Sourcegraph for deprecated usage", "find usages of deprecated exports", "analyze deprecation impact", or any similar request involving CDS deprecations and customer adoption.
正在显示 SKILL.md
| name | components.best-practices |
| description | Use this skill whenever working on CDS React components in any package. |
| user-invocable | false |
These high quality components demonstrate proper use of patterns/conventions:
Every main CDS component should live within its own folder:
ComponentName/
├── ComponentName.tsx # Main component file
├── SubComponent.tsx # Supporting component (if needed)
├── index.ts # Re-exports for public API
├── __stories__/ # Storybook stories
│ └── ComponentName.stories.tsx
├── __tests__/ # Unit tests
│ └── ComponentName.test.tsx
├── __figma__/ # Figma Code Connect files
│ └── ComponentName.figma.tsx
Organize components into category folders:
buttons - Button, IconButton, SlideButtoncontrols - TextInput, Select, Checkbox, Radio, Switchcards - Card, DataCard, ContentCardoverlays - Modal, Toast, Alert, Drawerlayout - Box, Stack, Dividertypography - Text, Headingicons - Iconnavigation - Tabs, Breadcrumb@default tags*BaseProps and *Props type (e.g., ButtonBaseProps, ButtonProps)testID prop on root element for every componentDesign tokens are defined in packages/common/src/core/theme.ts:
Colors use a spectrum system with hue + step notation:
Semantic tokens map to spectrum colors and adapt to light/dark mode:
fgPrimary: blue60 (light) / blue70 (dark)bgPrimary: blue60 (light) / blue70 (dark)bgNegative: red60 (both modes)bgPositive: green60 (both modes)space: {
'0': 0, // 0px
'0.25': 2, // 2px
'0.5': 4, // 4px
'0.75': 6, // 6px
'1': 8, // 8px - base unit
'1.5': 12, // 12px
'2': 16, // 16px
'3': 24, // 24px
'4': 32, // 32px
'5': 40, // 40px
// ... up to 10 (80px)
}
*Component/Default* naming:
NavigationComponent = DefaultCarouselNavigation,
PaginationComponent = DefaultCarouselPagination,
classNames.pagination, styles.pagination).Benefits:
use*Context() hooks that throw descriptive errors on misuse:
export const useCarouselContext = () => {
const context = useContext(CarouselContext);
if (!context) throw new Error('useCarouselContext must be used within Carousel');
return context;
};
value but not onChange)const open = openProp ?? openInternal;type SelectComponent = <Type extends SelectType, Value extends string>(
props: SelectProps<Type, Value>,
) => React.ReactElement;
When a composite wraps inner Text and intercepts typography style props so they style the label (not the layout wrapper), intercept and forward the full set: font, fontFamily, fontSize, fontWeight, lineHeight, textTransform.
Reference: SegmentedTab and Tag.
Component modules encapsulate two prop Types: *BaseProps (platform-agnostic) and *Props (extends BaseProps with platform and component specific properties like className, classNames, styles, etc.)
Reuse other components' Types via utilities: Pick being preferred then secondarily Omit/Exclude
Compose prop types using Typescript intersections (&) in this order: (1) full types (2) Picks (3) Omits (4) other type literal(s):
type MyComponentProps = BoxBaseProps &
Pick<OtherComponentProps, 'someProp'> &
Omit<AnotherComponentProps, 'otherProp'> & {
propA: string;
propB: number;
};
When accepting components as props, define the contract types (*Props, *Component) in the main component file. These child component contracts do not use the *BaseProps pattern—only the main component needs BaseProps/Props separation. Default implementations can extend the contract with additional props in their own file:
// In MyComponent.tsx - defines the contract
type ChildProps = { id: string; label: ReactNode };
type ChildComponent = React.FC<ChildProps>;
// In DefaultChild.tsx - extends for default implementation
type DefaultChildProps = & <, > & ;