Notre avis
Refactorisation sécurisée avec tests de garde : exécute les tests avant et après les modifications pour garantir que le comportement n'est pas altéré.
Points forts
- Maintient une barrière de sécurité grâce aux tests
- Processus incrémental avec validation à chaque étape
- Affiche un diff pour revue
- Ne modifie pas le comportement existant
Limites
- Nécessite une suite de tests existante et fiable
- Peut être lent si les tests sont longs
- Ne traite pas les problèmes de conception qui nécessiteraient des changements de comportement
Utilisez cette compétence lorsque vous devez restructurer du code existant sans en changer le comportement et que vous disposez d'une suite de tests de qualité.
Ne l'utilisez pas pour ajouter des fonctionnalités, corriger des bugs ou lorsque les tests sont absents ou défaillants.
Analyse de sécurité
SûrThe skill uses standard development tools (Bash, Read, Write, Edit, Glob, Grep) for safe refactoring with test guardrails. It does not instruct destructive actions, exfiltration, or obfuscated payloads.
Aucun point d'attention détecté
Exemples
/refactor extract helper functions from the processOrder method to improve readabilityrefactor this file to reduce duplication and simplify conditionalsclean up this code by renaming variables and functions to be more descriptivename: refactor description: Safe refactoring with test guardrails. Use when the user says "/refactor", "refactor this", "clean up this code", or wants to restructure code without changing behavior. Runs tests before and after to ensure safety. allowed-tools:
- Bash
- Read
- Write
- Edit
- Glob
- Grep
Refactor
安全重构:测试基线 → 重构 → 验证绿灯 → 展示 diff。
Workflow
1. Understand Scope
Clarify with the user:
- What to refactor (file, function, module)
- What kind of refactoring (extract, rename, simplify, reorganize)
- What NOT to change
2. Baseline Tests
Run the test suite BEFORE any changes:
[test command]
All tests must pass. If they don't, fix tests first (or ask user) before refactoring.
Record the baseline: N tests, all passing.
3. Read the Code
Read the target code thoroughly. Understand:
- Current structure and responsibilities
- Dependencies (who calls this, what does it call)
- Edge cases handled
4. Plan the Refactoring
Describe what you'll change and why. Common refactoring types:
| Type | When | |------|------| | Extract function | 函数太长或有重复逻辑 | | Rename | 命名不清晰 | | Simplify conditionals | 嵌套过深或逻辑复杂 | | Move/reorganize | 职责错位 | | Remove dead code | 未使用的代码 | | Reduce duplication | DRY 原则 |
5. Execute
Apply changes incrementally:
- One refactoring step at a time
- Run tests after each step
- If tests break, revert and retry differently
6. Verify
Run the full test suite:
[test command]
All baseline tests must still pass. Show the output.
7. Show Diff
git diff
Present the diff so the user can review the changes.
Rules
- 不改变行为——所有现有测试必须通过
- 不添加功能——重构和 feature 分开做
- 不一次改太多——小步快跑,每步验证
- 如果没有测试覆盖,先建议添加测试再重构
Expert Next.js App Router
Developpement
Un skill qui transforme Claude en expert Next.js App Router.
Générateur de README
Developpement
Crée des README.md professionnels et complets pour vos projets.
Rédacteur de Documentation API
Developpement
Génère de la documentation API complète au format OpenAPI/Swagger.