ワンクリックで
add-feature-end-to-end
为项目端到端地添加一个完整的新功能。覆盖从需求分析到代码生成、测试验证的全部流程,涉及 Content Script、Vue 组件、选项配置、国际化等多个层面。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
为项目端到端地添加一个完整的新功能。覆盖从需求分析到代码生成、测试验证的全部流程,涉及 Content Script、Vue 组件、选项配置、国际化等多个层面。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
代码生成后执行自动化质量检查。运行 Prettier 格式化、ESLint 检查修复和 TypeScript 类型检查。
以持续追问的方式"拷问"用户的设计方案或计划,沿决策树逐一解决每个分支的依赖关系,直到达成共识。当用户想要压力测试方案、被"盘问"设计思路,或提到"拷问我"/"grill me"/"审查方案"/"盘问方案"/"帮我梳理"等表达时使用。
添加一个新的 Content Script,注入到过早客论坛页面中。包含脚本创建、Vue 应用挂载和在主入口注册的完整流程。
为过早客论坛页面添加新的 HTML 解析函数,从论坛 HTML 中提取结构化数据。遵循项目现有的正则解析模式。
为项目添加国际化翻译。使用 vue-i18n 管理中文和英文翻译,包含翻译 key 设计、文件更新和使用方式。
在扩展的选项页面中添加一个新的子页面。包含路由配置、Vue 页面创建和侧边栏导航集成的完整流程。
| name | add-feature-end-to-end |
| description | 为项目端到端地添加一个完整的新功能。覆盖从需求分析到代码生成、测试验证的全部流程,涉及 Content Script、Vue 组件、选项配置、国际化等多个层面。 |
在执行本 Skill 前,先阅读以下知识库文件以获取必要的背景知识:
.codebuddy/knowledge/architecture.md - 理解三进程架构、数据流和模块依赖关系.codebuddy/knowledge/forum-domain.md - 如功能涉及论坛页面,了解页面结构和 URL 模式本技能指导为"过早客 Plus"浏览器扩展从零到一添加一个完整功能。一个功能通常涉及多个层面:Content Script(注入论坛页面)、Vue 组件(UI 渲染)、选项配置(用户设置)、国际化(中英文翻译)等。
明确以下问题:
如需新的枚举、存储字段或类型,在对应文件中添加:
枚举/常量: src/constants/index.ts
// 新增选项开关
export const enum OptionsKey {
// ... 已有
NewFeature = 'newFeature',
}
// 新增消息类型(如需要)
export const enum ExtensionMessageType {
// ... 已有
NewFeatureAction,
}
默认选项: 在 defaultExtensionOptions 中添加默认值
[OptionsKey.NewFeature]: {
checked: true, // 或自定义结构
},
类型定义: src/types/index.ts
export interface Options {
// ... 已有
[OptionsKey.NewFeature]: CheckedOption; // 或其他结构
}
在 src/scripts/ 中创建新文件:
// src/scripts/new-feature.ts
import { createScriptApp } from '@/utils';
import NewFeatureComponent from '@/components/NewFeature.vue';
import type { Pinia } from 'pinia';
export const createNewFeatureApp = (pinia: Pinia) => {
createScriptApp({
root: NewFeatureComponent,
pinia,
containerId: 'gzk-new-feature-app',
containerParentNode: document.body,
});
};
在 src/scripts/index.ts 中注册:
import { createNewFeatureApp } from './new-feature';
// 在 setupApp 中添加条件调用
if (options[OptionsKey.NewFeature].checked) {
createNewFeatureApp(pinia);
}
在 src/components/ 中创建组件:
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useStorageStore } from '@/stores/storage';
import type { OptionsKey } from '@/constants';
interface Props {
optionKey: OptionsKey;
}
const props = defineProps<Props>();
const storage = useStorageStore();
const isEnabled = computed(() => {
return storage.options?.[props.optionKey]?.checked;
});
</script>
<template>
<div v-if="isEnabled" class="new-feature-container">
<!-- 功能 UI -->
</div>
</template>
<style lang="scss" scoped>
.new-feature-container {
// 样式
}
</style>
在 src/views/basic-setting/ 中创建或修改设置项:
<script setup lang="ts">
import { useStorageStore } from '@/stores/storage';
import { OptionsKey } from '@/constants';
import type { SettingProps } from '@/types';
const props = defineProps<SettingProps<OptionsKey.NewFeature>>();
const storage = useStorageStore();
</script>
<template>
<el-form-item>
<el-switch :model-value="storage.options?.[OptionsKey.NewFeature].checked"
@update:model-value="(val) => { /* update storage */ }" />
</el-form-item>
</template>
将新选项添加到 src/views/basic-setting/BasicSetting.vue 的配置列表中。
在 src/i18n/locales/zh.json 和 en.json 中添加翻译:
{
"settings": {
"newFeature": {
"name": "新功能",
"description": "启用新功能"
}
}
}
pnpm format # 格式化
pnpm lint:fix # ESLint 修复
pnpm type-check # 类型检查(可选,用户手动执行)
使用 git-commit-message skill 生成提交信息,scope 视情况选择 scripts、components、views 等。
// 读取整个存储
const { options } = await getStorage();
// 读取特定选项
const newFeatureOption = options[OptionsKey.NewFeature];
// 写入
await setStorage({
options: newOptions,
});
// Content Script 发送
await runtime.sendMessage({
msgType: ExtensionMessageType.NewFeatureAction,
data: 'some data',
});
// Background 接收
runtime.onMessage.addListener(async (message: ExtensionMessage) => {
if (message.msgType === ExtensionMessageType.NewFeatureAction) {
// 处理
}
});
添加新功能时典型的文件变更:
src/constants/index.ts # 新枚举值、常量
src/types/index.ts # 新类型定义
src/scripts/new-feature.ts # Content Script(新文件)
src/scripts/index.ts # 注册新脚本
src/components/NewFeature.vue # Vue 组件(新文件)
src/views/basic-setting/*.vue # 选项 UI
src/i18n/locales/zh.json # 中文翻译
src/i18n/locales/en.json # 英文翻译