← 返回 Skills 市场
Form Handling
作者
Bovin Phang
· GitHub ↗
· v2.5.0
· MIT-0
38
总下载
0
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install fec-form-handling
功能描述
Use when building or reviewing substantial forms with React Hook Form, Zod schemas, typed validation, dynamic fields, controlled third-party inputs, file upl...
使用说明 (SKILL.md)
表单处理
Purpose
管理表单状态、校验和提交,避免复杂表单输入卡顿。
Procedure
- 先判断复杂度:10+ 字段、动态字段、联动校验、文件上传、多步流程或输入卡顿时使用 React Hook Form + Zod;极简表单可用原生受控组件。
- 用 Zod 定义运行时 schema,并用
z.infer推导 TypeScript 类型;schema 是外部输入边界,不要只写 TS 类型。 useForm必须提供defaultValues,通过zodResolver统一校验;错误提示用aria-invalid、aria-describedby和role="alert"。- 第三方受控组件用
Controller,原生 input 优先register;不要混用两套状态源。 - 提交时处理 loading、服务端错误、重复提交和 reset;大型表单用局部订阅和子组件隔离控制重渲染。
Quick Start
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
const loginSchema = z.object({
email: z.string().email("请输入有效的邮箱地址"),
password: z.string().min(8, "密码至少 8 个字符"),
});
type LoginForm = z.infer\x3Ctypeof loginSchema>;
export function LoginFormView() {
const {
register,
handleSubmit,
formState: { errors, isSubmitting },
} = useForm\x3CLoginForm>({
resolver: zodResolver(loginSchema),
defaultValues: { email: "", password: "" },
});
return (
\x3Cform onSubmit={handleSubmit((data) => api.login(data))} noValidate>
\x3Clabel htmlFor="email">邮箱\x3C/label>
\x3Cinput id="email" {...register("email")} aria-invalid={!!errors.email} />
{errors.email && \x3Cspan role="alert">{errors.email.message}\x3C/span>}
\x3Clabel htmlFor="password">密码\x3C/label>
\x3Cinput id="password" type="password" {...register("password")} />
{errors.password && \x3Cspan role="alert">{errors.password.message}\x3C/span>}
\x3Cbutton disabled={isSubmitting}>
{isSubmitting ? "提交中..." : "提交"}
\x3C/button>
\x3C/form>
);
}
Detailed References
涉及 Controller、useFieldArray、联动校验、文件上传、多步表单、异步校验和性能模式时,加载 references/advanced-form-patterns.md。
Constraints
- React Hook Form 默认非受控;只有第三方受控组件才用
Controller。 defaultValues必须完整,避免 undefined 触发受控/非受控警告。reset()应传服务器返回或明确的完整默认对象。- 异步校验必须 debounce 或放到提交边界,避免每次键入请求。
- Zod
refine/superRefine的path必须指向实际字段。
Expected Output
产出类型安全、可访问、提交状态明确的表单;复杂字段和文件上传有 schema 约束,输入过程无明显卡顿,服务端错误能回填到用户可理解的位置。
安全使用建议
Reasonable to install if you want help with complex form design or review. Be aware it may activate for ordinary form-related frontend requests, so check that it is relevant before following its guidance.
能力评估
Purpose & Capability
The stated purpose is helping build or review substantial forms, and the supplied evidence shows no unrelated high-impact capabilities, credential handling, destructive actions, or exfiltration behavior.
Instruction Scope
The activation wording is broad enough to trigger on many frontend form tasks, but that is a scoping and usability concern rather than evidence of unsafe behavior.
Install Mechanism
No supplied artifact or scan evidence indicates postinstall execution, hidden setup commands, dependency abuse, or automatic runtime behavior.
Credentials
No evidence indicates access to local files, sessions, credentials, network services, private profiles, or other sensitive environment resources.
Persistence & Privilege
No evidence indicates persistence, background workers, privilege escalation, scheduled execution, or mutation of agent configuration.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install fec-form-handling - 安装完成后,直接呼叫该 Skill 的名称或使用
/fec-form-handling触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v2.5.0
- Major documentation update: SKILL.md expanded with clear purpose, procedure, quick start example, detailed constraints, and advanced references.
- Clarifies scenarios for using React Hook Form and Zod, especially for substantial forms or performance needs.
- Provides best practices for typed validation, accessibility, error handling, and state management.
- Includes a code sample for rapid onboarding and typical form setup.
- Outlines expected outcomes for complex form handling and common pitfalls to avoid.
元数据
常见问题
Form Handling 是什么?
Use when building or reviewing substantial forms with React Hook Form, Zod schemas, typed validation, dynamic fields, controlled third-party inputs, file upl... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 38 次。
如何安装 Form Handling?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install fec-form-handling」即可一键安装,无需额外配置。
Form Handling 是免费的吗?
是的,Form Handling 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Form Handling 支持哪些平台?
Form Handling 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Form Handling?
由 Bovin Phang(@bovinphang)开发并维护,当前版本 v2.5.0。
推荐 Skills