用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/linzb93/ai-coding-docs --skill api-extractor命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | api-extractor |
| description | 将指定文件或目录下的 .vue 文件中的内联 API 调用提取出来。支持批量重构整个目录。 |
此 Skill 帮助你将嵌入在 .vue 组件(或指定目录下的所有组件)中的 API 调用重构到统一的 shared/api.js 文件中,并在 types/index.ts 中生成相应的类型定义。
你是一位代码重构和 API 管理专家。你的目标是通过集中管理 API 逻辑来保持代码库的整洁。支持单文件处理,也支持处理“提取 xx 目录下的 api 调用”这类批量指令。
分析输入与上下文:
.vue 文件。views/<Module>/ 的子目录(如 children, components 等)下,根目录为 views/<Module>/。views/<Module>/ 下,根目录为 views/<Module>/。src/views/<Module>/shared/api.js。src/views/<Module>/types/index.ts。types 目录不存在,请创建它。绝对禁止在 shared 目录下创建 type.ts 或 types.ts。提取信息(针对每个文件):
await post('/url', { ... }))。post, get 等。/review/list。pageIndex/pageSize,响应是否包含 list/totalCount/totalPages。生成代码:
/review/list -> getReviewList)。types/index.ts):
@/types/index 导入 PaginationParms。Request 接口应 extends PaginationParms。@/types/index 导入 PaginationResponse。Response 接口应 extends PaginationResponse<ItemType>。Request 接口(例如:ReviewListRequest)。Response 接口(例如:ReviewListResponse)。shared/api.js):
@/utils/request 导入 post/get。../types 导入类型(注意路径是 ../types 而不是 ./type)。@file(如果已知 YApi 链接)、@param、@returns。应用变更:
types/index.ts 添加新接口(追加模式)。shared/api.js 添加新函数(追加模式)。.vue 文件:
shared/api.js 相对于当前 .vue 文件的路径(例如:在 components 目录下需使用 ../../shared/api)。src/views/<Module>/shared/api.jssrc/views/<Module>/types/index.tssrc/views/<Module>/shared/type.ts。src/types/index.ts。import { PaginationParms, PaginationResponse } from '@/types/index';/**
* 接口描述
* @file YApi_链接 (如果提供)
* @param {import('../types').RequestType} params
* @returns {Promise<import('../types').ResponseType>}
*/
普通接口:
export interface RequestType {
// 属性定义
}
分页接口:
import { PaginationParms, PaginationResponse } from '@/types/index';
export interface ListRequest extends PaginationParms {
otherParam: string;
}
export interface ListItem {
id: number;
name: string;
}
export interface ListResponse extends <> {}
用户指令: "提取 src/views/demo 目录下的 API"
执行过程:
src/views/demo/components/Filter.vue。post('/demo/filter', { ... })。src/views/demo/。src/views/demo/types/index.ts 和 src/views/demo/shared/api.js。.vue 文件:
import { getDemoFilter } from '../../shared/api'; // 注意相对路径
// ...