Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计通过

ahooksahooks 搜索

Agent Skill

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

总安装

541

周安装

23

GitHub Stars

88

下载量

190
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/blockmatic/basilic --skill ahooks

简介

针对 React 状态管理的 ahooks v3+ 库提供专业使用指引与最佳实践。

  • 涵盖 useSetState、useLocalStorageState 等核心 hook 的正确应用场景。
  • 明确排除数据获取与 URL 状态管理职责,建议搭配 TanStack Query 使用。
  • 需确保运行环境为浏览器端,TypeScript 严格模式以启用完整类型推断。
  • ahooks 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Skill: ahooks

Scope

  • Applies to: ahooks v3+ utility hooks for React state management, grouped state updates, localStorage persistence
  • Does NOT cover: Data fetching (use TanStack Query), URL state management (use nuqs), complex state machines, async operations

Assumptions

  • ahooks v3+
  • React 18+ with hooks support
  • TypeScript v5+ (for type inference)
  • Client-side only (hooks require browser APIs for localStorage)

Principles

  • Use useSetState for grouped state that changes together (not URL-shareable)
  • Use useLocalStorageState for persistent state across browser sessions
  • Prefer nuqs for URL-shareable state over localStorage
  • Prefer TanStack Query for async operations and loading states
  • Use useState only for simple independent state (rare)

Constraints

MUST

  • Use useSetState for grouped state not in URL (form state, game engine state, ephemeral UI state)
  • Use useLocalStorageState for localStorage persistence

SHOULD

  • Prefer nuqs for URL-shareable state over localStorage
  • Prefer TanStack Query for async operations and loading states
  • Use TypeScript generics for type-safe state: useLocalStorageState<boolean>('key', {defaultValue: false})

AVOID

  • Using for URL state (use nuqs instead)
  • Using for loading/error states (use TanStack Query instead)
  • Using for complex async operations (use TanStack Query instead)
  • Mixing URL state with localStorage without explicit sync logic

Interactions

  • Complements nuqs for URL state management (can sync bidirectionally)
  • Complements TanStack Query for async operations (use TanStack Query for data fetching)
  • Part of state management decision tree (see React rules)
  • Works with React 18+ hooks architecture

Patterns

useSetState Pattern

Use for grouped state that updates together:

import { useSetState } from 'ahooks'

const [state, setState] = useSetState({
  name: '',
  email: '',
  age: 0,
})

// Partial updates (shallow merge)
setState({ name: 'John' })
setState(prev => ({ ...prev, email: 'john@example.com' }))

When to use: Form state, game engine state, UI state that changes together (if not URL-shareable)

When NOT to use: URL-shareable state (use nuqs), loading states (use TanStack Query)

useLocalStorageState Pattern

Use for state that persists across browser sessions:

import { useLocalStorageState } from 'ahooks'

const [value, setValue] = useLocalStorageState<boolean>('key', {
  defaultValue: false,
})

// Type-safe with generics
const [settings, setSettings] = useLocalStorageState<Settings>('settings', {
  defaultValue: { theme: 'light', fontSize: 14 },
})

When to use: User preferences, debug flags, settings that should persist across sessions

When NOT to use: URL-shareable state (use nuqs), sensitive data (use secure storage)

Integration with nuqs

Bidirectional sync between URL and localStorage:

import { useLocalStorageState } from 'ahooks'
import { useQueryState } from 'nuqs'
import { useEffect, useRef } from 'react'

const [queryState, setQueryState] = useQueryState('debug')
const [storageState, setStorageState] = useLocalStorageState<boolean>('debug', {
  defaultValue: false,
})
const isFirstMount = useRef(true)

// Sync on mount: localStorage → URL
useEffect(() => {
  if (isFirstMount.current) {
    isFirstMount.current = false
    if (storageState && queryState !== 'true') {
      setQueryState('true')
      return
    }
  }
  // Sync changes: URL → localStorage
  if (queryState === 'true' && !storageState) {
    setStorageState(true)
  } else if (queryState === 'false' && storageState) {
    setStorageState(false)
  }
}, [queryState, storageState, setQueryState, setStorageState])

Use case: Debug flags, feature toggles that should be both URL-shareable and persistent

State Management Decision Tree

  1. URL-shareable state → Use nuqs (filters, search, tabs, pagination)
  2. Grouped state not in URL → Use useSetState (form state, game engine, ephemeral UI)
  3. Async operations → Use TanStack Query (data fetching, mutations, caching)
  4. localStorage persistence → Use useLocalStorageState (preferences, settings)
  5. Simple independent state → Use useState (rare, prefer other options)

References

  • ahooks documentation - Official documentation
  • React rules - State management decision tree and patterns
  • TanStack Query - Async operations and data fetching patterns

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

35.59%
按下载量换算68

Claude

30.18%
按下载量换算57

Cursor

19.88%
按下载量换算38

Gemini CLI

9.52%
按下载量换算18

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

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

来源信息

继续浏览同类 Skills