advpl-refactoring

Refactor legacy ADVPL/TLPP code with pre-check and lint validation.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/JoniPraia/plugadvpl --skill advpl-refactoring
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: advpl-refactoring
Source: https://github.com/JoniPraia/plugadvpl/tree/main/skills/advpl-refactoring
Command: npx skills add https://github.com/JoniPraia/plugadvpl --skill advpl-refactoring

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps you improve legacy ADVPL/TLPP code by identifying common refactoring opportunities and providing safe, production-focused before/after transformations.

Core Features & Use Cases

  • Six high-impact refactor patterns: DbSeek loop to embedded SQL, repeated Posicione(), hardcoded IF chains to configuration tables or central functions, AxCadastro/Modelo2/Modelo3 to MVC, string concatenation in loops to buffered arrays, and unsafe RecLock usage replaced with Begin Transaction.
  • Refactor workflow with guardrails: guidance to inspect architecture, callers, and lint findings before changing code, and to reindex + lint after changes.
  • Encoding safety for .prw (cp1252): explicit stage/commit steps to avoid UTF-8/byte corruption and compile-time failures.

Quick Start

Ask the AI: "Refatore o arquivo FATA050.prw aplicando apenas os padrões indicados pelo lint e respeitando o fluxo de stage/commit para cp1252."

Frequently Asked Questions about advpl-refactoring

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor legacy ADVPL code to fix slow database access?

To refactor slow ADVPL code, replace DbSeek loops with embedded SQL and repeated Posicione() calls with buffered arrays. This targets common performance anti-patterns to improve maintainability and execution speed.

What is the best way to modernize AxCadastro and Modelo2 screens in ADVPL?

Modernizing AxCadastro, Modelo2, and Modelo3 screens involves converting them to the MVC architecture in ADVPL. This refactoring pattern replaces legacy hardcoded IF chains with configuration tables or central functions for better structure.

How do I handle cp1252 encoding when editing .prw source files?

Handling cp1252 encoding for .prw files requires explicit stage, edit, and commit steps. This workflow prevents UTF-8 or byte corruption during refactoring, avoiding compile-time failures in your ADVPL sources.

Why should I use Begin Transaction instead of RecLock in ADVPL?

You should use Begin Transaction instead of unsafe RecLock usage to ensure transactional correctness. Replacing RecLock with Begin Transaction provides safer transactional control and prevents data inconsistency during legacy ADVPL refactoring.

Can I apply targeted refactoring patterns to ADVPL without breaking existing callers?

You can apply targeted refactoring patterns safely by inspecting architecture, callers, and lint findings before making changes. After applying transformations, reindex and run lint validation to ensure existing callers remain intact.