refactor

refactor is a skill for Claude Code, Codex from totvs/engpro-advpl-tlpp-skills. It costs 76 tokens per session (3,393 once invoked), scanned A, original, MIT.

A code-improvement guide for changing how existing code is organised while keeping its behaviour the same. It covers smaller functions, clearer names, safer types, and common code problems.

In plain words
What is it for?
Use it to split up oversized functions or classes, remove code smells, improve type safety, and make future feature work easier.
Why use it?
It helps make difficult-to-maintain code easier to understand and change without rewriting the whole project.

Skill for Claude CodeCodex

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

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is Refer to [references/sonarqube-rules-reference.md](../references/sonarqube-rules-reference.md) for the complete SonarQube rules reference..

Good fit Use it to split up oversized functions or classes, remove code smells, improve type safety, and make future feature work easier.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/totvs/engpro-advpl-tlpp-skills
agentmods
npx agentmods add skills/totvs/engpro-advpl-tlpp-skills/refactor

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 refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/totvs/engpro-advpl-tlpp-skills/refactor/github.svg)](https://agentmods.dev/skills/totvs/engpro-advpl-tlpp-skills/refactor)
Your own site
<a href="https://agentmods.dev/skills/totvs/engpro-advpl-tlpp-skills/refactor"><img src="https://agentmods.dev/badge/skills/totvs/engpro-advpl-tlpp-skills/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 refactor

Your own site · 80×15
<a href="https://agentmods.dev/skills/totvs/engpro-advpl-tlpp-skills/refactor"><img src="https://agentmods.dev/badge/skills/totvs/engpro-advpl-tlpp-skills/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 76 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,393 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: 2 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 Prompt Injection · line 385
    Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
    Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
  • medium Prompt Injection · line 394
    Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
    Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
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.00076 $0.03393
Opus 5 $0.00038 $0.01697
Sonnet 5 $0.00015 $0.00679
Haiku 4.5 $0.00008 $0.00339

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

Security

Grade A, and why

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

skills/advpl-tlpp/refactor/SKILL.md · 403 lines

How it starts

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

Refactor

Overview

Improve code structure and readability without changing external behavior. Refactoring is gradual evolution, not revolution. Use this for improving existing code, not rewriting from scratch.

When to Use

Use this skill when:

  • Code is hard to understand or maintain
  • Functions/classes are too large
  • Code smells need addressing
  • Adding features is difficult due to code structure
  • User asks "clean up this code", "refactor this", "improve this"

Refactoring Principles

The Golden Rules

  1. Behavior is preserved - Refactoring doesn't change what the code does, only how
  2. Small steps - Make tiny changes, test after each
  3. Version control is your friend - Commit before and after each safe state
  4. Tests are essential - Without tests, you're not refactoring, you're editing
  5. One thing at a time - Don't mix refactoring with feature changes

When NOT to Refactor

- Code that works and won't change again (if it ain't broke...)
- Critical production code without tests (add tests first)
- When you're under a tight deadline
- "Just because" - need a clear purpose

Common Code Smells

Identify and fix these common code smells. See references/code-smells-and-patterns.md for detailed before/after examples.

# Smell Fix
1 Long Method/Function Break into focused functions
2 Duplicated Code Extract common logic
3 Large Class/Module Single responsibility per class
4 Long Parameter List Group into parameter objects or use builder
5 Feature Envy Move logic to the object that owns the data
6 Primitive Obsession Use domain types
7 Magic Numbers/Strings Named constants
8 Nested Conditionals Guard clauses / early returns
9 Dead Code Remove it (git has history)
10 Inappropriate Intimacy Ask, don't tell — use encapsulation
11 IIF Usage Replace IIF() / IF() with If/Else/EndIf for clarity and testability
12 API Calls in Loops Move GetMV(), ExistBlock(), Type() out of loops — cache before loop
13 UI in Transactions Never call MsgAlert, MsgYesNo, Aviso, Help inside transaction scope
14 SQL Injection via Concatenation Replace string concatenation in queries with FWExecStatement
15 ISAM Driver Usage Migrate MSCREATE, DBCREATE, CRIATRAB to FWTemporaryTable

Read the full file on GitHub · 403 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 · 403 lines · 76 tokens per session scan A 216854941917

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository totvs/engpro-advpl-tlpp-skills (127 stars, last pushed 26d ago), licensed MIT. It adds 76 tokens to every session and 3,393 once invoked, about $0.0004 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.