local-link/skills/bem-refactor/SKILL.md
将 Vue 组件重构为使用 BEM(Block-Element-Modifier)命名规范。 使用场景: - 用户说"用 useBEM 改造这个组件" - 用户说"给这个组件加上 BEM 类名" - 用户要求重构组件以符合项目 BEM 规范 - 需要将 Tailwind 工具类与 BEM 语义类名结合使用 触发关键词:useBEM、BEM、重构组件、BEM 改造、bem-refactor
npx skillsauth add lionad-morotar/local-tools bem-refactorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
读取目标文件,了解:
搜索项目中的 useBEM 使用方式:
useBEM 的实现位置(通常在 app/composables/bem/)page-*, cmpt-*, layout-*)根据组件类型和位置,选择合适的 block 名:
| 组件类型 | Block 前缀示例 |
|---------|--------------|
| 页面级组件 | page-xxx |
| 可复用 UI 组件 | cmpt-xxx |
| 布局组件 | layout-xxx |
引入 useBEM:
const { b, e, is } = useBEM('block-name')
类名绑定规则:
class:class示例:
<!-- Before -->
<div class="px-6 py-4 bg-white rounded-sm">
<h2 class="text-lg font-semibold text-gray-900">标题</h2>
</div>
<!-- After -->
<div class="px-6 py-4 bg-white rounded-sm" :class="e('header')">
<h2 class="text-lg font-semibold text-gray-900" :class="e('title')">标题</h2>
</div>
在组件末尾添加嵌套 BEM 结构的 style 占位:
<style scoped lang="css">
.p-block-name {
/* container */
&__header {
/* header wrapper */
&-inner {
/* header inner */
}
}
&__title {
/* title element */
}
&__main {
/* main content */
&.is-empty {
/* modifier state */
}
}
}
</style>
重构前:
<template>
<div class="w-full">
<div class="px-6 py-4 bg-white rounded-sm">
<h2 class="text-lg font-semibold">{{ title }}</h2>
</div>
<div class="main bg-white rounded-sm">
<slot />
</div>
</div>
</template>
重构后:
<script setup lang="ts">
const { b, e, is } = useBEM('page-saas')
const props = defineProps<{
title?: string
}>()
</script>
<template>
<div class="w-full" :class="b()">
<div class="px-6 py-4 bg-white rounded-sm" :class="e('header')">
<h2 class="text-lg font-semibold" :class="e('title')">{{ title }}</h2>
</div>
<div class="bg-white rounded-sm" :class="e('main')">
<slot />
</div>
</div>
</template>
<style scoped lang="css">
.p-page-saas {
/* container */
&__header {
/* header wrapper */
}
&__title {
/* page title */
}
&__main {
/* main content */
}
}
</style>
v-tw-merge 指令确保 class 合并正确is('state') 生成状态类名(如 is-empty)tools
理解用户意图;listen 模式通过 grill-me 深挖任务并归档经验
development
给 VSCode(Insiders/Stable) 内置 ripgrep 加 5s 超时包装,防止搜索卡死吃满 CPU。--on 包装(幂等) / --off 还原 / 不带参数查状态。Use when VSCode 搜索卡死、rg 进程占满 CPU,或 VSCode 更新后超时保护失效需要重包。
development
为指定项目创建完全隔离的 hapi(Claude Code On the Go)实例,包括独立数据目录、LaunchAgent 持久化、zsh wrapper 和 app.hapi.run 直连 URL。与全局 ~/.hapi 互不干扰。
development
关闭承载当前 Claude Code 会话的宿主(VSCode 窗口或其终端面板),连同 claude 一起退出。通过 close-host-window 扩展触发:先 SIGTERM claude(走完 SessionEnd hooks)再关 host,不抢焦点、不丢 hooks。--host vscode 关窗口、--host terminal(默认)只关终端面板。Use when 任务结束要随宿主退出,或需精确关闭某 claude 终端所在窗口/面板。