install
source · Clone the upstream repo
git clone https://github.com/Intense-Visions/harness-engineering
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/Intense-Visions/harness-engineering "$T" && mkdir -p ~/.claude/skills && cp -r "$T/agents/skills/claude-code/nuxt-auto-imports" ~/.claude/skills/intense-visions-harness-engineering-nuxt-auto-imports && rm -rf "$T"
manifest:
agents/skills/claude-code/nuxt-auto-imports/SKILL.mdsource content
Nuxt Auto-Imports
Use composables, components, and utilities in Nuxt without writing any import statements
When to Use
- You are working in a Nuxt 3 project and writing composables, components, or utility functions
- You see import errors for things like
,ref
,computed
,useState
, or custom composablesuseFetch - You want to understand why a Nuxt project has no import statements at the top of
files.vue - You are registering custom auto-import directories or disabling auto-imports for specific cases
Instructions
- Place composables in
— any function exported from a file in this directory is auto-imported by name. Use named exports for tree-shaking.composables/ - Place components in
— components are auto-imported using their file path as the component name (e.g.,components/
becomescomponents/base/Button.vue
).<BaseButton /> - Place utility functions in
— exported functions are auto-imported globally.utils/ - Vue Composition API (
,ref
,computed
,watch
, etc.) and Nuxt composables (reactive
,useFetch
,useRoute
, etc.) are always auto-imported — never import them manually.useState - To add custom auto-import directories, use
inimports.dirs
:nuxt.config.ts
// nuxt.config.ts export default defineNuxtConfig({ imports: { dirs: ['stores', 'services'], }, });
- To disable auto-imports globally (rare), set
. To disable per-file, addimports.autoImport: false
or restructure to use explicit imports.// @ts-nocheck - Use
for explicit imports in edge cases (e.g., Vitest tests that run outside Nuxt context):#imports
import { ref, computed } from '#imports';
- Auto-imported types are available in
— regenerate with.nuxt/types/imports.d.ts
when stale.nuxt prepare - Avoid naming collisions: if two composables in different files export the same name, Nuxt resolves by the last one found. Use unique, descriptive names.
Details
Nuxt's auto-import system is powered by
unplugin-auto-import and unplugin-vue-components. At build time, Nuxt scans the configured directories and generates TypeScript declaration files in .nuxt/ that declare each composable and component as a global. The result: zero import statements in application code while retaining full type safety.
Component naming convention:
The component name is derived from its path relative to
components/. Nested directories are flattened using PascalCase concatenation:
components/ ui/ Card.vue → <UiCard /> button/ Primary.vue → <UiButtonPrimary /> base/ Input.vue → <BaseInput />
Lazy-loading components:
Prefix with
Lazy to defer loading until the component is mounted:
<LazyHeavyChart v-if="showChart" />
Explicit disabling for testing:
Vitest runs outside Nuxt's build pipeline, so auto-imports are unavailable by default. Use
@nuxt/test-utils or import from #imports:
// In test files import { mountSuspended } from '@nuxt/test-utils/runtime';
When NOT to use auto-imports:
- Library packages intended to be consumed outside Nuxt (use explicit imports for portability)
- Files in
— server routes use a separate auto-import layer with different rulesserver/
Source
https://nuxt.com/docs/guide/concepts/auto-imports
Process
- Read the instructions and examples in this document.
- Apply the patterns to your implementation, adapting to your specific context.
- Verify your implementation against the details and edge cases listed above.
Harness Integration
- Type: knowledge — this skill is a reference document, not a procedural workflow.
- No tools or state — consumed as context by other skills and agents.
Success Criteria
- The patterns described in this document are applied correctly in the implementation.
- Edge cases and anti-patterns listed in this document are avoided.