destructive-changes
Skill1 starsChanged 7 months agoMITView on GitHub
Build a Salesforce `destructiveChanges.xml` interactively from a list of components to delete. Validates that nothing else in source still references them before authoring the file.
In this repository53 other files it gives its agents.
- templates/CLAUDE.mdCLAUDE.md
- adrSkill
- agent-deploySkill
- agent-discoverSkill
- agent-eval-trendSkill
- agent-exchange-listSkill
- agent-specSkill
- agent-testSkill
- agent-vs-flow-vs-apexSkill
- before-vs-after-triggerSkill
- code-reviewSkill
- complexitySkill
- coverage-trendSkill
- dead-codeSkill
- dependency-graphSkill
- deploySkill
- diff-deploySkill
- erdSkill
- field-impactSkill
- flaky-test-finderSkill
- flow-auditSkill
- flow-vs-apexSkill
- fls-auditSkill
- gateway-configSkill
- generate-docsSkill
- limit-usageSkill
- lwc-vs-reactSkill
- mcp-tool-vs-restSkill
- notifySkill
- onboardSkill
- org-diffSkill
- org-exploreSkill
- package-versionSkill
- pattern-packSkill
- perf-reviewSkill
- permset-auditSkill
- pr-prepareSkill
- queueable-vs-batchSkill
- quick-deploySkill
- react-initSkill
- release-notesSkill
- scratch-orgSkill
- security-scanSkill
- sequence-diagramSkill
- sf-initSkill
- sharing-reviewSkill
- slack-agentSkill
- soql-analyzerSkill
- test-coverageSkill
- test-dataSkill
- test-planSkill
- trust-evalSkill
- trust-layer-auditSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 102
Default Markdown after validate:
- Distinctive: line 149
Pre vs post matters: Document both; default to post (the safe default)
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
You are building a destructiveChanges.xml file (and the matching package.xml placeholder) to delete metadata from a Salesforce org. Destructive changes are the only safe way to delete components on deploy — manual UI deletes don't propagate.
Read Project Config First
source "${CLAUDE_PLUGIN_ROOT}/hooks/lib/config.sh"
APEX_SRC="$(sf_config_get '.paths.apexSource' "$ENV")"
LWC_SRC="$(sf_config_get '.paths.lwcSource' "$ENV")"
API_VERSION="$(sf_config_get '.platform.apiVersion' "$ENV")"Input
$ARGUMENTS:
add <metadataType>:<fullName>— add a component to the destructive set (e.g.,ApexClass:OrderHelper,CustomField:Account.Old_Field__c)add-from <file>— read components from a file (one per line, same format)preview— print the current destructive setvalidate— verify no source still references the listed componentswrite [<dir>]— authordestructiveChanges.xml+package.xmlto<dir>(defaultmanifest/destructive/)clear— wipe the in-progress set--ci— machine output
State
The in-progress set lives in ${CLAUDE_PLUGIN_DATA}/argo/destructive/<project>/pending.json:
{
"items": [
{"type": "ApexClass", "fullName": "OrderHelper"},
{"type": "CustomField", "fullName": "Account.Old_Field__c"}
],
"lastModified": "2026-04-28T14:45:00Z"
}Steps
add <Type>:<fullName>
Validate type against the supported list (ApexClass, ApexTrigger, LightningComponentBundle, CustomObject, CustomField, ValidationRule, Layout, FlowDefinition, PermissionSet, etc.).
For CustomField, fullName format is <Object>.<Field> (e.g., Account.Old_Field__c).
Append to the pending set; refuse duplicates.
validate
For each pending item, run the equivalent of /argo:field-impact (for fields) or a grep for the symbol (for classes/components):
- ApexClass: grep references to
ClassName.andnew ClassName( - LightningComponentBundle: grep
c-<lwc-name>in HTML andfrom 'c/<lwcName>'in JS - CustomField: full field-impact across all metadata types
- CustomObject: every reference to
<Object>__cin queries, layouts, profiles, perms, flows - FlowDefinition: every Apex
Flow.Interviewlookup of the developer name
Report:
- ✅ if no references found in source
- ⚠️ if references exist (list them; refuse to write until cleaned up or user passes
--force)
write [<dir>]
Generate two files:
<dir>/destructiveChanges.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>OrderHelper</members>
<name>ApexClass</name>
</types>
<types>
<members>Account.Old_Field__c</members>
<name>CustomField</name>
</types>
<version>{{platform.apiVersion}}</version>
</Package><dir>/package.xml (empty placeholder required by the API):
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<version>{{platform.apiVersion}}</version>
</Package>Print the deploy command:
sf project deploy start --target-org <ORG> --manifest <dir>/package.xml --post-destructive-changes <dir>/destructiveChanges.xml --wait 30(Use --pre-destructive-changes if the deletion must happen before the deploy of new components.)
Output
Default Markdown after validate:
# Destructive Changes Validation
Pending items: 3
| Type | Full Name | Source refs | Verdict |
|------|-----------|-------------|---------|
| ApexClass | OrderHelper | 0 | ✅ safe to delete |
| CustomField | Account.Old_Field__c | 2 (in OrderController.cls:42, acmeAccountForm.html:18) | ⚠️ in use |
| FlowDefinition | Old_Auto_Assign | 0 | ✅ safe to delete |
⚠️ Cannot write destructive set — clean up references first or pass `--force`.Default after write:
# Destructive Changes Written
Files written:
- manifest/destructive/destructiveChanges.xml (3 items)
- manifest/destructive/package.xml (placeholder)
## Deploy command
sf project deploy start \
--target-org DevVM \
--manifest manifest/destructive/package.xml \
--post-destructive-changes manifest/destructive/destructiveChanges.xml \
--wait 30
## Pre vs Post Destructive
- Use `--post-destructive-changes` (default) when the deletion can happen after new components deploy
- Use `--pre-destructive-changes` when the new components depend on the deletion (e.g., renaming a field requires deleting the old name first)
## Reminder
Run `/argo:diff-deploy --validate` first against prod to catch Salesforce-side dependency errors that source-side validation can't see.Exit codes
- 0 — operation succeeded
- 1 — validate found references (default refuse to write)
- 2 — invocation error / type unsupported
Rules
- Always validate before writing. Source-side reference checks catch most accidental deletions
- Don't write directly into deploy. This skill produces the manifest; the user (or CI) runs the deploy
- Pre vs post matters. Document both; default to post (the safe default)
- Refuse if references exist unless the user passes
--forceand accepts responsibility — don't make destruction easy - Persist state across sessions. The pending file lets the user
addover multiple sessions before writing
Consumers
- Release pipeline: build the destructive manifest as part of a release that retires legacy components
/argo:field-impactis the underlying scanner forvalidatemode
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

