Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计通过

react-hook-authoring-fixReact hook authoring FIX 前端

Agent Skill

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

总安装

225

周安装

9

GitHub Stars

公开资料未说明

下载量

73
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/b4r7x/agent-skills --skill react-hook-authoring-fix

简介

用于修复和优化现有 React Hook 实现的技能。

  • 适用于解决无限重渲染、闭包陷阱等常见问题。
  • 提供性能分析和内存泄漏排查方法。react-hook-authoring-fix 属于前端设计类 Skill,可作为该场景下的辅助能力补充。
  • 通过 GitHub 安装,修改前应保留原始版本备查。
  • 建议在 CI 流程中加入 Hook 专项测试。

SKILL.md

React Hook Authoring Fix

Audits custom hooks using the react-hook-authoring skill principles and applies fixes.

Workflow

Step 1 — Resolve files

Parse the argument as file paths or glob patterns. If no argument is provided, ask:

"Which hook files should I audit? Pass file paths or glob patterns (e.g. registry/hooks/*.ts)."

Step 2 — Load principles

Read ../react-hook-authoring/SKILL.md for the decision tree and antipatterns. Read ../react-hook-authoring/references/approaches.md for Approach A/B details.

Step 3 — Audit each hook

For each file containing a custom hook (function starting with use and using React hooks internally):

  1. Read the file contents
  2. Check for each antipattern:
#CheckWhat to look for
1Premature useCallbackuseCallback where any dep is unstable (props callback, filtered array, new object) — the memoization achieves nothing
2Side effect in state updateronChange/callback invoked inside setState((prev) => {...}) — fires 2x in Strict Mode
3Ref-during-renderref.current = value in component body without useLayoutEffect — tearing risk. OK only if no "use client" (SSR constraint)
4Forcing consumer memoizationCallback from consumer in useEffect/useCallback deps — consumer must useCallback or hook misbehaves
5Overengineered patternMultiple refs + useCallback + useLayoutEffect when plain function (Approach A) would suffice. Look for: no context consumers, no measured perf issue, hook used in <5 places
6useMemo on primitivesuseMemo returning string/number/boolean — pointless, compared by value
7useCallback without memo on childFunction memoized but passed to non-memo() component
8Unstable context valueContext Provider without useMemo on value object — all consumers re-render on every parent render
9Missing Object.is checkonChange called without checking if value actually changed — unnecessary parent updates
  1. For each issue, record:

- Line number(s) - Check # (1-9) - Severity: high (bug/DX problem), medium (unnecessary complexity), low (style) - The offending code (1-5 lines) - Suggested approach (A or B, or specific fix)

Step 4 — Classify fixes

  • Auto-fixable (mechanical, safe):

- Remove useCallback with unstable deps → plain function (Check 1) - Remove useMemo on primitives (Check 6) - Add useMemo on context value object (Check 8)

  • Semi-auto (likely safe, brief explanation before applying):

- Move onChange out of state updater (Check 2) - Replace ref-during-render with useLayoutEffect (Check 3) - Simplify overengineered hook to Approach A (Check 5) - Add Object.is guard before onChange (Check 9)

  • Manual only (report, don't fix):

- Consumer memoization requirement (Check 4) — needs API change - useCallback without memo (Check 7) — needs consumer-side change - Switching from Approach B to A when context consumers exist — needs profiling

Step 5 — Apply fixes

Process fixes bottom-up within each file (highest line number first).

For auto-fixable: apply silently, record change. For semi-auto: state what changes and why, then apply. For manual: list in report only.

Step 6 — Output report

## Hook Authoring Audit Report

**Files audited:** N
**Issues found:** N (H high, M medium, L low)

---

### `path/to/hook.ts`

| Line | Severity | Check | Issue |
|------|----------|-------|-------|
| 23 | high | #2: Side effect in updater | `onChange?.(resolved)` inside `setInternal((prev) => ...)` |
| 40 | medium | #1: Premature useCallback | `useCallback([isControlled, onChange])` — onChange is unstable |

**Changes applied:**
- L23: Moved `onChange` call after `setInternal`
- L40: Replaced `useCallback` with plain function (Approach A)

**Manual review needed:**
- L67: Consumer must `useCallback` on `onFilter` prop or `useEffect` at L70 re-runs

---

### Summary

| Check | Count |
|-------|-------|
| 1. Premature useCallback | N |
| 2. Side effect in updater | N |
| ... | ... |

### Verify

Run type-check and tests to confirm nothing broke:
\`\`\`bash
pnpm type-check && pnpm test
\`\`\`

If zero issues found:

## Hook Authoring Audit Report

**Files audited:** N
**Issues found:** 0

Clean. No hook authoring issues detected.

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

展示第三方安全扫描或审计结果

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

平台分布

Codex

36.89%
按下载量换算27

Claude

30.87%
按下载量换算23

Cursor

18.47%
按下载量换算13

Gemini CLI

9.1%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

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

安装前确认

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

来源信息

继续浏览同类 Skills