一键导入
rue
Use when generating Rue components, hooks, pages, examples, migrations, or when comparing Rue with Vue 3 and React.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when generating Rue components, hooks, pages, examples, migrations, or when comparing Rue with Vue 3 and React.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
当需要在编码前创建或更新实施计划时使用,尤其适用于多步骤功能开发、重构、包含多个活动部件的缺陷修复,或需要拆分为可独立执行并跟踪进度的任务文件的请求。
在创建、精简或改写技能说明,且需要让技能更清晰、可发现、可执行时使用
当你有书面实现计划需要在单独会话中执行,并带有审查检查点时使用
通过 `rustcodegraph` 命令行界面使用 RustCodeGraph 理解、导航或脚本化操作已索引代码库。当用户要求使用 RustCodeGraph、需要高性能搜索检索代码、需要符号/源码/调用流上下文、调用方/被调用方/影响分析或受影响测试选择时使用。
Use when migrating away from legacy compat helpers, checking for removed compat symbols, or validating Renderable-first cleanup work in Rue.
Use when diagnosing Rue runtime errors, decoding Vapor/Wasm trap stacks, or updating production error reference docs.
基于 SOC 职业分类
| name | rue |
| description | Use when generating Rue components, hooks, pages, examples, migrations, or when comparing Rue with Vue 3 and React. |
Arguments:
Use this skill whenever the user asks for Rue code, Rue examples, or framework comparisons. The goal is to keep generated code in Rue idioms instead of drifting into Vue 3 SFC syntax or React-only patterns.
Rue also supports JSX directive attributes in TSX, including v-if, v-else, v-for, v-pre, r-if, r-for, and r-pre. When the user asks for directive examples, or when the surrounding file already uses this style, generate them as Rue JSX directives rather than rewriting everything to plain .map() and ternaries.
Rue is best treated as:
useState, #sym:useEffect, useMemo, useCallback, and useRef when matching existing code styleref, reactive, and computedsignal API for getter/setter style stateuseApp(...).mount(...)Default preference when generating code:
ref / reactive / computed for most state exampleswatch, watchEffect, and lifecycle hooks for reactive side effects@rue-js/router for routing examples.vue single-file components<template> / <script setup> / <style scoped>:class, @click, v-model, or {{ value }}v-if, v-for, v-pre, and r-pre are valid only as TSX directive attributes, not inside Vue templatesuseState + useEffectDo not cross-wrap state containers: avoid putting createStore() / defineStore() stores, ref, reactive, or computed handles inside useState, and avoid re-wrapping useState state inside store state, ref, reactive, or computed just to pass it around
Pick one owner for each piece of state: use useState for plain local values or a single local object shape, and use store / ref / reactive / computed directly when the surrounding code already depends on Rue reactivity primitives
Rue also supports React-style hooks such as #sym:useEffect, useMemo, useCallback, and useRef; use them when the user asks for React-like Rue code or when matching existing local style
Generate Rue imports
@rue-js/rue@rue-js/routerUse JSX event props and plain JavaScript expressions
onClick, onInput, onChange&&, and .map() for conditional rendering and listsv-if, v-for, v-pre, r-pre, r-if, and r-for directly in TSXPrefer explicit form bindings
value + onInput or checked + onChangev-modelComponent communication uses props and callbacks
defineProps, defineEmits, or Vue emits option objectsonSubmit, onChange, onSelectBootstrapping should look like Rue
useApp(App).mount('#app')Similarities:
ref, reactive, computed, watch, watchEffectonMountedKey differences:
className, onClick, and {expr}v-if and v-forv-modelVue-to-Rue translation example:
Wrong for Rue:
<template>
<button @click="count++">{{ count }}</button>
</template>
<script setup>
import { ref } from 'vue'
const count = ref(0)
</script>
Correct Rue version:
import { type FC, ref } from '@rue-js/rue'
const Counter: FC = () => {
const count = ref(0)
return <button onClick={() => count.value++}>{count.value}</button>
}
export default Counter
Similarities:
onClick and onInputuseState, #sym:useEffect, useMemo, useCallback, and useRefKey differences:
computed, not ad-hoc useMemo everywherewatch / watchEffect, and Rue also supports #sym:useEffect when a React-like dependency-array style is the better matchref / reactive / signal instead of only useStateuseApp, not createRoot(...).render(...)React-to-Rue translation example:
React style:
import { useState } from 'react'
export default function Counter() {
const [count, setCount] = useState(0)
return <button onClick={() => setCount(count + 1)}>{count}</button>
}
Preferred Rue version:
import { type FC, ref } from '@rue-js/rue'
const Counter: FC = () => {
const count = ref(0)
return <button onClick={() => count.value++}>{count.value}</button>
}
export default Counter
React-like Rue version when explicitly requested:
import { type FC, useState } from '@rue-js/rue'
const Counter: FC = () => {
const [count, setCount] = useState(0)
return <button onClick={() => setCount(count.value + 1)}>{count.value}</button>
}
export default Counter
React-like effect example supported in Rue:
import { type FC, useEffect, useRef, useState } from '@rue-js/rue'
const SearchPanel: FC = () => {
const [keyword, setKeyword] = useState('')
const requestVersionRef = useRef(0)
useEffect(() => {
requestVersionRef.current += 1
console.log('keyword =', keyword.value, 'request =', requestVersionRef.current)
}, [() => keyword.value])
return (
<input
value={keyword.value}
onInput={event => {
setKeyword((event.target as HTMLInputElement).value)
}}
placeholder="搜索关键词"
/>
)
}
export default SearchPanel
Rue supports directive-style TSX when the example is specifically about directives or when the surrounding file already uses that style.
Prefer these forms:
v-if={condition} and v-else for conditional directive examplesv-for="item in list" or v-for="(item, index) in list" for array and numeric iterationr-for="(value, key) in object" for object iteration examplesv-pre and r-pre when showing raw directive text or skipping directive compilation in a subtreeDirective example:
import { computed, type FC, ref } from '@rue-js/rue'
const profileMeta = {
framework: 'Rue',
renderer: 'Vapor',
}
const DirectiveDemo: FC = () => {
const phase = ref<'draft' | 'published'>('draft')
const count = ref(3)
const items = computed(() => [
{ id: 1, name: 'Apple' },
{ id: 2, name: 'Banana' },
])
return (
<div className="grid gap-4">
<div className="rounded-box border border-base-300 p-4">
<span v-if={phase.value === 'draft'}>当前阶段:{phase.value}</span>
<span v-else>当前阶段:{phase.value}</span>
</div>
<ul className="list rounded-box bg-base-100">
<li v-for="(item, index) in items.get()" key={item.id} className="list-row">
{index + 1}. {item.name}
</li>
</ul>
<div className="flex flex-wrap gap-2">
<span r-for="(value, key) in profileMeta" key={key} className="badge badge-outline">
{key}: {value}
</span>
</div>
<div v-pre className="rounded-box border border-dashed border-base-300 p-4">
<span v-if={phase.value === 'draft'}>{'{{ phase.value }}'}</span>
</div>
<div className="flex flex-wrap gap-2">
<span v-for="step in count.value" key={step} className="badge badge-primary">
Step {step}
</span>
</div>
</div>
)
}
export default DirectiveDemo
Directive generation rules:
key for repeated nodes when the example iterates arrays or objectsr-for for object iteration examples and v-for for arrays or numeric rangesv-pre or r-pre only when the example needs to preserve directive-looking text or skip directive expansion in that subtreePrefer this for general examples:
import { type FC, computed, reactive, ref } from '@rue-js/rue'
const ProfileCard: FC = () => {
const count = ref(0)
const profile = reactive({ name: 'Rue', city: 'Shanghai' })
const label = computed(() => `${profile.name}: ${count.value}`)
return (
<section>
<h2>{label.value}</h2>
<p>{profile.city}</p>
<button onClick={() => count.value++}>增加</button>
</section>
)
}
export default ProfileCard
Avoid cross-wrapping reactive containers:
const [state] = useState(() => ({ store, count, summary })) when store comes from defineStore(), count is a ref, or summary is a computeduseState return values into store state, reactive(...), or computed(...) only to expose them through another containeruseState, keep that state plain and local instead of mixing ownership with store / ref / reactive / computedPrefer this for subscriptions or reactive reactions:
import { type FC, onMounted, ref, watchEffect } from '@rue-js/rue'
const SearchBox: FC = () => {
const keyword = ref('')
onMounted(() => {
console.log('mounted')
})
watchEffect(() => {
console.log('keyword =', keyword.value)
})
return (
<input
value={keyword.value}
onInput={event => {
keyword.value = (event.target as HTMLInputElement).value
}}
placeholder="请输入关键词"
/>
)
}
export default SearchBox
If the surrounding code already uses React-like hooks, this is also valid Rue code:
import { type FC, useEffect, useRef, useState } from '@rue-js/rue'
const SearchBox: FC = () => {
const [keyword, setKeyword] = useState('')
const mountedRef = useRef(false)
useEffect(() => {
mountedRef.current = true
console.log('keyword =', keyword.value)
return () => {
mountedRef.current = false
}
}, [() => keyword.value])
return (
<input
value={keyword.value}
onInput={event => {
setKeyword((event.target as HTMLInputElement).value)
}}
placeholder="请输入关键词"
/>
)
}
export default SearchBox
Prefer this for runnable examples:
import { type FC, ref, useApp, useError } from '@rue-js/rue'
const App: FC = () => {
const count = ref(0)
return <button onClick={() => count.value++}>点击次数:{count.value}</button>
}
useError({ overlay: true, console: true })
useApp(App).mount('#app')
v-model, :class, @click, or {{ value }} as if the file were a Vue templatereact inside Rue examplescreateRoot or ReactDOM.render in Rue app entry filescomputed values with manual effect bookkeepingcomputed handles, refs, or reactive objects inside useState, or wrapping useState state back into those containers#sym:useEffect / useMemo / useCallback / useRef and rewriting existing React-like Rue code unnecessarilyv-if, v-for, v-pre, or r-pre when the user explicitly asks for directive exampleskey when rendering lists{{ value }} into JSXBefore returning Rue code, verify:
@rue-js/rue and related Rue packagesonClick and onInput