Vibe Coding
AI Vibe CodingStarter91% · Ready

Vue 3 Nuxt 3 Admin Dashboard Vibe Coding Configuration: Table Filtering, Status, and RBAC Guards

An enterprise-grade backend development blueprint based on Cursor and Nuxt 3, achieving 91% automated delivery, covering pagination filtering, Pinia caching, and RBAC guards.

Est. time: 55 minUpdated: 2026-11-27
Cursor IDEVue 3Nuxt 3PiniaVitest
Vue 3 Nuxt 3 Admin Dashboard Vibe Coding Configuration: Table Filtering, Status, and RBAC Guards

Completion Score

Overall completion reached 91%. The AI excelled in generating standard CRUD tables, Pinia Store structures, and basic permission logic. The main bottlenecks lie in handling edge cases for complex business logic and pixel-perfect UI component reproduction, which require manual fine-tuning.

91%Ready

Dimension breakdown

Complex Table Pagination and Multi-Condition Filtering94%

The AI accurately generates table components with debounced search, pagination state management, and multi-condition filtering. The code structure is clear and maintainable.

Pinia State Management and Request Caching92%

High-quality state management generation using the Setup Store pattern. Correctly implements useFetch caching strategies to avoid duplicate requests.

Route Middleware and Button-Level Permissions86%

Route guard logic is accurate. However, fine-grained control for button-level permissions requires manual confirmation of role mappings, as the AI occasionally misses edge-case permission scenarios.

Vitest Component and Store Unit Tests91%

Generates high-quality unit tests for components and Stores with reasonable mocking strategies. However, test cases for complex asynchronous states require manual supplementation of edge conditions.

Human checkpoint

Before deployment, manually review the permission logic in all route middleware to ensure no unauthorized access risks. Additionally, verify that Vitest test cases cover critical business state change scenarios.

Upgrade / downgrade path

If resources are constrained, remove the mandatory Vitest coverage checks and retain only core Store tests. For upgrades, introduce Playwright for end-to-end testing and integrate ESLint plugins to enforce consistent code style.

When to use & prerequisites

Target users are Vue 3 developers using the Cursor IDE. The environment must have Nuxt 3, Pinia, and Vitest pre-installed. This setup is ideal for rapidly building internal management systems or SaaS backends featuring data tables, form validation, and role-based access control.

Ready-to-copy configs

.cursor/rules/nuxt3-admin.mdcmarkdown

定义 Nuxt 3 后台管理系统的代码规范、Pinia 状态管理及权限守卫逻辑,确保 AI 生成符合企业级标准的代码。

---
name: Nuxt3 Admin Coding Standards
description: Enforces Vue 3 Composition API, Pinia patterns, and RBAC guards for admin dashboards.
---

# Nuxt 3 Admin Dashboard Rules

## 1. Architecture & Structure
- **Composition API Only**: Use `<script setup lang="ts">` exclusively. No Options API.
- **File Naming**: `PascalCase.vue` for components, `camelCase.ts` for logic.
- **Imports**: Use `@/` alias for root-relative imports.

## 2. Pinia State Management
- **Store Pattern**: Use `defineStore` with `setup` syntax.
- **Caching**: Implement `useFetch` or `useAsyncData` for data fetching. Cache keys must include query params.
- **Example**:
```typescript
export const useUserStore = defineStore('user', () => {
  const user = ref(null)
  const fetchUser = async () => { /* ... */ }
  return { user, fetchUser }
})
```

## 3. RBAC & Guards
- **Route Middleware**: Create `middleware/auth.ts` to check `userStore.isAuthenticated`.
- **Button Permissions**: Use a composable `usePermission` to check roles before rendering actions.
- **Never** hardcode role checks in templates; always use computed properties or composables.

## 4. Testing (Vitest)
- **Component Tests**: Mock `useFetch` and Pinia stores.
- **Store Tests**: Test state mutations and actions in isolation.
- **Coverage**: Aim for >80% on `stores/` and `composables/`.
AGENTS.mdmarkdown

指导 AI 代理在生成代码时遵循特定的 Vibe Coding 工作流,包括表格筛选逻辑、表单校验及单元测试生成策略。

# AI Agent Guidelines for Nuxt 3 Admin

## Role
You are a Senior Vue 3 Engineer specializing in Nuxt 3 admin dashboards.

## Core Directives

### 1. Table & Filtering Logic
- When generating tables, always include:
  - Pagination state (page, pageSize, total).
  - Filter state (search, status, dateRange).
  - Debounced search input (300ms).
- Use `useFetch` with `watch` on filter changes to trigger refetches.

### 2. Form Validation
- Use `VeeValidate` or `Zod` for schema validation.
- Validate on `blur` and `submit`.
- Display errors inline below inputs.

### 3. Permission Guards
- Wrap sensitive actions in `v-if="hasPermission('edit')"`.
- Ensure route middleware redirects unauthenticated users to `/login`.

### 4. Testing Strategy
- For every new component, generate a corresponding `.spec.ts` file.
- Mock API responses using `vi.mock`.
- Test edge cases: empty data, loading states, error states.

## Output Format
- Always provide complete, runnable code blocks.
- Include necessary imports.
- Add JSDoc comments for complex logic.

AI Vibe Coding in 4 steps

Progress: 0 / 4
  1. 1

    Initialize Nuxt 3 Project and Basic Configuration

    Goal: Create a Nuxt 3 project, install Pinia, Vitest, and necessary dependencies, and configure the .cursor/rules file.

    Prompt
    Initialize a Nuxt 3 project using TypeScript. Install pinia, vitest, and @nuxt/test-utils. Create a .cursor/rules/nuxt3-admin.mdc file following the provided Nuxt3 Admin Coding Standards. Ensure package.json includes a test script.

    Verify: Run `npm run dev` to confirm the project starts without errors and check that the .cursor/rules/nuxt3-admin.mdc file exists and is complete.

  2. 2

    Build Table Component with Pagination and Filtering

    Goal: Generate a user management table component supporting search, status filtering, and pagination, using Pinia for state management.

    Prompt
    Create a UserTable.vue component using <script setup>. Include a search box (debounced 300ms), a status filter dropdown, and pagination controls. Use useFetch to retrieve data and watch filter changes to trigger re-requests. Simulate the data source at /api/users.

    Verify: Access the component in the browser, enter search terms, and switch filter conditions to observe if network requests trigger as expected and if table data updates correctly.

  3. 3

    Implement RBAC Permission Guards

    Goal: Create route middleware and a composable function for permissions to implement login interception and button-level access control.

    Prompt
    Create middleware/auth.ts to check userStore.isAuthenticated; redirect to /login if not authenticated. Create composables/usePermission.ts providing a hasPermission(role) method. In UserTable.vue, display the delete button only if the user has the 'admin' role.

    Verify: Simulate an unauthenticated state accessing a protected route to confirm redirection. Simulate users with different roles to verify the correct display/hide logic for buttons.

  4. 4

    Write Vitest Unit Tests

    Goal: Write unit tests for the UserTable component and UserStore, covering core interaction logic.

    Prompt
    Write Vitest tests for UserTable.vue and useUserStore. Mock useFetch and API responses. Test cases should include: initial load, search trigger, filter changes, and pagination clicks. Ensure test coverage exceeds 80%.

    Verify: Run `npm run test` to confirm all test cases pass and the coverage report meets requirements.

Pitfalls & fixes

  • Pinia state is not cleaned up after component unmounting, leading to memory leaks. Fix: Reset state in onUnmounted or ensure useFetch keys are unique.
  • Route middleware does not trigger correctly during client-side navigation. Fix: Ensure middleware is correctly registered in Nuxt configuration and useRoute is used to listen for changes.
  • Incomplete mocking in Vitest tests causes real API requests to be sent. Fix: Use vi.mock to globally mock all network requests or configure Vitest's server options to intercept requests.

FAQ

How to handle performance issues when dealing with large table datasets?

Use virtual scrolling (e.g., vue-virtual-scroller) to render table rows. Ensure pagination logic is implemented at the API level to avoid loading all data at once.

How to customize the useFetch caching strategy in Pinia?

Set the key option in useFetch to include query parameters, ensuring different filter conditions correspond to different cache entries. You can also combine this with the transform function in useAsyncData to process data.

How to ensure the security of button-level permissions?

Frontend permission control is for UI experience only; the backend API must verify permissions again. Ensure the usePermission composable function aligns with backend role definitions and is synchronized regularly.

Related blueprints

Vue 3 Nuxt 3 Admin Dashboard Vibe Coding Configuration: Table Filtering, Status, and RBAC Guards · CursorHome