Agent Skillswinstonkoh87/Athena-Public › Diagnostic-First Refactoring

Diagnostic-First Refactoring

GitHub

一种非破坏性代码重构协议,主张先诊断后修改。AI仅生成包含死代码、复杂度、冗余及性能问题的“物料清单”报告,禁止直接重写代码,需用户审批后再执行,确保重构安全可控。

examples/skills/coding/diagnostic-refactor/SKILL.md winstonkoh87/Athena-Public

Trigger Scenarios

需要分析代码质量并生成优化建议时 希望在动手修改前评估重构风险和收益时

Install

npx skills add winstonkoh87/Athena-Public --skill Diagnostic-First Refactoring -g -y
More Options

Non-standard path

npx skills add https://github.com/winstonkoh87/Athena-Public/tree/main/examples/skills/coding/diagnostic-refactor -g -y

Use without installing

npx skills use winstonkoh87/Athena-Public@Diagnostic-First Refactoring

指定 Agent (Claude Code)

npx skills add winstonkoh87/Athena-Public --skill Diagnostic-First Refactoring -a claude-code -g -y

安装 repo 全部 skill

npx skills add winstonkoh87/Athena-Public --all -g -y

预览 repo 内 skill

npx skills add winstonkoh87/Athena-Public --list

SKILL.md

Frontmatter
{
    "name": "Diagnostic-First Refactoring",
    "model": "default",
    "source": "r\/vibecoding community pattern",
    "created": 1770163200,
    "auto-invoke": false,
    "description": "A non-destructive, decoupled analysis protocol for refactoring code. Generates a \"Bill of Materials\" report before any code is touched.",
    "context_trigger": "refactor, code smell, tech debt, cleanup, restructure, modularize, extract function, DRY"
}

🩺 Diagnostic-First Refactoring (The "Surgeon's Scan")

Philosophy: Diagnose first. Cut second. Source: r/vibecoding ("Tip #1 - don't forget to have AI review its own code")

1. The Prompt (Universal Polyglot)

When invoking this skill on a file (or set of files), use the following System Prompt logic.

Role: Senior Software Architect & Performance Engineer.

Objective: Analyze the provided code files and generate a "Refactoring & Optimization Report." DO NOT rewrite the full files or generate refactored code blocks yet. Instead, provide a diagnostic report.

Specific Focus Areas:

  1. Dead & Unreachable Code: Identify variables, functions, or imports that are declared but never used.
  2. Cognitive Complexity: Highlight areas with excessive nesting (if/else hell), complex state management, or hard-to-read logic.
  3. Redundancy: Point out repeated logic that should be abstracted into utility functions (violation of DRY principles).
  4. Performance Heavy-Lifters: Analyze loops, recursive functions, DOM manipulations (if JS), and resource-heavy operations.
    • Check: Is this technically unneeded? Can it be replaced by a lighter alternative (e.g., CSS instead of JS animation)?
  5. Modernization: Identify where language-specific modern syntax (e.g., Python 3.12+ features, ES6+ features) could reduce LOC.

Constraints for AI:

  • NO DIRECT EDITING: Do not output the full modified code files.
  • Strictly Diagnostic: Focus on what can be improved and why.
  • Quantify Impact: Estimate LOC reduction (Low/Medium/High) and Complexity Impact.

2. Output Format (The "Bill of Materials")

The output MUST be written to a report file using the following structure:

# Refactoring & Optimization Report: [Filename]

## 📊 Summary
* **Est. LOC Reduction**: ~[X] lines
* **Complexity Reduction**: [Low/Medium/High]
* **Critical Issues**: [Count]

## 1. Issue Matrix

| Issue Category | Description of Inefficiency | Proposed Solution | Est. LOC Reduction | Complexity Impact |
| :--- | :--- | :--- | :--- | :--- |
| **Dead Code** | Unused import `foo` on line 12 | Remove import | ~1 line | None |
| **Bloat** | Animation function X uses complex JS loop | Replace with CSS Keyframes | ~15 lines | High |
| **Syntax** | Old style variable declarations | Convert to const/let & arrow funcs | ~5 lines | Low |
| **DRY** | Repeated error handling logic in 3 functions | Create `handle_error` utility | ~20 lines | Medium |

## 2. Critical Recommendations (Bulleted)
* [Recommendation 1]
* [Recommendation 2]

## 3. Risks & Regressions
* [Potential side effect of refactoring]

3. Execution Workflow

  1. Select Target: Identify the file(s) to refactor.
  2. Run Diagnosis: Feed file content + The Prompt to the AI.
  3. Review Report: User reviews the Matrix.
  4. Authorize: User approves specific line items.
  5. Execute: AI switches to "Execution Mode" and applies the approved changes.

Why This Pattern?

Traditional Refactoring Diagnostic-First
AI rewrites entire file AI produces analysis first
Risk of breaking changes User reviews before any edit
Hard to track what changed Clear "Bill of Materials"
All-or-nothing Granular approval per issue

skill #refactoring #code-quality #diagnostic

Version History

  • e624e2d Current 2026-07-19 08:46

Same Skill Collection

examples/protocols/diagnostics/DIA-SKILL.md
examples/skills/business/brand-foundations/SKILL.md
examples/skills/business/client-pricing/SKILL.md
examples/skills/business/distribution-physics/SKILL.md
examples/skills/business/marketing-swarm/SKILL.md
examples/skills/business/seo-auditor/SKILL.md
examples/skills/business/sovereign-economics-engine/SKILL.md
examples/skills/coding/agentic-code-orchestrator/SKILL.md
examples/skills/coding/atomic-execution/SKILL.md
examples/skills/coding/dashboard-builder/SKILL.md
examples/skills/coding/git-worktree-swarm/SKILL.md
examples/skills/coding/micro-commit/SKILL.md
examples/skills/coding/spec-driven-dev/SKILL.md
examples/skills/coding/visual-verify-ui/SKILL.md
examples/skills/decision/bionic-decision-engine/SKILL.md
examples/skills/decision/decision-journal/SKILL.md
examples/skills/decision/mcda-solver/SKILL.md
examples/skills/decision/trading-risk-gate/SKILL.md
examples/skills/decision/zenith-execution/SKILL.md
examples/skills/quality/bionic-safety-net/SKILL.md
examples/skills/quality/circuit-breaker/SKILL.md
examples/skills/quality/consiglieri-protocol/SKILL.md
examples/skills/quality/power-inversion/SKILL.md
examples/skills/quality/red-team-review/SKILL.md
examples/skills/quality/web-launch-gate/SKILL.md
examples/skills/research/data-analysis/SKILL.md
examples/skills/research/deep-research-loop/SKILL.md
examples/skills/research/semantic-search/SKILL.md
examples/skills/research/statistical-analysis/SKILL.md
examples/skills/research/synthetic-parallel-reasoning/SKILL.md
examples/skills/social-physics-filter/SKILL.md
examples/skills/structural-trading-gate/SKILL.md
examples/skills/therapeutic-ifs/SKILL.md
examples/skills/workflow/academic-delivery/SKILL.md
examples/skills/workflow/context-compactor/SKILL.md
examples/skills/workflow/daemon-loop/SKILL.md
examples/skills/workflow/skill-compiler/SKILL.md
examples/skills/workflow/trade-journal-analyzer/SKILL.md

Metadata

Files
0
Version
e624e2d
Hash
fa1bebe0
Indexed
2026-07-19 08:46

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-20 13:43
浙ICP备14020137号-1 $Carte des visiteurs$