refactoring

refactoring is a skill for Claude Code from ludo-technologies/pyscn. It costs 52 tokens per session (547 once invoked), scanned A, original, MIT.

A Python code review helper that finds duplicate code, overly complex functions, and code that can never run. It uses a command-line scanner called pyscn.

In plain words
What is it for?
Use it to locate complexity hotspots, repeated code, dead code, or a combination of these issues and produce detailed reports.
Why use it?
It shows where a Python codebase is difficult to maintain or contains unnecessary code, so refactoring can be focused on specific findings.

Skill for Claude Code

Written for Claude Code: a Claude Code plugin manifest.

Part of the pyscn-mcp plugin — 4 skills shipped together

Good fit Use it to locate complexity hotspots, repeated code, dead code, or a combination of these issues and produce detailed reports.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ludo-technologies/pyscn/refactoring
About the project

pyscn is a Python code-quality analyzer that examines dead code, duplication, complexity, hotspots, architecture, dependencies, and class design, then reports which areas need attention. It is used to maintain and refactor codebases, including AI-generated code, and provides agent skills for health checks, architecture reviews, refactoring, and CI reports.

ludo-technologies/pyscn · 1,095 stars · on GitHub · docs.codescan.dev

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 ludo-technologies/pyscn --skill refactoring
Clone the repo
git clone --depth 1 https://github.com/ludo-technologies/pyscn

Made for: Claude Code.

Or install pyscn-mcp, the plugin that ships this one along with the rest of its 4 skills.

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 refactoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/ludo-technologies/pyscn/refactoring/github.svg)](https://agentmods.dev/skills/ludo-technologies/pyscn/refactoring)
Your own site
<a href="https://agentmods.dev/skills/ludo-technologies/pyscn/refactoring"><img src="https://agentmods.dev/badge/skills/ludo-technologies/pyscn/refactoring/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 refactoring

Your own site · 80×15
<a href="https://agentmods.dev/skills/ludo-technologies/pyscn/refactoring"><img src="https://agentmods.dev/badge/skills/ludo-technologies/pyscn/refactoring.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 547 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 warn 7 Sept 2026
SkillSpector: 5 findings, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium MCP Rug Pull · line 8
    uvx/uv tool run commands without ==version create a rug-pull risk.
    Fix: Pin the version: uvx package-name==1.2.3
  • medium MCP Rug Pull · line 14
    uvx/uv tool run commands without ==version create a rug-pull risk.
    Fix: Pin the version: uvx package-name==1.2.3
  • medium MCP Rug Pull · line 15
    uvx/uv tool run commands without ==version create a rug-pull risk.
    Fix: Pin the version: uvx package-name==1.2.3
  • medium MCP Rug Pull · line 16
    uvx/uv tool run commands without ==version create a rug-pull risk.
    Fix: Pin the version: uvx package-name==1.2.3
  • medium MCP Rug Pull · line 17
    uvx/uv tool run commands without ==version create a rug-pull risk.
    Fix: Pin the version: uvx package-name==1.2.3
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.00052 $0.00547
Opus 5.5 $0.00021 $0.00219
Sonnet 5.5 $0.00010 $0.00109
Haiku 4.5 $0.00005 $0.00055

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

Security

Grade A, and why

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.

.claude-plugin/pyscn-mcp/skills/refactoring/SKILL.md · 37 lines

What it actually says

Python Refactoring Analysis with pyscn

Run the pyscn CLI to locate concrete refactoring targets. No install needed: uvx pyscn@latest <command>.

Commands

User Request Command
"Find complex functions" uvx pyscn@latest analyze --select complexity <path>
"Find duplicate code" uvx pyscn@latest analyze --select clones <path>
"Find dead code" uvx pyscn@latest analyze --select deadcode <path>
"What should I refactor first?" uvx pyscn@latest analyze --select complexity,deadcode,clones <path>

Key Flags

  • --min-complexity <n>: minimum complexity to report (default: 5). Risk levels: Low (<10), Medium (10-20), High (>20)
  • --clone-threshold <0.0-1.0>: minimum similarity for clone detection (default: 0.65)
  • --min-severity <critical|warning|info>: dead code severity floor (default: warning). Critical means code after return/break/continue/raise that can never execute.
  • --json: write a detailed report with line-level findings. Report files are NOT written to stdout; they go to .pyscn/reports/ and the path is printed on completion.

Prioritizing Findings

  1. Critical dead code: safe deletions, do these first.
  2. High-complexity functions (>20): extract functions, flatten conditionals.
  3. Clone groups spanning multiple files: extract shared helpers; clones within one file are usually quicker wins.

When suggesting a refactor, cite the specific function names, files, and line ranges from the results, and re-run the same command afterward to confirm the improvement.

MCP Alternative

If the pyscn-mcp MCP server is connected, you can use its tools instead of the CLI: check_complexity (min_complexity), detect_clones (similarity_threshold, min_lines), find_dead_code, or analyze_code with analyses: ["complexity", "clone", "dead_code"] to run several at once. Results are returned inline with no report files.

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 · 37 lines · 52 tokens per session scan A c8bf61b74aba

Subscribe to this mod's changes

refactoring is a skill published in the GitHub repository ludo-technologies/pyscn (1,095 stars, last pushed yesterday), licensed MIT. It adds 52 tokens to every session and 547 once invoked, about $0.0002 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

enola

Use Enola when investigating architecture, dependencies, blast radius, cross-repository relationships, structural regressions, or what a code change did to the system.

enola-labs/enola · 34 tokens

code-quality

Python code-quality anti-patterns and review checks: exception-hierarchy correctness, singleton identity comparison, narrow exception handling, wildcard-import avoidance, magic-number naming, and dead-local removal. Use when reviewing or self-reviewing Python code for correctness and readability defects that linters…

bobmatnyc/claude-mpm-skills · 61 tokens

code-review

Perform a structured code review of changes, checking for correctness, style, tests, and potential issues.

langchain-ai/deepagents · 23 tokens

code-review

Code review assistance with linting, style checking, and best practices.

agno-agi/agno · 16 tokens

splitting-oversized-modules

Split an oversized Python module (a thousand-plus-line logic.py, models.py, api.py, or its test file) into a package of one module per concern, mechanically and provably without changing behavior. Use on a request to split / break up / decompose a god module or move functions out of one, once a human has agreed to…

PostHog/posthog-foss · 197 tokens

red-team-review

Unified adversarial review, two modes. Strategic Matrix v4.3 (MTA-004) for arguments/plans/decisions: Priors → Rubric → Adversarial Lenses → SWOT/TOWS → MCDA → Blind Spot/Kill Switch → Summary. Deliverable Audit for built artefacts (assignments, reports, code outputs): isolated fresh-context hunt against the brief…

winstonkoh87/Athena-Public · 103 tokens