cds-code

作者: coinbase

在每个会话中,技能激活后仅执行以下操作一次。

npx skills add https://github.com/coinbase/cds --skill cds-code

CDS Code Skill

On every request

Before responding, determine what the user needs:

Coding — the user wants to create or update UI → follow the Coding Workflow.

Review — the user explicitly asks to audit, review, or check existing code for CDS adherence → read guidelines/code-review.md and follow it instead.

Default to coding. Only treat a request as a review if the user's intent is explicit. Writing code is the primary use case for this skill.

Initialization

Run this once per session, before doing anything else.

Run the discovery script: scripts/discover-cds-packages.sh

Its output tells you:

  • The CDS Runtime (web or mobile) — use this value as the platform argument for the CDS MCP server if it is needed.
  • Every installed CDS package: its name, version, and valid export subpaths — these import paths are the ONLY ALLOWED PATHS when importing from CDS packages

If the script cannot be run, much of the information it provides can be determined via manual inspection:

  • Infer the platform by inspecting existing CDS imports in the project's source code
  • Find valid import paths by reading the exports field of the package.json of installed CDS packages in node_modules

Coding Workflow

For all frontend coding tasks, follow these steps in order.

YOU MUST perform steps 1 and 2 before writing any code!

Step 1: Prepare CDS documentation

For any CDS documentation needs, use either of the following tools. If neither are available, let the user know but continue — documentation is helpful but not required.

  • Activate the cds-docs skill OR...
  • If the cds-docs skill is not configured, try calling the CDS MCP server list-cds-routes tool.

Then read the platform-specific docs (using the runtime detected in Initialization):

  • getting-started/styling
  • getting-started/theming

Step 2: Identify the appropriate components

Use guidelines/components.md to help identify the appropriate CDS components for the task. The guidelines file will cover most use cases, but you may optionally browse the CDS docs for the full list of supported CDS components.

If you decide your task will require icons (Icon or IconButton) or illustrations (SpotSquare, Pictogram, HeroSquare, etc.) please read the corresponding guidelines files for more details.

IconsIllustrations
guidelines/icons.mdguidelines/illustrations.md

If no CDS component fits your use case, you may fall back to the following options in this order of priority:

  1. search for a relevant and reusable React component from the project's codebase to use
  2. build your own custom React component using CDS primitives as building blocks
  3. use the native platform's JSX elements (div, View, etc.) for bespoke UI as a last resort

IMPORTANT: Always inform the user which CDS components you are planning to use before moving on to Step 3.

Step 3: Optionally read component docs

For any CDS component you plan to use, retrieve and read their documentation (see Step 1 in this workflow for more details on docs setup).

If documentation is not retrievable for any reason, the published type definitions for the component may be used to determine the full props API a component affords. This is no substitute for reading the documentation, but it can be a useful fallback when documentation is not available.

Step 4: Execute the task (writing code)

Now create or update the UI with proper CDS components and usage.

Package scope

The package name may vary between projects. Different repos may install CDS under different scopes. Always match the full CDS package name(s) as determined in the initialization step. If the project already has CDS imports in existing code, match whatever scope those files use.

Using the Design System

In most cases, you should avoid using inline style objects or CSS classNames (web only). Through these methods it is very easy to make common mistakes like using hardcoded property values instead of the CDS design tokens. Doing so would break the component's connection to the CDS theme.

If you must use a style object or a CSS className, you can still access the CDS theme either through the useTheme hook or by CSS variables (web only).

Most CDS components implement an API that conveniently allows you to apply CDS design tokens, internally we call these 'style props'.

In cds-web, style props essentially act as an API for applying atomic CSS classes, much like Tailwind's utility classes which are so prevelant in the web ecosystem.

You should prefer setting these style props for styling components over setting custom style via inline styles or CSS.

Why this matters: When you set font, color, textAlign, or other typography properties through style instead of props, the component loses its connection to the CDS theme. For example, setting fontSize and fontWeight via style without a font prop means the CDS font family never applies -- the text falls back to inherit and may render in the wrong typeface.

You should check a component's documentation which includes a props table to verify the available API.

Examples of opportunities to use style props over inline styles:

Instead of styleUse the prop
style={{ color: "var(--color-fgMuted)" }}color="fgMuted"
style={{ fontSize: 12, fontWeight: 500, lineHeight: "16px" }}font="caption" (or the matching CDS font token)
style={{ textAlign: "center" }}textAlign="center"
style={{ textTransform: "uppercase" }}textTransform="uppercase"
style={{ display: "flex", flexDirection: "column" }}Use VStack, or flexDirection="column" on Box
style={{ gap: 8 }}gap={1}
style={{ padding: 16 }}padding={2}
style={{ backgroundColor: "..." }}background="bgAlternate" (or semantic token)

Step 5: Validate changes

Your task will be complete if:

  1. You performed skill initialization and explicitly identified the specific CDS components you would use
  2. Your changes DO NOT include any raw rgb/hex/etc color values
  3. Your changes DO NOT use any raw pixel values for spacing properties (padding, margin, gap, border radius). Explicit layout dimensions like width or height set to specific designer-specified values are acceptable.
  4. Your changes DO NOT import any depreacted CDS components or hooks.
  5. Your changes use components' style props (e.g. font, color, background, textTransform, paddingX, gap) instead of customization via inline style objects or with CSS classNames.
  6. All import paths are valid CDS package exports, determined in initialization
  7. The project's linting/typechecking/formatting tasks are passing

来自 coinbase 的更多技能

authenticate-wallet
coinbase
基于邮箱OTP的钱包认证,包含验证与状态检查。两步登录流程:通过邮箱发起请求获取6位数字OTP,随后使用flowId和验证码完成认证。在执行命令前,对邮箱、flowId和OTP进行输入验证规则检查,防止shell注入。提供状态检查、余额查询、地址获取及通过配套CLI命令访问钱包窗口。所有命令支持--json输出,便于机器读取...
official
fund
coinbase
通过Coinbase Onramp或直接转账将USDC存入钱包。打开配套界面,用户可选择预设金额(10美元、20美元、50美元)或自定义数值,并选择Apple Pay、借记卡、银行转账或Coinbase账户充值。支持多种支付方式,结算时间不同:卡和Apple Pay即时到账,ACH银行转账需1-3天。资金以USDC形式存入Base网络;用户也可通过npx [email protected]...直接将USDC发送至钱包地址。
official
monetize-service
coinbase
部署一个付费API端点,其他代理可通过x402协议发现并支付。基于Base网络使用HTTP 402支付协议按请求收取USDC;客户端通过签名交易支付,无需API密钥或账户。声明发现扩展后自动将端点注册到x402 Bazaar供代理发现。支持多种定价层级、通配符路由及每个端点多个支付选项,使用Express中间件实现。基于@x402/express和@x402/core构建...
official
pay-for-service
coinbase
通过x402协议在Base上调用付费API,自动完成USDC支付。执行HTTP请求(GET、POST等)到支持x402的端点,自动处理原子级USDC支付。支持通过方法、JSON体、查询参数和自定义标头定制请求。包含支付控制:设置每次请求的最大USDC金额,并通过关联ID对相关操作进行分组。需要钱包认证和足够的USDC余额;验证所有用户输入以防止shell...
official
query-blockchain-data
coinbase
通过x402使用CDP SQL API查询Base上的链上区块链数据。当你或你的用户想要查看关于已解码区块的链上信息时使用…
official
query-onchain-data
coinbase
使用SQL在Base上查询链上数据,每次查询通过x402支付。通过CoinbaseQL(基于ClickHouse的SQL方言,支持连接、CTE、子查询和标准函数)访问解码后的事件、交易和区块。提供三个主要表:base.events(解码的智能合约日志)、base.transactions(完整交易数据)和base.blocks(区块元数据)。在事件查询中需对索引字段(event_signature、address、block_timestamp)进行过滤,以避免全表扫描...
official
search-for-service
coinbase
搜索并发现x402集市市场上可用的付费API服务。通过BM25相关性搜索查询市场,列出所有可用资源,或检查特定端点以查看定价和支付要求(无需付费)。支持按网络(base、base-sepolia)和输出格式(人类可读或JSON)进行过滤。结果本地缓存,每12小时自动刷新;所有搜索或发现操作无需认证。当无其他可用选项时作为备用方案使用。
official
send-usdc
coinbase
在Base上将USDC转账至以太坊地址或ENS名称。支持十六进制地址(0x...)和ENS名称(.eth)作为收款方,并自动解析ENS。支持灵活金额格式:美元符号($5.00)、小数(1.50)或原子单位(1000000)。发送前需通过authenticate-wallet技能进行钱包认证,并确保USDC余额充足。包含输入验证以防止shell注入,并提供可选的JSON输出以支持程序化使用。
official