
Create Adaptable Composable
Design Vue 3 composables that accept plain values, refs, or getters so one API works across components and agent-generated UI code.
Overview
Create Adaptable Composable is an agent skill for the Build phase that teaches library-grade Vue composables using MaybeRef and MaybeRefOrGetter with toValue/toRef normalization.
Install
npx skills add https://github.com/hyf0/vue-skills --skill create-adaptable-composableWhat is this skill?
- 4-step flow: confirm API, mark reactive params, normalize with toValue/toRef, implement with watch/watchEffect
- Supports MaybeRef and MaybeRefOrGetter so callers pass value, ref, shallowRef, writable computed, or getter
- Library-grade guidance aligned with Vue 3.5+ / Nuxt 3+ reactivity APIs
- Predictable behavior inside reactive effects by normalizing inputs at effect boundaries
- MIT-licensed vuejs-ai skill (metadata version 17.0.0)
- 4-step composable design procedure
Adoption & trust: 1.9k installs on skills.sh; 2.5k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your agent keeps generating composables that only work with refs and break when callers pass plain values or getters.
Who is it for?
Solo builders extracting shared reactive logic in Vue 3 / Nuxt 3 apps before publishing internal or open composable utilities.
Skip if: One-off composables with fixed ref-only inputs, non-Vue stacks, or teams that already enforce a mature internal composable standard without agent assistance.
When should I use this skill?
User asks for creating adaptable or reusable Vue composables that accept maybe-reactive inputs (MaybeRef / MaybeRefOrGetter).
What do I get? / Deliverables
You get a consistent composable API design with normalized reactive inputs and predictable watch/watchEffect behavior across Vue 3 or Nuxt 3 projects.
- Composable implementation using toValue/toRef normalization
- Typed public params with MaybeRef / MaybeRefOrGetter
Recommended Skills
Journey fit
How it compares
Use for Vue-specific composable contracts instead of generic React hook or plain TypeScript helper patterns.
Common Questions / FAQ
Who is create-adaptable-composable for?
Indie and solo frontend developers (and their agents) building Vue 3 or Nuxt 3 products who want reusable composables that accept flexible reactive inputs.
When should I use create-adaptable-composable?
During Build frontend work when you ask to create adaptable, reusable, or library-grade composables, or when normalizing MaybeRef / MaybeRefOrGetter parameters before wiring core logic.
Is create-adaptable-composable safe to install?
It is documentation-style procedural guidance (MIT); review the Security Audits panel on this Prism page before adding any third-party skill repo to your agent.
SKILL.md
READMESKILL.md - Create Adaptable Composable
# 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 ```ts /** * 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 ```ts 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 ```ts 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 } } ```