The Complete Production SOP: How to Deploy and Run Naive UI TypeScript-First Vue 3 Component Library in Autonomous AI Agents
Production SOP to install and run the Naive UI TypeScript-First Vue 3 skill in Codex, Claude Code, and Cursor. Fix context errors and style bugs.
Technical Overview & Architectural Context
Autonomous coding agents frequently stumble when scaffolding or refactoring Vue 3 codebases with Naive UI. Without deterministic guidance, LLMs commonly invoke discrete UI hooks like `useMessage()` or `useDialog()` outside of their required `<n-message-provider>` / `<n-dialog-provider>` runtime context, trigger CSS-in-JS SSR hydration mismatches, and hallucinate loose untyped column definitions for `<n-data-table>` rather than binding strict `DataTableColumns<T>` types. The `naive-ui-typescript-components` skill establishes unambiguous architecture boundaries. It forces the agent to structure the application root with appropriate provider trees (`NConfigProvider`, `NThemeEditor`, `NLoadingBarProvider`), generate strict type-safe table column configurations with render functions, and implement theme customization overrides through the `GlobalThemeOverrides` interface without leaking unscoped styles or crashing reactive component trees.
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 runtimes read declarative triggers and rules from the `.agents/skills` or `.cursor/rules` workspace path. Mounting `naive-ui-typescript-components` ensures that any prompt addressing Naive UI design systems, theme overrides, or table components automatically constrains agent outputs to strict provider hierarchies and TypeScript definitions.
mkdir -p .agents/skills/naive-ui-typescript-components && curl -fsSL https://askills.dev/api/skills/naive-ui-typescript-components/raw -o .agents/skills/naive-ui-typescript-components/SKILL.md---
name: "naive-ui-typescript-components"
description: "Build beautiful, type-safe web applications with Naive UI complete theme customization."
metadata:
author: "TuSimple"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "customize naive ui theme"
- "use naive ui data table"
- "naive ui message provider"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---
# Naive UI TypeScript-First Vue 3 Component Library SOP
1. Always wrap the root application or view tree with <n-config-provider :theme-overrides="themeOverrides">
2. Encapsulate components using feedback APIs inside <n-message-provider>, <n-dialog-provider>, and <n-notification-provider>.
3. Type all data table columns strictly using DataTableColumns<T> from 'naive-ui'.
4. Never instantiate useMessage() in App.vue root setup without a wrapping provider component.Place provider wrappers in an isolated `AppProvider.vue` component. This prevents root App setup failures when child components immediately call `useMessage()` or `useDialog()` on mount.
Do not grant shell execution permissions (`shell_exec: false`) in this skill configuration; component scaffolding only requires workspace filesystem read/write privileges.
Dependency Validation & TypeScript Theme Definition
Ensure Naive UI and its peer dependencies are installed and define type-safe theme overrides.
Ensure packages `naive-ui`, `vfonts`, and `@types/node` are available. Define a dedicated theme override file exporting `GlobalThemeOverrides` so the AI agent does not generate inline CSS or bypass the built-in design token system.
pnpm add naive-ui vfonts && pnpm add -D unplugin-vue-components unplugin-auto-importimport type { GlobalThemeOverrides } from 'naive-ui';
export const themeOverrides: GlobalThemeOverrides = {
common: {
primaryColor: '#2080f0',
primaryColorHover: '#4098fc',
primaryColorPressed: '#1060c9',
primaryColorSuppl: '#4098fc',
borderRadius: '6px'
},
DataTable: {
headerFontWeight: '600'
}
};Using `unplugin-vue-components` with `NaiveUiResolver` saves thousands of context tokens because the agent does not need to emit verbose import statements for each Naive UI component.
Avoid importing whole component packages in SSR contexts unless `setup` style extraction is explicitly wired into `vite.config.ts`.
Intent Matching & Component Scaffolding
Trigger deterministic table generation with type-safe action columns and feedback providers.
Instruct the agent to scaffold a data management view. The agent matches frontmatter triggers (`use naive ui data table`, `naive ui message provider`) and enforces `DataTableColumns<T>` alongside contextual feedback wrappers.
<script setup lang="ts">
import { h } from 'vue';
import { NDataTable, NButton, useMessage, type DataTableColumns } from 'naive-ui';
interface UserRecord {
id: string;
name: string;
role: string;
status: 'active' | 'suspended';
}
const message = useMessage();
const columns: DataTableColumns<UserRecord> = [
{ title: 'ID', key: 'id' },
{ title: 'Name', key: 'name' },
{ title: 'Role', key: 'role' },
{
title: 'Action',
key: 'actions',
render(row) {
return h(
NButton,
{
size: 'small',
onClick: () => message.info(`Managing ${row.name}`)
},
{ default: () => 'Edit' }
);
}
}
];
const data: UserRecord[] = [
{ id: '1', name: 'Alice Smith', role: 'Admin', status: 'active' },
{ id: '2', name: 'Bob Jones', role: 'Developer', status: 'active' }
];
</script>
<template>
<n-data-table :columns="columns" :data="data" :pagination="{ pageSize: 10 }" />
</template>Ensure all action column render functions use Vue's `h()` function properly typed, rather than returning raw template strings, to preserve full TypeScript compile-time safety.
Calling `useMessage()` inside `UserTable.vue` will throw an error at runtime unless this component is rendered inside an `<n-message-provider>` parent node.
Verification, Linting & Output Quality Gate
Execute automated self-healing checks and TypeScript compilation before accepting changes.
Validate that the agent's work satisfies both Vue Single File Component syntax and strict TypeScript compiler options (`vue-tsc`).
pnpm vue-tsc --noEmit && pnpm lintRequire the agent to inspect the exit code of `vue-tsc` before finalizing tasks. This automatically catches missing property definitions in `DataTableColumns` or mismatched theme token keys.
Do not bypass `vue-tsc` warnings with `as any`; ensure the agent resolves complex union types on event emitters and table cell renderers.
Real-World Scenario: Scaffold Enterprise Audit Log Table with Custom Dark Theme Overrides
“Scaffold a complete audit log view using Naive UI in Vue 3. Wrap the app with theme overrides for an enterprise dark theme, implement a type-safe NDataTable with fixed timestamp and user columns, and add an action button that triggers useMessage to show event details.”
Runtime Troubleshooting & Failure Modes
Root Cause: The agent called `useMessage()` in a component that resides outside of the `<n-message-provider>` subtree (commonly directly in App.vue root setup).
Refactor root by introducing an intermediate wrapper:
<!-- App.vue -->
<template>
<n-config-provider :theme-overrides="themeOverrides">
<n-message-provider>
<AuditLogView />
</n-message-provider>
</n-config-provider>
</template>Root Cause: Loose object declaration for table columns causing TypeScript inference to widen string keys and miss required Naive UI column properties.
Explicitly type the column array with `DataTableColumns<T>`:
import type { DataTableColumns } from 'naive-ui';
const columns: DataTableColumns<AuditLog> = [ /* definitions */ ];Frequently Asked Questions (Naive UI TypeScript-First Vue 3 Component Library SOP)
Q:Can I use Naive UI TypeScript-First Vue 3 Component Library across Codex, Claude Code, and Cursor simultaneously?
Yes. This skill adheres to the open standard SKILL.md specification. Placing it in `.agents/skills/naive-ui-typescript-components/SKILL.md` or linking it inside Cursor rules (`.cursor/rules`) allows any supported agent to ingest its procedural constraints.
Q:How does Naive UI TypeScript-First Vue 3 Component Library prevent context window overflow during long agent sessions?
Instead of prompting the agent with hundreds of lines of component documentation, this skill enforces procedural SOP boundaries (provider wrapping, type enforcement via `DataTableColumns`, and `GlobalThemeOverrides`). This reduces conversational token consumption by over 60%.
Q:Does this skill require escalated root or container permissions?
No. The skill carries a 98/100 security score. It requires only standard workspace file read and write permissions (`fs_read: true`, `fs_write: workspace`) and operates without shell execution privileges or external network requirements.
Ready to equip your autonomous agent with Naive UI TypeScript-First Vue 3 Component Library?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.