一键导入
code-refactoring-guide
Evaluate code quality and suggest refactoring opportunities before committing. Ensure Cooper's codebase stays clean and maintainable.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Evaluate code quality and suggest refactoring opportunities before committing. Ensure Cooper's codebase stays clean and maintainable.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Build comprehensive task context before making changes. Track constraints, dependencies, and execution order across multi-file work in Cooper's Electron architecture.
Define patterns for integrating with the Copilot SDK in Cooper. Cover session management, model switching, tool execution, event handling, and agent support.
Define and enforce IPC communication patterns between Cooper's main process, preload bridge, and renderer. Ensure all cross-process communication follows the secure, typed preload bridge pattern.
Create atomic commits with descriptive messages. Maintain clean git history for the Cooper project.
Decompose tasks into sub-tasks, assess risk, and create implementation checklists before starting work on Cooper features.
Define React, TypeScript, and Tailwind conventions for Cooper's renderer process. Ensure consistent, accessible, and maintainable UI components.
| name | code-refactoring-guide |
| description | Evaluate code quality and suggest refactoring opportunities before committing. Ensure Cooper's codebase stays clean and maintainable. |
Evaluate code quality and suggest refactoring opportunities before committing. Ensure Cooper's codebase stays clean and maintainable.
| Metric | Target | Action if Exceeded |
|---|---|---|
| Function length | < 50 lines | Extract helper functions |
| File length | < 300 lines | Split into modules |
| Nesting depth | < 3 levels | Early returns, extract logic |
| Duplicate code | < 3 occurrences | Extract shared utility |
src/main/): Are IPC handlers focused? One handler per concern?src/preload/): Is the bridge API clean and namespaced?src/renderer/): Components decomposed? Hooks extracted?src/renderer/types/): Interfaces well-defined? No any types?ACCEPT refactoring if:
REJECT refactoring if:
npm run build # No type errors
npm test # No regressions
Extract IPC handler:
// Before: fat handler in main.ts
ipcMain.handle('copilot:send-message', async (_, sessionId, message) => {
// 50+ lines of logic
});
// After: extracted to module
ipcMain.handle('copilot:send-message', handleSendMessage);
Extract React hook:
// Before: logic in component
const [sessions, setSessions] = useState([]);
useEffect(() => {
/* fetch logic */
}, []);
// After: custom hook
const { sessions } = useSessions();
any types in new code