refactor-audit

refactor-audit is a skill for Claude Code from jason21wc/ai-governance-mcp. It costs 146 tokens per session (875 once invoked), scanned A, original, Apache-2.0.

A readiness assessment for code changes that checks whether a refactor—a restructuring of code without intended behavior changes—can be done safely. It reviews code structure, hidden behavior risks, affected areas, and test coverage.

In plain words
What is it for?
Use it before refactoring a file, module, or function to assess risk, check the test prerequisite, map affected code, and receive a readiness verdict.
Why use it?
It identifies contracts that search tools can verify and warns about behavior they cannot see, such as ordering, state transitions, and invariants—rules that must remain true.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it before refactoring a file, module, or function to assess risk, check the test prerequisite, map affected code, and receive a readiness verdict.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jason21wc/ai-governance-mcp/refactor-audit
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 jason21wc/ai-governance-mcp --skill refactor-audit
Clone the repo
git clone --depth 1 https://github.com/jason21wc/ai-governance-mcp

Made for: Claude Code.

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 refactor-audit

README.md
[![agentmods](https://agentmods.dev/badge/skills/jason21wc/ai-governance-mcp/refactor-audit/github.svg)](https://agentmods.dev/skills/jason21wc/ai-governance-mcp/refactor-audit)
Your own site
<a href="https://agentmods.dev/skills/jason21wc/ai-governance-mcp/refactor-audit"><img src="https://agentmods.dev/badge/skills/jason21wc/ai-governance-mcp/refactor-audit/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 refactor-audit

Your own site · 80×15
<a href="https://agentmods.dev/skills/jason21wc/ai-governance-mcp/refactor-audit"><img src="https://agentmods.dev/badge/skills/jason21wc/ai-governance-mcp/refactor-audit.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 146 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 875 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 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.00146 $0.00875
Opus 5 $0.00073 $0.00438
Sonnet 5 $0.00029 $0.00175
Haiku 4.5 $0.00015 $0.00088

Measured 10d ago against content hash a2d6e1568993, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

refactor-audit 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 10d 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.

global-skills/refactor-audit/SKILL.md · 56 lines

How it starts

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

Runtime Context

After the skill loads, inspect the branch, working diff, framework manifests, and test configuration with ordinary read-only calls. Derive the framework from the repository rather than relying on eager host-specific output.

Instructions

You are performing a refactoring readiness assessment. This skill answers one question: "Is this code ready to be safely refactored?"

Read procedure.md in this skill folder for the full 3-phase protocol.

Quick Start

  1. Collect the Runtime Context above and determine the target. If the user specified a file, module, or function, use that. If they said "is this safe to refactor?" after viewing code, assess that code. If ambiguous, ask.

  2. Read procedure.md for the full protocol.

  3. Execute all three phases in order:

    • Phase 1: Map — structural contract mapping (grep-verified), invisible contracts warning (UNVERIFIED), blast radius + dynamic dispatch detection, test coverage prerequisite gate
    • Phase 2: Assess — prerequisite gate, risk classification, readiness verdict
    • Phase 3: Report — structured output with evidence and recommendations
  4. Deliver the assessment with structural contracts, invisible contract warnings, and readiness verdict.

Key Principles

  • Structural contract mapping is the core value. Identify what grep CAN confirm must not change — exported functions, side effects, error behavior, integration points. Each item gets file:line evidence.
  • Invisible contracts are an honest warning, not a claim. Grep finds syntax, not semantics. Ordering guarantees, state machine invariants, concurrency contracts — flag as UNVERIFIED. "3 potential invisible contracts identified (UNVERIFIED)" is honest. "All contracts verified" is a confidence trap.
  • Test coverage is a prerequisite, not a post-check. If no tests exist for the target, the verdict is STOP — not a suggestion to "maybe add tests." Recommend /test-suite for baseline generation.
  • Never output bare "SAFE." Strongest verdict: STRUCTURALLY READY (invisible contracts not verified). The skill is honest about what tool-assisted verification can and cannot establish.

Read the full file on GitHub · 56 lines

Files

What ships with it

1 file 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. 10d ago First seen · 56 lines · 146 tokens per session scan A a2d6e1568993

Subscribe to this mod's changes

refactor-audit is a skill published in the GitHub repository jason21wc/ai-governance-mcp (0 stars, last pushed 10d ago), licensed Apache-2.0. It adds 146 tokens to every session and 875 once invoked, about $0.0007 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-31.