guiding-refactoring-with-code-health

guiding-refactoring-with-code-health is a skill for Claude Code, Codex from Cratis/AI. It costs 44 tokens per session (606 once invoked), scanned A, a copy of guiding-refactoring-with-code-health, MIT.

A refactoring guide that uses CodeScene findings to assess how difficult a file is to maintain before and after small code changes. It only applies in repositories configured for the Cratis CodeScene profile with CodeScene tools available.

In plain words
What is it for?
Use it when a file is complex, hard to read, risky to change, or often linked to defects. It helps review maintainability findings, choose focused refactoring steps, and compare code-health results over time.
Why use it?
It replaces guesswork with a measurable baseline and checks whether each small refactoring step actually improves the code. Without the required repository setup and tools, it should be skipped.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when a file is complex, hard to read, risky to change, or often linked to defects. It helps review maintainability findings, choose focused refactoring steps, and compare code-health results over time.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cratis/ai/guiding-refactoring-with-code-health
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 Cratis/AI --skill guiding-refactoring-with-code-health
Clone the repo
git clone --depth 1 https://github.com/Cratis/AI

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 guiding-refactoring-with-code-health

README.md
[![agentmods](https://agentmods.dev/badge/skills/cratis/ai/guiding-refactoring-with-code-health/github.svg)](https://agentmods.dev/skills/cratis/ai/guiding-refactoring-with-code-health)
Your own site
<a href="https://agentmods.dev/skills/cratis/ai/guiding-refactoring-with-code-health"><img src="https://agentmods.dev/badge/skills/cratis/ai/guiding-refactoring-with-code-health/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 guiding-refactoring-with-code-health

Your own site · 80×15
<a href="https://agentmods.dev/skills/cratis/ai/guiding-refactoring-with-code-health"><img src="https://agentmods.dev/badge/skills/cratis/ai/guiding-refactoring-with-code-health.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 606 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.
Origin 91% copy Near-identical to another mod 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.00044 $0.00606
Opus 5.5 $0.00018 $0.00242
Sonnet 5.5 $0.00009 $0.00121
Haiku 4.5 $0.00004 $0.00061

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

Security

Grade A, and why

guiding-refactoring-with-code-health 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.

Origin

This is a copy

91% identical to guiding-refactoring-with-code-health — 10 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.cratis/ai/skills/guiding-refactoring-with-code-health/SKILL.md · 47 lines

How it starts

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

Guiding Refactoring With Code Health

Use only in repositories that opted into cratis/codescene and have CodeScene MCP tools available; otherwise skip without blocking and say so. The Cratis policy in .cratis/ai/rules/codescene.md overrides this skill where they differ.

Overview

Use Code Health as the control signal for refactoring. The agent should first understand why a file is hard to work with, establish a measurable baseline, then improve it in small structural steps and verify that each step helped. The goal is not just cleaner code, but code that is easier for both humans and agents to understand and modify safely.

When to Use

  • A file is hard to read, risky to change, or repeatedly attracts defects.
  • The user asks for refactoring help and wants an objective way to measure progress.
  • A safeguard or review points to complexity, size, low cohesion, or deep nesting.

Do not use this skill when the task is to rank project-wide priorities. Use prioritizing-technical-debt for that.

Quick Reference

  • code_health_review: Detailed maintainability findings for a file.
  • code_health_score: Numeric baseline and trend check across refactoring iterations.

Implementation

  1. Run code_health_review on the target file.
  2. Record the current code_health_score so the refactoring starts from a measurable baseline.
  3. Identify the highest-leverage structural problems, such as excessive responsibilities, deep nesting, low cohesion, or hard-to-follow control flow.
  4. Propose 3 to 5 small structural refactor steps, not a single rewrite.
  5. After each meaningful step, re-run code_health_review to see whether the targeted structural problems were reduced.
  6. Use code_health_score as the compact checkpoint to confirm directional improvement across iterations.
  7. Stop only when the targeted structural issues are substantially reduced and the score has measurably improved, or when the user explicitly accepts a partial uplift.

Read the full file on GitHub · 47 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 Changed · -48 tokens per session 0ff641c17ed4
  2. 1mo ago Changed · +38 tokens per session c5afcfe17f7d
  3. 1mo ago Changed 8097050592b6
  4. 1mo ago First seen · 47 lines · 54 tokens per session scan A 2a9c87659958

Subscribe to this mod's changes

guiding-refactoring-with-code-health is a skill published in the GitHub repository Cratis/AI (4 stars, last pushed today), licensed MIT. It adds 44 tokens to every session and 606 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 91% identical to guiding-refactoring-with-code-health, differing in 10 lines, and is treated as a copy.

Related

guiding-refactoring-with-code-health compared with skills from other repositories

guiding-refactoring-with-code-health next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
guiding-refactoring-with-code-healthCratis/AISkill4todayMITA44Claude Code, Codex
imagegenopenai/codexSkill137ktodayApache-2.0A113Codex
playwright-climicrosoft/playwrightSkill101ktodayApache-2.0A19Claude Code
browser-automationopenclaw/openclawSkill395ktodayMITA36Claude Code
systematic-debuggingobra/superpowersSkill330k2d agoMITA21Claude Code
free-llm-apismnfst/awesome-free-llm-apisSkill14kyesterdayCC0-1.0A113Claude Code, Codex
next-cache-components-adoptionvercel/next.jsSkill144ktodayMITA95Claude Code