Skip to content

refactor(cli): replace --compact/--brief with --detail flag - #634

Merged
cixzhang merged 2 commits into
mainfrom
navi/refactor/detail-flag
Mar 17, 2026
Merged

cixzhang merged 2 commits into
mainfrom
navi/refactor/detail-flag

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

Replaces the separate --compact, --brief, and --brief-all boolean flags with a single --detail <level> global option (full|compact|brief).

Why

Having both --compact and --brief as separate booleans was messy. --compact --brief was ambiguous, and --brief-all was a special case bolted on. We asked Claude Opus about this from three angles (OSS user UX, AI agent token efficiency, CLI design conventions) and the consensus was clear: mutually exclusive booleans are a code smell. A single enum flag is cleaner and scales better.

What changed

  • New global --detail <level> option (defaults to full)
  • Removed --compact, --brief, --brief-all per-command options
  • xds --detail brief component --list replaces the old --brief-all
  • Updated all docs, skill files, AGENTS.md, CLAUDE.md, vibe test scripts

Usage

xds component Button                        # full docs (default)
xds --detail compact component Button        # token-optimized
xds --detail brief component Button          # one-liner
xds --detail brief component --list          # brief catalog (replaces --brief-all)
xds --detail compact --lang dense component Button  # compact + compressed prose

All 197 tests pass.

Replace the separate --compact, --brief, and --brief-all boolean flags
with a single --detail <level> global option (full|compact|brief).

API decision informed by Claude Opus prompts asking about CLI design
patterns from three angles: OSS user UX, AI agent token efficiency,
and general CLI conventions. The consensus was that mutually exclusive
boolean flags are a code smell and a single enum flag is cleaner,
scales better, and avoids ambiguous --compact --brief combinations.

Changes:
- Add --detail <level> global option (defaults to 'full')
- Remove --compact, --brief, --brief-all per-command options
- xds --detail brief component --list replaces --brief-all
- Update all docs, skill files, AGENTS.md, CLAUDE.md, vibe test
  scripts to reference the new flag
- All 197 tests pass
@josephfarina
josephfarina requested a review from cixzhang as a code owner March 16, 2026 22:30
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 16, 2026
@github-actions

github-actions Bot commented Mar 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 9.4KB 15.2KB 2.4KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@josephfarina

Copy link
Copy Markdown
Contributor Author

Test plan

All 197 CLI tests pass. Manual verification of every combination:

Command Result
xds component Button ✅ Full docs
xds --detail full component Button ✅ Same as default
xds --detail compact component Button ✅ Token-optimized with import
xds --detail brief component Button ✅ One-liner signature
xds --detail compact --lang zh component Button ✅ Compact + Chinese prose
xds --detail compact --lang dense component Button ✅ Compact + compressed
xds --detail brief --lang dense component Button ✅ Brief + compressed
xds component --list ✅ Names by category
xds --detail brief component --list ✅ Brief summaries (replaces --brief-all)
xds --detail brief component --category Layout ✅ Brief summaries for category
xds component Button --props ✅ Props table only
xds component Button --source ✅ Source code
xds --zh component Button ✅ Legacy flag still works
xds --dense component Button ✅ Legacy flag still works
xds --detail banana component Button ✅ Error: invalid value
xds component Buton ✅ Fuzzy match suggestion
xds component Zzzzzz ✅ Not found error
xds --help ✅ Shows --detail in global options
xds component --help ✅ No --compact/--brief/--brief-all

@josephfarina

Copy link
Copy Markdown
Contributor Author

Test Plan — Manual Verification

All 197 CLI tests pass (npx vitest run packages/cli/).

Below is the actual output from every --detail + --lang combination.


xds component Button

# Button

XDSButton component with multiple variants, sizes, and isLoading state support.

## Features

- Variants: 'primary', 'secondary', 'ghost', 'destructive'
- Sizes: sm (28px), md (32px), lg (36px)
...(truncated)

xds --detail compact component Button

# Button

XDSButton component with multiple variants, sizes, and isLoading state support.

## Import

```tsx
import { XDSButton } from '@xds/core/Button';

Features

  • Variants: 'primary', 'secondary', 'ghost', 'destructive'
  • Sizes: sm (28px), md (32px), lg (36px)
  • Loading state: Shows spinner, disables interaction
  • Focus visible: Accessible focus outline with variant-specific colors
  • Hover/active states: Uses overlay colors via backgroundImage for consistent layering

Props

Prop Type Default Description
label string — Accessible label; used as aria-label for icon-only buttons. (required)
variant `'primary' 'secondary' 'ghost'
size `'sm' 'md' 'lg'`
isLoading boolean false Shows a loading spinner and disables interaction.
isDisabled boolean false Disables the button.
icon ReactNode — Icon element. When provided without children the button renders as a square icon-only button.
children ReactNode — Button content. When provided alongside icon, the text is rendered next to the icon.
endSlot `ReactElement ReactElement` —
tooltip string — Tooltip text shown on hover.
onClick (e: MouseEvent) => void — Standard click handler (passed through from ButtonHTMLAttributes).
onClickAction `(e: MouseEvent) => void Promise` —

Usage

Basic

<XDSButton label="Click me" variant="primary" />

With size

<XDSButton label="Large button" variant="primary" size="lg" />

Loading state

<XDSButton label="Saving..." variant="primary" isLoading />

Notes

  • XDSButtonVariant type is derived from the variants StyleX object using keyof typeof variants.
  • Hover/active states use backgroundImage with linear-gradient to layer overlay colors on top of the base background.
  • Destructive variant uses colorTokens.negative for its focus outline color.
  • endSlot is wrapped in a with color: inherit so icons/badges match the button text color across all variants.
  • When icon is provided without children, the button becomes icon-only: it renders as a perfect square (aspectRatio: 1/1), and label is used as aria-label (not rendered visually). Works with any ReactNode as the icon — SVG components, emoji, or text.
  • endSlot is ignored for icon-only buttons (when icon is provided without children) to preserve the square aspect ratio.
  • Prefer XDSButton over
    or for accessibility — it provides keyboard navigation, focus management, and screen reader support.
  • Icon-only buttons are suitable for toolbars, action grids, and compact controls.

### `xds --detail brief component Button`

XDSButton(variant: primary|secondary|ghost|destructive, size: sm|md|lg, endSlot: ReactElement|ReactElement, onClickAction: (e: MouseEvent) => void|Promise) ← from '@xds/core/Button'
XDSButton component with multiple variants, sizes, and isLoading state support.
label: string · isLoading · isDisabled · icon · children · tooltip · onClick


### `xds --detail compact --lang zh component Button`

Button

XDSButton 组件,支持多种变体、尺寸和加载状态。

Import

import { XDSButton } from '@xds/core/Button';

Features

  • 变体:'primary'、'secondary'、'ghost'、'destructive'
  • 尺寸:sm(28px)、md(32px)、lg(36px)
  • 加载状态:显示加载旋转器,禁用交互
  • 焦点可见:带有变体特定颜色的无障碍焦点轮廓
  • 悬停/激活状态:通过 backgroundImage 使用叠加颜色,实现一致的层级效果

Props

Prop Type Default Description
label string — 无障碍标签;纯图标按钮时用作 aria-label。 (required)
variant `'primary' 'secondary' 'ghost'
size `'sm' 'md' 'lg'`
isLoading boolean false 显示加载旋转器并禁用交互。
isDisabled boolean false 禁用按钮。
icon ReactNode — 图标元素。仅提供 icon 而不提供 children 时,按钮渲染为正方形的纯图标按钮。
children ReactNode — 按钮内容。与 icon 同时提供时,文本渲染在图标旁边。
endSlot `ReactElement ReactElement` —
tooltip string — 悬停时显示的提示文本。
onClick (e: MouseEvent) => void — 标准点击处理函数(从 ButtonHTMLAttributes 透传)。
onClickAction `(e: MouseEvent) => void Promise` —

Usage

基础用法

<XDSButton label="Click me" variant="primary" />

指定尺寸

<XDSButton label="Large button" variant="primary" size="lg" />

加载状态

<XDSButton label="Saving..." variant="primary" isLoading />

Notes

  • XDSButtonVariant 类型通过 keyof typeof variants 从 variants StyleX 对象派生。
  • 悬停/激活状态使用 backgroundImage 和 linear-gradient 在基础背景上叠加覆盖颜色。
  • destructive 变体使用 colorTokens.negative 作为焦点轮廓颜色。
  • endSlot 包裹在带有 color: inherit 的 中,使图标/徽章在所有变体中匹配按钮文本颜色。
  • 仅提供 icon 而不提供 children 时,按钮变为纯图标模式:渲染为正方形(aspectRatio: 1/1),label 用作 aria-label(不可视渲染)。支持任何 ReactNode 作为图标——SVG 组件、emoji 或文本。
  • 纯图标按钮(提供 icon 但不提供 children 时)会忽略 endSlot,以保持正方形的宽高比。
  • 为了无障碍性,优先使用 XDSButton 而非
    或 ——它提供键盘导航、焦点管理和屏幕阅读器支持。
  • 纯图标按钮适用于工具栏、操作网格和紧凑控件。

### `xds --detail compact --lang dense component Button`

Button

button w/ multiple variants, sizes, loading state

Import

import { XDSButton } from '@xds/core/Button';

Features

  • variants: primary, secondary, ghost, destructive
  • sizes: sm(28px), md(32px), lg(36px)
  • loading state: shows spinner+disables interaction
  • focus visible: accessible focus outline w/ variant-specific colors
  • hover/active: overlay colors via backgroundImage for consistent layering

Props

Prop Type Default Description
label string — accessible label; aria-label for icon-only buttons (required)
variant `'primary' 'secondary' 'ghost'
size `'sm' 'md' 'lg'`
isLoading boolean false shows spinner+disables interaction
isDisabled boolean false Disables the button.
icon ReactNode — icon element; w/o children renders square icon-only button
children ReactNode — w/ icon, text rendered next to icon
endSlot `ReactElement ReactElement` —
tooltip string — tooltip on hover
onClick (e: MouseEvent) => void — standard click handler
onClickAction `(e: MouseEvent) => void Promise` —

Usage

Basic

<XDSButton label="Click me" variant="primary" />

With size

<XDSButton label="Large button" variant="primary" size="lg" />

Loading state

<XDSButton label="Saving..." variant="primary" isLoading />

Notes

  • XDSButtonVariant derived from keyof typeof variants StyleX object
  • hover/active use backgroundImage linear-gradient overlay on base bg
  • destructive variant uses colorTokens.negative for focus outline
  • endSlot wrapped in w/ color:inherit, matches button text across variants
  • icon w/o children=icon-only: square (aspectRatio:1/1), label=aria-label, any ReactNode as icon
  • endSlot ignored for icon-only to preserve square ratio
  • prefer XDSButton over
    for a11y: keyboard nav, focus management, screen reader
  • icon-only suits toolbars, action grids, compact controls

### `xds --detail brief --lang dense component Button`

XDSButton(variant: primary|secondary|ghost|destructive, size: sm|md|lg, endSlot: ReactElement|ReactElement, onClickAction: (e: MouseEvent) => void|Promise) ← from '@xds/core/Button'
button w/ multiple variants, sizes, loading state
label: string · isLoading · isDisabled · icon · children · tooltip · onClick


### `xds component --list`

Layout:
AspectRatio
Center
Grid
GridSpan
HStack
Layout
LayoutContent
LayoutFooter
LayoutHeader
LayoutPanel
Stack
StackItem
VStack
...(truncated)


### `xds --detail brief component --list` (replaces --brief-all)

Layout

XDSAspectRatio ← from '@xds/core/AspectRatio'
Maintains a specific aspect ratio for its children.
children: ReactNode · ratio: number · xstyle
<XDSAspectRatio ratio={16 / 9}>

XDSCenter(axis: both|horizontal|vertical, width: number|string, height: number|string) ← from '@xds/core/Center'
Centers children horizontally and/or vertically using flexbox.
isInline · children · xstyle

XDSGrid(width: number|string, height: number|string) ← from '@xds/core/Grid'
Grid container with fixed or responsive auto-fit columns.
columns · minChildWidth · gap · rowGap · columnGap · align · justify · children · xstyle

XDSGridSpan ← from '@xds/core/Grid'
Source code for core UI components.

...(truncated)


### `xds --detail brief component --category Input`

...(truncated)


### `xds component Button --props`

Props

Prop Type Default Description
label string — Accessible label; used as aria-label for icon-only buttons. (required)
variant `'primary' 'secondary' 'ghost'
size `'sm' 'md' 'lg'`
isLoading boolean false Shows a loading spinner and disables interaction.
isDisabled boolean false Disables the button.
icon ReactNode — Icon element. When provided without children the button renders as a square icon-only button.
children ReactNode — Button content. When provided alongside icon, the text is rendered next to the icon.
endSlot `ReactElement ReactElement` —
tooltip string — Tooltip text shown on hover.
onClick (e: MouseEvent) => void — Standard click handler (passed through from ButtonHTMLAttributes).
onClickAction `(e: MouseEvent) => void Promise` —

### `xds --zh component Button` (legacy flag)

Button

XDSButton 组件,支持多种变体、尺寸和加载状态。

Features


### `xds --dense component Button` (legacy flag)

Button

button w/ multiple variants, sizes, loading state

Features


### `xds --detail banana component Button` (invalid value)

### `xds component Buton` (fuzzy match)

Component "Buton" not found. Did you mean one of these?

Button


### `xds --help`

Usage: xds [options] [command]

XDS design system CLI — components, themes, and tooling

Options:
-V, --version output the version number
--zh Output docs in Chinese Simplified
--dense Output docs in compressed dense format
(token-efficient)
--lang Output docs in specified language/format
(en, zh, dense)
--detail Output detail level (full, compact, brief)
(default: "full")
-h, --help display help for command

Commands:
init Interactive XDS initialization wizard
component [options] [name] List components or print component docs
docs [topic] Print XDS reference docs (principles,
tokens)
swizzle [options] [component] Copy component source for customization
agent-docs [options] Install/update XDS component index in
AGENTS.md (and CLAUDE.md if present)
template [options] [name] [path] Inject a page template
gap-report [options] Report a gap in the XDS design system
upgrade [options] Run codemods to migrate between XDS
versions
theme Theme tools — build, export, and manage XDS
themes
help Show all commands


### `xds component --help`

Usage: xds component [options] [name]

List components or print component docs

Options:
--list List all components grouped by category
--category List components in a specific category
--props Print only the props table
--source Print component source code
-h, --help display help for command

@cixzhang
cixzhang merged commit 4cf96f3 into main Mar 17, 2026
13 checks passed
@cixzhang
cixzhang deleted the navi/refactor/detail-flag branch March 20, 2026 16:59
cixzhang pushed a commit that referenced this pull request Apr 26, 2026
* refactor(cli): replace --compact/--brief with --detail flag

Replace the separate --compact, --brief, and --brief-all boolean flags
with a single --detail <level> global option (full|compact|brief).

API decision informed by Claude Opus prompts asking about CLI design
patterns from three angles: OSS user UX, AI agent token efficiency,
and general CLI conventions. The consensus was that mutually exclusive
boolean flags are a code smell and a single enum flag is cleaner,
scales better, and avoids ambiguous --compact --brief combinations.

Changes:
- Add --detail <level> global option (defaults to 'full')
- Remove --compact, --brief, --brief-all per-command options
- xds --detail brief component --list replaces --brief-all
- Update all docs, skill files, AGENTS.md, CLAUDE.md, vibe test
  scripts to reference the new flag
- All 197 tests pass

* fix(cli): validate --detail flag values

---------

Co-authored-by: Joey's Navi <[email protected]>
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
* refactor(cli): replace --compact/--brief with --detail flag

Replace the separate --compact, --brief, and --brief-all boolean flags
with a single --detail <level> global option (full|compact|brief).

API decision informed by Claude Opus prompts asking about CLI design
patterns from three angles: OSS user UX, AI agent token efficiency,
and general CLI conventions. The consensus was that mutually exclusive
boolean flags are a code smell and a single enum flag is cleaner,
scales better, and avoids ambiguous --compact --brief combinations.

Changes:
- Add --detail <level> global option (defaults to 'full')
- Remove --compact, --brief, --brief-all per-command options
- xds --detail brief component --list replaces --brief-all
- Update all docs, skill files, AGENTS.md, CLAUDE.md, vibe test
  scripts to reference the new flag
- All 197 tests pass

* fix(cli): validate --detail flag values

---------

Co-authored-by: Joey's Navi <[email protected]>
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
* refactor(cli): replace --compact/--brief with --detail flag

Replace the separate --compact, --brief, and --brief-all boolean flags
with a single --detail <level> global option (full|compact|brief).

API decision informed by Claude Opus prompts asking about CLI design
patterns from three angles: OSS user UX, AI agent token efficiency,
and general CLI conventions. The consensus was that mutually exclusive
boolean flags are a code smell and a single enum flag is cleaner,
scales better, and avoids ambiguous --compact --brief combinations.

Changes:
- Add --detail <level> global option (defaults to 'full')
- Remove --compact, --brief, --brief-all per-command options
- xds --detail brief component --list replaces --brief-all
- Update all docs, skill files, AGENTS.md, CLAUDE.md, vibe test
  scripts to reference the new flag
- All 197 tests pass

* fix(cli): validate --detail flag values

---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants