一键导入
refactor
Safe code refactoring workflow focused on behavior preservation and strict testing
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Safe code refactoring workflow focused on behavior preservation and strict testing
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Execute security scanning commands on remote worker agents. Use when you need to run CLI tools like nmap, subfinder, httpx, nuclei, or any shell command on worker nodes.
Perform deep analysis of CVEs and security vulnerabilities including CVSS scoring, affected versions, exploit maturity, and remediation steps. Use when the user needs detailed vulnerability intelligence.
Perform web research using CVE databases, security advisories, and threat intelligence sources. Use when the user asks about CVEs, security news, vulnerabilities, patch releases, or any external security information not available in the workspace.
Workflow for committing code with comprehensive validation from linting to deployment
Workflow for API development and modification with strict checks from design to deployment
Workflow for creating and submitting bug reports to GitHub
| name | refactor |
| description | Safe code refactoring workflow focused on behavior preservation and strict testing |
Use this when improving internal code quality (readability, maintainability, structure, typing) without changing external behavior. Not for feature development or bug fixes — if logic must change, create a separate PR.
Define scope: list files, functions, classes, modules being refactored. Identify code smells: duplicated logic, large functions, unclear naming, tight coupling, weak typing. Impact analysis: trace callers, dependencies, public APIs. Highlight high-risk areas (auth, money, state, async, concurrency). Strategy: select 1–2 techniques per iteration (extract functions, rename, simplify control flow, improve boundaries, improve typing).
Test existence gate: every service file being refactored must have a corresponding test file. If none exists, tests must be added first describing current behavior exactly. Refactoring is forbidden until these tests pass.
Establish baseline: run all related tests before modifying code. All must pass. If any fail, stop and handle separately.
Per-step safety checklist:
Run tests frequently during refactoring. After completion, run full test suite. Do not skip tests or update snapshots just to make tests pass.
# Backend
cd core-api && npx eslint src/path/to/modified/files.ts
# Frontend
cd console && npx eslint src/path/to/modified/files.tsx
Zero errors, zero warnings.
# Backend
cd core-api && npm run test
# Frontend
cd console && npm run test
Confirm no regressions and no performance degradation.
Update English comments if structure changes. Do not add comments describing new behavior.