pattern-detector
偵測設計模式和反模式
不良的程式碼結構會導致技術債和維護問題。此技能可分析程式碼以識別正在使用的設計模式和應該修復的反模式,並提供明確的改進建議。
下载技能 ZIP
在 Claude 中上传
前往 设置 → 功能 → 技能 → 上传技能
开启并开始使用
测试它
正在使用“pattern-detector”。 Use pattern-detector to analyze this authentication module for design patterns and anti-patterns
预期结果:
- ✓ Factory Pattern detected at auth/Factory.js:12 - Clean implementation for creating auth providers
- ⚠️ Singleton Pattern overused at auth/Logger.js:8 - Consider dependency injection instead
- ❌ God Object detected at auth/AuthManager.js:45 - Handles 7 responsibilities, should be split
- Anti-pattern severity: High - Recommend splitting into AuthService, SessionManager, and TokenHandler
安全审计
安全This is a pure markdown prompt skill containing only documentation and code examples. No executable code, scripts, network calls, filesystem access, or command execution. The static analyzer triggered on legitimate software pattern names (Strategy, Command, State, Singleton, Builder) which are incorrectly flagged as cryptographic keywords. JavaScript template literals in code examples were misidentified as shell backticks. All 61 findings are false positives.
风险因素
🌐 网络访问 (1)
⚙️ 外部命令 (32)
质量评分
你能构建什么
審查程式碼品質
分析您的程式碼以識別架構問題,並接收具體的重構建議。
評估程式碼庫健康狀況
評估團隊程式碼中的反模式,確保遵守架構標準。
學習模式識別
了解為什麼某些模式是有問題的,以及如何透過實際範例來修復它們。
试试这些提示
Use @pattern-detector to analyze this code and identify all design patterns and anti-patterns present.
@pattern-detector --anti-patterns-only this code and explain each problem with severity level.
Use @pattern-detector to check if this code follows proper pattern implementation practices.
@pattern-detector this code and provide specific recommendations for improving the architecture with code examples.
最佳实践
- 先從反模式偵測開始,以識別最關鍵的問題
- 優先將重構工作集中在上帝物件和義大利麵程式碼上,再優化模式
- 將模式建議作為指南而非命令——情境很重要
避免
- 使用模式偵測來證明過度工程是正當的,而非保持解決方案的簡單性
- 忽略嚴重性等級,優先嘗試修復低優先順序的問題
- 在不了解模式所要解決的特定問題的情況下應用模式