/sf-decomposer:edit-metadatafrom sf-decomposer
Reads, compares, audits, and edits large Salesforce metadata XML files (permission sets, profiles, labels, workflows) by decomposing them into per-element files with sf-decomposer, then rebuilding the originals.
Ships in sf-decomposer. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Large metadata files (permission sets, profiles, labels, workflows) are thousands of lines of repetitive XML. Editing them in place is error-prone and reading them whole wastes context. sf-decomposer splits each file into one small file per element (for example one file per field permission), so you can find, read, add, change, or delete exactly the element you need, then rebuild the original file.
All commands below run npx -y sf-decomposer-core@7, which needs Node.js 22.19
or newer and nothing else. Never install the Salesforce CLI or the sf plugin
for this.
sfdx-project.json in the working directory or a parent. If there is
none, stop: sf-decomposer only works in a Salesforce DX project. Run every
command below from the folder that holds it.node --version is 22.19 or newer.<Name>.<suffix>-meta.xml
(for example permissionset, profile, labels, workflow, flow).
Custom objects (object) and types stored as bundles or with content files
(Apex classes, LWC, Aura, static resources, Experience sites) are not
supported. Edit those directly.sfdx-project.json for sourceBehaviorOptions (for example
decomposePermissionSetBeta2, decomposeCustomLabelsBeta2,
decomposeWorkflowBeta, decomposeSharingRulesBeta). If the type you need
is listed, Salesforce's own decomposition already splits it. Don't run
sf-decomposer on that type; edit the files Salesforce created directly.Check whether the project already uses sf-decomposer: a
.sfdecomposer.config.json in the project root, or .key_order.json files in
folders next to the metadata files.
git ls-files lists files
like permissionsets/Sales_Ops.permissionset-meta.xml), rebuild them so they
match: npx -y sf-decomposer-core@7 recompose -c -m <suffix>. If only the
small files are tracked, skip this; the team's hooks or CI rebuild them..sfdecomposer.config.json, .forceignore, or the decompose
strategy or format unless the user asks.Check that the target files have no uncommitted changes
(git status --porcelain -- <paths>). If they do, tell the user and ask
before continuing, so their edits and yours stay distinguishable.
Write a package.xml outside the repository (in a fresh temporary folder)
that lists only the components you need, using the Metadata API type names:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Sales_Ops</members>
<members>Support_Agent</members>
<name>PermissionSet</name>
</types>
<version>62.0</version>
</Package>
<members>*</members> covers every component of that type, which suits
repo-wide questions such as "which permission sets grant X". For the type
names, see references/metadata-types.md.
Check the round trip is safe before touching anything:
npx -y sf-decomposer-core@7 verify -x <manifest> --json
drift: stop and tell the user. Rebuilding would change those
files beyond your edit.reordered: rebuilding would reorder elements in those files
(Salesforce ignores the order, but the diff will show it). Tell the user
and ask whether to continue.Decompose with the defaults (one file per element, XML):
npx -y sf-decomposer-core@7 decompose -x <manifest>
Never pass --postpurge, --update-forceignore, --update-gitattributes,
or -c in this mode. Those change the project's layout or config.
Do the work in the small files (see below).
Rebuild the original files and remove the small ones:
npx -y sf-decomposer-core@7 recompose -x <manifest> --postpurge
Run every command from the project root, and never cd into a component
folder. On Windows, a shell whose working directory is inside a folder
locks it, so --postpurge stops partway through and still exits 0.
Run git status and git diff on the changed files. For a read-only task,
the diff should be empty. If a component folder is still there after step
6, the purge stopped partway and some small files are already gone:
git diff shows
only your intended change, delete the leftover folder.git checkout -- <file>,
delete the leftover folder, and start again from step 4.Delete the temporary manifest folder.
Always finish step 6, even if the edit fails or the user changes their mind partway, so the project never stays half-decomposed.
After decompose, each component gets a folder next to its original file:
permissionsets/
├── Sales_Ops.permissionset-meta.xml ← original (Mode B keeps it until recompose)
└── Sales_Ops/
├── Sales_Ops.permissionset-meta.xml ← top-level fields: label, description, license
├── .key_order.json ← element order; never edit
├── fieldPermissions/
│ └── Account.Industry.fieldPermissions-meta.xml
├── objectPermissions/
│ └── Account.objectPermissions-meta.xml
└── userPermissions/
└── ApiEnabled.userPermissions-meta.xml
Each small file holds one element wrapped in the type's root tag, named after its identifying value (the field, object, class, or permission name):
<?xml version="1.0" encoding="UTF-8"?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<fieldPermissions>
<editable>false</editable>
<field>Account.Industry</field>
<readable>true</readable>
</fieldPermissions>
</PermissionSet>
*Account.Industry*), then contents. To
answer "which components grant X", decompose with <members>*</members> and
search across all component folders.objectPermissions/,
fieldPermissions/, classAccesses/, tabSettings/,
recordTypeVisibilities/, and so on), then show the user what you deleted
before recomposing..key_order.json, .multi_level.json, .sidecars.json, or
.trailing_newline.json. Recompose needs them.<fullName>.label-meta.xml per label directly in
labels/.references/metadata-types.md lists common types, their suffixes and Metadata API
names, and layout notes for bots, flows, and other nested types.
Summarize what changed in plain terms (for example "Sales Ops can now read Account.Industry"), name the files that changed, and say whether the project was left as it was (Mode B) or which small files changed (Mode A). Don't deploy, and don't commit unless the user asks.
sfdx-project.json not found: run from the project root.No directories named <folder> were found: the project has no metadata of
that type in its package directories.Metadata type not found for the given suffix: check the suffix in the file
name.Custom Objects are not supported or an unsupported strategy: edit that file
directly instead.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub mcarvin8/sf-decomposer --plugin sf-decomposer2 skills in this plugin
Other plugins' skills for the same job