360 Secure SkillHub
360 安全技能中心

Refactoring Functions

用于保持行为不变的前端重构,聚焦函数结构、命名、参数、共享上下文与阶段边界。提供11种规范技法,含意图、信号、禁用条件、机械步骤、保留检查点、组合提示及JS/TS/React/Vue适配。典型场景:安全拆分/合并函数、重命名、调整参数、提取共享上下文。输入为待重构代码与选定技法,输出为最小步重构及验证结果;每次只做一个技法并立即验证,避免公共契约、生命周期或状态标识失控。

bovinphang
bovinphang
热度 7.62
最近更新 2026-09-27 11:36:35
分类:开发依赖:读写文件 / 代码执行应用场景:代码审查 / 代码生成

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add fec-refactoring-functions
Metadata
name
fec-refactoring-functions
description
Use when behavior-preserving frontend refactoring focuses on function structure, naming, parameters, shared context, or phase boundaries, and the selected technique needs family-specific mechanics, risks, and JavaScript/TypeScript/React/Vue adaptation.

Function Refactorings

Overview

Use this family after evidence identifies a fitting structural transformation. Apply one primary technique at a time and verify immediately.

Procedure

  1. Confirm the selected technique and its preconditions in Function Refactorings.
  2. Record affected behavior and a diff budget.
  3. Apply only the selected technique's smallest viable step.
  4. Verify the step before composing another transformation.
  5. Stop and reassess when public contracts, lifecycle, state identity, or actual scope exceed expectations.

Quick Reference

The family reference contains 11 canonical techniques with intent, signals, avoid conditions, mechanics, preservation checkpoints, smell links, composition hints, JavaScript/TypeScript notes, React/Vue notes, adaptation guidance, and original frontend examples.

Common Mistakes

  • Choosing a technique by name without checking its preconditions.
  • Combining several structural intentions in one diff.
  • Assuming a classical class-based form is mandatory in modern frontend code.
  • Treating passing tests as proof when the relevant behavior is not covered.