Token导航 LogoToken导航

Agent Skill · 前端设计

migrate-frontend-forms(迁移前端表单)

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

migrate-frontend-forms 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 3,500。

总安装 1,294周安装 55GitHub Stars 43,678下载 453核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:migrate-frontend-forms(迁移前端表单)
来源仓库:https://github.com/getsentry/sentry
仓库路径:skills/migrate-frontend-forms
安装命令:
npx skills add https://github.com/getsentry/sentry --skill migrate-frontend-forms
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/getsentry/sentry --skill migrate-frontend-forms

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

用于辅助前端页面、组件、样式和交互逻辑的开发与维护,支持 React、Next.js、Vue 等框架。适合生成或审查前端代码,整理组件结构,定位布局和性能问题。需结合项目现有设计系统和构建方式使用,避免生成孤立片段。涉及页面改动时应配合本地预览和构建检查确认视觉效果。

migrate-frontend-forms 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/migrate-frontend-forms

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/getsentry/sentry --skill migrate-frontend-form…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

migrate-frontend-forms 怎么安装?

在终端执行 npx skills add https://github.com/getsentry/sentry --skill migrate-frontend-forms。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

migrate-frontend-forms 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

migrate-frontend-forms 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

migrate-frontend-forms 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

migrate-frontend-forms 用的人多吗?

公开数据是累计安装 1,294 次,近一周安装 55 次,下载 453 次,GitHub 43,678 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

migrate-frontend-forms 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。
  • 来源仓库有 43,678 星,维护活跃度相对可查。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
migrate-frontend-forms

迁移前端表单 · 本页

1,29443,678需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Form Migration Guide

This skill helps migrate forms from Sentry's legacy form system (JsonForm, FormModel) to the new TanStack-based system.

Feature Mapping

Old SystemNew SystemNotes
saveOnBlur: trueAutoSaveFormDefault behavior
confirmconfirm prop`string \((value) => string \undefined)`
showHelpInTooltipvariant="compact"On layout components
disabledReasondisabled="reason"String shows tooltip
extraHelpJSX in layoutRender <Text> below field
getDatamutationFnTransform data in mutation function
mapFormErrorssetFieldErrorsTransform API errors in catch block
saveMessageonSuccessShow toast in mutation onSuccess callback
formatMessageValueonSuccessControl toast content in onSuccess callback
resetOnErroronErrorCall form.reset() in mutation onError
saveOnBlur: falseuseScrapsFormUse regular form with explicit Save button
(automatic)form.reset()Call after successful mutation if form stays on page
helphintTextOn layout components
labellabelOn layout components
requiredrequiredOn layout + Zod schema

Feature Details

confirm → confirm prop

Old:

{
  name: 'require2FA',
  type: 'boolean',
  confirm: {
    true: 'Enable 2FA for all members?',
    false: 'Allow members without 2FA?',
  },
  isDangerous: true,
}

New:

<AutoSaveForm
  name="require2FA"
  confirm={value =>
    value
      ? 'Enable 2FA for all members?'
      : 'Allow members without 2FA?'
  }
  {...}
>

showHelpInTooltip → variant="compact"

Old:

{
  name: 'field',
  help: 'This is help text',
  showHelpInTooltip: true,
}

New:

<field.Layout.Row
  label="Field"
  hintText="This is help text"
  variant="compact"
>

disabledReason → disabled="reason"

Old:

{
  name: 'field',
  disabled: true,
  disabledReason: 'Requires Business plan',
}

New:

<field.Input
  disabled="Requires Business plan"
  {...}
/>

extraHelp → JSX

Old:

{
  name: 'sensitiveFields',
  help: 'Main help text',
  extraHelp: 'Note: These fields apply org-wide',
}

New:

<field.Layout.Stack label="Sensitive Fields" hintText="Main help text">
  <field.TextArea {...} />
  <Text size="sm" variant="muted">
    Note: These fields apply org-wide
  </Text>
</field.Layout.Stack>

getData → mutationFn

The getData function transformed field data before sending to the API. In the new system, handle this in the mutationFn.

Old:

// Wrap field value in 'options' key
{
  name: 'sentry:csp_ignored_sources_defaults',
  type: 'boolean',
  getData: data => ({options: data}),
}

// Or extract/transform specific fields
{
  name: 'slug',
  getData: (data: {slug?: string}) => ({slug: data.slug}),
}

New:

<AutoSaveForm
  name="sentry:csp_ignored_sources_defaults"
  schema={schema}
  initialValue={project.options['sentry:csp_ignored_sources_defaults']}
  mutationOptions={{
    mutationFn: data => {
      // Transform data before API call (equivalent to getData)
      const transformed = {options: data};
      return fetchMutation({
        url: `/projects/${organization.slug}/${project.slug}/`,
        method: 'PUT',
        data: transformed,
      });
    },
  }}
>
  {field => (
    <field.Layout.Row label="Use default ignored sources">
      <field.Switch checked={field.state.value} onChange={field.handleChange} />
    </field.Layout.Row>
  )}
</AutoSaveForm>

Simpler pattern - If you just need to wrap the value:

mutationOptions={{
  mutationFn: fieldData => {
    return fetchMutation({
      url: `/projects/${org}/${project}/`,
      method: 'PUT',
      data: {options: fieldData}, // getData equivalent
    });
  },
}}

Important: Typing mutations correctly

The mutationFn should be typed with the API's data type (e.g., Partial<Organization>, Partial<Project>), not the schema-inferred type. The schema is for client-side field validation only — the mutation receives whatever the API endpoint accepts. Tying the mutation to the schema couples two unrelated concerns and can cause type errors when the schema types don't exactly match the API types.

// ❌ Don't use generic types - breaks field type narrowing
mutationOptions={{
  mutationFn: (data: Record<string, unknown>) => {
    return fetchMutation({url: '/user/', method: 'PUT', data: {options: data}});
  },
}}

// ❌ Don't tie mutation type to the zod schema
mutationOptions={{
  mutationFn: (data: Partial<z.infer<typeof preferencesSchema>>) => {
    return fetchMutation({url: '/user/', method: 'PUT', data: {options: data}});
  },
}}

// ✅ Use the API's data type
mutationOptions={{
  mutationFn: (data: Partial<UserDetails>) => {
    return fetchMutation({url: '/user/', method: 'PUT', data: {options: data}});
  },
}}

Make sure the zod schema's types are compatible with (i.e., assignable to) the API type. For example, if the API expects a string union like 'off' | 'low' | 'high', use z.enum(['off', 'low', 'high']) instead of z.string().

mapFormErrors → setFieldErrors

The mapFormErrors function transformed API error responses into field-specific errors. In the new system, handle this in the catch block using setFieldErrors.

Old:

// Form-level error transformer
function mapMonitorFormErrors(responseJson?: any) {
  if (responseJson.config === undefined) {
    return responseJson;
  }
  // Flatten nested config errors to dot notation
  const {config, ...rest} = responseJson;
  const configErrors = Object.fromEntries(
    Object.entries(config).map(([key, value]) => [`config.${key}`, value])
  );
  return {...rest, ...configErrors};
}

<Form mapFormErrors={mapMonitorFormErrors} {...}>

New:

import {setFieldErrors} from '@sentry/scraps/form';

const form = useScrapsForm({
  ...defaultFormOptions,
  defaultValues: {...},
  validators: {onDynamic: schema},
  onSubmit: async ({value, formApi}) => {
    try {
      await mutation.mutateAsync(value);
    } catch (error) {
      // Transform API errors and set on fields (equivalent to mapFormErrors)
      const responseJson = error.responseJSON;
      if (responseJson?.config) {
        // Flatten nested errors to dot notation
        const {config, ...rest} = responseJson;
        const errors: Record<string, {message: string}> = {};

        for (const [key, value] of Object.entries(rest)) {
          errors[key] = {message: Array.isArray(value) ? value[0] : String(value)};
        }
        for (const [key, value] of Object.entries(config)) {
          errors[`config.${key}`] = {message: Array.isArray(value) ? value[0] : String(value)};
        }

        setFieldErrors(formApi, errors);
      }
    }
  },
});

Simpler pattern - For flat error responses:

onSubmit: async ({value, formApi}) => {
  try {
    await mutation.mutateAsync(value);
  } catch (error) {
    // API returns {email: ['Already taken'], username: ['Invalid']}
    const errors = error.responseJSON;
    if (errors) {
      setFieldErrors(formApi, {
        email: {message: errors.email?.[0]},
        username: {message: errors.username?.[0]},
      });
    }
  }
},
Note: setFieldErrors supports nested paths with dot notation: 'config.schedule': {message: 'Invalid schedule'}

saveMessage → onSuccess

The saveMessage showed a custom toast/alert after successful save. In the new system, handle this in the mutation's onSuccess callback.

Old:

{
  name: 'fingerprintingRules',
  saveOnBlur: false,
  saveMessageAlertVariant: 'info',
  saveMessage: t('Changing fingerprint rules will apply to future events only.'),
}

New:

import {addSuccessMessage} from 'sentry/actionCreators/indicator';

<AutoSaveForm
  name="fingerprintingRules"
  schema={schema}
  initialValue={project.fingerprintingRules}
  mutationOptions={{
    mutationFn: data => fetchMutation({...}),
    onSuccess: () => {
      // Custom success message (equivalent to saveMessage)
      addSuccessMessage(t('Changing fingerprint rules will apply to future events only.'));
    },
  }}
>

formatMessageValue → onSuccess

The formatMessageValue controlled how the changed value appeared in success toasts. Setting it to false disabled showing the value entirely (useful for large text fields). In the new system, you control this directly in onSuccess.

Old:

{
  name: 'fingerprintingRules',
  saveMessage: t('Rules updated'),
  formatMessageValue: false, // Don't show the (potentially huge) value in toast
}

New:

mutationOptions={{
  mutationFn: data => fetchMutation({...}),
  onSuccess: () => {
    // Just show the message, no value (equivalent to formatMessageValue: false)
    addSuccessMessage(t('Rules updated'));
  },
}}

// Or if you want to show a formatted value:
onSuccess: (data) => {
  addSuccessMessage(t('Slug changed to %s', data.slug));
},

resetOnError → onError

The resetOnError option reverted fields to their previous value when a save failed. In the new system, call form.reset() in the mutation's onError callback.

Old:

// Form-level reset on error
<Form resetOnError apiEndpoint="/auth/" {...}>

// Or field-level (BooleanField always resets on error)
<FormField resetOnError name="enabled" {...}>

New (with useScrapsForm):

const form = useScrapsForm({
  ...defaultFormOptions,
  defaultValues: {password: ''},
  validators: {onDynamic: schema},
  onSubmit: async ({value}) => {
    try {
      await mutation.mutateAsync(value);
    } catch (error) {
      // Reset form to previous values on error (equivalent to resetOnError)
      form.reset();
      throw error; // Re-throw if you want error handling to continue
    }
  },
});

New (with AutoSaveForm):

<AutoSaveForm
  name="enabled"
  schema={schema}
  initialValue={settings.enabled}
  mutationOptions={{
    mutationFn: data => fetchMutation({...}),
    onError: () => {
      // The field automatically shows error state via TanStack Query
      // If you need to reset the value, you can pass a reset callback
    },
  }}
>
Note: AutoSaveForm with TanStack Query already handles error states gracefully - the mutation's isError state is reflected in the UI. Manual reset is typically only needed for specific UX requirements like password fields.

Resetting After Save

When using useScrapsForm for a form that stays on the page after save, call form.reset() after a successful mutation. This re-syncs the form with updated defaultValues so it becomes pristine again — any UI that depends on the form being dirty (like conditionally shown Save/Cancel buttons) will update correctly.

onSubmit: ({value}) =>
  mutation
    .mutateAsync(value)
    .then(() => form.reset())
    .catch(() => {}),
Note: AutoSaveForm handles this automatically. You only need to add this when using useScrapsForm.

saveOnBlur: false → useScrapsForm

Fields with saveOnBlur: false showed an inline alert with Save/Cancel buttons instead of auto-saving. This was used for dangerous operations (slug changes) or large text edits (fingerprint rules).

In the new system, use a regular form with useScrapsForm and an explicit Save button. This preserves the UX of showing warnings before committing.

Old:

{
  name: 'slug',
  type: 'string',
  saveOnBlur: false,
  saveMessageAlertVariant: 'warning',
  saveMessage: t("Changing a project's slug can break your build scripts!"),
}

New:

import {Alert} from '@sentry/scraps/alert';
import {Button} from '@sentry/scraps/button';
import {defaultFormOptions, useScrapsForm} from '@sentry/scraps/form';

const slugSchema = z.object({
  slug: z.string().min(1, 'Slug is required'),
});

function SlugForm({project}: {project: Project}) {
  const mutation = useMutation({
    mutationFn: (data: {slug: string}) =>
      fetchMutation({url: `/projects/${org}/${project.slug}/`, method: 'PUT', data}),
  });

  const form = useScrapsForm({
    ...defaultFormOptions,
    defaultValues: {slug: project.slug},
    validators: {onDynamic: slugSchema},
    onSubmit: ({value}) => mutation.mutateAsync(value).catch(() => {}),
  });

  return (
    <form.AppForm form={form}>
      <form.AppField name="slug">
        {field => (
          <field.Layout.Stack label="Project Slug">
            <field.Input value={field.state.value} onChange={field.handleChange} />
          </field.Layout.Stack>
        )}
      </form.AppField>

      {/* Warning shown before saving (equivalent to saveMessage) */}
      <Alert variant="warning">
        {t("Changing a project's slug can break your build scripts!")}
      </Alert>

      <Flex gap="sm" justify="end">
        <Button onClick={() => form.reset()}>Cancel</Button>
        <form.SubmitButton>Save</form.SubmitButton>
      </Flex>
    </form.AppForm>
  );
}

When to use this pattern:

  • Dangerous operations where users should see a warning before committing (slug changes, security tokens)
  • Large multiline text fields where you want to finish editing before saving (fingerprint rules, filters)
  • Any field where auto-save doesn't make sense

Preserving Form Search Functionality

Sentry's SettingsSearch allows users to search for individual settings fields. When migrating forms, you must preserve this searchability by wrapping migrated forms with FormSearch.

The FormSearch Component

FormSearch is a build-time marker component — it has zero runtime behavior and simply renders its children unchanged. Its route prop is read by a static extraction script to associate form fields with their navigation route, enabling them to appear in SettingsSearch results.

import {FormSearch} from 'sentry/components/core/form';

<FormSearch route="/settings/account/details/">
  <FieldGroup title={t('Account Details')}>
    <AutoSaveForm name="name" schema={schema} initialValue={user.name} mutationOptions={...}>
      {field => (
        <field.Layout.Row label={t('Name')} hintText={t('Your full name')} required>
          <field.Input />
        </field.Layout.Row>
      )}
    </AutoSaveForm>
  </FieldGroup>
</FormSearch>

Props:

PropTypeDescription
routestringThe settings route for this form (e.g., '/settings/account/details/'). Used for search navigation.
childrenReactNodeThe form content — rendered unchanged at runtime.

Rules:

  • The route must match the settings page URL exactly (including trailing slash).
  • Wrap the entire form section with a single FormSearch, not individual fields.
  • Every <AutoSaveForm> or <form.AppField> inside a FormSearch will be indexed. Make sure label and hintText are plain string literals or t() calls — computed/dynamic strings will be skipped by the extractor.

The Form Field Registry

After adding or updating FormSearch wrappers, regenerate the field registry so that search results stay up to date:

pnpm run extract-form-fields

This script (scripts/extractFormFields.ts) scans all TSX files, finds <FormSearch> components, extracts field metadata (name, label, hintText, route), and writes the generated registry to static/app/components/core/form/generatedFieldRegistry.ts. Commit this generated file alongside your migration PR — it is part of the source tree.

Run the command after any change to forms inside a FormSearch wrapper (adds, removals, label changes). The generated file is checked in and should not be edited manually.

Migration: Old Forms Already Searchable

If the legacy JsonForm being migrated was already indexed by SettingsSearch (i.e., it had entries in sentry/data/forms), you must add a FormSearch wrapper to the new form so search functionality is preserved. The old and new sources coexist — new registry entries take precedence over old ones for the same route + field combination — but once you remove the legacy form the old entries will disappear.

Handling Nullable Initial Values

Legacy select fields often started with an empty/undefined value and required a selection. In the new system, use .nullable().refine() in the schema, type defaultValues with z.input<typeof schema>, and call schema.parse(value) in onSubmit.

Old:

{
  name: 'provider',
  type: 'select',
  required: true,
  choices: [['github', 'GitHub'], ['launchdarkly', 'LaunchDarkly']],
}

New:

const schema = z.object({
  provider: z
    .enum(['github', 'launchdarkly'])
    .nullable()
    .refine(v => v !== null, 'Provider is required'),
});

// z.input accepts null; z.output (after refine) does not
const defaultValues: z.input<typeof schema> = {
  provider: null,
};

const form = useScrapsForm({
  ...defaultFormOptions,
  defaultValues,
  validators: {onDynamic: schema},
  onSubmit: ({value}) => {
    // schema.parse narrows null away — mutation receives z.output
    return mutation.mutateAsync(schema.parse(value)).catch(() => {});
  },
});

This pattern is necessary whenever a required field has no meaningful initial value. The z.input / z.output distinction ensures the form accepts null as default while the mutation receives the validated, non-null type.

Intentionally Not Migrated

FeatureUsageReason
allowUndo3 formsUndo in toasts adds complexity with minimal benefit. Use simple error toasts instead.

Migration Checklist

  • Replace JsonForm/FormModel with useScrapsForm or AutoSaveForm
  • Convert field config objects to JSX AppField components
  • Replace help → hintText on layouts
  • Replace showHelpInTooltip → variant="compact"
  • Replace disabledReason → disabled="reason string"
  • Replace extraHelp → additional JSX in layout
  • Convert confirm object to function: (value) => message | undefined
  • Handle getData in mutationFn
  • Handle mapFormErrors with setFieldErrors in catch
  • Handle saveMessage in onSuccess callback
  • Convert saveOnBlur: false fields to regular forms with Save button
  • Call form.reset() after successful mutation (for forms that stay on page)
  • Verify onSuccess cache updates merge with existing data (use updater function) — some API endpoints may return partial objects
  • Wrap the migrated form with <FormSearch route="..."> if the old form was searchable in SettingsSearch
  • Run pnpm run extract-form-fields and commit the updated generatedFieldRegistry.ts

平台分布

Codex

35.94%
按下载量换算163

Claude

28.59%
按下载量换算130

Cursor

16.96%
按下载量换算77

Gemini CLI

9.12%
按下载量换算41

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills