forcedotcom/sf-skills / skills/dx-org-analyze
dx-org-analyze
VerifiedCompare two Salesforce orgs side-by-side and produce a comparison report with drift score, or analyze a single org to produce an inventory covering metadata components, org permissions, system permissions, profiles, installed packages, licenses, and org limits. Use this skill when the user wants to compare orgs, diff orgs, audit configuration drift, find what changed between two environments, compare sandbox against production, or analyze a single org. Trigger phrases include: 'compare orgs', 'compare these 2 orgs', 'compare my orgs', 'diff orgs', 'org diff', 'what is different between these orgs', 'compare metadata', 'org comparison', 'audit org differences', 'compare sandbox to production', 'introspect org', 'org inventory', 'what is in my org', 'analyze org', 'org analysis', 'analyze my org', 'analyze my Salesforce org'. Do NOT use for retrieving metadata (use platform-metadata-retrieve), deploying metadata (use platform-metadata-deploy), or switching orgs (use dx-org-switch).
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 13.3 KB |
| SKILL.md | skill md | 10.7 KB |
| references/collection-details.md | markdown | 3.3 KB |
| references/report-format.md | markdown | 3.0 KB |
| scripts/collect_org_data.pyexecutable | script | 36.5 KB |
| scripts/compute_diff.pyexecutable | script | 46.5 KB |
| scripts/introspect_org.pyexecutable | script | 15.5 KB |
| tests/README.md | markdown | 1.8 KB |
| tests/fixtures/org_a.json | config | 2.6 KB |
| tests/fixtures/org_b.json | config | 2.3 KB |
| tests/test_compute_diff.shexecutable | script | 10.2 KB |
| tests/test_consistency.shexecutable | script | 13.4 KB |
references/collection-details.md
View on GitHub# Collection Details
The `scripts/collect_org_data.py` script collects all data from a single org into a split directory with per-category JSON files.
## Usage
```bash
python3 ./scripts/collect_org_data.py \
--org-alias my-dev-org \
--output /tmp/org-data
```
| Flag | Purpose |
|------|---------|
| `--org-alias` | SF CLI alias or username for the org (required) |
| `--output` | Output directory path (required) |
| `--skip-deep-data` | Skip Tooling API content-level queries (faster, less detail) |
## Output Directory Structure
```text
/tmp/org-data/
manifest.json # Lists category files
identity.json # Org ID, name, edition, errors
metadata.json # Metadata types and components
permissions.json # Org settings (OrganizationSettingsDetail)
org_values.json # Org limits
packages.json # Installed packages
licenses.json # User, PSL, and package licenses
system_permissions.json # PermissionsXxx on PermissionSet
deep_data.json # Apex bodies, Flow state, etc.
combined.json # All-in-one (backward compatibility)
```
Split files enable parallel agent access — each agent loads only the section it needs.
## What Gets Collected
### Metadata (Name-Level)
All types discovered via `sf org list metadata-types` (typically 100+ types). Falls back to Tooling API queries if CLI metadata commands are unavailable. Namespaced (managed-package) components are tracked separately.
Metadata listing uses 12 parallel workers via `ThreadPoolExecutor`.
### Deep Data (Content-Level via Tooling API)
| Category | Fields Collected |
|----------|-----------------|
| Apex Classes | Body hash (SHA-256), API version, LOC, status |
| Apex Triggers | Body hash comparison |
| Custom Fields | Per-object field sets, data type, length, precision, required |
| Validation Rules | Active/inactive state, error message |
| Flows | Process type, API version, active version ID |
| Named Credentials | Endpoint URL |
| Object Permissions | Per-profile CRUD (Create/Read/Edit/Delete) per object |
| Field Permissions | Per-profile Read/Edit per field (FLS) |
| Connected Apps | Presence |
| Custom Metadata Types | Presence |
Deep data queries use 8 parallel workers. SOQL pagination handles >2000 records automatically.
### Org Settings
Queries `OrganizationSettingsDetail` via Tooling API (enabled/disabled features). Falls back to `SecurityHealthCheckRisks` if unavailable.
### Org Limits
Uses `sf limits api display` (preferred) or REST `/limits/` endpoint (fallback). Captures max values for API calls, storage, features.
### System Permissions
Dynamically discovers `PermissionsXxx` boolean fields via `sf sobject describe --sobject PermissionSet`, then queries all custom and profile-owned PermissionSet records. Filters out auto-generated permission sets (ID-based names).
### Installed Packages
Queries `InstalledSubscriberPackage` via Tooling API. Captures name, namespace, and version.
### Licenses
Queries `UserLicense`, `PermissionSetLicense`, and `PackageLicense` with total/used counts.
## Exit Codes
| Code | Meaning |
|------|---------|
| `0` | Success |
| `1` | Fatal error (bad args, network failure, sf CLI not available) |
| `2` | Session expired (caller should re-authenticate and retry) |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |