@ryanstark24/sfgraph-skills 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/cursor-format.test.d.ts +2 -0
- package/dist/__tests__/cursor-format.test.d.ts.map +1 -0
- package/dist/__tests__/cursor-format.test.js +44 -0
- package/dist/__tests__/cursor-format.test.js.map +1 -0
- package/dist/__tests__/installer.test.d.ts +2 -0
- package/dist/__tests__/installer.test.d.ts.map +1 -0
- package/dist/__tests__/installer.test.js +64 -0
- package/dist/__tests__/installer.test.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/installer.d.ts +39 -0
- package/dist/installer.d.ts.map +1 -0
- package/dist/installer.js +187 -0
- package/dist/installer.js.map +1 -0
- package/package.json +51 -0
- package/skills/sf-cross-layer-trace/SKILL.md +97 -0
- package/skills/sf-cross-org-diff/SKILL.md +70 -0
- package/skills/sf-dead-code-audit/SKILL.md +72 -0
- package/skills/sf-deployment-manifest/SKILL.md +70 -0
- package/skills/sf-explain-code/SKILL.md +66 -0
- package/skills/sf-flow-impact/SKILL.md +67 -0
- package/skills/sf-governor-risk-fix/SKILL.md +64 -0
- package/skills/sf-impact-from-diff/SKILL.md +64 -0
- package/skills/sf-metadata-refresh/SKILL.md +71 -0
- package/skills/sf-omnistudio-migration-audit/SKILL.md +71 -0
- package/skills/sf-schema-overview/SKILL.md +66 -0
- package/skills/sf-security-audit/SKILL.md +66 -0
- package/skills/sf-snapshot-compare/SKILL.md +68 -0
- package/skills/sf-web-explorer/SKILL.md +56 -0
- package/skills/sf-what-broke/SKILL.md +64 -0
- package/skills/sf-wip-impact/SKILL.md +74 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf-dead-code-audit
|
|
3
|
+
description: Identify unused Apex / LWC / Flow / fields with confidence buckets and freshness signals.
|
|
4
|
+
triggers:
|
|
5
|
+
- "dead code"
|
|
6
|
+
- "unused apex"
|
|
7
|
+
- "unused fields"
|
|
8
|
+
- "what can I delete"
|
|
9
|
+
- "cleanup audit"
|
|
10
|
+
tools_used:
|
|
11
|
+
- dead_code_audit
|
|
12
|
+
- freshness_report
|
|
13
|
+
- trace_upstream
|
|
14
|
+
- staleness_check
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# sf-dead-code-audit
|
|
18
|
+
|
|
19
|
+
Use when the user wants to inventory metadata that appears unreferenced. Output must be bucketed by confidence — deletion in Salesforce is reversible only via backup, so we communicate uncertainty.
|
|
20
|
+
|
|
21
|
+
## Playbook
|
|
22
|
+
|
|
23
|
+
1. Call `dead_code_audit` over the user's chosen scope (entire org, single namespace, or one metadata category). Capture every candidate plus the evidence the tool used (no incoming edges, no inclusion in deploy manifests, etc.).
|
|
24
|
+
2. Call `freshness_report` to layer last-touched timestamps onto each candidate. Stale + unreferenced is stronger evidence than unreferenced alone.
|
|
25
|
+
3. For any candidate the user names interactively, call `trace_upstream` to confirm absence of indirect callers (dynamic Apex, Flow lookups, callable interfaces).
|
|
26
|
+
4. Sort candidates into three buckets:
|
|
27
|
+
- **confident-dead** — no incoming edges, no dynamic-invocation signature match, freshness > 12 months, no inclusion in active permission sets / page layouts.
|
|
28
|
+
- **likely-dead** — no incoming edges, but at least one weak signal (recently modified, referenced from a managed package boundary, or named in a metadata file we don't parse fully).
|
|
29
|
+
- **suspicious-uncertain** — looks dead but the graph has known blind spots (dynamic SOQL string-interpolated field name, reflection-style `Type.forName`, external system reference).
|
|
30
|
+
5. Render the Mermaid bar-chart / treemap returned by the tool grouped by category.
|
|
31
|
+
6. For confident-dead items, propose a destructive-changes.xml snippet but do not save it. The user owns the delete decision.
|
|
32
|
+
|
|
33
|
+
## Visualization
|
|
34
|
+
|
|
35
|
+
Render a **`flowchart TD`** treemap-style grouping. Top-level nodes are metadata categories (ApexClass, LWC, Flow, Field); under each, sub-nodes are the three confidence buckets, sized loosely by item count. Avoid drawing the dead items themselves — the table carries that detail.
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
flowchart TD
|
|
39
|
+
Root --> Apex
|
|
40
|
+
Apex --> A_conf[confident-dead: 12]:::conf
|
|
41
|
+
Apex --> A_likely[likely-dead: 8]:::likely
|
|
42
|
+
Apex --> A_uncert[uncertain: 4]:::uncert
|
|
43
|
+
classDef conf fill:#fcc
|
|
44
|
+
classDef likely fill:#ffe6cc
|
|
45
|
+
classDef uncert fill:#ffd
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
When the org has >100 dead candidates, drop the diagram and rely on the per-bucket tables — the chart becomes noise.
|
|
49
|
+
|
|
50
|
+
## Staleness check
|
|
51
|
+
|
|
52
|
+
Before calling `dead_code_audit`, invoke `staleness_check` for the target org. Stale ingests make dead-code analysis dangerously wrong (a recently-added caller would be invisible). If the report says stale, surface a warning to the user:
|
|
53
|
+
|
|
54
|
+
> Your ingest is N days old. Run `sfgraph ingest --org <alias>` to refresh, or proceed with the understanding that the graph may not reflect recent changes.
|
|
55
|
+
|
|
56
|
+
Then continue with the playbook.
|
|
57
|
+
|
|
58
|
+
## Response Shape
|
|
59
|
+
|
|
60
|
+
- **Scope** — what was scanned (org id, category filter).
|
|
61
|
+
- **Bucket: confident-dead** — table of name / type / last-touched / evidence.
|
|
62
|
+
- **Bucket: likely-dead** — same shape.
|
|
63
|
+
- **Bucket: suspicious-uncertain** — same shape with the specific blind spot called out.
|
|
64
|
+
- **Mermaid summary chart** — embedded.
|
|
65
|
+
- **Proposed destructive-changes.xml** (confident bucket only, fenced block, not written to disk).
|
|
66
|
+
|
|
67
|
+
## Don't
|
|
68
|
+
|
|
69
|
+
- Do not collapse buckets. Confidence is the product here.
|
|
70
|
+
- Do not delete or stage anything. Output only.
|
|
71
|
+
- Do not include managed-package items as deletable.
|
|
72
|
+
- Do not skip the `trace_upstream` confirmation step for any item the user actually plans to remove.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf-deployment-manifest
|
|
3
|
+
description: Generate a package.xml deployment manifest covering a change set and its required dependencies.
|
|
4
|
+
triggers:
|
|
5
|
+
- "deployment manifest"
|
|
6
|
+
- "package.xml"
|
|
7
|
+
- "what do I need to deploy"
|
|
8
|
+
- "build manifest"
|
|
9
|
+
- "deploy plan"
|
|
10
|
+
tools_used:
|
|
11
|
+
- deployment_manifest_gen
|
|
12
|
+
- cross_org_diff
|
|
13
|
+
- staleness_check
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# sf-deployment-manifest
|
|
17
|
+
|
|
18
|
+
Use when the user wants a `package.xml` that captures a set of changes plus everything they transitively depend on for a successful deploy.
|
|
19
|
+
|
|
20
|
+
## Playbook
|
|
21
|
+
|
|
22
|
+
1. Establish the source and target orgs. The tool's contract today is a strict cross-org diff: it inputs `from_org` (source) and `to_org` (target) and emits the metadata that exists in `from_org` but is missing or different in `to_org` (plus a `destructiveChanges.xml` for things present only in `to_org`).
|
|
23
|
+
2. Optionally call `cross_org_diff` first to preview the set difference before generating the manifest XML.
|
|
24
|
+
3. Call `deployment_manifest_gen` with `from_org` + `to_org` (+ optional `category` filter). The tool does NOT currently walk `DEPENDS_ON` edges — it returns the set difference as `package.xml` / `destructiveChanges.xml`. Dependency-closure walking is planned future work; for now the user is responsible for any additional parent metadata not surfaced by the diff.
|
|
25
|
+
4. Inspect the result for ambiguous dependencies (managed-package types, namespace mismatches) and surface them as warnings.
|
|
26
|
+
5. Emit the `package.xml` inside a fenced code block. Also emit `destructiveChanges.xml` if the diff includes removals.
|
|
27
|
+
6. If extra dependencies are needed beyond the raw diff, ask the user to extend the set manually — do not silently fabricate dependency edges the graph doesn't have.
|
|
28
|
+
|
|
29
|
+
## Visualization
|
|
30
|
+
|
|
31
|
+
Render a **`flowchart LR`** dependency closure graph. The user's explicit change set is one subgraph; auto-pulled dependencies are another. Edge labels carry the dependency reason (`parent-of`, `layout-for`, `required-permission`).
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
flowchart LR
|
|
35
|
+
subgraph Requested
|
|
36
|
+
F[Field:Account.Tier__c]
|
|
37
|
+
end
|
|
38
|
+
subgraph Closure
|
|
39
|
+
O[CustomObject:Account]
|
|
40
|
+
L[Layout:Account-Layout]
|
|
41
|
+
end
|
|
42
|
+
F -->|parent-of| O
|
|
43
|
+
F -->|layout-for| L
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
If the closure expands past 60 nodes, summarise per metadata type and only render the diagram for the top 20 — beyond that the graph becomes unreadable.
|
|
47
|
+
|
|
48
|
+
## Staleness check
|
|
49
|
+
|
|
50
|
+
Before calling `deployment_manifest_gen`, invoke `staleness_check` for the source org. A stale graph means missing dependencies in the manifest, which fail at deploy time. If the report says stale, surface a warning to the user:
|
|
51
|
+
|
|
52
|
+
> Your ingest is N days old. Run `sfgraph ingest --org <alias>` to refresh, or proceed with the understanding that the graph may not reflect recent changes.
|
|
53
|
+
|
|
54
|
+
Then continue with the playbook.
|
|
55
|
+
|
|
56
|
+
## Response Shape
|
|
57
|
+
|
|
58
|
+
- **Source set** — what was requested.
|
|
59
|
+
- **Closure additions** — what was pulled in by dependency traversal, grouped by metadata type.
|
|
60
|
+
- **Warnings** — managed-package / namespace / ambiguous-dependency notes.
|
|
61
|
+
- **package.xml** — fenced code block.
|
|
62
|
+
- **destructiveChanges.xml** — fenced code block (only if applicable).
|
|
63
|
+
- **Mermaid dependency graph** — embedded.
|
|
64
|
+
|
|
65
|
+
## Don't
|
|
66
|
+
|
|
67
|
+
- **Never deploy.** This skill emits XML; the user runs `sf project deploy start`.
|
|
68
|
+
- Do not silently include managed-package types as deployable — flag them.
|
|
69
|
+
- Do not omit API version; default to the source org's API version unless the user overrides.
|
|
70
|
+
- Do not write the XML to disk on the user's behalf. They paste it where they want it.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf-explain-code
|
|
3
|
+
description: Explain an Apex method, LWC handler, or other code unit; highlight conditional branches; cache the explanation back to the graph.
|
|
4
|
+
triggers:
|
|
5
|
+
- "explain this method"
|
|
6
|
+
- "what does <ClassName.method> do"
|
|
7
|
+
- "walk me through <qname>"
|
|
8
|
+
- "annotate the conditionals"
|
|
9
|
+
tools_used:
|
|
10
|
+
- explain_code
|
|
11
|
+
- trace_upstream
|
|
12
|
+
- trace_downstream
|
|
13
|
+
- staleness_check
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# sf-explain-code
|
|
17
|
+
|
|
18
|
+
Use this skill when the user wants a plain-English explanation of a specific code unit (an Apex method, an LWC handler, a trigger body). It reads the stored source via the graph's snippet store, generates an annotated explanation, and caches that explanation back so the next caller gets it for free.
|
|
19
|
+
|
|
20
|
+
## Playbook
|
|
21
|
+
|
|
22
|
+
1. **Resolve the target qname.** Most users say "explain `AccountSvc.calculate`" — that maps to the qname `ApexMethod:AccountSvc.calculate(N)` where N is the arity. If the arity is unknown or the name is ambiguous, call `trace_upstream` with a partial match to enumerate candidates and confirm with the user.
|
|
23
|
+
2. **`staleness_check`** for the linked org. If stale, surface a warning so the user knows the cached source may not reflect production.
|
|
24
|
+
3. **`explain_code(qname=X)`** — pull the stored snippet and any prior cached explanation. The tool returns the source text in a fenced code block.
|
|
25
|
+
4. **Generate the explanation**, structured as:
|
|
26
|
+
- **One-paragraph summary**: what the method does at a high level.
|
|
27
|
+
- **Annotated source block**: re-emit the source with terse `// → ...` comments after each conditional branch and each loop. Keep comments to one line.
|
|
28
|
+
- **Side effects**: list any SOQL/DML found in the body, with target objects/fields. The reader needs to know what hits the database.
|
|
29
|
+
- **Reaches** (optional): if the method clearly delegates to other code, call `trace_downstream(qname=X, depth=2)` and summarise what it touches.
|
|
30
|
+
5. **Cache the explanation back** via `explain_code(qname=X, annotation=<summary + annotated block>)`. This makes the next read of the same qname instant.
|
|
31
|
+
|
|
32
|
+
## Visualization
|
|
33
|
+
|
|
34
|
+
When the method has **more than two branches** (counting `if`, `else if`, `switch when`, and early `return` guards), render a `flowchart TD` of the conditional structure. Skip the diagram for straight-line code — it adds noise.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
flowchart TD
|
|
38
|
+
S[start] --> C1{isClosed?}
|
|
39
|
+
C1 -- yes --> R1[return early]
|
|
40
|
+
C1 -- no --> C2{amount > 0?}
|
|
41
|
+
C2 -- yes --> A[apply tax]
|
|
42
|
+
C2 -- no --> E[throw]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Staleness check
|
|
46
|
+
|
|
47
|
+
Before reading the snippet, call `staleness_check` for the org. If the ingest is stale:
|
|
48
|
+
|
|
49
|
+
> Your ingest is N days old. The source you're explaining may not match production. Run `sfgraph ingest --org <alias>` to refresh.
|
|
50
|
+
|
|
51
|
+
Continue the playbook either way; just flag the risk.
|
|
52
|
+
|
|
53
|
+
## Response shape
|
|
54
|
+
|
|
55
|
+
- **TL;DR** — one sentence: "what this method does".
|
|
56
|
+
- **Annotated source** — fenced code block tagged with the source format.
|
|
57
|
+
- **Side effects** — SOQL/DML/callouts.
|
|
58
|
+
- **Mermaid** — only when conditional structure justifies it.
|
|
59
|
+
- **Cached** — confirm the explanation was cached back, with the qname.
|
|
60
|
+
|
|
61
|
+
## Don't
|
|
62
|
+
|
|
63
|
+
- Don't modify the source. This skill is read-only against the local graph.
|
|
64
|
+
- Don't write anything to Salesforce.
|
|
65
|
+
- Always render the source inside a fenced code block tagged with the `sourceFormat` returned by `explain_code` (`apex`, `js`, `html`, etc.).
|
|
66
|
+
- Don't fabricate behaviour — if the source is empty or stubbed, say so plainly.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf-flow-impact
|
|
3
|
+
description: Find every Flow / Process Builder / workflow that reads or writes a given field or object.
|
|
4
|
+
triggers:
|
|
5
|
+
- "which flows use"
|
|
6
|
+
- "flow impact"
|
|
7
|
+
- "what flows touch"
|
|
8
|
+
- "flow references"
|
|
9
|
+
- "automation on this field"
|
|
10
|
+
tools_used:
|
|
11
|
+
- analyze_field
|
|
12
|
+
- trace_upstream
|
|
13
|
+
- staleness_check
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# sf-flow-impact
|
|
17
|
+
|
|
18
|
+
Use when the user asks which automation references a specific field or object — typically before a field rename, type change, or deletion.
|
|
19
|
+
|
|
20
|
+
## Playbook
|
|
21
|
+
|
|
22
|
+
1. Resolve the target. Call `analyze_field` for a single field; for an SObject, list its fields first and ask the user to narrow if the scope is large.
|
|
23
|
+
2. Filter the readers/writers from `analyze_field` to Flow-family node types: `Flow`, `ProcessBuilder`, `WorkflowRule`, `OmniProcess`.
|
|
24
|
+
3. Call `trace_upstream` on each Flow to surface what triggers it (record-triggered context, Apex `Invocable`, platform event, button).
|
|
25
|
+
4. Bucket results into **reads**, **writes**, **both**. Note whether each Flow is `Active`, `Draft`, or `Obsolete`.
|
|
26
|
+
5. Render the Mermaid field-to-flow diagram returned by the tool. If more than 20 flows reference the field, group by entry trigger type.
|
|
27
|
+
6. Call out compatibility risk: type changes break decision criteria; deletions break assignments.
|
|
28
|
+
|
|
29
|
+
## Visualization
|
|
30
|
+
|
|
31
|
+
Render a **`flowchart LR`** field-to-flow diagram. The target field is the central node; each Flow is a leaf node. Edge style encodes read (`-->`) vs write (`==>`); colour encodes Flow status (Active / Draft / Obsolete).
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
flowchart LR
|
|
35
|
+
F[(Account.Tier__c)]
|
|
36
|
+
F --> Fl1[Flow:Account_OnUpdate]:::active
|
|
37
|
+
F ==> Fl2[Flow:Account_BeforeInsert]:::active
|
|
38
|
+
F --> Fl3[Flow:Account_Legacy]:::obsolete
|
|
39
|
+
classDef active fill:#cfc
|
|
40
|
+
classDef obsolete fill:#eee,stroke-dasharray:3 3
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If more than 20 flows reference the field, group leaves by entry-trigger type and render at the group level rather than per-flow.
|
|
44
|
+
|
|
45
|
+
## Staleness check
|
|
46
|
+
|
|
47
|
+
Before calling `analyze_field`, invoke `staleness_check` for the target org. Newly-created or recently-modified Flows are invisible in a stale graph, which makes this skill produce false negatives. If the report says stale, surface a warning to the user:
|
|
48
|
+
|
|
49
|
+
> Your ingest is N days old. Run `sfgraph ingest --org <alias>` to refresh, or proceed with the understanding that the graph may not reflect recent changes.
|
|
50
|
+
|
|
51
|
+
Then continue with the playbook.
|
|
52
|
+
|
|
53
|
+
## Response Shape
|
|
54
|
+
|
|
55
|
+
- **Target** — `SObject.Field` or `SObject`.
|
|
56
|
+
- **Reads** — table of Flow name / status / entry trigger.
|
|
57
|
+
- **Writes** — same shape.
|
|
58
|
+
- **Both** — same shape.
|
|
59
|
+
- **Mermaid field-to-flow diagram** — embedded.
|
|
60
|
+
- **Compatibility risks** — bullets for type-change / delete / rename impacts.
|
|
61
|
+
|
|
62
|
+
## Don't
|
|
63
|
+
|
|
64
|
+
- Do not include Apex callers here; that belongs to `sf-cross-layer-trace`.
|
|
65
|
+
- Do not modify or activate / deactivate any Flow.
|
|
66
|
+
- Do not skip Draft / Obsolete flows by default — call them out separately instead.
|
|
67
|
+
- Do not assume `analyze_field` covers Apex-generated dynamic field references; flag the limitation.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf-governor-risk-fix
|
|
3
|
+
description: Detect governor-limit risks (SOQL/DML in loops, unbounded queries) and produce a remediation checklist.
|
|
4
|
+
triggers:
|
|
5
|
+
- "governor limit"
|
|
6
|
+
- "SOQL in loop"
|
|
7
|
+
- "DML in loop"
|
|
8
|
+
- "CPU time"
|
|
9
|
+
- "heap"
|
|
10
|
+
- "bulkification"
|
|
11
|
+
tools_used:
|
|
12
|
+
- governor_risk_check
|
|
13
|
+
- staleness_check
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# sf-governor-risk-fix
|
|
17
|
+
|
|
18
|
+
Use when the user wants to find Apex code that risks hitting governor limits at scale. The skill produces a prioritised remediation checklist; it never rewrites Apex automatically.
|
|
19
|
+
|
|
20
|
+
## Playbook
|
|
21
|
+
|
|
22
|
+
1. Call `governor_risk_check` over the requested scope (single class, namespace, or full org). The tool returns risk records with rule id (`SOQL_IN_LOOP`, `DML_IN_LOOP`, `UNBOUNDED_QUERY`, `NON_SELECTIVE_QUERY`, `CALLOUT_IN_LOOP`, `LARGE_HEAP`, `RECURSIVE_TRIGGER`), location (class + method + line), and severity.
|
|
23
|
+
2. Group findings by rule id; within each group, sort by call-site fan-in (more callers = higher blast radius).
|
|
24
|
+
3. For each finding, describe the canonical fix pattern (e.g. "extract the SOQL above the loop and key the result by `Id`") in one or two sentences — do not write the code.
|
|
25
|
+
4. Render the Mermaid heat-map (class-by-rule) from the tool response.
|
|
26
|
+
5. Produce a checklist the user can copy into a ticket: `- [ ] ClassName.methodName:line — rule — recommended pattern`.
|
|
27
|
+
6. Recommend `sf-impact-from-diff` after the user applies fixes, to verify nothing downstream regressed.
|
|
28
|
+
|
|
29
|
+
## Visualization
|
|
30
|
+
|
|
31
|
+
Render a **`flowchart TD`** heat-map: rows are Apex classes (top N by fan-in), columns are rule ids. Cell colour encodes severity (high/medium/low). When the tool returns its own Mermaid heat-map, embed that and skip this template.
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
flowchart TD
|
|
35
|
+
ClassA -->|SOQL_IN_LOOP: high| Risk1[:::hi]
|
|
36
|
+
ClassA -->|UNBOUNDED_QUERY: med| Risk2[:::med]
|
|
37
|
+
ClassB -->|DML_IN_LOOP: high| Risk3[:::hi]
|
|
38
|
+
classDef hi fill:#fcc,stroke:#900
|
|
39
|
+
classDef med fill:#ffe6cc,stroke:#c60
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
If the scan returns >50 findings, render only the top-10-by-fan-in row and link to the full table — a wall of cells doesn't help triage.
|
|
43
|
+
|
|
44
|
+
## Staleness check
|
|
45
|
+
|
|
46
|
+
Before calling `governor_risk_check`, invoke `staleness_check` for the target org. If the report says stale, surface a warning to the user:
|
|
47
|
+
|
|
48
|
+
> Your ingest is N days old. Run `sfgraph ingest --org <alias>` to refresh, or proceed with the understanding that the graph may not reflect recent changes.
|
|
49
|
+
|
|
50
|
+
Then continue with the playbook.
|
|
51
|
+
|
|
52
|
+
## Response Shape
|
|
53
|
+
|
|
54
|
+
- **Summary counts** — total findings by severity (high / medium / low) and by rule.
|
|
55
|
+
- **Findings grouped by rule** — each finding: location, fan-in, recommended pattern.
|
|
56
|
+
- **Mermaid heat-map** — embedded.
|
|
57
|
+
- **Remediation checklist** — copy-pasteable Markdown checkboxes.
|
|
58
|
+
|
|
59
|
+
## Don't
|
|
60
|
+
|
|
61
|
+
- **Never auto-apply fixes.** This skill does not edit Apex.
|
|
62
|
+
- Do not flatten severities — the bucket ordering matters.
|
|
63
|
+
- Do not invent additional rules; only report what `governor_risk_check` returns.
|
|
64
|
+
- Do not silently exclude managed-package code; mention it was filtered out if so.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf-impact-from-diff
|
|
3
|
+
description: Compute downstream blast radius and test-coverage gaps for a git diff before merge.
|
|
4
|
+
triggers:
|
|
5
|
+
- "what does this PR break"
|
|
6
|
+
- "impact of this diff"
|
|
7
|
+
- "before I merge"
|
|
8
|
+
- "blast radius"
|
|
9
|
+
- "what does this change affect"
|
|
10
|
+
tools_used:
|
|
11
|
+
- impact_from_git_diff
|
|
12
|
+
- test_gap_intelligence_from_git_diff
|
|
13
|
+
- staleness_check
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# sf-impact-from-diff
|
|
17
|
+
|
|
18
|
+
Use when the user wants to understand the downstream consequences of a pending change in their working tree (uncommitted or branch-vs-base) before merging.
|
|
19
|
+
|
|
20
|
+
## Playbook
|
|
21
|
+
|
|
22
|
+
1. Confirm the diff source: working tree, staged, or a branch range (e.g. `origin/main...HEAD`). If unspecified, default to staged + unstaged against the merge-base of `origin/main`.
|
|
23
|
+
2. Call `impact_from_git_diff` with the resolved diff scope. Expect a list of changed metadata nodes plus their downstream dependents grouped by edge type (`READS_FIELD`, `CALLS_METHOD`, `INVOKES_FLOW`, `RENDERS_COMPONENT`, …).
|
|
24
|
+
3. Call `test_gap_intelligence_from_git_diff` on the same diff scope. Cross-reference impacted nodes against existing Apex test coverage and surface the uncovered set.
|
|
25
|
+
4. Group findings by risk tier — **direct edits**, **first-degree dependents**, **transitive (depth ≥ 2)** — and call out anything that crosses metadata layers (LWC -> Apex -> Flow).
|
|
26
|
+
5. Render the Mermaid impact graph returned by the tool. If the impact set is large (>40 nodes), summarise by category and offer a follow-up call scoped to a single changed file.
|
|
27
|
+
6. If test gaps exist, list the specific impacted classes + methods that lack assertions, not just totals.
|
|
28
|
+
|
|
29
|
+
## Visualization
|
|
30
|
+
|
|
31
|
+
Render a **`flowchart LR`** impact graph. Changed nodes are leftmost (highlighted), first-degree dependents in the middle, transitive (depth >= 2) on the right. Edge style encodes edge type (`CALLS_METHOD`, `READS_FIELD`, `INVOKES_FLOW`, `RENDERS_COMPONENT`).
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
flowchart LR
|
|
35
|
+
C[ApexClass:AccountSvc]:::changed --> D1[ApexClass:AccountCtl]
|
|
36
|
+
C --> D2[Flow:Account_OnUpdate]
|
|
37
|
+
D1 --> T1[LWC:accountList]
|
|
38
|
+
classDef changed fill:#fcc,stroke:#900
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
When the impact set exceeds 40 nodes, summarise per category and offer the user a follow-up scoped to a single changed file before drawing the diagram.
|
|
42
|
+
|
|
43
|
+
## Staleness check
|
|
44
|
+
|
|
45
|
+
Before calling `impact_from_git_diff`, invoke `staleness_check` for the linked org. A stale graph will under-report dependents added since the last sync. If the report says stale, surface a warning to the user:
|
|
46
|
+
|
|
47
|
+
> Your ingest is N days old. Run `sfgraph ingest --org <alias>` to refresh, or proceed with the understanding that the graph may not reflect recent changes.
|
|
48
|
+
|
|
49
|
+
Then continue with the playbook.
|
|
50
|
+
|
|
51
|
+
## Response Shape
|
|
52
|
+
|
|
53
|
+
- **TL;DR** — one sentence: N files changed, M dependents touched, K gaps.
|
|
54
|
+
- **Impact by tier** — direct / first-degree / transitive bullets with node names + types.
|
|
55
|
+
- **Test gaps** — bulleted list of `ClassName.methodName` not covered, with the impacted node that surfaced them.
|
|
56
|
+
- **Mermaid graph** — embedded from tool output.
|
|
57
|
+
- **Suggested follow-ups** — point at `sf-governor-risk-fix` or `sf-cross-layer-trace` if the change touches Apex or spans layers.
|
|
58
|
+
|
|
59
|
+
## Don't
|
|
60
|
+
|
|
61
|
+
- Do not "approve" or "reject" the diff. You report; the human decides.
|
|
62
|
+
- Do not auto-write tests or modify code. This skill is read-only.
|
|
63
|
+
- Do not silently truncate the dependent list — always say when results were capped.
|
|
64
|
+
- Do not run on a clean working tree without telling the user there is nothing to analyse.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf-metadata-refresh
|
|
3
|
+
description: Check sfgraph ingest staleness, surface dead/stale metadata in the org, and tell the user exactly how to refresh.
|
|
4
|
+
triggers:
|
|
5
|
+
- "refresh the graph"
|
|
6
|
+
- "is my data fresh"
|
|
7
|
+
- "how do I update"
|
|
8
|
+
- "sync the org"
|
|
9
|
+
- "re-ingest"
|
|
10
|
+
tools_used:
|
|
11
|
+
- staleness_check
|
|
12
|
+
- freshness_report
|
|
13
|
+
- start_ingest_job
|
|
14
|
+
- get_ingest_job
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# sf-metadata-refresh
|
|
18
|
+
|
|
19
|
+
Use when the user asks whether their sfgraph data is current, how to refresh it, or wants to see both graph staleness and org-side dead-metadata freshness.
|
|
20
|
+
|
|
21
|
+
## Playbook
|
|
22
|
+
|
|
23
|
+
1. Call `staleness_check` for the target org. Report the exact age in days and whether it's stale.
|
|
24
|
+
2. If stale, call `start_ingest_job` — it does NOT run the ingest. It returns
|
|
25
|
+
`{ executed: false, run_this_command: "sfgraph ingest --org <alias>" }`.
|
|
26
|
+
Surface that command verbatim to the user. Do not promise the MCP server
|
|
27
|
+
will run it. After the user has executed the ingest in a shell, MCP tools
|
|
28
|
+
will see the new data on their next invocation.
|
|
29
|
+
3. Suggest the right shape of the command for their situation:
|
|
30
|
+
- For their default org: `sfgraph ingest`
|
|
31
|
+
- For a named alias: `sfgraph ingest --org <alias>`
|
|
32
|
+
- For **multiple orgs** in one run: `sfgraph ingest --orgs prod,uat,qa` (sequential) or add `--parallel` to fan them out concurrently.
|
|
33
|
+
- For **every authenticated org**: `sfgraph ingest --all` (add `--parallel` to refresh them all at once).
|
|
34
|
+
- For a **clean rebuild from scratch** (when the graph has drifted or parser logic changed): `sfgraph ingest --rebuild --org <alias>` (existing graph moves to `backups/`; pair with `--no-backup` to delete instead).
|
|
35
|
+
- On **production orgs without Source Tracking**, add `--detect-deletions` so qnames that disappeared upstream get removed during the full sync.
|
|
36
|
+
- If the user just changed `sf` CLI state (logged into a new org, renamed an alias, or ran `sf config set target-org=…`), tell them to run **`sfgraph refresh-orgs`** before any sfgraph workflow — that re-snapshots `~/.sf/` into `<dataDir>/orgs-snapshot.json` so the MCP child (running in a sandbox that can't read `~/.sf/` directly) sees the new aliases / default-org. This command does NOT touch the graph or MCP config; it only refreshes the alias snapshot.
|
|
37
|
+
4. `get_ingest_job` only returns historical CLI runs the MCP process happened to observe in-memory; it has no relationship to `start_ingest_job` anymore. Use it only if the user asks about a prior run.
|
|
38
|
+
5. Call `freshness_report` to surface dead/stale metadata in the org itself (not the graph) — Apex classes/Flows/LWCs/objects that haven't been touched in months. This explains _what content might be old_ even after the graph is refreshed.
|
|
39
|
+
6. Bucket the `freshness_report` output into hot / current / stale / dead and call out the worst offenders.
|
|
40
|
+
|
|
41
|
+
## Visualization
|
|
42
|
+
|
|
43
|
+
**No diagram.** This skill is about timestamps and commands, not topology. Render a tight markdown checklist instead:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
- Last ingest: 2024-05-01T08:12:33Z
|
|
47
|
+
- Age: 13 days (STALE)
|
|
48
|
+
- Recommended action: refresh now
|
|
49
|
+
- Command: `sfgraph ingest --org prod`
|
|
50
|
+
- Then re-run the analysis you started.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Pair it with the bucketed freshness table from `freshness_report` for the org-side picture.
|
|
54
|
+
|
|
55
|
+
## Staleness check
|
|
56
|
+
|
|
57
|
+
`staleness_check` _is_ the first step here — the whole skill is the staleness check. If `staleness_check` returns `stale=false`, still continue to `freshness_report` so the user sees the org-side picture.
|
|
58
|
+
|
|
59
|
+
## Response Shape
|
|
60
|
+
|
|
61
|
+
- **Graph staleness** — checklist above.
|
|
62
|
+
- **Refresh command** — fenced one-liner the user can copy.
|
|
63
|
+
- **Org-side freshness** — bucketed table from `freshness_report` (hot / current / stale / dead with counts and top items).
|
|
64
|
+
- **Suggested next skill** — `sf-dead-code-audit` if the dead bucket is large.
|
|
65
|
+
|
|
66
|
+
## Don't
|
|
67
|
+
|
|
68
|
+
- Do not run the ingest yourself via the shell. The user must execute `sfgraph ingest`; `start_ingest_job` returns the command, not a running job.
|
|
69
|
+
- Do not conflate graph staleness (ingest timestamp) with org-side freshness (metadata last-modified) — they're independent signals.
|
|
70
|
+
- Do not draw a Mermaid diagram for this skill. Timestamps + commands beat shapes.
|
|
71
|
+
- Do not silently skip `freshness_report` even when the graph is fresh — org-side rot is still useful signal.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf-omnistudio-migration-audit
|
|
3
|
+
description: Inventory Vlocity-CMT vs OmniStudio-on-Core assets and verify CANONICAL_OF mirror counts.
|
|
4
|
+
triggers:
|
|
5
|
+
- "omnistudio migration"
|
|
6
|
+
- "vlocity to omnistudio"
|
|
7
|
+
- "CMT migration"
|
|
8
|
+
- "omnistudio audit"
|
|
9
|
+
- "migrate from vlocity"
|
|
10
|
+
tools_used:
|
|
11
|
+
- cross_org_diff
|
|
12
|
+
- staleness_check
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# sf-omnistudio-migration-audit
|
|
16
|
+
|
|
17
|
+
Use when the user is mid-migration from Vlocity CMT (managed package) to OmniStudio on Core and wants to verify parity by category.
|
|
18
|
+
|
|
19
|
+
## Playbook
|
|
20
|
+
|
|
21
|
+
1. Enumerate Vlocity-CMT node categories present in the graph: `vlocity_cmt__DataRaptor`, `vlocity_cmt__IntegrationProcedure`, `vlocity_cmt__OmniScript`, `vlocity_cmt__VlocityCard`.
|
|
22
|
+
2. Enumerate the OmniStudio-on-Core equivalents: `OmniDataTransform`, `OmniIntegrationProcedure`, `OmniProcess` (OmniScript), `OmniUiCard`.
|
|
23
|
+
3. For each pair, count nodes on both sides and count `CANONICAL_OF` edges that mirror a CMT asset to its OmniStudio twin. Report `cmt_count`, `core_count`, `canonical_pairs`, `unmirrored_cmt`, `unmirrored_core`.
|
|
24
|
+
4. If the user provided two orgs (typically a CMT-only sandbox vs an OmniStudio-on-Core sandbox), call `cross_org_diff` to highlight assets present in one and not the other.
|
|
25
|
+
5. Bucket findings:
|
|
26
|
+
- **fully migrated** — pair exists, `CANONICAL_OF` edge present, no logic drift.
|
|
27
|
+
- **partial** — twin exists but `CANONICAL_OF` missing or one-side has additional logic nodes.
|
|
28
|
+
- **not started** — CMT asset has no Core twin.
|
|
29
|
+
6. Render a Mermaid bar chart per category: CMT / Core / Canonical / Unmirrored.
|
|
30
|
+
|
|
31
|
+
## Visualization
|
|
32
|
+
|
|
33
|
+
Render a **`flowchart LR`** parity diagram. Left subgraph is Vlocity-CMT; right is OmniStudio-on-Core; `CANONICAL_OF` edges connect mirrored pairs. Unmirrored nodes hang off either side with a dashed border.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
flowchart LR
|
|
37
|
+
subgraph CMT
|
|
38
|
+
D1[vlocity_cmt__DataRaptor:Foo]
|
|
39
|
+
end
|
|
40
|
+
subgraph Core
|
|
41
|
+
D2[OmniDataTransform:Foo]
|
|
42
|
+
end
|
|
43
|
+
D1 -. CANONICAL_OF .-> D2
|
|
44
|
+
D3[vlocity_cmt__OmniScript:Bar]:::unmirrored
|
|
45
|
+
classDef unmirrored stroke-dasharray:4 4,fill:#fdd
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For orgs with >50 CMT assets, swap the diagram for a per-category counts table — the parity story is the counts, not the topology.
|
|
49
|
+
|
|
50
|
+
## Staleness check
|
|
51
|
+
|
|
52
|
+
Before running the audit, invoke `staleness_check` for each org in scope. A stale ingest means recently-created CANONICAL_OF edges or new OmniStudio twins are missing, which inflates the "not started" bucket. If the report says stale, surface a warning to the user:
|
|
53
|
+
|
|
54
|
+
> Your ingest is N days old. Run `sfgraph ingest --org <alias>` to refresh, or proceed with the understanding that the graph may not reflect recent changes.
|
|
55
|
+
|
|
56
|
+
Then continue with the playbook.
|
|
57
|
+
|
|
58
|
+
## Response Shape
|
|
59
|
+
|
|
60
|
+
- **Scope** — one org or two orgs compared.
|
|
61
|
+
- **Per-category table** — DataRaptor / IntegrationProcedure / OmniScript / VlocityCard rows with the five counts above.
|
|
62
|
+
- **Buckets** — fully migrated / partial / not started, each as a bulleted list of asset names.
|
|
63
|
+
- **Mermaid bar chart** — embedded.
|
|
64
|
+
- **Recommended next step** — typically a focused `sf-cross-layer-trace` on the highest-risk unmirrored asset.
|
|
65
|
+
|
|
66
|
+
## Don't
|
|
67
|
+
|
|
68
|
+
- Do not include non-OmniStudio Vlocity assets (e.g. `vlocity_cmt__Pricebook2`) in migration counts.
|
|
69
|
+
- Do not auto-create `CANONICAL_OF` edges. This is a read-only audit.
|
|
70
|
+
- Do not assume name match implies semantic equivalence; require the `CANONICAL_OF` edge before counting as migrated.
|
|
71
|
+
- Do not modify or deploy any OmniStudio metadata.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf-schema-overview
|
|
3
|
+
description: Build an ERD-style overview of one or more SObjects and how they relate across Apex, Flow, and LWC layers.
|
|
4
|
+
triggers:
|
|
5
|
+
- "show the schema"
|
|
6
|
+
- "object model"
|
|
7
|
+
- "data model"
|
|
8
|
+
- "how are these objects related"
|
|
9
|
+
- "ERD"
|
|
10
|
+
- "field map for"
|
|
11
|
+
tools_used:
|
|
12
|
+
- analyze_field
|
|
13
|
+
- trace_upstream
|
|
14
|
+
- trace_downstream
|
|
15
|
+
- staleness_check
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# sf-schema-overview
|
|
19
|
+
|
|
20
|
+
Use when the user wants a high-level picture of the data model — which objects exist in a domain, how they connect via Lookup/MasterDetail, and which Apex/Flow/LWC artifacts depend on them.
|
|
21
|
+
|
|
22
|
+
## Playbook
|
|
23
|
+
|
|
24
|
+
1. Identify the focal object(s) from the user's question. If they named a domain ("the Order schema"), pick the lead object and include its first-degree neighbours.
|
|
25
|
+
2. Call `staleness_check` for the org. Warn if stale.
|
|
26
|
+
3. For each focal object, call `trace_downstream` with `qname=CustomObject:<name>` to enumerate Lookup/MasterDetail references coming out of it.
|
|
27
|
+
4. Call `trace_upstream` for the same object to find what depends on it (Apex selectors, Flows, LWCs, layouts).
|
|
28
|
+
5. If the user named a specific field, call `analyze_field` to get its readers/writers and a precise role description.
|
|
29
|
+
6. Produce an ERD-like diagram with one entity per object and relationship lines for each Lookup/MasterDetail edge.
|
|
30
|
+
|
|
31
|
+
## Visualization
|
|
32
|
+
|
|
33
|
+
Render an **`erDiagram`**. One entity per object; relationship cardinality from Lookup (`||--o{`) vs MasterDetail (`||--|{`). Fall back to a **`flowchart LR`** if the client renderer doesn't support `erDiagram`.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
erDiagram
|
|
37
|
+
Account ||--o{ Contact : "has"
|
|
38
|
+
Account ||--o{ Opportunity : "has"
|
|
39
|
+
Opportunity }o--|| Pricebook2 : "uses"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
When the schema has >20 entities, prune to the focal object's two-hop neighbourhood — a sprawling ERD is unreadable. State that you pruned, and offer to expand on request.
|
|
43
|
+
|
|
44
|
+
## Staleness check
|
|
45
|
+
|
|
46
|
+
Before tracing, invoke `staleness_check` for the org. New custom objects/fields and recently-added relationships are invisible in a stale graph. If the report says stale, surface a warning to the user:
|
|
47
|
+
|
|
48
|
+
> Your ingest is N days old. Run `sfgraph ingest --org <alias>` to refresh, or proceed with the understanding that the graph may not reflect recent changes.
|
|
49
|
+
|
|
50
|
+
Then continue with the playbook.
|
|
51
|
+
|
|
52
|
+
## Response Shape
|
|
53
|
+
|
|
54
|
+
- **Focal objects** — the object(s) the diagram is centred on.
|
|
55
|
+
- **Entities** — one bullet per object with its key fields (highest-arity fields first).
|
|
56
|
+
- **Relationships** — table: source object / target object / type (Lookup/MasterDetail) / required.
|
|
57
|
+
- **Cross-layer consumers** — bullets per object naming the Apex classes, Flows, and LWCs that touch it.
|
|
58
|
+
- **Mermaid ERD** — embedded.
|
|
59
|
+
- **Suggested next skill** — typically `sf-cross-layer-trace` for any field the user asks about in detail.
|
|
60
|
+
|
|
61
|
+
## Don't
|
|
62
|
+
|
|
63
|
+
- Do not include every field on every object — pick highest-arity or user-named ones. ERDs that list 200 fields are useless.
|
|
64
|
+
- Do not infer relationships from name match; only use edges from `trace_downstream`/`trace_upstream`.
|
|
65
|
+
- Do not modify the schema. This is pure read.
|
|
66
|
+
- Do not skip the cross-layer consumer summary — the value of this skill over a raw ERD is the layer context.
|