Diagnostic-First Refactoring

Diagnostic-First Refactoring is a skill for Claude Code, Codex from winstonkoh87/Athena-Public. It costs 35 tokens per session (923 once invoked), scanned A, original, MIT.

A code-review process that examines files and produces a refactoring report before any code is changed. Refactoring means improving code structure without changing what it is meant to do.

In plain words
What is it for?
Use it to inspect one or more code files for dead code, hard-to-follow nesting, repeated logic, and performance-heavy loops, recursion, or browser-page updates.
Why use it?
It gives you a written diagnosis before edits, making unused code, overly complicated logic, repeated code, and expensive operations easier to review and prioritize.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: model in frontmatter.

Good fit Use it to inspect one or more code files for dead code, hard-to-follow nesting, repeated logic, and performance-heavy loops, recursion, or browser-page updates.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/winstonkoh87/athena-public/diagnostic-refactor
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add winstonkoh87/Athena-Public --skill diagnostic-refactor
Clone the repo
git clone --depth 1 https://github.com/winstonkoh87/Athena-Public

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for Diagnostic-First Refactoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/winstonkoh87/athena-public/diagnostic-refactor/github.svg)](https://agentmods.dev/skills/winstonkoh87/athena-public/diagnostic-refactor)
Your own site
<a href="https://agentmods.dev/skills/winstonkoh87/athena-public/diagnostic-refactor"><img src="https://agentmods.dev/badge/skills/winstonkoh87/athena-public/diagnostic-refactor/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for Diagnostic-First Refactoring

Your own site · 80×15
<a href="https://agentmods.dev/skills/winstonkoh87/athena-public/diagnostic-refactor"><img src="https://agentmods.dev/badge/skills/winstonkoh87/athena-public/diagnostic-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 923 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00035 $0.00923
Opus 5.5 $0.00014 $0.00369
Sonnet 5.5 $0.00007 $0.00185
Haiku 4.5 $0.00003 $0.00092

Measured 1mo ago against content hash fa1bebe04043, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

Diagnostic-First Refactoring scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

examples/skills/coding/diagnostic-refactor/SKILL.md · 90 lines

How it starts

The opening of the file, as written. The whole thing — 90 lines — stays where its author put it; the contents beside it link to each section on GitHub.

🩺 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]

Read the full file on GitHub · 90 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 90 lines · 35 tokens per session scan A fa1bebe04043

Subscribe to this mod's changes

Diagnostic-First Refactoring is a skill published in the GitHub repository winstonkoh87/Athena-Public (619 stars, last pushed yesterday), licensed MIT. It adds 35 tokens to every session and 923 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

credit-note-fixer

Fix the tiny credit-note formatting bug and rerun the exact targeted test command.

openai/openai-agents-python · 21 tokens

explain

Deep research into a topic or issue — investigates until confident, then presents an executive summary and root-cause analysis. Use when you need to understand WHY something happens. Takes [topic, question, or issue description].

Ashkaan/contextium · 46 tokens

second-opinion

Get an independent review of the current change from a different model family (GPT via Codex, Copilot or Cursor; Gemini via Antigravity) through agent-intern, then check each finding against the code and reconcile it with your own view. Use before merging a risky diff, when stuck on a bug, or when the user asks for a…

SinanTufekci/agent-intern · 86 tokens

REFACTORING & TECHNICAL DEBT

Use this skill when improving code structure without changing external behavior, reducing technical debt, deciding between refactor vs rewrite, or planning legacy system modernization. Activated when the user mentions cleaning up code, reducing complexity, making code maintainable, improving a module that keeps…

Kingdaddy007/my-os · 188 tokens

PERFORMANCE ENGINEERING

Use this skill when diagnosing or resolving performance problems, optimizing slow systems, or proactively preparing for load. Activated when the user mentions slow response times, high resource consumption, timeouts, memory leaks, or anticipates increased traffic. Signal phrases: "it's slow", "optimize this"…

Kingdaddy007/my-os · 144 tokens

DEBUGGING & SYSTEMATIC TROUBLESHOOTING

Use this skill when investigating errors, crashes, unexpected behavior, or system failures. Activated when the user reports a bug, shares a stack trace or error message, describes tests failing unexpectedly, notices a regression (a feature that used to work no longer does), or when production telemetry alerts have…

Kingdaddy007/my-os · 124 tokens