用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/vinilana/dotcontext --skill refactoring命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| type | skill |
| name | Refactoring |
| description | Safe code refactoring with step-by-step approach |
| skillSlug | refactoring |
| phases | ["E"] |
| generated | "2026-03-18T00:00:00.000Z" |
| status | filled |
| scaffoldVersion | 2.0.0 |
Safe, systematic refactoring procedures for the @dotcontext/cli codebase.
any usageBefore starting any refactoring:
npm testnpm run buildThe project follows a directory-per-service pattern. To extract logic into a new service:
src/services/<name>/ directory// src/services/cache/cacheService.ts
export interface CacheServiceOptions {
repoPath: string;
cacheDir?: string;
}
export class CacheService {
private readonly repoPath: string;
private readonly cacheDir: string;
constructor(options: CacheServiceOptions) {
this.repoPath = options.repoPath;
this.cacheDir = options.cacheDir || '.context/.cache';
}
async get(key: string): Promise<string | null> { /* ... */ }
async set(key: string, value: string): Promise<void> { /* ... */ }
}
src/services/<name>/index.ts barrel:export { CacheService, CacheServiceOptions } from './cacheService';
src/services/<name>/cacheService.test.tsGateway handlers in src/services/mcp/gateway/ can grow large. To split:
export async function handleContext(params: ContextParams, options: ContextOptions): Promise<MCPToolResponse> {
switch (params.action) {
case 'check': return handleCheck(options);
case 'init': return handleInit(params, options);
// Each case delegates to a focused function
}
}
Common type improvements:
any with unknown: Then add type guards:// Before
function process(data: any) { return data.value; }
// After
function process(data: unknown): string {
if (typeof data === 'object' && data !== null && 'value' in data) {
return String((data as { value: unknown }).value);
}
throw new Error('Invalid data shape');
}
type ContextParams =
| { action: 'check'; repoPath?: string }
| { action: 'init'; repoPath?: string; type?: string }
| { action: 'fill'; repoPath?: string; target?: string };
AIContextMCPServer with contextBuilder).Common duplication spots in this project:
repoPath + outputDir. Extract to src/services/shared/.src/utils/frontMatter.ts.src/services/shared/ for existing utilities.createErrorResponse() from response.ts.When moving or renaming files, update the export chain:
src/services/mcp/gateway/<file>.ts -- implementation
-> src/services/mcp/gateway/index.ts -- gateway barrel
-> src/services/mcp/gatewayTools.ts -- compatibility barrel
-> src/services/mcp/mcpServer.ts -- consumer
npm test and npm run buildrefactor(<scope>): prefixnpx jest --testPathPattern="<area>" after each step.npm run build will catch broken imports, type mismatches, and missing exports.noUnusedLocals temporarily to find dead code after extraction.