Skip to main content
skill CX Codex

vueuse-math-skilld — Claude Code skill: reactive math for Vue 3

vueuse-math-skilld — a skill for @vueuse/math composables in Vue 3: clamp, project, round, and aggregate reactive numbers.

MIT 119 installs ★ 186 updated 2026-10-10

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add skilld-dev/vue-ecosystem-skills --skill vueuse-math-skilld -a claude-code
Open on GitHub

What vueuse-math-skilld does

The skill gives the agent the API of @vueuse/math version 15.0.0, a set of composables for reactive math in Vue 3. It includes useClamp (writes to a mutable ref are clamped to range automatically), useProjection (linear mapping between domains for sliders and charts), usePrecision (rounding to decimal places with float drift protection), aggregations useSum, useAverage, useMin, useMax, and logic gates logicAnd, logicOr, logicNot.

Every composable accepts refs, getters or plain numbers as arguments and returns a ComputedRef<number> tracking every input. Requires Vue ^3.5.0 and Node.js >= 22; the package is ESM-only since v13. useAverage with an empty array yields NaN; useMax() and useMin() with no arguments resolve to -Infinity and Infinity.

Install with npx skills add skilld-dev/vue-ecosystem-skills --skill vueuse-math-skilld -a claude-code; the file lands in ~/.claude/skills/vueuse-math-skilld/SKILL.md.

What it helps with

  • clamp a reactive value to range with automatic clamping on write
  • project scroll or input onto another domain for progress bars
  • round a number to decimal places without float drift
  • aggregate multiple refs into sum, average, minimum or maximum
  • build a logical condition from reactive flags

Example prompts for the agent

  • Create a useClamp for volume in range 0–100 so assignments are clamped automatically
  • Make a projection of scrollY from [0, pageHeight] to [0, 100] with useProjection
  • Round price to two decimal places with usePrecision, rounding method ceil

How to install vueuse-math-skilld

1Skills CLI (Vercel)

npx skills add skilld-dev/vue-ecosystem-skills --skill vueuse-math-skilld -a claude-code

2Manually: put the files in place

~/.claude/skills/vueuse-math-skilld/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/vueuse-math-skilld/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about vueuse-math-skilld

How to install vueuse-math-skilld in Claude Code?

Run npx skills add skilld-dev/vue-ecosystem-skills --skill vueuse-math-skilld -a claude-code; the skill will appear in ~/.claude/skills/vueuse-math-skilld/SKILL.md.

What does vueuse-math-skilld do?

It gives the agent the description of @vueuse/math composables for reactive math in Vue 3: clamping, projection, rounding, aggregation and logic operations over refs.

Which Vue and Node.js versions does @vueuse/math require?

It requires Vue ^3.5.0 and Node.js >= 22. The library is ESM-only since version 13; CommonJS is not supported.

Source text

SKILL.md · MIT
---
name: vueuse-math-skilld
description: Math composables for Vue 3 from @vueuse/math. Use when writing or debugging code that imports "@vueuse/math", or when clamping, projecting, rounding, averaging, summing, or combining reactive numbers in Vue.
license: MIT
---

# @vueuse/math 15.0.0

Reactive math for Vue 3. Every composable resolves inputs with `toValue` inside a `computed`, so arguments accept plain numbers, refs, or getters (`MaybeRefOrGetter<number>`), and the result is a `ComputedRef<number>` that tracks every input (`dist/index.js:70-71`). The one exception: `useClamp` with a mutable ref returns a writable computed (`dist/index.d.ts:83`).

## Environment

- Install: `npm i @vueuse/math @vueuse/core` (`README.md:10`). `@vueuse/core` is needed only when combining with core functions such as `whenever`.
- Vue `^3.5.0` peer dependency (`package.json:42`), minimum since v14.
- Node.js `>= 22` (`package.json:39`); v15 dropped Node.js 20 ([release](https://github.com/vueuse/vueuse/releases/tag/v15.0.0)).
- ESM-only since v13: `"type": "module"`, no CommonJS build (`package.json:3`; [release](https://github.com/vueuse/vueuse/releases/tag/v13.0.0)). Use dynamic `import()` if a CJS context must load it.
- `"sideEffects": false` (`package.json:24`): unused composables tree shake away.
- Runtime dependency: `@vueuse/[email protected]` (`package.json:45`), which supplies `clamp` and `reactify`.
- Entry `dist/index.js`, types `dist/index.d.ts` (`package.json:30,34`).

## Exports

From `dist/index.d.ts:167`:

- Functions: `createGenericProjection`, `createProjection`, `logicAnd`, `logicNot`, `logicOr`, `useAbs`, `useAverage`, `useCeil`, `useClamp`, `useFloor`, `useMath`, `useMax`, `useMin`, `usePrecision`, `useProjection`, `useRound`, `useSum`, `useTrunc`
- Types: `ProjectorFunction`, `UseProjection`, `UseMathKeys`, `UseMathReturn`, `UsePrecisionOptions`
- Deprecated aliases: `and`, `or`, `not` (`dist/index.d.ts:20-21,32-33,44-45`)

Signatures, behavior notes, and per-function examples: [references/api.md](./references/api.md). Version-specific changes: [references/migrations.md](./references/migrations.md).

## Common tasks

Writable clamped state; pass a mutable ref so assignments are clamped automatically:

```ts
import { useClamp } from '@vueuse/math'

const level = ref(0)
const clamped = useClamp(level, 0, 10)
clamped.value = 15 // clamped.value and level.value are 10
```

Read-only clamp; pass a getter or readonly ref (`dist/index.js:113`):

```ts
const ratio = useClamp(() => raw.value / total.value, 0, 1)
```

Aggregate fixed refs with rest arguments instead of building an array (`dist/index.d.ts:154-155`):

```ts
const total = useSum(refA, refB, refC)
const peak = useMax(refA, refB, refC)
```

Map a value between domains, for sliders, charts, or progress UIs:

```ts
const progress = useProjection(scrollY, [0, pageHeight], [0, 100])
```

Reuse one projection across components; domains may be reactive:

```ts
const toPercent = createProjection(domain, [0, 100])
const a = toPercent(inputA)
```

Round to decimal places and keep a `number`, not the string `toFixed` returns:

```ts
const price = usePrecision(ref(3.1415), 2) // 3.14
const up = usePrecision(ref(3.1415), 2, { math: 'ceil' }) // 3.15
```

Combine boolean flags reactively, then feed side effects to `whenever` from `@vueuse/core`:

```ts
import { whenever } from '@vueuse/core'
import { logicAnd } from '@vueuse/math'

whenever(logicAnd(ready, hasData), run)
```

## Rules and pitfalls

- Never use the aliases `and`, `or`, `not`; deprecated since v14 in favor of `logicAnd`, `logicOr`, `logicNot` (`dist/index.d.ts:20,32,44`; [release](https://github.com/vueuse/vueuse/releases/tag/v14.0.0)).
- `useAverage` divides by `array.length` with no empty check: empty input yields `NaN` (`dist/index.js:91-96`). Guard the empty case yourself.
- `useMax()` with no inputs resolves to `-Infinity` and `useMin()` to `Infinity`, because both spread into `Math.max` / `Math.min` (`dist/index.js:157-176`).
- Aggregations (`useSum`, `useAverage`, `useMin`, `useMax`) accept refs, getters, numbers, arrays of those, and flatten nested arrays one level via `toValueArgsFlat` (`dist/index.js:75-81`).
- `usePrecision` avoids float drift by scaling through the decimal string of the value (`accurateMultiply`, `dist/index.js:187-193`); `options.math` defaults to `'round'` (`dist/index.d.ts:122`).
- `useMath` accepts only `Math` keys that are functions, such as `'pow'` or `'sqrt'`, never constants like `PI` (`dist/index.d.ts:96`).
- Projection is linear by default: `(input - from[0]) / (from[1] - from[0]) * (to[1] - to[0]) + to[0]` (`dist/index.js:12-14`). For non-linear mapping (log scales, easing), pass a custom `projector`, or use `createGenericProjection` for non-number domains (`dist/index.d.ts:4-6`).
- Prefer these composables over `computed(() => Math.x(...))` in templates and watchers; they centralize the `Math` call, stay reactive to every argument, and carry `@__NO_SIDE_EFFECTS__` annotations for tree shaking (`dist/index.js:4,15,111`).

© skilld-dev · MIT · skilld-dev/vue-ecosystem-skills

Similar skills

All skills for Frontend and UI →

From the same set32

The whole set →
vueuse-motion-skilld vueuse-motion-skilld guides coding agents through @vueuse/motion v3 APIs in Vue 3 and Nuxt 3, preventing runtime bugs with SSR, timing units, and imports. CX Codex +1 141installs vueuse-shared-skilld vueuse-shared-skilld — a skill that brings @vueuse/shared v15.0.0 API reference into Claude Code, Cursor, and other editors. Covers reactive utilities: debounce, throttle, watch variants, state sharing, and ref synchronization for Vue 3. CX Codex +1 137installs tanstack-vue-virtual-skilld The tanstack-vue-virtual-skilld skill guides Vue work with @tanstack/vue-virtual, from implementing virtual lists to debugging adapter usage. It also covers window scrolling and chat feeds anchored at the end. CX Codex +1 129installs tanstack-vue-form-skilld tanstack-vue-form-skilld guides agents through writing, reviewing, and debugging Vue forms built with @tanstack/vue-form and its current API. CX Codex +1 125installs floating-ui-vue-skilld floating-ui-vue-skilld guides AI coding agents on anchoring tooltips, popovers, and menus using @floating-ui/vue 2.0.1 in Vue 3.3+. CX Codex +1 119installs vue-data-ui-skilld The vue-data-ui-skilld skill guides agents working with the vue-data-ui Vue 3 chart library, from component selection and theming to SSR and debugging. CX Codex +1 118installs unovis-vue-skilld unovis-vue-skilld is a Claude Code skill for building and debugging Vue 3 code with @unovis/vue, including chart work and migration to API 1.7.0. CX Codex +1 112installs vitepress-skilld vitepress-skilld supplies API specs, config references, and CLI instructions for VitePress 1.6.4. CX Codex +1 110installs

Project sponsors

Companies that keep this analytics open