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.
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
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
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.
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---
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
---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.
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.
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.
pnpm add -D unplugin-vue-components unplugin-auto-importimport { 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',
}),
],
});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'.
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'.
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.
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.
Avoid prompt instructions like 'import components everywhere'. Runtimes might misunderstand and append manual imports instead of configuring the unplugin compilation pipeline.
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.
pnpm vite build --mode development && pnpm vue-tsc --noEmit{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": [
"env.d.ts",
"src/**/*",
"src/**/*.vue",
"src/auto-imports.d.ts",
"src/components.d.ts"
]
}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.
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
“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'.”
Runtime Troubleshooting & Failure Modes
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.
npx vite build --emptyOutDir false --watch=false && pnpm vue-tsc --noEmitRoot Cause: ESLint is analyzing the Vue SFC before reading the auto-import globals generated by unplugin.
// 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.