Once the project has been confirmed to use the Vue framework, this Skill is responsible for code writing standards and component usage guidance under that framework. Based on Vue 3 (Composition API + <script setup>) for development.
Important: Prerequisites for Use
The following conditions must all be met to use this Skill:
- The current directory already contains the
.kd/config.jsonfile - In the configuration file, the
frameworkfield value isvue - The project has been initialized via
kwc-project-scaffoldComplete initialization
This Skill is prohibited in the following scenarios and must be handed over to kwc-project-scaffold:
- Project initialization (
kd project init) - Create components or pages (
kd project create) - Generate or modify
.js-meta.kwccomponent metadata - Generate or modify
.page-meta.kwppage metadata - Environment configuration (
kd envrelated commands) - Deployment operations (
kd project deploy) - Debug operations (
kd debug) — Debugging is handled by kwc-project-scaffold and must be run in background mode (is_background: true), see its debugging conventions for details
If the above prerequisites are not currently met, stop immediately and switch to kwc-project-scaffold Skill。
Core Responsibilities
You are responsible for guiding users in the development, modification, and maintenance of KWC Vue components.
Important: You must strictly comply withthe hard constraints defined in the rule.md file in this Skill's directory. Before starting any code writing, be sure to read and understand these rules.
1. Environment Context Confirmation
- Project root directory: contains the
.kdfolder and theapp/kwcdirectory. - Configuration environment:
.kd/config.jsoninframeworkisvue。 - Important: If the current environmentdoes not meetthe above conditions,you must immediately stopusing all constraints of this Skill, and instead assist the user according togeneric Vue Web projectstandards.
2. Vue 3 Development Basics
This project is based on Vue 3, and the following basic principles must be followed:
- Composition API: uniformly use
<script setup>syntax,prohibitedto use the Options API (export default { data(), methods, computed, watch }) - Reactivity: use
ref()/reactive()to declare reactive state,prohibitedto usethis. When passing complex data (objects/arrays) to Web Components, because the underlying layer needs to detect reference changes,absolutely prohibitedpushorsplicein-place modification; new references must be produced by reassignment (e.g.,data.value = [...data.value, new]) to trigger rendering. - Lifecycle: use
onMounted()/onUnmounted()and other Composition API hooks - Template Syntax:
- Attribute binding:
:prop="value" - Event binding:
@sl-change="handler"(Shoelace components use the@sl-*prefix) - Passing object/array properties to a Web Component: must use camelCase +
.propmodifier:【✅ 正确】 <sl-table :dataSource.prop="rows" :columns.prop="cols" :rowSelection.prop="sel"></sl-table> 【❌ 错误】 <sl-table :data-source="rows" :row-selection="sel"></sl-table> - Numeric properties use camelCase without
.prop(e.g.,:pageSize="20");String/boolean properties must use camelCase(e.g.,rowKey="id"、showHeader、simpleMode),Prohibited kebab-case (e.g.,row-key、show-header)
- Attribute binding:
- TypeScript: Recommended to use
<script setup lang="ts">
3. Standard Workflow
-
Create a new component:
- Mustuse the CLI tool; manually creating files is strictly prohibited:
kd project create [组件名] --type kwc - Component naming follows
PascalCase。
- Mustuse the CLI tool; manually creating files is strictly prohibited:
-
Code implementation and modification:
- Learning: Prioritize referring to
app/kwc/exampleComponent。 - Strict compliance: Code must comply withthe
rule.mdall constraints (import specifications, event binding, etc.). - Shoelace integration: When Shoelace components are involved, ensure to import from the correct path.
- Learning: Prioritize referring to
-
Verification and delivery:
- Update
app/kwc/main*references according to the project entry. - Run
npm run devfor verification.
- Update
4. Key Constraints Summary (For details, see rule.md under this Skill directory)
- Import:
import '@kdcloudjs/shoelace/dist/components/input/input.js'; - Business component import:
import '@kdcloudjs/shoelace-biz/dist/components/lookup/lookup.js';(Note the package name isshoelace-biz) - Template: Use
<sl-input>(kebab-case)。 - Event: Use
@sl-changebinding. - CSS: Styles must use Shoelace Design Token (
var(--sl-color-*)、var(--sl-spacing-*)、var(--sl-font-size-*)、var(--sl-border-radius-*)); hardcoding hex color values and px values is prohibited. For details, see./reference/css-design-tokens.md。
5. Common Resources
- Extended component documentation(located in this Skill's
reference/directory):- Basic extended components(
@kdcloudjs/shoelace): - Table:
reference/table/index.md - DatePicker:
reference/datepicker/index.md - TimePicker:
reference/sl-timepicker.md - Pagination:
reference/sl-pagination.md - Daterangepicker:
reference/sl-daterangepicker.md - ThoughtChain:
reference/sl-thought-chain.md - Nav:
reference/sl-nav.md - XMarkdown:
reference/sl-xmarkdown.md - Think:
reference/sl-think.md - TreeSelect:
reference/sl-tree-select.md - Cascader:
reference/sl-cascader.md - FloatButton:
reference/sl-float-button.md - FloatButtonGroup:
reference/sl-float-button.md - Sender:
reference/sender/index.md - SenderHeader:
reference/sender/index.md - SenderSwitch:
reference/sender/index.md - Steps:
reference/sl-steps.md - Grid:
reference/sl-grid.md - Notification:
reference/sl-notification.md - RadioGroup:
reference/sl-radio-group.md - Space:
reference/sl-space.md - Upload:
reference/upload/index.md - Segmented:
reference/sl-segmented.md - Transfer:
reference/sl-transfer.md - Popconfirm:
reference/sl-popconfirm.md - Bubble:
reference/sl-bubble.md - Business components(
@kdcloudjs/shoelace-biz, import path is@kdcloudjs/shoelace-biz/dist/components/...): - Lookup (F7):
reference/sl-lookup.md - Must read the corresponding documentation before use。
- Basic extended components(
- Standard component documentation:https://shoelace.style/
6. Output Checklist
Before submitting code, please self-check:
- Used Vue 3 Composition API (
<script setup>), did not use Options API - New component used
kd project create [组件名] --type kwc - Have read and complied withthe
rule.mdall constraints - Imported all used Web Components
- Template tags are kebab-case
- Events use
@sl-* - Did not runany ESLint/Prettier fix commands, andignoredall ESLint format errors