Create a composable (useX)

VerifiedSafe

Create a reusable Vue composable (useX) with tests, following TrackGrowth conventions and Pinia vs composable distinction.

Sby Skills Guide Bot
DevelopmentIntermediate
8/6/2026
Claude CodeCursorWindsurfCopilotCodex
#vue#composable#pinia#trackgrowth

Recommended for

Automated summary

This skill creates a new Vue composable (useX) for the TrackGrowth app, following the project's conventions for file structure, testing, and the choice between composable and Pinia store.

Strengths

  • Enforces a clear folder and naming convention for each composable.
  • Guides the decision between a composable and a Pinia store based on shared state needs.
  • Recommends extracting pure business logic into src/utils to improve testability.
  • Requires unit tests and running yarn lint:fix.

Limitations

  • Specific to TrackGrowth project conventions, not directly reusable elsewhere.
  • Assumes existing knowledge of Vue 3 and VueUse.
  • Does not cover Pinia store creation, which is delegated to another skill.
When to use it

When the user asks to create a new composable (useX) for the TrackGrowth app.

When not to use it

When the logic requires shared state across unrelated components or belongs to a domain already covered by a Pinia store.

Security analysis

Safe
Quality score95/100

The skill provides structured guidance on creating composable files and running linting, with no indication of destructive commands, file exfiltration, or unsafe practices. It does not instruct the agent to execute arbitrary code beyond standard development tooling.

No concerns found

How this analysis is made

Examples

Criar useStreak
Criar novo composable useStreak para calcular a sequência de check-ins.
Criar useTheme
Create a new composable useTheme that persists a simple UI preference in localStorage using the key trackgrowth:theme.

name: new-composable description: Use this skill when the user asks to create a new composable (useX) for the TrackGrowth app — reusable reactive logic such as frequency evaluation, streak calculation, theme, or backup. Triggers on "criar composable", "novo composable", "new composable", "useX".

Criar novo composable

Segue as convenções documentadas em docs/context/06-file-structure-conventions.md e docs/context/05-architecture.md (divisão Pinia vs useStorage).

Passos

  1. Local do arquivo: pasta própria src/composables/useX/, nome em camelCase prefixado com use (ex: composables/useHabitFrequency/, composables/useStreak/), contendo:

    composables/
      useX/
        index.ts
        tests/
          useX.spec.ts
        models/          # opcional, só se houver tipos locais ao composable
    
  2. Antes de criar, decida se é realmente um composable ou deveria ser um store Pinia (use a skill /new-store nesse caso):

    • Composable: lógica reativa reutilizável sem necessidade de estado compartilhado entre componentes distantes na árvore, ou wrapper fino sobre useStorage do VueUse para uma preferência simples de UI (tema, filtro selecionado).
    • Store Pinia: dados de domínio que precisam ser acessados/mutados por múltiplos componentes não relacionados (hábitos, check-ins, tags, gamificação).
  3. Estrutura do index.ts:

    import { computed, ref } from "vue";
    
    export function useX() {
      const state = ref();
    
      const derived = computed(() => {
        // lógica derivada
      });
    
      function action() {
        // lógica de ação
      }
    
      return { state, derived, action };
    }
    
    • Se o composable envolve lógica de negócio pura (cálculo de streak, avaliação de FrequencyRule), extraia a função pura para src/utils/ (ex: frequency-evaluator.ts) e deixe o composable como uma casca reativa fina em cima dela — facilita testar a lógica isoladamente sem montar um componente Vue.
    • Se o composable precisa de tipos próprios além dos já definidos em src/types/, adicione-os lá, não inline no composable.
  4. Composables de preferência de UI (ex: useTheme): usar useStorage do VueUse diretamente, com uma chave de localStorage clara e namespaced (ex: trackgrowth:theme), para não colidir com as chaves usadas pelo pinia-plugin-persistedstate dos stores de domínio.

  5. Após criar index.ts, criar tests/useX.spec.ts cobrindo o estado/derivações/ações expostos — não é opcional. Depois, rode yarn lint:fix.

O que não fazer

  • Não crie um composable que só reexporta um store Pinia sem adicionar lógica — importe o store diretamente no componente nesse caso.
  • Não guarde dados de domínio (hábitos, check-ins) dentro de um composable com useStorage — isso é responsabilidade dos stores Pinia persistidos, que oferecem getters/ações compartilhados.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/create-a-composable-usex-msh3us5s/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/create-a-composable-usex-msh3us5s' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/create-a-composable-usex-msh3us5s/download' --output '.skill-downloads/create-a-composable-usex-msh3us5s/SKILL.md.part' && mv '.skill-downloads/create-a-composable-usex-msh3us5s/SKILL.md.part' '.skill-downloads/create-a-composable-usex-msh3us5s/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/create-a-composable-usex-msh3us5s/SKILL.md' && test -s '.skill-downloads/create-a-composable-usex-msh3us5s/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/new-composable' && cp -R '.skill-downloads/create-a-composable-usex-msh3us5s' '.claude/skills/new-composable'

Cursor
test -f '.skill-downloads/create-a-composable-usex-msh3us5s/SKILL.md' && test -s '.skill-downloads/create-a-composable-usex-msh3us5s/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/new-composable' && cp -R '.skill-downloads/create-a-composable-usex-msh3us5s' '.cursor/skills/new-composable'

Codex
test -f '.skill-downloads/create-a-composable-usex-msh3us5s/SKILL.md' && test -s '.skill-downloads/create-a-composable-usex-msh3us5s/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/new-composable' && cp -R '.skill-downloads/create-a-composable-usex-msh3us5s' '.agents/skills/new-composable'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/create-a-composable-usex-msh3us5s'

openskills read 'create-a-composable-usex-msh3us5s'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/create-a-composable-usex-msh3us5s/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills