Windsurf rules for Vue 3 Composition API with TypeScript: typed props and emits, loading/error handling that cannot get stuck, reactive composable inputs and Pinia setup stores.
.devin/rules/vue-3-composition-api-for-windsurf.md. Downloaded files need to be placed in that repository path.---
trigger: glob
globs: "**/*"
---
Apply these rules to Vue 3 code using `<script setup lang="ts">`.
## Script setup
```vue
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
import { fetchUser, type User } from '@/api/users';
const props = defineProps<{ userId: string }>();
const emit = defineEmits<{ update: [id: string] }>(); // Vue 3.3+ syntax
const user = ref<User | null>(null);
const loading = ref(false);
const error = ref<string | null>(null);
const displayName = computed(() => user.value?.name ?? 'Unknown');
watch(
() => props.userId,
async (id) => {
loading.value = true;
error.value = null;
try {
user.value = await fetchUser(id);
} catch (e) {
error.value = e instanceof Error ? e.message : 'Failed to load';
} finally {
loading.value = false;
}
},
{ immediate: true }
);
</script>
<template>
<div v-if="loading">Loading…</div>
<p v-else-if="error" role="alert">{{ error }}</p>
<div v-else>
{{ displayName }}
<button type="button" @click="emit('update', props.userId)">Edit</button>
</div>
</template>
```
- Reset `loading` in `finally` so a failed request cannot leave the UI loading forever.
- Watch props that data depends on; `onMounted` runs only once.
## Composables
```ts
// composables/useUser.ts
import { ref, toValue, watch, type MaybeRefOrGetter } from 'vue';
import { api, type User } from '@/api';
export function useUser(id: MaybeRefOrGetter<string>) {
const user = ref<User | null>(null);
const loading = ref(true);
const error = ref<Error | null>(null);
async function refresh() {
loading.value = true;
error.value = null;
try {
user.value = await api.getUser(toValue(id));
} catch (e) {
error.value = e instanceof Error ? e : new Error(String(e));
} finally {
loading.value = false;
}
}
watch(() => toValue(id), refresh, { immediate: true });
return { user, loading, error, refresh };
}
```
- Accept `MaybeRefOrGetter` inputs so `useUser(() => props.userId)` refetches when the prop changes.
## State with Pinia
```ts
import { defineStore } from 'pinia';
import { ref } from 'vue';
import { api, type Credentials, type User } from '@/api';
export const useUserStore = defineStore('user', () => {
const currentUser = ref<User | null>(null);
async function login(credentials: Credentials) {
currentUser.value = await api.login(credentials);
}
function logout() {
currentUser.value = null;
}
return { currentUser, login, logout };
});
```
Cursor rules for Tailwind CSS v4: automatic class sorting, mobile-first breakpoints, CVA variants with merging, class-based dark mode via @custom-variant, and CSS-first @theme configuration.
Cursor rules for React with TypeScript: typed function components, React 19 ref-as-prop, hooks discipline, state ownership, error boundaries and measured performance work.
CLAUDE.md rules for React 19 with TypeScript covering typed components, derived state, compiler-aware memoization, useId-based accessibility and review checks.
Windsurf
frontend
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
A Windsurf Vue app's useUser(id: string) composable never refetches when the route param changes and leaves loading true when the API throws.
Update src/composables/useUser.ts and src/components/UserCard.vue following the Vue 3 Composition API rule.
useUser accepts MaybeRefOrGetter<string>, watches toValue(id) with immediate: true, resets loading in finally and exposes an error ref; UserCard watches props.userId (or calls useUser(() => props.userId)), shows an error state and declares emits with named tuple syntax.
Windsurf's rules documentation (docs.windsurf.com/windsurf/cascade/memories) now redirects to Devin documentation, which describes rules for the Devin Local agent in Devin Desktop. Current rules live in .devin/rules/*.md with a trigger setting, and the legacy Windsurf files (.windsurf/rules/*.md, .windsurf/global_rules.md and .windsurfrules) are still imported by default. AGENTS.md files are read as always-on rules.
.devin/rules/vue-3-composition-api-for-windsurf.mdStarting point, not a tested configuration for your repository. Applied when files matching globs are involved (trigger: glob). Review the instructions, adapt the file paths and run your project's existing checks.
---
trigger: glob
globs: "**/*"
---
Apply these rules to Vue 3 code using `<script setup lang="ts">`.
## Script setup
```vue
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
import { fetchUser, type User } from '@/api/users';
const props = defineProps<{ userId: string }>();
const emit = defineEmits<{ update: [id: string] }>(); // Vue 3.3+ syntax
const user = ref<User | null>(null);
const loading = ref(false);
const error = ref<string | null>(null);
const displayName = computed(() => user.value?.name ?? 'Unknown');
watch(
() => props.userId,
async (id) => {
loading.value = true;
error.value = null;
try {
user.value = await fetchUser(id);
} catch (e) {
error.value = e instanceof Error ? e.message : 'Failed to load';
} finally {
loading.value = false;
}
},
{ immediate: true }
);
</script>
<template>
<div v-if="loading">Loading…</div>
<p v-else-if="error" role="alert">{{ error }}</p>
<div v-else>
{{ displayName }}
<button type="button" @click="emit('update', props.userId)">Edit</button>
</div>
</template>
```
- Reset `loading` in `finally` so a failed request cannot leave the UI loading forever.
- Watch props that data depends on; `onMounted` runs only once.
## Composables
```ts
// composables/useUser.ts
import { ref, toValue, watch, type MaybeRefOrGetter } from 'vue';
import { api, type User } from '@/api';
export function useUser(id: MaybeRefOrGetter<string>) {
const user = ref<User | null>(null);
const loading = ref(true);
const error = ref<Error | null>(null);
async function refresh() {
loading.value = true;
error.value = null;
try {
user.value = await api.getUser(toValue(id));
} catch (e) {
error.value = e instanceof Error ? e : new Error(String(e));
} finally {
loading.value = false;
}
}
watch(() => toValue(id), refresh, { immediate: true });
return { user, loading, error, refresh };
}
```
- Accept `MaybeRefOrGetter` inputs so `useUser(() => props.userId)` refetches when the prop changes.
## State with Pinia
```ts
import { defineStore } from 'pinia';
import { ref } from 'vue';
import { api, type Credentials, type User } from '@/api';
export const useUserStore = defineStore('user', () => {
const currentUser = ref<User | null>(null);
async function login(credentials: Credentials) {
currentUser.value = await api.login(credentials);
}
function logout() {
currentUser.value = null;
}
return { currentUser, login, logout };
});
```
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
The docs recommend keeping rules short and specific. The current docs say AGENTS.md, AGENTS.local.md and AGENT.md are read as always-on rules, including files in subdirectories. Use .devin/rules/ when you need glob, model-decision or manual triggers.
Documentation checked 2026-11-05: Devin docs: Local customizations (redirect target of Windsurf memories docs)Windsurf docs: Cascade memories (redirects)
Cursor rules for Tailwind CSS v4: automatic class sorting, mobile-first breakpoints, CVA variants with merging, class-based dark mode via @custom-variant, and CSS-first @theme configuration.
Cursor rules for React with TypeScript: typed function components, React 19 ref-as-prop, hooks discipline, state ownership, error boundaries and measured performance work.
CLAUDE.md rules for React 19 with TypeScript covering typed components, derived state, compiler-aware memoization, useId-based accessibility and review checks.