ワンクリックで
refactoring
Safe code refactoring with step-by-step approach
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Safe code refactoring with step-by-step approach
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Review code quality, patterns, and best practices
Design MCP tools and gateway interfaces for the dotcontext server
Systematic bug investigation and root cause analysis
Generate commit messages following conventional commits with scope detection
Generate and update technical documentation
Break down features into implementable tasks
| 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.