install
source · Clone the upstream repo
git clone https://github.com/Intense-Visions/harness-engineering
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/Intense-Visions/harness-engineering "$T" && mkdir -p ~/.claude/skills && cp -r "$T/agents/skills/codex/vue-composables-pattern" ~/.claude/skills/intense-visions-harness-engineering-vue-composables-pattern-8ae36f && rm -rf "$T"
manifest:
agents/skills/codex/vue-composables-pattern/SKILL.mdsource content
Vue Composables Pattern
Extract and reuse stateful logic across components using Vue composables
When to Use
- Multiple components share the same stateful logic (e.g., window size tracking, API fetching, form validation)
- You want to extract complex logic out of a component's
for readability and reuse<script setup> - Replacing Vue 2 mixins with a more explicit, composable approach
Instructions
- Create a function prefixed with
(e.g.,use
,useWindowSize
).useFetch - Inside, use
,ref
,reactive
,computed
, and lifecycle hooks as needed.watch - Return only what consumers need — keep internal state private.
- Co-locate composable files with their primary consumer or place in a
directory.composables/
// composables/useWindowSize.ts import { ref, onMounted, onUnmounted } from 'vue'; export function useWindowSize() { const width = ref(window.innerWidth); const height = ref(window.innerHeight); function update() { width.value = window.innerWidth; height.value = window.innerHeight; } onMounted(() => window.addEventListener('resize', update)); onUnmounted(() => window.removeEventListener('resize', update)); return { width, height }; }
- Composables can accept parameters (refs or plain values) for configuration.
- Return cleanup functions or use lifecycle hooks to handle side-effect teardown.
Details
Composables are the Vue 3 Composition API's answer to code reuse. They replace mixins, which suffered from namespace collisions, implicit dependencies, and unclear data sources. A composable is a plain function that uses Vue's reactivity primitives, making dependencies explicit.
Trade-offs:
- Composables must be called during
— they cannot be used conditionally or in loops (similar to React hooks rules)setup() - Deeply nested composable calls can make the dependency chain hard to trace
- Over-extracting into composables can fragment logic that is easier to understand inline
When NOT to use:
- For stateless utility functions — just export a plain function, no need for Vue reactivity
- When the logic is used by only one component — inline it in
until reuse is needed<script setup> - For global state — use Pinia stores instead of a composable with module-level state
Source
https://patterns.dev/vue/composables-pattern
Process
- Read the instructions and examples in this document.
- Apply the patterns to your implementation, adapting to your specific context.
- Verify your implementation against the details and edge cases listed above.
Harness Integration
- Type: knowledge — this skill is a reference document, not a procedural workflow.
- No tools or state — consumed as context by other skills and agents.
Success Criteria
- The patterns described in this document are applied correctly in the implementation.
- Edge cases and anti-patterns listed in this document are avoided.