al-refactor

Refactors AL/Business Central code through four parallel review lenses while keeping builds green.

4|Updated Feb 22, 2026
One-click install
npx skills add https://github.com/FBakkensen/bc-agentic-dev-tools-marketplace --skill al-refactor-fbakkensen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: al-refactor
Source: https://github.com/FBakkensen/bc-agentic-dev-tools-marketplace/tree/main/plugins/al-agentic-dev/skills/al-refactor
Command: npx skills add https://github.com/FBakkensen/bc-agentic-dev-tools-marketplace --skill al-refactor-fbakkensen

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? AL/Business Central codebases accumulate duplication, misleading names, shallow modules, and platform reinvention over time, and refactoring them safely requires keeping the build green and behaviour unchanged at every step. ## Core Features & Use Cases - Four parallel review lenses: Spawns subagents covering simplify/dedup, BC best-practice via bc-code-intelligence, structural shape (R → P → W), and naming, then merges findings into one ordered apply queue. - Serial apply with build gates: Applies one reshape at a time with /al-build after each, reverting any step that turns the build red. - Legacy code support: Provides a phased plan for refactoring legacy AL without tests, including dependency categorization and baseline test authoring. - Use Case: After /al-implement takes a task to green, run this Skill to dissolve pass-through codeunits, rename objects to BC vocabulary, and introduce seams before handing off to mutation testing. ## Quick Start Ask the assistant to run /al-refactor on the current task diff to reshape the AL code while keeping the build green.

Frequently Asked Questions about al-refactor

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

FAQPage Schema
How do I refactor AL Business Central code without breaking the build?

Apply one reshape at a time and run the AL build after each step, reverting any change that turns the build red. Land renames and seam introductions before dedup since they touch many call sites.

When should I run refactoring in an AL development workflow?

Run it after implementation takes a task to green, once per task on the full diff, or standalone on legacy code. Never refactor against a red build, since that is debugging and belongs in implementation.

Can I refactor legacy AL code that has no tests?

Yes, but write baseline tests first to establish a regression signal before changing anything. Then proceed in three phases: rename and tighten locality, reshape along the read-pure-write boundary, and modernize APIs.

What are the limitations when renaming objects in Business Central extensions?

Never rename shipped objects, table fields, page actions, or procedures that other extensions may bind to, per AppSource compliance. Mark them obsolete with ObsoleteState Pending then Removed, and introduce the new name alongside.

Why does refactoring stop and route to replanning sometimes?

Refactoring halts when it surfaces architectural gaps such as a missing module, pattern conflict, or a boundary cutting across tasks. The code stays green and the discovery routes to steering or design rather than being absorbed silently.