Staring at a blank <template> block again? You know the drill — hours of boilerplate before you even reach the interesting logic. But what if you could skip the busywork entirely and let an AI assistant generate the scaffolding while you focus on architecture?
This is not about replacing your brain with a chatbot. It's about using targeted prompts to eliminate repetitive tasks — component stubs, TypeScript interfaces, Pinia stores, route configs, even performance audits. Below are 15 prompts I've refined through months of production work on Vue 3 and Nuxt 3 projects. Each one includes a practical example and an explanation of why it accelerates development.
Whether you're a solo developer or part of a team, these prompts will turn your AI tool into a senior pair programmer — one that never gets tired of writing props validation.
1. Generate a Vue 3 Component with TypeScript and <script setup>
Use case: Kickstart any new component with consistent structure, props, and emits.
Prompt:
Create a Vue 3 component named `UserCard` using `<script setup>` and TypeScript. It should accept `user` (object with name, email, avatarUrl) and `role` (string, default 'guest') as props. Emits an event `click` when the card is clicked. Include a scoped style block with a clean card design (border, shadow, hover effect). Use `defineProps` and `defineEmits`.
Example output (abridged):
<script setup lang="ts">
interface User {
name: string;
email: string;
avatarUrl?: string;
}
const props = defineProps<{
user: User;
role?: string;
}>();
const emit = defineEmits<{
(e: 'click', event: MouseEvent): void;
}>();
</script>
<template>
<div class="user-card" @click="emit('click', $event)">
<img :src="props.user.avatarUrl || 'default.png'" alt="avatar" />
<div>
<h3>{{ props.user.name }}</h3>
<p>{{ props.user.email }}</p>
<span>{{ props.role }}</span>
</div>
</div>
</template>
<style scoped>
.user-card { border: 1px solid #ccc; border-radius: 8px; padding: 16px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.user-card:hover { box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
</style>
Why it helps: This eliminates 20 minutes of boilerplate and ensures consistency. The AI automatically adds TypeScript interfaces, proper prop typing, and event declarations — common sources of bugs.
2. Convert an Options API Component to Composition API
Use case: Refactoring legacy Vue 2 code to Vue 3 Composition API.
Prompt:
Convert the following Options API component to Vue 3 `<script setup>` with Composition API. Keep the same logic and template. Add appropriate `ref`, `computed`, and lifecycle hooks. Ensure the conversion is idiomatic Vue 3.
[Paste your component code]
Why it helps: Manual conversion is tedious and error-prone. AI can handle it in seconds, preserving template and logic while switching to the modern API.
3. Create a Reusable Composable for Data Fetching
Use case: Centralize API calls with loading and error states.
Prompt:
Write a Vue 3 composable `useFetchData` that accepts a URL string and returns `{ data, error, loading, refresh }`. Use `ref` and `watchEffect`. On mount, fetch data and handle errors. Provide a `refresh` function to re-fetch. Include TypeScript generics for the data type.
Example usage:
const { data, error, loading, refresh } = useFetchData<User[]>('/api/users');
Why it helps: This composable is reusable across nearly every view. AI generates a robust implementation with proper error handling in one go.
4. Generate a Pinia Store with Actions and Getters
Use case: Set up a store for authentication or cart logic.
Prompt:
Create a Pinia store for user authentication. Use `defineStore` with `state` containing `user`, `token`, and `isAuthenticated`. Include actions `login(credentials)`, `logout()`, and `fetchUser()`. Use a mock API or a provided endpoint. Add getters like `isAdmin`. Use TypeScript.
Example snippet:
export const useAuthStore = defineStore('auth', {
state: () => ({ user: null as User | null, token: '' }),
getters: {
isAuthenticated: (state) => !!state.token,
isAdmin: (state) => state.user?.role === 'admin',
},
actions: {
async login(credentials: { email: string; password: string }) {
const { data } = await api.post('/login', credentials);
this.token = data.token;
this.user = data.user;
},
logout() { this.token = ''; this.user = null; },
},
});
Why it helps: Pinia stores follow a predictable pattern. AI can generate the entire store, including state, getters, and actions, saving you from repetitive typing.
5. Build a Nuxt 3 Page with SEO Meta Tags
Use case: Quickly scaffold a page with proper meta tags for SEO.
Prompt:
Generate a Nuxt 3 page component for a blog post. Use `useHead` to set the title, meta description, and Open Graph tags. The page should accept a `slug` prop and fetch the post content via `useAsyncData`. Include a loading state and error handling.
Example code:
<script setup lang="ts">
const { slug } = useRoute().params;
const { data: post, error } = await useAsyncData(`post-${slug}`, () => $fetch(`/api/posts/${slug}`));
useHead({
title: post.value?.title || 'Post',
meta: [
{ name: 'description', content: post.value?.excerpt || '' },
{ property: 'og:title', content: post.value?.title },
{ property: 'og:description', content: post.value?.excerpt },
],
});
</script>
Why it helps: SEO meta tags are crucial but often neglected. This prompt ensures you get them right from the start, without needing to memorize useHead options.
6. Automatically Generate TypeScript Interfaces from an API Response
Use case: Quickly define types for API data.
Prompt:
Given the following JSON response from an API, generate a TypeScript interface for it. Include nested objects and arrays. Name the interface `Product`.
[Paste JSON here]
Why it helps: Manually writing types for complex API responses is time-consuming. AI does it instantly with perfect structure.
7. Write a Custom Vue Directive for Lazy Loading Images
Use case: Improve performance by lazy loading images.
Prompt:
Create a custom Vue 3 directive `v-lazy` that uses IntersectionObserver to load images only when they enter the viewport. The directive should set the `src` attribute from a `data-src` attribute. Handle cleanup when the element is unmounted.
Example registration:
app.directive('lazy', {
mounted(el) {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
el.src = el.dataset.src;
observer.unobserve(el);
}
});
});
observer.observe(el);
},
});
Why it helps: This is a classic performance optimization. The AI-generated directive is ready to use and includes proper cleanup.
8. Generate a Vue Router Configuration with Lazy Loading
Use case: Set up routes with code splitting.
Prompt:
Create a Vue Router configuration for a typical dashboard with routes: `/login`, `/dashboard`, `/users/:id`, and `/settings`. Use lazy loading for all routes. Include a navigation guard that checks for authentication and redirects to `/login` if not authenticated.
Example output (abridged):
const routes = [
{ path: '/login', component: () => import('@/pages/Login.vue'), meta: { public: true } },
{ path: '/dashboard', component: () => import('@/pages/Dashboard.vue') },
{ path: '/users/:id', component: () => import('@/pages/UserDetail.vue') },
{ path: '/settings', component: () => import('@/pages/Settings.vue') },
];
router.beforeEach((to) => {
if (!to.meta.public && !isAuthenticated()) return '/login';
});
Why it helps: Lazy loading is critical for performance. This prompt gives you the entire routing structure with guards.
9. Debug a Vue Component Logic
Use case: Find bugs in your component.
Prompt:
Here is a Vue component that is not working as expected. The button click should increment the counter by 1, but it stays at 0. Analyze the code and suggest fixes.
[Paste your component code]
Why it helps: AI can spot common mistakes like forgetting to use .value in script setup or incorrect event handling.
10. Write Unit Tests for a Vue Component
Use case: Create tests for your component.
Prompt:
Write unit tests using Vitest and Vue Test Utils for the following component. Test that it renders the correct name, emits the 'click' event when a button is pressed, and reacts to prop changes.
[Paste your component code]
Why it helps: Writing tests is often skipped due to time. AI generates a solid test suite that you can refine.
11. Optimize Nuxt 3 Server-Side Rendering with useAsyncData
Use case: Improve SSR data fetching performance.
Prompt:
Explain how to optimize data fetching in Nuxt 3 for SSR. Consider using `useAsyncData` with `server` and `client` options. Provide an example of a composable that fetches data on the server and caches it for the client.
Why it helps: AI can give you best practices and code examples for SSR optimization, which is critical for Nuxt performance.
12. Generate a Nuxt Module Configuration for Tailwind CSS
Use case: Set up Tailwind CSS in a Nuxt project.
Prompt:
Provide the Nuxt 3 configuration (`nuxt.config.ts`) to add Tailwind CSS via the `@nuxtjs/tailwindcss` module. Also show how to create a `tailwind.config.js` with custom colors and fonts.
Example config:
export default defineNuxtConfig({
modules: ['@nuxtjs/tailwindcss'],
tailwindcss: {
config: {
theme: {
extend: {
colors: { primary: '#3490dc' },
fontFamily: { sans: ['Helvetica', 'Arial', 'sans-serif'] },
},
},
},
},
});
Why it helps: Tailwind is a common requirement. AI provides the exact config, saving you from searching docs.
13. Create a Form Validation Schema with VeeValidate
Use case: Validate forms easily.
Prompt:
Using VeeValidate 4 and Yup, create a validation schema for a registration form with fields: name, email, password (min 8 chars), and password_confirmation (must match password). Show how to integrate it into a Vue component with `<Form>` and `<Field>`.
Why it helps: Form validation is verbose. AI generates the schema and component integration.
14. Write a Performance Audit Report for a Vue Application
Use case: Analyze and improve performance.
Prompt:
List common performance bottlenecks in Vue 3 applications and provide concrete solutions for each. Include tips for reducing bundle size, optimizing re-renders, and using `v-memo`. Provide code examples.
Why it helps: AI can generate a checklist and code snippets for performance improvements, which you can apply immediately.
15. Generate a Dockerfile for a Nuxt 3 App
Use case: Set up containerization.
Prompt:
Create a multi-stage Dockerfile for a Nuxt 3 application. Use node:20-alpine for build, then copy to a runner base. Include steps for installing dependencies, building the app, and running with `node .output/server/index.mjs`. Expose port 3000.
Why it helps: Dockerizing Nuxt apps has specific steps. AI generates a working Dockerfile.
These prompts are not magic — they still require you to review and adapt the output. But they reduce the time spent on boilerplate by an order of magnitude. The key is to be specific: mention the Vue version, whether you use TypeScript, and any libraries like Pinia or VeeValidate. The more context you give, the better the result.
Start with one prompt that matches your current task. Try it, refine the output, and soon you'll find yourself reaching for AI for every repetitive piece of code. That's how you achieve 3x speed — not by typing faster, but by thinking less about syntax and more about solutions.
Now go ahead and paste a prompt into your favorite AI tool. Your future self — not stuck writing prop types — will thank you.
Comments