AgentLint 实测验证 100/100实证最佳实践起步模板(基于 TypeScript/JS 仓库规则)

    Vue 3 / Nuxt CLAUDE.md & AGENTS.md 模板

    <script setup lang="ts"> 组合式 API 一致性、Pinia storeToRefs 响应式守卫与 vue-tsc 校验。

    # Vue 3 / Nuxt Project — Vue TypeScript Harness
    
    Vue 3 + TypeScript application using `<script setup>`, Pinia state stores, Vite/Nuxt, `vue-tsc`, and Vitest.
    
    ## Commands
    
    - Install: `pnpm install --frozen-lockfile`
    - Fast single test: `npx vitest run src/components/PricingCard.test.ts`
    - Full test suite: `pnpm test`
    - Typecheck & lint: `npx vue-tsc --noEmit && pnpm lint`
    - Production build: `pnpm build`
    
    ## Rules
    
    - Don't mix Options API (`export default { data() }`) into new components. Instead use `<script setup lang="ts">` with typed `defineProps<T>()` and `defineEmits<T>()`. Because mixed API styles confuse composables and type inference.
    - Don't destructure Pinia store state directly. Instead wrap state properties in `storeToRefs(store)`. Because plain destructuring silently drops Vue reactivity.
    - Don't use `tsc --noEmit` alone for `.vue` files. Instead run `npx vue-tsc --noEmit`. Because standard `tsc` skips template type errors.
    - When editing Nuxt server routes or route middleware, read `docs/nuxt-routing.md` first.
    
    ## Continuity & Safety
    
    - Keep `.env*`, `.nuxt/`, and `CLAUDE.local.md` in `.gitignore`.
    - Record verified `vue-tsc` and Vitest outputs in `HANDOFF.md`.

    Vue 3 / Nuxt 开源生态中最常采用的工程规则

    参考 4,533 仓库研究中对应主语言生态的高频工程规则采纳率,并结合框架核心防踩坑约束:

    tailwindcss工具链

    Tailwind CSS styling (measured in 1,533 TypeScript corpus repos)

    38.8%595 个仓库
    unit-tests测试

    Composable and component unit tests (1,533 TS corpus repos)

    37.6%577 个仓库
    eslint工具链

    ESLint + eslint-plugin-vue rules (1,533 TS corpus repos)

    36.9%565 个仓库
    vitest测试

    Vitest + @vue/test-utils (1,533 TS corpus repos)

    32.6%499 个仓库
    必写验证命令(对应规则 W1 与 W7)
    安装依赖
    pnpm install --frozen-lockfile
    快速单测(秒级迭代)
    npx vitest run src/composables/useCart.test.ts
    全量测试
    pnpm test
    Lint 与静态检查
    pnpm lint && npx vue-tsc --noEmit
    生产构建
    pnpm build
    Vue 3 / Nuxt 项目中 AI 代理常见踩坑
    • 01在组合式 API 项目里混写 Options API,割裂团队代码风格与类型推导。
    • 02直接解构 Pinia store 状态而不用 storeToRefs(),悄悄丢失响应式更新。
    • 03只跑 tsc --noEmit 而非 vue-tsc --noEmit,漏掉 .vue 模板表达式类型错误。

    更多实证验证模板