Agent skill
smith-nuxt
Nuxt 3 development patterns including auto-import stubbing for tests, environment variable conventions, and middleware testing. Use when working with Nuxt projects, testing Nuxt components/middleware, or configuring Nuxt environment variables.
Install this agent skill to your Project
npx add-skill https://github.com/tianjianjiang/smith/tree/main/smith-nuxt
SKILL.md
Nuxt Development Standards
- Scope: Nuxt 3 specific patterns
- Load if: Working with Nuxt projects
- Prerequisites: @smith-principles/SKILL.md, @smith-standards/SKILL.md,
@smith-typescript/SKILL.md
CRITICAL: Auto-Import Stubbing (Primacy Zone)
Stub Nuxt auto-imports BEFORE importing modules that use them - module code executes at import time.
- Mocking
h3module expecting auto-imports (they're globals) - Importing middleware before stubbing globals
Auto-Import Stubbing in Tests
Nuxt auto-imports utilities like defineEventHandler, createError, useState. These are globally available in Nuxt runtime but NOT in test environments.
Stub auto-imports globally BEFORE importing the module under test:
import { describe, it, expect, vi } from 'vitest';
import type { H3Event } from 'h3';
// Stub Nuxt auto-imports BEFORE any imports that use them
(globalThis as Record<string, unknown>).defineEventHandler =
(handler: (event: H3Event) => unknown) => handler;
(globalThis as Record<string, unknown>).createError =
(options: { statusCode: number; statusMessage: string }) =>
Object.assign(new Error(options.statusMessage), { statusCode: options.statusCode });
// Now import the module that uses auto-imports
import middleware from '../myMiddleware';
- NEVER mock
h3module expecting auto-imports to work (they're globals, not module exports) - NEVER import middleware before stubbing globals (module executes at import time)
Environment Variables
Nuxt uses NUXT_ prefix for runtime config environment variables.
NUXT_PUBLIC_*- Exposed to clientNUXT_*- Server-only
Server-only:
NUXT_DATABASE_URL=postgres://...
NUXT_API_SECRET=secret
Public (exposed to browser):
NUXT_PUBLIC_API_BASE=https://api.example.com
@smith-typescript/SKILL.md- General TypeScript patterns@smith-tests/SKILL.md- Testing standards
ACTION (Recency Zone)
Before testing Nuxt code:
- Stub auto-imports BEFORE any imports
- Use
NUXT_PUBLIC_*for client-exposed env vars - Use
NUXT_*for server-only env vars
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
smith-style
File naming, path standards, and conventional commits. Use when naming files, creating branches, writing commit messages, or setting up new projects. Covers underscore vs hyphen conventions, commit format, and branch naming patterns.
smith-stacks
Stacked pull request workflows for large features. Use when creating stacked PRs, managing dependent PRs, or rebasing after parent merges. Covers stack creation, merge order, and squash merge handling.
smith-python
Python development with uv, pytest, ruff, and type hints. Use when writing Python code, running tests, managing Python packages, or working with virtual environments. Covers import organization, type hints, pytest patterns, and environment variables.
smith-principles
Fundamental coding principles (DRY, KISS, YAGNI, SOLID, HHH). Use when starting any development task, evaluating implementation approaches, or reviewing code quality. Always active as foundation for all development decisions.
smith-plan
Plan tracking protocol (portable). Progress tracking with checkboxes, iteration workflow, completion/blocker signals. Use when executing multi-step plans, tracking task progress, or working from plan files. IMPORTANT - Always update the plan file after completing tasks.
smith-analysis
Reasoning frameworks and problem decomposition techniques. Use when planning implementation, evaluating arguments, estimating scope, decomposing complex tasks, or applying first principles thinking.
Didn't find tool you were looking for?