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 $0.00017 $0.00462
Sonnet 5 $0.00007 $0.00185
Haiku 4.5 $0.00003 $0.00092

Measured 12d ago against content hash fa1bebe04043, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, 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 12d 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. 12d 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 (587 stars, last pushed today), licensed MIT. It adds 35 tokens to every session and 923 once invoked, about $0.0002 per session on Opus 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

manage-skills

A maintenance workflow for checking whether project verification skills still cover the code and rules that changed during a session.

sangrokjung/claude-forge · 54 tokens

systematic-debugging

Structured debugging methodology — use before proposing fixes for any error or failure. Covers: code bugs, build errors, deploy failures, config conflicts, dependency issues, infra problems. Also use when previous fix attempts failed or root cause is unclear.

sangrokjung/claude-forge · 53 tokens

review-loop

Run the adversarial verification loop — implement, then hand the change to a fresh checker that did not write it, fix what it finds, and re-dispatch until APPROVE. Use before claiming any behavioural change is done, and on requests like "review loop", "adversarial review", "independent review", "get this verified"…

sangrokjung/claude-forge · 100 tokens

python-memory-safe-scripts

Memory-safe Python script patterns for long-running processes under systemd MemoryMax constraints. Covers allocator purge (mimalloc/glibc malloctrim), HTTP response lifecycle, DataFrame cleanup, thread-local connection reuse, and periodic GC cadence. Battle-tested through 5 OOM optimization cycles on production GPU…

terrylica/cc-skills · 197 tokens

feedback-workflow

A command-line workflow for reading and responding to approved software feedback. It keeps track of the feedback version, approval, work claim, evidence, and result.

Peiiii/nextclaw · 44 tokens