coinbase/cds

jetpack-best-practices

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.

ソースを見る
リポジトリの原文

見出し、例、コード、表、リンク、参照画像を含む原文を表示しています。

Jetpack Compose API guidelines

references/compose-api-guidelines.md is the official AOSP Compose API guidelines document, vendored verbatim. Read it before writing or reviewing a Compose API. It is the authority here; do not invent house style that contradicts it, and do not paraphrase it from memory.

How the requirement levels apply to us

The document assigns different requirement levels to different audiences. CDS Android is "Library development based on Jetpack Compose" — we publish @Composable functions and supporting types for other teams to consume. Read the MUST/SHOULD/MAY markers for that audience, not the app-development ones. In practice we hold close to the framework-development bar, because anything we ship publicly is expensive to change later.

The rules that come up most in this codebase

These are the ones worth checking on every change. The document explains each in full.

  • Every element accepts and respects a `Modifier` parameter. It is the first optional

parameter, defaults to Modifier, is applied to the outermost layout node the element emits, and is used exactly once. Never accept a Modifier and drop it.

  • Composables that emit UI return `Unit` and are named as PascalCase nouns (Button,

SlideButton) — they declare a piece of UI rather than performing an action.

  • Hoist state. Prefer stateless composables taking a value plus an onValueChange callback

over ones that own their state internally.

  • `CompositionLocal` is for cross-cutting context, not for passing parameters. In this

codebase that means theme. A local should have a sensible default and should not be how a caller configures a specific component.

  • Parameter order: required parameters, then modifier, then other optional parameters, then a

trailing @Composable content lambda if there is one.

  • Default values belong in the signature, so callers can see them and override any one of them

independently.

Boundary rules specific to CDS Android

Complementary to the guidelines, not covered by them. packages/cds-android/AGENTS.md is the full version:

  • :cds compiles with Kotlin explicit API mode. Every public declaration is a customer promise —

make it a decision, not a compiler-satisfying reflex, and default to internal.

  • Read tokens through CdsTheme.colors / CdsTheme.space; author themes with cdsTheme { }.

LocalCdsTheme is public only so custom Modifier nodes can read theme outside composition.

  • Never widen a declaration's visibility just to make apps/android-app compile.

Related reading

The separate component API guidelines go deeper on designing individual components (slots, state holders, styling). Not vendored here; consult it when designing a new component from scratch.

同じリポジトリから

関連する Skills

すべての Skills
coinbase
公式

cds-code

Provides a workflow for building and reviewing high-quality React and React Native UI with the Coinbase Design System (CDS). Use this skill to create UI or make visual changes to existing UI with CDS components, tokens, style props, icons, and illustrations. Use it for explicit CDS-adherence audits and reviews, not non-visual logic, data, analytics, navigation, tests, generated code, or refactoring. Examples: "build this screen", "fix spacing on this component", "replace this UI with CDS components", "perform a CDS audit on our changes", "check our codebase for CDS adherence", "does this feature use CDS well?"

導入数
1
GitHub Stars
500
更新日
9月3日
coinbase
公式

cds-docs

Retrieve Coinbase Design System (CDS) documentation: setup, installation, theming, tokens, and per-component APIs/examples. Use this skill whenever the task involves CDS components, design-system rules, theming, or choosing between web and mobile CDS packages, even if the user only says "use CDS" or names a component. Always start from the docs route index, then fetch only the pages you need to reason and implement correctly. Prefer the CDS MCP server (list-cds-routes, get-cds-doc); if MCP is unavailable, use curl against https://cds.coinbase.com/llms/....

導入数
1
GitHub Stars
500
更新日
9月3日
coinbase
公式

components.styles

Guidelines writing styles API (styles, classNames, and static classNames) for a CDS component. Use this skill when adding customization options to a React component via styles or classNames props or when needing to update the docsite with component styles documentation.

導入数
1
GitHub Stars
500
更新日
9月3日
coinbase
公式

dev.cds-mobile

USE THIS when asked to work on a new or existing (MOBILE) CDS React component in packages/mobile

導入数
1
GitHub Stars
500
更新日
9月3日