agentleFS
vhmarquezvhmarquez/argo/skills/org-explore/SKILL.md

org-explore

Skill1 starsChanged 7 months agoMITView on GitHub

Snapshot the target Salesforce org's schema (objects, fields, profiles, permission sets, installed packages) into a local cache for downstream argo skills. Cache is for offline use, batch reports, and snapshot-vs-snapshot diffs.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 0 are distinctive, and 4 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.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If $CACHE_FILE exists and (now - _meta.cachedAt) < TTL and not --refresh, exit 0 with "cache fresh" message.

    line 63
  2. Very specific:

    Atomic writes: Always write <file>.tmp then mv to avoid leaving a half-written cache that another skill might read mid-write.

    line 151
  3. Very specific:

    Don't fail noisily on partial errors: If a single sobject describe fails, log it to the cache _meta.errors array and continue.

    line 153
  4. Very specific:

    Report stale-but-usable: If consumers (@architect, etc.) detect a stale cache, they should still use it but note the timestamp in their …

    line 154

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

You are populating the org cache that downstream argo skills (especially @architect, /argo:flow-audit, /argo:permset-audit, /argo:field-impact) read for grounded design and analysis.

Note: the cache is opt-in — useful for offline work, deterministic reports, and historical comparisons. Bare org-explore prints a live summary via the sf CLI and writes nothing; pass --cache to produce a snapshot.

Cache Location

${CLAUDE_PLUGIN_DATA:-$HOME/.claude/plugin-data}/argo/org-cache/<orgAlias>.json

Cache is per-org alias. A project may have several (dev / qa / prod), each cached separately. The cache file embeds a _meta block with timestamp and ttlSeconds so consumers can detect staleness.

Read Project Config First

Source the helper and load merged config (with optional --env):

source "${CLAUDE_PLUGIN_ROOT}/hooks/lib/config.sh"
source "${CLAUDE_PLUGIN_ROOT}/hooks/lib/sf-cli.sh"
sf_cli_check || exit 2

platform.defaultTargetOrg is the target unless overridden.

Input

The user provided: $ARGUMENTS

Argument forms:

  • (empty) — print live CLI summary; do NOT write cache
  • --cache — produce a cache snapshot at the path below (legacy v1.3 behavior)
  • --target-org <alias> — override the org alias (-o is also accepted)
  • --env <name> — load .claude/sf-project.<name>.json overrides; defaultTargetOrg comes from the merged config
  • --refresh — force refresh of an existing cache
  • --all-objects — describe every sObject (slow; default is "custom + standard objects referenced in source")
  • --ttl <seconds> — override the freshness TTL (default 86400 = 24h)
  • --ci — exit non-zero with no human-readable noise; emit a one-line JSON summary

Default behavior changed in v2.1 (Phase 13): bare org-explore no longer writes a cache. Use --cache to opt in. This avoids stale-cache surprises.

Steps

1. Resolve org alias

ORG="$(sf_config_get '.platform.defaultTargetOrg' "$ENV")"
[[ -n "$TARGET_OVERRIDE" ]] && ORG="$TARGET_OVERRIDE"
sf_cli_alias_exists "$ORG" || { echo "[org-explore] Org alias '$ORG' not found in `sf org list`" >&2; exit 2; }

2. Check cache freshness

CACHE_DIR="${CLAUDE_PLUGIN_DATA:-$HOME/.claude/plugin-data}/argo/org-cache"
CACHE_FILE="$CACHE_DIR/$ORG.json"
mkdir -p "$CACHE_DIR"
TTL="${TTL:-86400}"

If $CACHE_FILE exists and (now - _meta.cachedAt) < TTL and not --refresh, exit 0 with "cache fresh" message.

3. Discover in-scope objects (unless --all-objects)

  • Custom: query sf sobject list --target-org $ORG --sobject custom --json
  • Standard objects referenced in source: grep the apex source dir for Account|Contact|Case|Lead|Opportunity|User|... — only describe those that actually appear

4. Describe each object

For each object in scope:

sf_cli_describe "$obj" "$ORG" > /tmp/desc-$obj.json

Capture: API name, label, fields (api name, type, length, picklist values, custom flag, formula expression), child relationships, record-type info.

5. Query profiles, permission sets, package versions

sf_cli_query "SELECT Id, Name, UserType, IsCustom FROM Profile" "$ORG"
sf_cli_query "SELECT Id, Name, Label, License.Name FROM PermissionSet WHERE IsOwnedByProfile = false" "$ORG"
sf_cli_query "SELECT Id, MasterLabel, DeveloperName, IsActive FROM PermissionSetGroup" "$ORG"
sf_cli_query "SELECT Id, SubscriberPackage.Name, SubscriberPackage.NamespacePrefix, SubscriberPackageVersion.MajorVersion, SubscriberPackageVersion.MinorVersion, SubscriberPackageVersion.PatchVersion, SubscriberPackageVersion.BuildNumber FROM InstalledSubscriberPackageVersion" "$ORG"

6. Query active Flows (cheap; flow-audit will dig deeper)

sf_cli_query "SELECT DeveloperName, Label, ProcessType, TriggerType, ActiveVersion.VersionNumber FROM FlowDefinitionView WHERE IsActive = TRUE" "$ORG"

7. Assemble cache JSON

{
  "_meta": {
    "orgAlias": "DevVM",
    "orgInstanceUrl": "https://...",
    "orgEdition": "Developer",
    "cachedAt": "2026-04-28T10:30:00Z",
    "ttlSeconds": 86400,
    "schemaVersion": 1,
    "scope": {
      "allObjects": false,
      "objectsCustom": 27,
      "objectsStandardReferencedInSource": 8
    }
  },
  "objects": [
    {
      "apiName": "Account",
      "label": "Account",
      "isCustom": false,
      "fields": [
        { "apiName": "Name", "label": "Account Name", "type": "string", "length": 255, "isCustom": false }
      ],
      "childRelationships": [],
      "recordTypes": []
    }
  ],
  "profiles": [],
  "permissionSets": [],
  "permissionSetGroups": [],
  "installedPackages": [],
  "activeFlows": []
}

Pretty-print with 2-space indentation. Write atomically (write to $CACHE_FILE.tmp, then mv).

8. Report

Default output:

[org-explore] Cached org 'DevVM' (Developer Edition)
  Objects:               27 custom + 8 standard
  Profiles:              17
  Permission sets:       43
  Permission set groups: 6
  Installed packages:    2
  Active flows:          12
  Cache:                 <CLAUDE_PLUGIN_DATA>/argo/org-cache/DevVM.json
  Fresh until:           2026-04-29T10:30:00Z (24h TTL)

CI mode (--ci): emit one line of JSON to stdout:

{"org":"DevVM","cachedAt":"...","objects":35,"profiles":17,"permsets":43,"flows":12}

Rules

  • Never write secrets to the cache. The cache is for shape/metadata, not data. No record contents, no auth tokens.
  • Atomic writes. Always write <file>.tmp then mv to avoid leaving a half-written cache that another skill might read mid-write.
  • Incremental discovery. A custom org may have hundreds of sObjects; describing all of them takes minutes. Default to "custom + source-referenced standard"; --all-objects is opt-in.
  • Don't fail noisily on partial errors. If a single sobject describe fails, log it to the cache _meta.errors array and continue.
  • Report stale-but-usable. If consumers (@architect, etc.) detect a stale cache, they should still use it but note the timestamp in their output.

Consumers

Skills and agents that read the cache:

  • @architect — pre-design data-model verification
  • @data-architect (Phase 3) — schema design
  • /argo:org-diff — diff against this snapshot
  • /argo:permset-audit — combine cache profiles/permsets with ObjectPermissions queries
  • /argo:field-impact — verify field exists in target before searching source
  • /argo:flow-audit — combine activeFlows summary with detailed run-history queries

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.