Skip to main content

Claude Prompt to Build a Vue 3 Composition API Feature

Scaffold a complete Vue 3 Composition API feature: composables, a Pinia store module, TypeScript interfaces and Vitest unit tests, following Vue best practices.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt scaffolds a complete, production-ready Vue 3 feature using the Composition API with TypeScript. You name the [feature_name], spell out [feature_requirements], and set your [styling_approach], [api_pattern], [persist_state], and [test_count], and it generates a coordinated set of files: a composable, a Pinia store, the component, TypeScript interfaces, and Vitest unit tests.

The structure works because it pins the output to modern Vue conventions instead of leaving them to chance. By requiring <script setup>, typed return objects (not tuples), defineProps/defineEmits, and adherence to the Vue Style Guide's Priority A and B rules, the generated code lands close to how an experienced Vue developer would hand-write it — which makes review fast. The [feature_requirements] field drives the actual behavior, while [persist_state] and [test_count] control the persistence plugin and how thoroughly the tests cover happy path, error states, and edge cases.

When to use it

  • You're building a new Vue 3 feature and want a full slice — composable, store, types, tests — in one pass.
  • You want to enforce <script setup> and Composition API patterns across a team's output.
  • You need typed Pinia stores with $reset() support and optimistic updates as a starting point.
  • You're adding a feature that needs [persist_state] for some data (like user preferences) but not others.
  • You want Vitest tests scaffolded alongside the code so coverage isn't an afterthought.
  • You're onboarding to a Vue codebase and want idiomatic reference code that follows the Style Guide.

Example output

You get five coordinated files: a use<FeatureName>.ts composable with reactive state, computed properties, watchers, and typed returns; a [feature_name]Store.ts Pinia store with CRUD actions, getters, and $reset(); a <FeatureName>.vue component using <script setup lang="ts"> with proper props, emits, and scoped styles in your [styling_approach]; a types/[feature_name].ts file with DTOs and union types; and a spec file with at least [test_count] Vitest cases plus integration notes for routing and i18n.

Pro tips

  • Make [feature_requirements] detailed and behavioral — the richer the requirements, the more complete the composable and component logic.
  • Set [test_count] to a realistic floor; bump it up if your feature has many error and edge-case branches.
  • Use [persist_state] to distinguish what belongs in localStorage (preferences) from transient data (live lists).
  • Match [styling_approach] to your real setup so the scoped styles don't need rewriting.
  • Specify your [api_pattern] precisely; the composable's loading and error handling is generated around it.
  • Review the generated tests for genuine assertions — regenerate or extend any that only check that something rendered.

Frequently Asked Questions

Does this generate Options API or Composition API code?
Composition API exclusively, using `<script setup lang="ts">` syntax with Vue 3.4+. It enforces typed return objects, `defineProps`/`defineEmits`, and Vue Style Guide Priority A and B rules, so the output matches modern idiomatic Vue rather than legacy Options API patterns.
Will it include tests, and how many?
Yes. It generates Vitest plus Vue Test Utils specs covering the composable, component, and Pinia store, with at least the number of cases you set in `[test_count]`. Review them to confirm the assertions are meaningful rather than shallow render checks.
Does it use Pinia or Vuex for state?
Pinia, written with the setup syntax via `defineStore`. The store includes CRUD actions with optimistic updates, cached getters, and `$reset()` support for testing, plus persistence wiring when you enable `[persist_state]`.
Can I control whether state persists to localStorage?
Yes, through the `[persist_state]` variable. You can persist some slices (like user preferences) while keeping volatile data (like a live notification list) in memory, and the store is generated with the persist plugin configured accordingly.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Frontend Development Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support