CR

create-adaptable-composable

This guide helps build reusable composables by normalizing inputs with toValue and toRef for predictable reactivity.

Install

mkdir -p .claude/skills/create-adaptable-composable && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3805" && unzip -o skill.zip -d .claude/skills/create-adaptable-composable && rm skill.zip

Installs to .claude/skills/create-adaptable-composable

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Create a library-grade Vue composable that accepts maybe-reactive inputs (MaybeRef / MaybeRefOrGetter) so callers can pass a plain value, ref, or getter. Normalize inputs with toValue()/toRef() inside reactive effects (watch/watchEffect) to keep behavior predictable and reactive. Use this skill when user asks for creating adaptable or reusable composables.
358 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Accept reactive and non-reactive inputs
  • Normalize inputs using toValue and toRef
  • Implement core logic using Vue reactivity APIs
  • Support MaybeRef and MaybeRefOrGetter types

How it works

It uses type utilities to accept various input forms and normalizes them within reactive effects to ensure consistent behavior regardless of the input type.

Inputs & outputs

You give it
MaybeRef or MaybeRefOrGetter input parameters
You get back
A reusable, library-grade Vue composable

When to use create-adaptable-composable

  • Building library-grade composables
  • Normalizing reactive component inputs
  • Optimizing Vue 3 reactivity

About this skill

Create Adaptable Composable

Adaptable composables are reusable functions that can accept both reactive and non-reactive inputs. This allows developers to use the composable in a variety of contexts without worrying about the reactivity of the inputs.

Steps to design an adaptable composable in Vue.js:

  1. Confirm the composable's purpose and API design and expected inputs/outputs.
  2. Identify inputs params that should be reactive (MaybeRef / MaybeRefOrGetter).
  3. Use toValue() or toRef() to normalize inputs inside reactive effects.
  4. Implement the core logic of the composable using Vue's reactivity APIs.

Core Type Concepts

Type Utilities

/**
 * value or writable ref (value/ref/shallowRef/writable computed)
 */
export type MaybeRef<T = any> = T | Ref<T> | ShallowRef<T> | WritableComputedRef<T>;

/**
 * MaybeRef<T> + ComputedRef<T> + () => T
 */
export type MaybeRefOrGetter<T = any> = MaybeRef<T> | ComputedRef<T> | (() => T);

Policy and Rules

  • Read-only, computed-friendly input: use MaybeRefOrGetter
  • Needs to be writable / two-way input: use MaybeRef
  • Parameter might be a function value (callback/predicate/comparator): do not use MaybeRefOrGetter, or you may accidentally invoke it as a getter.
  • DOM/Element targets: if you want computed/derived targets, use MaybeRefOrGetter.

When MaybeRefOrGetter or MaybeRef is used:

  • resolve reactive value using toRef() (e.g. watcher source)
  • resolve non-reactive value using toValue()

Examples

Adaptable useDocumentTitle Composable: read-only title parameter

import { watch, toRef } from 'vue'
import type { MaybeRefOrGetter } from 'vue'

export function useDocumentTitle(title: MaybeRefOrGetter<string>) {
  watch(toRef(title), (t) => {
    document.title = t
  }, { immediate: true })
}

Adaptable useCounter Composable: two-way writable count parameter

import { watch, toRef } from 'vue'
import type { MaybeRef } from 'vue'

function useCounter(count: MaybeRef<number>) {
  const countRef = toRef(count)
  function add() {
    countRef.value++
  }
  return { add }
}

When not to use it

  • When parameters are intended to be functions like callbacks or predicates

Prerequisites

Vue 3 or Nuxt 3 project

Limitations

  • Requires careful handling of function-based parameters to avoid accidental execution

How it compares

This approach creates composables that are more flexible for consumers by handling plain values, refs, and getters uniformly.

Compared to similar skills

create-adaptable-composable side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
create-adaptable-composable (this skill)16moNo flagsAdvanced
vitepress56moNo flagsBeginner
ai-model-web12moReviewIntermediate
moai-domain-frontend13moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

vitepress

antfu

VitePress static site generator powered by Vite and Vue. Use when building documentation sites, configuring themes, or writing Markdown with Vue components.

56

ai-model-web

TencentCloudBase

Use this skill when developing browser/Web applications (React/Vue/Angular, static websites, SPAs) that need AI capabilities. Features text generation (generateText) and streaming (streamText) via @cloudbase/js-sdk. Built-in models include Hunyuan (hunyuan-2.0-instruct-20251111 recommended) and DeepSeek (deepseek-v3.2 recommended). NOT for Node.js backend (use ai-model-nodejs), WeChat Mini Program (use ai-model-wechat), or image generation (Node SDK only).

13

moai-domain-frontend

modu-ai

Frontend development specialist covering React 19, Next.js 16, Vue 3.5, and modern UI/UX patterns with component architecture. Use when building web UIs, implementing components, optimizing frontend performance, or integrating state management.

13

vueuse-functions

antfu

Apply VueUse composables where appropriate to build concise, maintainable Vue.js / Nuxt features.

11

perf-web-optimization

tech-leads-club

Optimize web performance: Core Web Vitals (LCP, CLS, INP), bundle size, images, caching. Use when site is slow, optimizing for Lighthouse scores, reducing bundle size, fixing layout shifts, or improving Time to Interactive. Triggers on: web performance, Core Web Vitals, LCP, CLS, INP, FID, bundle size, page speed, slow site.

10

rdc-setup

reactive

Install and set up @data-client/react or @data-client/vue in a project. Detects project type (NextJS, Expo, React Native, Vue, plain React) and protocol (REST, GraphQL, custom), then hands off to protocol-specific setup skills.

10

Search skills

Search the agent skills registry