Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问clear审计未展示

formily-core-fundamentals牢固的核心基础

Agent Skill

formily-core-fundamentals 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

5,364

周安装

240

GitHub Stars

公开资料未说明

下载量

1,559
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:formily-core-fundamentals(牢固的核心基础)
来源仓库:https://github.com/whinc/my-claude-plugins
仓库路径:skills/formily-core-fundamentals
安装命令:
npx skills add whinc/my-claude-plugins --skill "formily-core-fundamentals"
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

AgentSkills.tonpx skills
npx skills add whinc/my-claude-plugins --skill "formily-core-fundamentals"

简介

formily-core-fundamentals 提供 Formily 核心概念与基础 API 检索服务。

  • 适用于需要理解 Schema 驱动、字段联动与表单状态管理的开发者。
  • 可通过关键词匹配教程、示例代码或常见问题解答。
  • 使用前应确认项目版本与 Formily 兼容性,避免 API 变更导致失效。
  • 建议结合官方文档验证输出内容,防止误导性建议。

SKILL.md

Formily Core Fundamentals

This skill provides essential guidance for using Formily as a React form solution. Focus on understanding core concepts, setting up Formily projects, and implementing basic forms with TypeScript.

Core Concepts Overview

Formily is a performant, flexible, and extensible form solution for React. It provides:

  • Schema-driven forms - Define forms through JSON schema
  • Path-based value management - Access nested form values via path strings
  • Powerful validation - Built-in validation with custom rules
  • Fine-grained reactivity - Efficient updates and minimal re-renders
  • TypeScript support - Full type safety for forms and validation

Installation and Setup

Install core Formily packages:

npm install @formily/core @formily/react @formily/validate

For TypeScript support, install types:

npm install -D @types/react @types/react-dom

Basic Form Implementation

Create a simple contact form to understand Formily fundamentals:

1. Define Form Schema

import { createForm } from '@formily/core'

const form = createForm({
  initialValues: {
    name: '',
    email: '',
    message: ''
  }
})

2. Connect Form to React

import { FormProvider, createField } from '@formily/react'

// In your component
const MyForm = () => {
  return (
    <FormProvider form={form}>
      {/* Form fields go here */}
    </FormProvider>
  )
}

3. Create Form Fields

import { Field } from '@formily/react'

const NameField = () => (
  <Field name="name">
    {(field, state) => (
      <div>
        <label>Name:</label>
        <input
          value={state.value || ''}
          onChange={e => field.onInput(e.target.value)}
        />
        {state.errors && <span>{state.errors}</span>}
      </div>
    )}
  </Field>
)

Form State Management

Formily manages form state through the form instance:

Accessing Form Values

// Get all form values
const values = form.values

// Get specific field value
const name = form.values.name

// Get nested values
const address = form.values.contact.address

Setting Form Values

// Set single field
form.setValues({
  name: 'John Doe'
})

// Set multiple fields
form.setValues({
  name: 'John Doe',
  email: 'john@example.com'
})

// Set nested values
form.setValues({
  'user.profile.name': 'John Doe'
})

Field State Management

// Access field state
const field = form.query('name')
const fieldValue = field.value
const fieldErrors = field.errors
const fieldTouched = field.touched

// Modify field state
form.setFieldState('name', state => {
  state.value = 'New value'
  state.errors = ['Error message']
})

Validation Basics

Formily provides built-in validation capabilities:

Schema Validation

import { createForm } from '@formily/core'

const form = createForm({
  schema: {
    type: 'object',
    properties: {
      name: {
        type: 'string',
        title: 'Name',
        required: true,
        'x-validator': [
          { required: true, message: 'Name is required' },
          { min: 2, message: 'Name must be at least 2 characters' }
        ]
      },
      email: {
        type: 'string',
        title: 'Email',
        format: 'email',
        'x-validator': [
          { format: 'email', message: 'Invalid email format' }
        ]
      }
    }
  }
})

Custom Validation Rules

import { createForm } from '@formily/core'

const form = createForm({
  validateFirst: true,
  effects() {
    onFieldChange('confirmPassword', ['value'], (field) => {
      const password = form.values.password
      const confirmPassword = field.value

      if (password !== confirmPassword) {
        field.errors = ['Passwords do not match']
      } else {
        field.errors = []
      }
    })
  }
})

Form Submission

Handle form submission with proper validation:

const handleSubmit = async () => {
  try {
    // Validate entire form
    await form.validate()

    // Get form values
    const values = form.values
    console.log('Form submitted:', values)

    // Reset form if needed
    form.reset()
  } catch (errors) {
    console.error('Validation errors:', errors)
  }
}

TypeScript Integration

Formily provides full TypeScript support:

Define Form Types

interface ContactForm {
  name: string
  email: string
  message: string
}

// Create typed form
const form = createForm<ContactForm>({
  initialValues: {
    name: '',
    email: '',
    message: ''
  }
})

// Access typed values
const name: string = form.values.name

Type-Safe Field Components

import { Field } from '@formily/react'

interface StringFieldProps {
  name: string
  label: string
  placeholder?: string
}

const StringField: React.FC<StringFieldProps> = ({ name, label, placeholder }) => (
  <Field name={name}>
    {(field, state) => (
      <div>
        <label>{label}:</label>
        <input
          value={state.value || ''}
          onChange={e => field.onInput(e.target.value)}
          placeholder={placeholder}
        />
        {state.errors && <span className="error">{state.errors[0]}</span>}
      </div>
    )}
  </Field>
)

Common Patterns

Conditional Fields

const form = createForm({
  effects() {
    onFieldChange('hasAccount', ['value'], (field) => {
      const hasAccount = field.value
      form.setFieldState('password', state => {
        state.visible = hasAccount
        if (!hasAccount) {
          state.value = ''
        }
      })
    })
  }
})

Dynamic Field Arrays

// Add item to array
form.pushValues('emails', '')

// Remove item from array
form.removeValues('emails.0')

// Insert item at specific position
form.insertValues('emails.1', 'new@email.com')

Performance Optimization

Minimize Re-renders

import { observer } from '@formily/reactive-react'

const OptimizedField = observer(({ name }: { name: string }) => (
  <Field name={name}>
    {(field, state) => (
      <input
        value={state.value || ''}
        onChange={e => field.onInput(e.target.value)}
      />
    )}
  </Field>
))

Batch Updates

// Batch multiple updates for better performance
form.batch(() => {
  form.setValues({ field1: 'value1' })
  form.setValues({ field2: 'value2' })
  form.setValues({ field3: 'value3' })
})

Error Handling

Global Error Handler

const form = createForm({
  effects() {
    onError((error) => {
      console.error('Form error:', error)
      // Handle global form errors
    })
  }
})

Field-Specific Error Handling

const form = createForm({
  effects() {
    onFieldError('email', (field, errors) => {
      if (errors.includes('Invalid format')) {
        // Show custom error UI
      }
    })
  }
})

Additional Resources

Reference Files

  • references/types-cheatsheet.md - Common TypeScript types and interfaces
  • references/validation-rules.md - Built-in validation rules reference

Example Files

  • examples/simple-contact-form.tsx - Complete working contact form example
  • examples/field-components.tsx - Reusable field component patterns

Common Formily Patterns

  • Use form.submit() for form submission with validation
  • Leverage form.reset() for clearing form state
  • Use form.setFieldState() for granular field control
  • Implement custom validators with x-validator or effects

Best Practices

  1. Always define TypeScript interfaces for your form schemas
  2. Use schema validation instead of manual validation when possible
  3. Leverage observer for performance-critical components
  4. Handle errors gracefully at both form and field levels
  5. Use batch operations for multiple state updates
  6. Create reusable field components to reduce code duplication
  7. Test validation thoroughly with edge cases and error scenarios

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

30.3%
按下载量换算472

windsurf

23.13%
按下载量换算361

trae

17.4%
按下载量换算271

OpenCode

11.5%
按下载量换算179

Codex

8.47%
按下载量换算132

Antigravity

3.75%
按下载量换算58

安全审计

暂无安全审计结果可展示。

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

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

来源信息

继续浏览同类 Skills