diff-deploy
Skill1 starsChanged 7 months agoMITView on GitHub
Deploy only the metadata that's changed since a git ref (default `main`) instead of the full project. Reads `git diff` to compute the changed-file set, intersects with the project's `paths`, and runs `sf project deploy start` with --source-dir flags. Useful for fast PR validation deploys.
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
- destructive-changesSkill
- 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
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 43
Only files under force-app/ (or whatever packageDirectories are in sfdx-project.json)
- Very specific: line 60
If Foo<TestSuffix>.cls exists in source, include it
- Very specific: line 128
Don't auto-deploy to prod: If the alias matches prod* or *production*, require --validate first or an explicit confirmation prompt
≈ “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 deploying only the metadata that has changed between the current state and a git reference. Full-project deploys can take 5–30 minutes; diff deploys typically take seconds-to-minutes.
Read Project Config First
source "${CLAUDE_PLUGIN_ROOT}/hooks/lib/config.sh"
ORG="$(sf_config_get '.platform.defaultTargetOrg' "$ENV")"
TEST_SUFFIX="$(sf_config_get '.naming.apex.testSuffix' "$ENV")"Input
$ARGUMENTS:
- (empty) — diff against
mainHEAD; deploy the changed metadata --vs <ref>— diff against a specific git ref (main,origin/main, a tag, a commit SHA)--validate— run as--dry-run(validate only, no actual deploy)--target-org <alias>/--env <name>— standard overrides--include-tests— include test classes in the deploy (default: include only when their production class also changed)--ci— machine output (deploy id, status, errors) as JSON
Steps
1. Resolve the diff base
BASE="${VS:-main}"
"$GIT" rev-parse "$BASE" >/dev/null 2>&1 || { echo "[diff-deploy] base ref not found: $BASE" >&2; exit 2; }2. Compute the changed-file set
"$GIT" diff --name-only --diff-filter=AMR "$BASE"...HEAD > /tmp/diff-deploy-files.txtFilter to:
- Only files under
force-app/(or whateverpackageDirectoriesare insfdx-project.json) - Exclude
.forceignore-matched files (usesf project list ignoredif available, otherwise read.forceignoredirectly)
3. Resolve metadata bundles
LWC and Aura components live in directories — a single file change must deploy the whole bundle:
- For any file under
<lwcSource>/<component>/, deploy the entire<component>/directory - For any file under
<aura>/<component>/, deploy the entire<aura>/<component>/directory - For Apex classes/triggers, deploy the
.cls+.cls-meta.xmlpair (or.trigger+.trigger-meta.xml) - For object/field changes, deploy the relevant
objects/<Object>/subtree (or just<Object>/fields/<Field>.field-meta.xml) - For permission sets, profiles: deploy the file as-is
Build a deduplicated list of --source-dir paths.
4. Include relevant test classes
For each modified Apex class Foo.cls:
- If
Foo<TestSuffix>.clsexists in source, include it - The test runs server-side as part of the deploy (RunSpecifiedTests or RunLocalTests)
5. Build the deploy command
sf project deploy start \
--target-org "$ORG" \
$([ "$VALIDATE" = "1" ] && echo "--dry-run") \
$(printf -- "--source-dir %q " "${PATHS[@]}") \
--test-level RunSpecifiedTests \
$(printf -- "--tests %q " "${TEST_CLASSES[@]}") \
--wait 30 \
--json > /tmp/diff-deploy-result.jsonCapture exit code + JSON output.
6. Output
Default Markdown:
# Diff Deploy: <ORG>
Diff base: main (abc123)
Changed metadata: 7 components, 12 files
Tests run: 4 classes, 23 methods
## Components deployed
- LightningComponentBundle: acmeOrderForm
- ApexClass: OrderController, OrderService
- CustomObject (field-only changes): Order__c.Status__c
## Test results
✅ 23 passed / 0 failed / 0 skipped
## Status
✅ Deploy succeeded (12.4s)
Deploy ID: 0Af...XYZCI mode JSON shape:
{
"org": "DevVM",
"diffBase": "main",
"deployId": "0Af...XYZ",
"status": "Succeeded",
"validateOnly": false,
"components": [{"type": "ApexClass", "fullName": "OrderController"}],
"testsRun": 23,
"testFailures": 0,
"errors": []
}7. Exit codes
- 0 — deploy succeeded (or validate succeeded)
- 1 — deploy failed (validation failure or test failure)
- 2 — invocation error (no diff, base ref invalid, etc.)
Rules
- Always include the meta files. A
.clsdeploys with its.cls-meta.xml; the diff-file computation must add the meta when the source is touched and vice versa - LWC/Aura bundles deploy whole. Even if only the CSS changed, the meta file must be in the deploy or the package is invalid
- Renames are tricky.
--diff-filter=AMRincludes Renames; the renamed source path is what we deploy. Salesforce sees this as "delete old, add new" — confirm.forceignoredoesn't accidentally exclude the new name - Include test classes for changed production classes.
--include-teststo also include all test classes in the diff (rare; mostly when refactoring tests themselves) - Persist the deploy ID. Append the result to
${CLAUDE_PLUGIN_DATA}/argo/deploys/<project>/history.jsonlso/quick-deploycan find it later - Don't auto-deploy to prod. If the alias matches
prod*or*production*, require--validatefirst or an explicit confirmation prompt
Consumers
- CI pipelines run
--validateon PRs /argo:quick-deployreads the persisted deploy ID/argo:release-noteslists components since the last successful prod deploy
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.

