trigger-refactor-pipeline

Refactor Salesforce Apex triggers into handler-based architectures with tests and deployment steps.

803|289|Updated Nov 7, 2025
One-click install
npx skills add https://github.com/forcedotcom/afv-library --skill trigger-refactor-pipeline
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: trigger-refactor-pipeline
Source: https://github.com/forcedotcom/afv-library/tree/main/skills/apex-development/trigger-refactor-pipeline
Command: npx skills add https://github.com/forcedotcom/afv-library --skill trigger-refactor-pipeline

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Refactor Salesforce Apex triggers into dedicated handler patterns with automated test generation and deployment scaffolding to reduce maintenance burden and improve reliability.

Core Features & Use Cases

  • Bulkify triggers by extracting DML/SOQL from loops and consolidating logic into reusable handlers.
  • Generate tests and deployment scaffolding to validate refactored code across contexts.
  • Provide guidelines and a reference implementation for common trigger patterns to accelerate modernization.

Quick Start

Analyze a legacy trigger and generate a bulk-safe handler structure with tests ready for deployment.

Frequently Asked Questions about trigger-refactor-pipeline

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

FAQPage Schema
How do I bulkify Salesforce Apex triggers with DML or SOQL inside loops?

To bulkify Apex triggers, you extract DML and SOQL operations from inside loops and consolidate the logic into reusable handler patterns. This refactoring process enforces bulk-processing safety and improves code maintainability.

What is the best way to refactor legacy Apex triggers into a testable handler pattern?

Refactoring legacy Apex triggers into a testable handler pattern involves analyzing existing logic, extracting it into dedicated handler classes, and generating automated tests with deployment scaffolding to validate the new structure.

Do I need Salesforce CLI and Python 3.9+ to refactor triggers into handler architectures?

Yes, refactoring triggers into handler architectures requires Salesforce CLI and Python 3.9+ as prerequisites. These tools analyze existing triggers, generate refactored code, and produce the necessary deployment steps.

Can I generate automated tests and deployment scaffolding when modernizing inconsistent Apex triggers?

Yes, modernizing inconsistent Apex triggers outputs refactored handler code alongside automated test generation and deployment scaffolding. This ensures the bulk-safe logic is validated and ready for Salesforce deployment.

When should I extract trigger logic into dedicated handler classes?

You should extract trigger logic into dedicated handler classes when triggers contain DML or SOQL inside loops, exhibit inconsistent patterns, or lack automated tests. This reduces maintenance burden and improves reliability.