Verified SOP & TutorialAudited Score 98/100

The Complete Production SOP: How to Deploy and Run unplugin-vue-components & Auto-Import Architecture in Autonomous AI Agents

Production SOP to install unplugin-vue-components-auto in Codex, Claude Code, & Cursor. Master auto-importing, components.d.ts, and TypeScript gates.

Target Runtimes:codexclaude-codecursorwindsurf
5 min read • Updated for 2026

Technical Overview & Architectural Context

Autonomous coding agents like Codex, Claude Code, and Cursor frequently introduce friction when scaffolding or refactoring modern Vue 3 + Vite applications. When tasked with importing components or composables, agents default to injecting redundant explicit imports ('import { ref, computed } from vue' or 'import BaseButton from @/components/BaseButton.vue') into SFC <script> blocks. This breaks established project conventions, pollutes version history, and can cause circular dependency cycles or hydration mismatches if treeshaking boundaries are misconfigured. Furthermore, agents frequently fail to account for dual TypeScript declaration generation. They modify 'vite.config.ts' with 'unplugin-vue-components' and 'unplugin-auto-import' but forget to synchronize 'tsconfig.json' include paths or fail to trigger Vite's development build that emits 'components.d.ts' and 'auto-imports.d.ts'. As a result, subsequent agent validation loops fail with Vue language server (Volar/vue-tsc) TS2304 ('Cannot find name') errors, sending the agent into hallucinated correction spirals. The 'unplugin-vue-components-auto' skill establishes strict architectural guardrails. It forces agents to configure deterministic resolvers (e.g., Ant Design Vue, Element Plus, Naive UI), verify declaration outputs, update TypeScript compiler boundaries, and enforce zero explicit imports in component templates and script blocks.

Prerequisites & Environment Requirements

Codex Desktop, Claude Code CLI, Cursor, or Windsurf installed with active workspace access
Node.js 20+ and pnpm / npm / yarn installed in the local environment
Vite 5+ Vue 3 TypeScript project initialized in git repository root

Verified Search Intents & Long-Tail Queries Solved

SEO Audit Score: 98/100

This operational tutorial is engineered to provide deterministic solutions for these developer search queries:

#install unplugin-vue-components-auto in cursor ide#claude code unplugin-vue-components-auto rules#codex desktop unplugin-vue-components-auto setup tutorial#how to fix unplugin-vue-components-auto agent execution error#auto import vue components vite typescript configuration#generate components d ts vue3 agent skill#unplugin-vue-components-auto sandbox permissions and security score#unplugin-vue-components-auto prompt examples and triggers

Step-by-Step Execution Playbook

1

Local Environment Setup & SKILL.md Mounting

Create the local skill manifest directory and inject verified procedural rules into the agent context.

Autonomous agent runtimes inspect workspace or global agent directories (such as ~/.claude/skills, .cursor/rules, or ~/.agents/skills) to register tool capabilities and domain SOPs. By mounting this SKILL.md file, you inform the agent's trigger parser that requests matching 'setup unplugin-vue-components' or 'generate components.d.ts' must adhere strictly to the unplugin architecture standard rather than ad-hoc script patching.

Terminal Command
mkdir -p ~/.agents/skills/unplugin-vue-components-auto && curl -fsSL https://askills.dev/api/skills/unplugin-vue-components-auto/raw -o ~/.agents/skills/unplugin-vue-components-auto/SKILL.md
SKILL.md
---
name: "unplugin-vue-components-auto"
description: "Automatically import UI components and composables on-demand with zero explicit import lines."
metadata:
  author: "Unplugin"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "setup unplugin-vue-components"
  - "auto import vue components vite"
  - "generate components.d.ts"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---
Production Pro-Tip

In Cursor and Windsurf, symlink the global SKILL.md directly to '.cursor/rules/unplugin-vue.md' to conserve prompt tokens by loading the SOP only when editing Vite config or Vue templates.

Sandbox Gotcha

Ensure directory permissions grant read access (chmod 644) so agent sub-processes operating in restricted user sandboxes can parse YAML frontmatter headers without throwing EACCES.

2

Vite Configuration & TypeScript Binding Injection

Install the required npm dependencies and configure vite.config.ts alongside tsconfig.json inclusions.

The agent executes dependency resolution for 'unplugin-vue-components' and 'unplugin-auto-import'. It then injects both plugins into 'vite.config.ts', specifying component directories, explicit UI resolvers (e.g., ElementPlusResolver or NaiveUiResolver if installed), and custom output paths for 'components.d.ts' and 'auto-imports.d.ts'. Crucially, the agent must inspect 'tsconfig.app.json' or 'tsconfig.json' to ensure both declaration targets are explicitly appended to the 'include' array.

Terminal Command
pnpm add -D unplugin-vue-components unplugin-auto-import
vite.config.ts
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import AutoImport from 'unplugin-auto-import/vite';

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ['vue', 'vue-router', 'pinia', '@vueuse/core'],
      dts: 'src/auto-imports.d.ts',
      eslintrc: {
        enabled: true,
        filepath: './.eslintrc-auto-import.json',
      },
    }),
    Components({
      dirs: ['src/components'],
      extensions: ['vue'],
      deep: true,
      dts: 'src/components.d.ts',
    }),
  ],
});
Production Pro-Tip

Always enable 'eslintrc.enabled: true' in AutoImport config when working with ESLint environments to prevent lint errors for undeclared global composables like 'ref' or 'computed'.

Sandbox Gotcha

If 'tsconfig.json' contains an 'include' field that restricts files solely to 'src/**/*.ts', TypeScript will ignore 'src/components.d.ts' until explicitly added or broadened to 'src/**/*.d.ts'.

3

Intent Matching & Trigger Invocation

Verify deterministic activation using tested natural language triggers matching SKILL.md frontmatter.

Trigger the agent using natural phrasing configured in the manifest. The runtime matches input against triggers like 'setup unplugin-vue-components' and executes the multi-file setup SOP. The agent strips explicit imports from existing SFCs and creates test components in 'src/components/' to verify dynamic registration without manual import syntax.

Production Pro-Tip

Invoke the agent with explicit reference to the target component library (e.g., 'setup unplugin-vue-components with naive-ui resolver') to prompt automatic resolver import configuration.

Sandbox Gotcha

Avoid prompt instructions like 'import components everywhere'. Runtimes might misunderstand and append manual imports instead of configuring the unplugin compilation pipeline.

4

Declaration Generation & Verification Quality Gate

Execute automated self-healing build and type-checks to guarantee declaration file creation.

Because 'unplugin-vue-components' and 'unplugin-auto-import' emit '.d.ts' files during the Vite development server startup or build phase, the agent must run a dry-run Vite build or trigger 'vue-tsc --noEmit' to ensure declaration files are persisted to disk and verified against TypeScript standards.

Terminal Command
pnpm vite build --mode development && pnpm vue-tsc --noEmit
tsconfig.app.json
{
  "extends": "@vue/tsconfig/tsconfig.dom.json",
  "include": [
    "env.d.ts",
    "src/**/*",
    "src/**/*.vue",
    "src/auto-imports.d.ts",
    "src/components.d.ts"
  ]
}
Production Pro-Tip

Ensure '.gitignore' is updated according to project standards: if running in CI without build steps prior to linting, check in 'components.d.ts' and 'auto-imports.d.ts' or configure CI to run 'vite build' before type-checking.

Sandbox Gotcha

Running 'vue-tsc' before executing 'vite build' will trigger false TS2304 failures because the .d.ts files have not yet been generated on the filesystem.

Real-World Scenario: Eliminating Cluttered Vue Imports and Enabling Auto-Imports in a Enterprise Vite Workspace

Tested Trigger Prompt (Feed directly into Codex, Claude, or Cursor):

“Refactor our Vue 3 Vite application to auto import vue components vite and generate components.d.ts using unplugin-vue-components & Auto-Import Architecture. Strip all manual imports of 'ref', 'computed', and custom components from 'src/views/DashboardView.vue'.”

Deterministic Agent Verification Pipeline:
Installs 'unplugin-vue-components' and 'unplugin-auto-import' devDependencies using detected package manager (pnpm).
Updates 'vite.config.ts' with 'Components()' and 'AutoImport()' configurations pointing dts outputs to 'src/components.d.ts' and 'src/auto-imports.d.ts'.
Verifies and patches 'tsconfig.json' to include the newly generated declaration files.
Refactors 'src/views/DashboardView.vue' by stripping out 'import { ref, computed } from vue' and all local component import statements from '<script setup>'.
Executes 'pnpm build --no-emit' or dry-run Vite compilation to instantiate '.d.ts' manifests and runs 'vue-tsc --noEmit' to verify 0 type errors.

Runtime Troubleshooting & Failure Modes

Error: TS2304: Cannot find name 'ref'. Did you mean 'btoa'? / TS2304: Cannot find name 'BaseHeader'

Root Cause: Vite has not executed in dev/build mode to generate 'src/auto-imports.d.ts' and 'src/components.d.ts', or 'tsconfig.json' does not include the declaration paths.

Resolution Command / Fix:
npx vite build --emptyOutDir false --watch=false && pnpm vue-tsc --noEmit
Error: ESLint: 'ref' is not defined (no-undef) / 'BaseButton' is not defined (vue/no-undef-components)

Root Cause: ESLint is analyzing the Vue SFC before reading the auto-import globals generated by unplugin.

Resolution Command / Fix:
// In vite.config.ts, set AutoImport({ eslintrc: { enabled: true } })
// Then in .eslintrc.cjs add: extends: ['./.eslintrc-auto-import.json']

Frequently Asked Questions (unplugin-vue-components & Auto-Import Architecture SOP)

Q:Can I use unplugin-vue-components & Auto-Import Architecture across Codex, Claude Code, and Cursor simultaneously?

Yes. The SKILL.md format uses universal YAML frontmatter and standard CLI instructions compatible with Codex, Claude Code CLI, Cursor, and Windsurf agent engines without vendor lock-in.

Q:How does unplugin-vue-components & Auto-Import Architecture prevent context window overflow during long agent sessions?

By codifying auto-import best practices into deterministic rules, the agent refrains from injecting large blocks of redundant import headers across every generated file, drastically reducing context payload sizes.

Q:Does this skill require escalated root or container permissions?

No. The skill runs with a verified 98/100 security score. It restricts operations strictly to workspace filesystem reads/writes and non-root package execution (fs_write: workspace, net_access: false).

Ready to equip your autonomous agent with unplugin-vue-components & Auto-Import Architecture?

Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.

Get 1-Click Install Spec