advpl-specialist: Command for Claude Code

.cursor/commands/refactor.md

refactor is a command for Claude Code, Cursor from thalysjuvenal/advpl-specialist. It costs 0 tokens per session (439 once invoked), scanned A, original, MIT.

A command for refactoring ADVPL and TLPP code used by TOTVS Protheus business software. Refactoring changes code structure without changing what the code does.

In plain words
What is it for?
Use it to extract functions, simplify deeply nested conditions, remove dead code, improve names, and review changes in a dry run.
Why use it?
It helps make complicated code easier to maintain while preserving its behavior. It presents proposed changes for approval before applying them.

Command for Claude CodeCursor

Written for Claude Code and Cursor: shipped in a Claude Code plugin, but also installed under .cursor/.

This is thalysjuvenal/advpl-specialist's own configuration. It tells Claude Code and Cursor how to work on advpl-specialist itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything advpl-specialist configures →

Part of the advpl-specialist plugin — 18 skills, 14 commands, 2 hooks shipped together

Reuse

Borrowing it

Nothing to install: this file belongs to thalysjuvenal/advpl-specialist. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/thalysjuvenal/advpl-specialist/main/.cursor/commands/refactor.md
Clone the repo
git clone --depth 1 https://github.com/thalysjuvenal/advpl-specialist

Made for: Claude Code, Cursor.

Or install advpl-specialist, the plugin that ships this one along with the rest of its 18 skills, 14 commands, 2 hooks.

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/commands/thalysjuvenal/advpl-specialist/refactor.svg)](https://agentmods.dev/commands/thalysjuvenal/advpl-specialist/refactor)
Your own site
<a href="https://agentmods.dev/commands/thalysjuvenal/advpl-specialist/refactor"><img src="https://agentmods.dev/badge/commands/thalysjuvenal/advpl-specialist/refactor.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 439 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.00000 $0.00439
Opus 5 $0.00000 $0.00219
Sonnet 5 $0.00000 $0.00088
Haiku 4.5 $0.00000 $0.00044

Measured 8d ago against content hash cbd8e8a0a515, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, 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 8d 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.

.cursor/commands/refactor.md · 34 lines

What it actually says

/refactor — Refactor ADVPL/TLPP code to extract functions, simplify logic, remove dead code, and improve naming

You are an expert ADVPL/TLPP assistant for TOTVS Protheus. This command analyzes and refactors code to improve structure without changing behavior.

Knowledge to load first

Locate the advpl-specialist skills (installed via npx skills add thalysjuvenal/advpl-specialist; in this repository they live under skills/) and read skills/advpl-refactoring/reference.md.

Workflow

  1. Parse the target file(s) and the --dry-run flag.
  2. Read the target file(s) completely.
  3. Identify refactoring opportunities using the patterns below.
  4. Draft a plan: a prioritized list of refactorings with before/after code for each. Present it and wait for user approval before applying any change.
  5. If --dry-run was requested, stop after presenting the plan.
  6. After approval, apply changes one refactoring at a time, preserving behavior.
  7. Report a summary of changes applied.

Refactoring patterns

ID Pattern Risk
RF-001 Extract Function (>100 lines) Low
RF-002 Simplify Conditionals (>3 levels) Low
RF-003 Remove Dead Code Low
RF-004 Improve Naming (Hungarian notation) Low
RF-005 Eliminate Duplication Medium
RF-006 Reduce Parameters (>5 params) Medium

Output rules

  • Every refactoring must preserve the original behavior — no functional changes without explicit user request.
  • Renamed identifiers must follow Hungarian notation and existing module-prefix conventions.
  • Preserve #include "totvs.ch" and Embedded SQL usage (BeginSQL/EndSQL) — never introduce raw SQL strings during refactoring.
  • Report improvements with a summary (function count, max function length, naming compliance).
  • Compilation must be validated in TDS / VS Code TOTVS extension — never claim the code compiles.
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. 8d ago First seen · 34 lines · 0 tokens per session scan A cbd8e8a0a515

Subscribe to this mod's changes

refactor is a command published in the GitHub repository thalysjuvenal/advpl-specialist (186 stars, last pushed 17d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 439 tokens. 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.