add-settings-page
GitHub用于添加新的设置页面或审计现有页面以符合设计系统规范。涵盖导航注册、模块接入、SettingsPanel 构建及状态保存逻辑,确保 UI 一致性。
触发场景
安装
npx skills add simstudioai/sim --skill add-settings-page -g -y
SKILL.md
Frontmatter
{
"name": "add-settings-page",
"description": "Add a new Sim settings page, or audit existing settings pages for design-system compliance with the shared SettingsPanel layout. Use when creating a settings tab, or when asked to check\/clean up settings pages so they match the design system (consistent title, header, search, spacing)."
}
Settings Page (add / audit)
Settings page chrome (header bar, scroll region, content column, nav-driven
title + description) is owned by the settings/[section]/layout.tsx shell. Each
page renders through SettingsPanel, which registers the page's header data
(actions, search, back) with that shell and renders only the body. The full
convention lives in .claude/rules/sim-settings-pages.md — read it first; this
skill is the procedure.
Key paths:
- Chrome shell:
apps/sim/app/workspace/[workspaceId]/settings/[section]/layout.tsx(SettingsHeaderShell) SettingsPanelregistrar:apps/sim/components/settings/settings-panel.tsx- Nav metadata (titles + descriptions):
apps/sim/components/settings/navigation.ts - Section switch + provider:
apps/sim/app/workspace/[workspaceId]/settings/[section]/settings.tsx - Pages:
apps/sim/app/workspace/[workspaceId]/settings/components/<name>/<name>.tsxand EE pages underapps/sim/ee/<feature>/components/
Mode A — Add a new settings page
- Navigation. In
navigation.ts: add the id toUnifiedSettingsSection, then aSETTINGS_SECTION_REGISTRYentry withlabel,icon, andunified: { id, description, group, order }(description verb-first, ~40–55 chars, product voice per.claude/rules/constitution.md). Set gating flags (requiresHosted,requiresEnterprise, …) onunified, and addplanesonly if the section also exists on a standalone plane. - Wire the switch. Register the module in
SECTION_MODULES(settings/section-warmers.ts), then addconst X = dynamic(() => SECTION_MODULES.x().then((m) => m.X))and its case in theeffectiveSectionswitch insettings/[section]/settings.tsx. - Build the body inside
SettingsPanelper the rule's canonical page shape:actions,search,children, modal siblings in a fragment. - If the page has editable state, wire the shared save/discard stack exactly as in
.claude/rules/sim-settings-pages.md"Save / Discard + unsaved-changes guard" (saveDiscardActions(),useSettingsUnsavedGuardbefore any early return). - Verify: the local gate in the root
CLAUDE.md("How your work is checked").
Mode B — Audit existing settings pages
For each page component, confirm the checklist in .claude/rules/sim-settings-pages.md:
Each grep lists candidates; review every match against the expected ones named below.
- Find hand-rolled shells that should be
SettingsPanel:git grep -n "flex h-full flex-col bg-\[var(--bg)\]" -- 'apps/sim/**/settings/**' 'apps/sim/ee/'— expected matches: the workspace and organizationsettings/layout.tsxshells and the shared header shell (components/settings/settings-header.tsx); an entitlement/loading gate is also fine.CredentialDetailLayout(thesettings/secrets/[credentialId]exception) is an exempt hand-rolled shell outside these pathspecs. A detail sub-view is never a match: it passesback={{ text, icon: ArrowLeft, onSelect }}toSettingsPanel. Anything else is a violation: render it throughSettingsPanel. - Find hand-rolled title blocks:
git grep -n "text-\[var(--text-body)\] text-lg" -- 'apps/sim/**/settings/**' 'apps/sim/ee/'— the only title is the<h1>insettings-header.tsx; a non-heading value at that size (e.g. the credit balance inee/organization-usage/components/usage-credits.tsx) is fine. - Find literal pixel text sizes (should be 0 — see "Text Scale" in
.claude/rules/sim-styling.md):git grep -nE "text-\[1[0-8]px\]" -- 'apps/sim/**/settings/**' 'apps/sim/ee/'. Display type above the scale (text-[40px]hero headings) is deliberate and out of scope. - Confirm each page imports
SettingsPaneland that its registry entry has an accuratedescriptionof consistent length with its peers.- Editable pages: confirm Save/Discard go through
saveDiscardActions()and dirty is wired viauseSettingsUnsavedGuard(called before early-return gates) — flag any hand-rolled Save button,beforeunload, or unsaved modal.git grep -n "beforeunload" -- 'apps/sim/**/settings/**' 'apps/sim/ee/' 'apps/sim/components/settings/' ':(exclude,glob)**/*.test.*'should only hit the centralizeduse-settings-browser-navigation.ts.
- Editable pages: confirm Save/Discard go through
- Fix each finding with the smallest structural change that satisfies the checklist;
do not touch handlers, state, queries, or gate returns. A pixel-size fix swaps
only the size class for its exact-pixel token (
text-[12px]→text-caption). - Verify the whole sweep: the local gate in the root
CLAUDE.md, plus the affected pages' tests. Diff each file against the base and confirm the change is purely structural before shipping.
Mode C — Migrate list rows to SettingsResourceRow
Read "The resource row" in .claude/rules/sim-settings-pages.md first — it is the
contract. Then, per page:
- Find hand-rolled rows:
git grep -n "truncate text-\[var(--text-body)\] text-sm" -- 'apps/sim/app/workspace/' 'apps/sim/ee/'Every match outsidesettings-resource-row.tsxis either a row to migrate or a genuinely different shape (multi-line body, tabular columns, a grid) that stays bespoke — decide which, and say so. - Convert the row and its wrapper per "The resource row" (props,
trailingvsbadge, bleed,navigable/clickLabel). Unlike Mode B, this conversion may change conditional rendering (a permission gate becomesonClick={can ? … : undefined}+navigable={can}); verify the gated state has no clickable affordance left. - Check what the hand-rolled row rendered beside the title (a badge, a timestamp, a
transport label). The row's title truncates as one unit, so anything folded
into it can be ellipsised away — move it to
descriptionorbadge. - Verify: the local gate, the page's tests, and a diff read of
every converted block for lost props, conditions, and
keyplacement.
版本历史
-
c6cef5f
当前 2026-10-20 02:37
更新导航注册流程:从使用 SettingsSection union 改为 UnifiedSettingsSection 和 SETTINGS_SECTION_REGISTRY;增加 SECTION_MODULES 动态加载机制;优化保存/丢弃状态逻辑。
- 8725250 2026-09-28 17:00


