Elements org diagnostic
Skill Q9Elements/elements-mcp-server/skills/elements-org-diagnostic
Produce a broad baseline health report of a Salesforce org across all five Tier-1 dimensions (structure, automation, tech debt, compliance, and governance) by calling the Elements health tools in parallel and synthesising one ranked risk summary, optionally enriched with object-level analytics (field population + object dependency hotspots). Use when the user wants an overall health check, first-pass assessment, executive diagnostic, or "where should we look first", e.g. "run an org diagnostic", "check org health". Do NOT use for a single-dimension deep-dive; use elements-tech-debt (tech debt) or elements-change-briefing (recent changes) instead; for one specific node use elements-metadata.From its SKILL.md
npx -y skills add Q9Elements/elements-mcp-server --skill elements-org-diagnosticAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
11.8 KB, as published. Nobody here has run it
elements-org-diagnostic
Run a full org health diagnostic by calling all 5 Tier 1 health MCP tools in parallel, synthesise findings into a structured report saved as org-diagnostic.md, then optionally enrich it with object-level analytics and drill into the worst slices conversationally.
Prerequisite: the 5 Tier-1 tools and
get_analytic_drill_downall require a Pro Space with an Analytics Cloud license; unlicensed tools are hidden from the tool list entirely, so if they appear missing, licensing is why.
Inputs
refModelId: provided by user, or discovered automaticallyspaceId: from active space, or discovered automatically.get_active_spacereturns this value asactiveTeamId(notspaceId/teamId), and it can benullif no space is active — set one withset_active_spacefirst. Map that one value to the{spaceId}cache placeholder and to the tools' optionalteamIdargument.
Workspace cache
Skill artifacts live under .elements/{spaceId}/{refModelId}/ at the workspace root; resolve the root with git rev-parse --show-toplevel, falling back to the current directory only if that fails ({spaceId} is the same value as the teamId passed to the tools). A wrong root misses existing caches and causes needless re-runs. Markdown artifacts written here must begin with a first line generatedAt: <ISO8601 UTC>, the single authoritative age source for freshness checks. Treat file mtime as unreliable (a clone/copy/worktree checkout resets it to "now"); if the header is genuinely absent and you fall back to mtime, say so and lean toward regenerating.
Steps
-
Resolve space and ref model. If
spaceIdorrefModelIdare not known, callget_active_spaceto get the space, thenlist_reference_modelsto list ref models. If multiple ref models exist, present the list and ask the user to confirm which one to use. -
Check for cached report. Look for
.elements/{spaceId}/{refModelId}/org-diagnostic.md(root and age rule per Workspace cache above). If it exists and itsgeneratedAtheader is less than 24 hours old, ask the user: "A diagnostic from {generatedAt} already exists; re-run or use cached?" Proceed according to their answer. -
Call all 5 tools in parallel (single batch):
get_org_structurewithrefModelIdget_automation_healthwithrefModelIdget_tech_debt_summarywithrefModelIdget_compliance_summarywithrefModelIdget_governance_summarywithrefModelId
If the batch fails or these tools are absent from the tool list, the space is not Pro + Analytics Cloud licensed; tell the user that plainly rather than retrying or guessing at a server fault.
-
Synthesise findings. For each of the 5 dimensions produce:
- Severity:
high/medium/low/unknown - Top concerns: 3–5 bullet points
- Summary: one sentence
- Severity:
-
Determine overall risk. Based on the 5 severities, assign an overall risk level (
critical/high/medium/low) with a 2–3 sentence narrative. -
Object analytics enrichment (best-effort). Both tools rank results and return the top page (the hotspots); no manual summing needed. Optional: do not let a failure block the core report.
get_field_populationwithrefModelId: objects ranked byadoptionGap(0%-filled + below-25% field counts) descending; the first page is the worst-populated objects. Pro-gated.get_object_dependency_analysiswithrefModelId: objects ranked bytotalDependenciesdescending; the first page is the complexity hotspots. Enterprise-gated (isSpaceEnterprise): on a non-Enterprise space it's rejected; catch that, skip the dependency half, and note "object dependency analysis requires an Enterprise space" rather than failing.
Take the first (ranked) page from each:
- Adoption gaps: top objects by
adoptionGap, with theirfilledband counts. - Complexity hotspots: top objects by
totalDependencies, with the dominantbarstypes. Each response carriestotalObjects+hasMore; the default page is enough for the diagnostic. If both error/empty, skip this enrichment.
Exhaustive corpus (opt-in; only when the user wants ALL objects, not just hotspots): call with
mode:"manifest"to get{totalObjects, pageSize, numPages}; ifnumPages > 1, fan the pages out across parallel subagents: dispatch them concurrently in a single batch, ONE subagent per page, ~5–8 in flight at a time (batch the rest if there are more pages). Each subagent calls the tool withformat:"ndjson"and its ownskip = pageIndex × pageSize, writes its returneddatato.elements/{spaceId}/{refModelId}/objdeps-page-{n}.ndjson(zero-padn, e.g.page-00), and returns only the file path (never the page contents). Do NOT loop the pages yourself in one agent; parallel subagents keep each page's raw data in a disposable context, out of yours, and cut wall-clock. (If your client has no subagent facility, page sequentially, but still write each page straight to its file.) Then merge and verify with the bundled script rather than a rawcat:
python3 <skill-dir>/scripts/merge_ndjson.py .elements/{spaceId}/{refModelId} \
.elements/{spaceId}/{refModelId}/master.ndjson --expected {totalObjects} --key _id
It concatenates the *page*.ndjson files in numeric order (defensively newline-joining), checks every line parses, count == totalObjects, no $$__tp__ leakage, and reports duplicates; exit 0/PASS only if the merge is intact. Then aggregate master.ndjson with jq/python, surfacing only the computed result; do not read the whole file back into context. (Use format:"ndjson", not csv, for multi-page fan-out; CSV repeats its header per page.)
-
Write artifact. Create
.elements/{spaceId}/{refModelId}/org-diagnostic.md(create parent directories if needed) with:- First line:
generatedAt: <ISO8601 UTC>(see Workspace cache; this is what step 2 reads) - Ref model name and ID
- Findings per dimension (severity, top concerns, summary)
- Overall risk assessment
- Object analytics section (only if step 6 produced data): the adoption-gap and complexity-hotspot lists, each with the object name and the relevant count. Note clearly if the dependency half was skipped (non-Enterprise space).
- First line:
-
Report to user. Confirm the file path written, display the overall risk level and per-dimension severities as a summary table, and (if present) the top adoption gaps and complexity hotspots. Then offer to drill in: "Want me to drill into the worst slices to show you the actual items behind them?"
-
Drill into slices conversationally (if user agrees). Two complementary drill-down tools: no Chrome, no clicking, no separate skill. Pick the slices that drive the high-severity findings from steps 4–6, or drill whatever the user names. Summarise each result inline (top items + total count), and offer to keep drilling.
a) Health & analytics charts:
get_analytic_drill_down.get_analytic_drill_down({refModelId, chartType, label, ...})returns the named metadata items behind a chart slice (name, API name, status, type, created/modified dates).chartTypemust be one of the enum'd values;labelis the slice within that chart. AddsfTypefor thecomplexitychart ("Apex Class" or "Flow"), andfrom/to(epoch ms) for the time-range/governance charts.Concrete examples:
- Worst tech-debt nodes:
get_analytic_drill_down({refModelId, chartType: "tech-debt-severity", label: "Extreme"}) - Flows with poor fault coverage:
get_analytic_drill_down({refModelId, chartType: "flows-fault", label: "Below 75%"})(useflows-faultfor Flows;test-coveragereturns Apex classes/triggers, not Flows) - All permission sets:
get_analytic_drill_down({refModelId, chartType: "permission-controls", label: "Permission Set"})
b) Object dependency hotspots:
get_object_dependency_drill_down(Enterprise-gated, pairs with step 6'sget_object_dependency_analysis). To list the actual dependency nodes behind one object + metadata type:get_object_dependency_drill_down({refModelId, objectId, dependencies, ...})whereobjectIdis the object's_idfrom theget_object_dependency_analysisresult anddependenciesis one or more bar keys (metadata type names, e.g.["Apex Class", "Flow"]). Returns lean nodes by default (name, API name, status, type, complexity, dates) with accuratetotalItems/hasMore; passdetail:"full"for all fields. For a very large slice, the samemode:"manifest"+format:"ndjson"fan-out from step 6 applies. (Objects with a null_idfrom the analysis cannot be drilled.)Example (the Apex on the busiest object):
get_object_dependency_drill_down({refModelId, objectId: "<object._id>", dependencies: ["Apex Class"]})c) Under-populated fields:
get_field_population(step 6) reports counts only. To list the specific sparsely-populated fields on an object, use theelements-metadata-queryskill /query_metadatawith a population filter on that object;get_field_populationdoes not itself return field names. - Worst tech-debt nodes:
Short lists: check _truncated
Every tool result passes through a size backstop, so a list can come back short even though the
call succeeded. When a result is over budget the backstop trims one list and adds
_truncated {field, returnedItems, totalItems, note}, plus nextSkip when the tool paginates —
resume the next call from nextSkip rather than from your own offset arithmetic, since the backstop
also rewrites pageSize and sets hasMore to stay consistent with what it returned. Which list gets
trimmed is decided by key priority (items, objects, list, rows, nodes, deps), falling back
to the array with the most elements.
A result with no list to trim comes back whole but flagged _oversize. The very largest are
replaced by an _oversize object carrying refusedInline: true — that is a refusal, not data:
never write it to a file or report it as a result. Read a _truncated or _oversize flag before
stating any count or declaring a sweep complete.
Output
org-diagnostic.md written to .elements/{spaceId}/{refModelId}/ at the workspace root.
What it answers well, and what it does not
| Question | This skill? |
|---|---|
| "How healthy is this org overall?" / "where should we look first?" | Yes, 5-dimension baseline + ranked risks |
| "Which objects are complexity or adoption hotspots?" | Yes, step 6 enrichment (Pro/Enterprise gates apply) |
| "Show me the items behind that chart slice" | Yes, step 9 drill-down |
| "What should we clean up first?" (ranked remediation) | No, use elements-tech-debt |
| "What changed this week?" | No, use elements-change-briefing |
| "Explain this one flow/field" | No, use elements-metadata |
Related skills
elements-metadata: explore individual metadata nodes flagged in the diagnosticelements-metadata-query: list the specific under-populated fields behind a field-population adoption gapelements-access: investigate the permission and access controls surfaced by drill-downelements-change-briefing: see recent change velocity and anomalieselements-tech-debt: deep-dive the tech debt dimension