跳转到正文
报告库
用途分类 / 开发辅助

Refactor Skill 安全审计

作者说它能做什么(原文)

Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.

第三方安全检查结论

发现安全风险

已检查文件
1
发现的风险
2
会不会运行危险命令?检查是否下载程序后直接运行、让他人远程控制电脑,或藏起要运行的命令。未发现风险
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。未发现风险
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。发现 1 项风险
中风险

流程可能在未单独确认的情况下创建分支和多次 Git 提交

原文依据:5 处
发现了什么

指导把“提交当前状态”“创建功能分支”“测试通过就提交”和“最终提交”列为默认重构步骤,而不是需用户明确同意的可选动作。

为什么需要注意

当用户只要求查看、建议或工作区修改时,代理仍可能改变当前分支状态并写入多条持久提交;自动编写缺失测试和删除被判定为死代码也会扩大文件改动范围。

该流程把创建功能分支和多次 Git 提交列为常规步骤,没有说明须先获得用户同意。若代理照此执行,会改动仓库历史和分支状态,可能干扰用户现有工作流或生成不需要的提交。用户可要求作者将这些操作改为仅在明确授权后执行,或限制技能不得创建分支和提交。

SKILL.md:563来自说明文档打开原文件
```1. PREPARE   - Ensure tests exist (write them if missing)   - Commit current state   - Create feature branch2. IDENTIFY   - Find the code smell to address   - Understand what the code does   - Plan the refactoring3. REFACTOR (small steps)   - Make one small change   - Run tests   - Commit if tests pass   - Repeat
查看另外 4 个位置
SKILL.md:585来自说明文档打开原文件
5. CLEAN UP   - Update comments   - Update documentation   - Final commit```
SKILL.md:310来自说明文档打开原文件
### 9. Dead Code```diff# BAD: Unused code lingers- function oldImplementation() { /* ... */ }- const DEPRECATED_VALUE = 5;- import { unusedThing } from './somewhere';- // Commented out code- // function oldCode() { /* ... */ }# GOOD: Remove it+ // Delete unused functions, imports, and commented code+ // If you need it again, git history has it```
SKILL.md:564来自说明文档打开原文件
```1. PREPARE   - Ensure tests exist (write them if missing)   - Commit current state   - Create feature branch
SKILL.md:574来自说明文档打开原文件
3. REFACTOR (small steps)   - Make one small change   - Run tests   - Commit if tests pass   - Repeat
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。未发现风险
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。发现 1 项风险
中风险

标为“类型安全”的示例实际改变折扣规则,违背行为保持承诺

原文依据:5 处
发现了什么

原代码让 gold 会员周五享受 25%、其他时间 20%,其他会员统一为 10%。所谓重构后的代码新增 silver 会员 15% 折扣,并改为读取 user.membership,而不再使用单独传入的 membership。这个变化属于定价规则变化,不只是增加类型。

为什么需要注意

如果代理模仿该示例重构真实结算代码,silver 客户的应付金额会降低,调用方传入的会员等级也可能被忽略,从而造成收入、账单或促销政策偏差;测试通过也未必能发现被同步改写的预期。

该示例违背技能自己声明的“保持行为”原则:原实现仅区分 gold 与其他会员,重构后却新增 silver 的 15% 折扣,并把判断来源从独立的 membership 参数改成 user.membership。若应用于真实计价代码,会在 silver 用户或两个会员值不一致时改变收费决定。用户可要求作者用等价测试证明行为不变,并禁止未经业务批准修改折扣规则。

SKILL.md:27来自说明文档打开原文件
### The Golden Rules1. **Behavior is preserved** - Refactoring doesn't change what the code does, only how2. **Small steps** - Make tiny changes, test after each3. **Version control is your friend** - Commit before and after each safe state4. **Tests are essential** - Without tests, you're not refactoring, you're editing5. **One thing at a time** - Don't mix refactoring with feature changes
查看另外 4 个位置
SKILL.md:409来自说明文档打开原文件
```diff# Before: No types- function calculateDiscount(user, total, membership, date) {-   if (membership === 'gold' && date.getDay() === 5) {-     return total * 0.25;-   }-   if (membership === 'gold') return total * 0.2;-   return total * 0.1;- }
SKILL.md:435来自说明文档打开原文件
++ function calculateDiscount(+   user: User,+   total: number,+   date: Date = new Date()+ ): DiscountResult {+   if (total < 0) throw new Error('Total cannot be negative');++   let rate = 0.1; // Default bronze++   if (user.membership === 'gold' && date.getDay() === 5) {+     rate = 0.25; // Friday bonus for gold+   } else if (user.membership === 'gold') {+     rate = 0.2;+   } else if (user.membership === 'silver') {+     rate = 0.15;+   }+
SKILL.md:29来自说明文档打开原文件
1. **Behavior is preserved** - Refactoring doesn't change what the code does, only how2. **Small steps** - Make tiny changes, test after each
SKILL.md:411来自说明文档打开原文件
# Before: No types- function calculateDiscount(user, total, membership, date) {-   if (membership === 'gold' && date.getDay() === 5) {-     return total * 0.25;-   }-   if (membership === 'gold') return total * 0.2;-   return total * 0.1;- }

Skill 逻辑拆解

8 个说明模块

该 Skill 是一份重构指导文档,声称目标是在不改变外部行为的前提下改善现有代码的结构和可读性。提供的材料只有 SKILL.md,没有脚本、安装步骤或外部引用。

查看原文
SKILL.md:2来自说明文档打开原文件
---name: refactordescription: 'Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.'license: MIT---
SKILL.md:9来自说明文档打开原文件
## OverviewImprove code structure and readability without changing external behavior. Refactoring is gradual evolution, not revolution. Use this for improving existing code, not rewriting from scratch.

工作流程要求先建立测试,然后创建功能分支,在每个通过测试的小步骤后提交,并最终再次提交。因此,使用该 Skill 不只会提出建议,还可能改变工作区和 Git 历史。

查看原文
SKILL.md:563来自说明文档打开原文件
```1. PREPARE   - Ensure tests exist (write them if missing)   - Commit current state   - Create feature branch2. IDENTIFY   - Find the code smell to address   - Understand what the code does   - Plan the refactoring3. REFACTOR (small steps)   - Make one small change   - Run tests   - Commit if tests pass   - Repeat
SKILL.md:580来自说明文档打开原文件
4. VERIFY   - All tests pass   - Manual testing if needed   - Performance unchanged or improved5. CLEAN UP   - Update comments   - Update documentation   - Final commit```

电子邮件、付款、订单和用户数据出现在标为 BAD/GOOD 的教学代码片段中;可见内容没有要求实际发送邮件、处理付款或向网络披露这些数据。

查看原文
SKILL.md:104来自说明文档打开原文件
### 3. Large Class/Module```diff# BAD: God object that knows too much- class UserManager {-   createUser() { /* ... */ }-   updateUser() { /* ... */ }-   deleteUser() { /* ... */ }-   sendEmail() { /* ... */ }-   generateReport() { /* ... */ }-   handlePayment() { /* ... */ }-   validateAddress() { /* ... */ }-   // 50 more methods...- }# GOOD: Single responsibility per class+ class UserService {
从这里开始 · 工作说明SKILL.md
refactor
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。 另有 2 个章节,可在原文件中查看。
文件与检查记录1 个文件

检查范围与遗漏

逐文件查看涉及的内容

下方列出本次涉及的原文范围;纳入检查不代表已查清所有问题。

  • SKILL.md已纳入全文

这份报告只针对上方版本。我们看了拿到的代码和说明文件,没有实际运行 Skill,也没有检查它另外安装的软件包。因此,这不是“保证安全”的承诺;换了版本或使用环境,结果也可能不同。

  • SKILL.md工作说明
读取了多少行
646
文件校验值(用于核对版本)
397b162768be2eab93b64a0f88d69434d11441d45e089a61771e5b7b990507ee