api-version-management

Use this skill when auditing, upgrading, or standardizing Salesforce API versions across metadata components, sfdx-project.json sourceApiVersion, Apex classes, LWC bundles, Aura bundles, and integration endpoints. Covers version drift detection, retirement risk analysis, and upgrade planning. NOT for REST/SOAP API design patterns (use rest-api-patterns or soap-api-patterns), OAuth configuration (use oauth-flows-and-connected-apps), or Metadata API deployment mechanics (use change-set-deployment or unlocked-package-development).

Best use case

api-version-management is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use this skill when auditing, upgrading, or standardizing Salesforce API versions across metadata components, sfdx-project.json sourceApiVersion, Apex classes, LWC bundles, Aura bundles, and integration endpoints. Covers version drift detection, retirement risk analysis, and upgrade planning. NOT for REST/SOAP API design patterns (use rest-api-patterns or soap-api-patterns), OAuth configuration (use oauth-flows-and-connected-apps), or Metadata API deployment mechanics (use change-set-deployment or unlocked-package-development).

Teams using api-version-management should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/api-version-management/SKILL.md --create-dirs "https://raw.githubusercontent.com/PranavNagrecha/AwesomeSalesforceSkills/main/skills/devops/api-version-management/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/api-version-management/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How api-version-management Compares

Feature / Agentapi-version-managementStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use this skill when auditing, upgrading, or standardizing Salesforce API versions across metadata components, sfdx-project.json sourceApiVersion, Apex classes, LWC bundles, Aura bundles, and integration endpoints. Covers version drift detection, retirement risk analysis, and upgrade planning. NOT for REST/SOAP API design patterns (use rest-api-patterns or soap-api-patterns), OAuth configuration (use oauth-flows-and-connected-apps), or Metadata API deployment mechanics (use change-set-deployment or unlocked-package-development).

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# API Version Management

This skill activates when you need to audit, standardize, or upgrade the API versions declared across a Salesforce metadata codebase. Every Salesforce metadata component carries an API version that controls which platform behaviors, fields, and features are available at runtime. Version drift — where different components run on different API versions — causes subtle behavioral inconsistencies, test failures, and eventual breakage when Salesforce retires old versions.

---

## Before Starting

Gather this context before working on anything in this domain:

- **What is the project's `sourceApiVersion`?** Found in `sfdx-project.json`, this is the baseline version the project intends to use. Individual components can override it, and that override is where drift begins.
- **What is the current Salesforce release?** Each major release (Spring, Summer, Winter) increments the API version by 1. As of Spring '25, the current API version is 63.0. Salesforce retires versions on a rolling basis — versions 7.0 through 30.0 were retired in Summer '22, and versions 21.0-30.0 lose support according to the minimum 3-year deprecation notice policy.
- **Are there integrations using explicit API version numbers?** External systems calling `/services/data/vXX.0/` or `/services/Soap/c/XX.0` endpoints pin to a version. These must be inventoried alongside metadata.

---

## Core Concepts

### 1. The Three Layers of API Versioning

Salesforce API versions operate at three distinct layers, each independently configurable:

1. **Transport API version** — the version in REST/SOAP endpoint URLs used by external integrations (e.g., `/services/data/v63.0/`). This controls which API resources and fields are visible to the caller.
2. **`sourceApiVersion` in `sfdx-project.json`** — the default version used by the Salesforce CLI during `sf project deploy` and `sf project retrieve`. It sets the baseline for metadata operations but does not override per-component versions at runtime.
3. **Per-component `apiVersion`** — declared in each component's metadata file (`.cls-meta.xml`, `.js-meta.xml`, `.trigger-meta.xml`, `.cmp`). This is the version the platform actually uses when executing the component. An Apex class at version 50.0 sees different System method signatures than one at version 63.0.

Version drift occurs when these three layers diverge. The most dangerous drift is between `sourceApiVersion` and per-component versions, because developers assume they are deploying at one version while the platform executes at another.

### 2. Salesforce API Retirement Policy

Salesforce publishes an API End-of-Life policy with a minimum 3-year deprecation notice. When a version is retired:

- REST and SOAP calls to that version return an error.
- Metadata components pinned to that version may exhibit undefined behavior or deployment failures.
- `ApiTotalUsage` event logs in Event Monitoring track which versions are actively called, providing a detection mechanism before retirement hits.

Versions 7.0-30.0 were retired in Summer '22. The next retirement wave will follow the same 3-year notice pattern. Proactive scanning is essential because Salesforce does not automatically upgrade component versions.

### 3. LWC Component Versioning (Spring '25+)

Starting in Spring '25, Lightning Web Components require an explicit `apiVersion` in their `.js-meta.xml` file. Previously, LWC inherited the org's current version implicitly. This change means:

- New LWC bundles must declare `<apiVersion>63.0</apiVersion>` (or current).
- Existing LWC bundles without an explicit version will use the org default, but this implicit behavior is deprecated.
- The declared version controls which base components, wire adapters, and decorators are available.

### 4. ApiTotalUsage Event Logs

The `ApiTotalUsage` event type in Event Monitoring records every API call with the version used. Query these logs to find external integrations still calling deprecated versions:

```sql
SELECT ApiVersion, Client, Count
FROM ApiTotalUsage
WHERE ApiVersion < 31
ORDER BY Count DESC
```

This data is critical for building an upgrade plan that covers runtime usage, not just static metadata.

---

## Common Patterns

### Pattern 1: Full Codebase Version Audit

**When to use:** Before a major Salesforce release, after inheriting a project, or when deprecation notices arrive.

**How it works:**

1. Read `sourceApiVersion` from `sfdx-project.json`.
2. Scan all `*-meta.xml` files for `<apiVersion>` elements.
3. Scan `.cmp` and `.app` Aura files for `<aura:component>` or `<aura:application>` version attributes.
4. Compare each component's version against `sourceApiVersion` and flag drift.
5. Flag any component below the minimum safe version (currently 31.0).

**Why not the alternative:** Manual spot-checking misses components because a typical org has hundreds of versioned files scattered across classes, triggers, pages, components, and flows.

### Pattern 2: Incremental Version Pinning

**When to use:** When upgrading all components at once is too risky (large codebase, limited test coverage).

**How it works:**

1. Group components by current version into tiers.
2. Upgrade the oldest tier first (highest risk of retirement).
3. Run the full test suite after each tier upgrade.
4. Update `sourceApiVersion` in `sfdx-project.json` only after all components reach the target version.

**Why not the alternative:** A big-bang upgrade changes runtime behavior across every component simultaneously, making it difficult to isolate regressions.

### Pattern 3: CI Pipeline Version Gate

**When to use:** To prevent version drift from recurring after cleanup.

**How it works:**

1. Add a pre-commit or CI check that scans `*-meta.xml` for `<apiVersion>`.
2. Reject any component whose version is more than 2 major versions behind the project's `sourceApiVersion`.
3. Reject any component below the absolute minimum (currently 31.0).
4. Report drift percentage in CI output.

**Why not the alternative:** Without a gate, developers create new components at the CLI's default version while old components stay on legacy versions, re-introducing drift within a single sprint.

---

## Decision Guidance

| Situation | Recommended Approach | Reason |
|---|---|---|
| All components within 2 versions of target | Big-bang upgrade to current version | Low risk; behavior changes are minimal across adjacent versions |
| Components span 10+ version range | Incremental tier-based upgrade | Isolates regressions; allows targeted test runs per tier |
| External integrations on old versions | Upgrade transport API version separately, coordinated with external teams | Transport version affects API consumers outside your control |
| New project setup | Pin `sourceApiVersion` to current release, add CI gate immediately | Prevents drift from day one |
| LWC bundles missing explicit `apiVersion` | Add `<apiVersion>` to every `.js-meta.xml` | Required from Spring '25; implicit versioning is deprecated |
| Managed package development | Pin to the lowest version your subscribers need | Managed packages must support the subscriber's minimum API version |

---

## Recommended Workflow

Step-by-step instructions for auditing and upgrading API versions across a Salesforce project:

1. **Read `sfdx-project.json`** — extract the `sourceApiVersion` value. This is the project's intended baseline. If it is missing, the CLI defaults to the latest version, which may not match component versions.
2. **Inventory all versioned components** — scan the metadata source directory for every `*-meta.xml`, `.cmp`, `.app`, and `.js-meta.xml` file. Extract the `<apiVersion>` element from each. Record the component name, type, and version.
3. **Identify drift and retirement risk** — compare each component's version against `sourceApiVersion`. Flag components more than 2 versions behind as drifted. Flag anything below version 31.0 as retirement-critical.
4. **Check runtime API usage** — if Event Monitoring is available, query `ApiTotalUsage` logs to find external integrations using deprecated versions. Merge this data with the metadata inventory.
5. **Build the upgrade plan** — prioritize retirement-critical components first, then drifted components, then cosmetic alignment. Group into tiers for incremental rollout. Document expected behavior changes per version jump using Salesforce release notes.
6. **Execute and validate** — upgrade each tier by updating `<apiVersion>` in metadata files. Run the full test suite after each tier. Confirm deployment succeeds in a sandbox before production.
7. **Add a CI gate** — implement a version-check step in the CI pipeline to prevent future drift. Set the minimum acceptable version to no more than 2 behind `sourceApiVersion`.

---

## Review Checklist

Run through these before marking work in this area complete:

- [ ] `sourceApiVersion` in `sfdx-project.json` is set to the target version
- [ ] No component has an `apiVersion` below the minimum safe version (31.0)
- [ ] All components are within 2 major versions of `sourceApiVersion`
- [ ] Every LWC `.js-meta.xml` file has an explicit `<apiVersion>` element
- [ ] External integration endpoint URLs have been checked for deprecated versions
- [ ] Full test suite passes at the new version(s)
- [ ] CI pipeline includes a version-drift gate

---

## Salesforce-Specific Gotchas

Non-obvious platform behaviors that cause real production problems:

1. **`sourceApiVersion` does not override per-component versions at runtime** — many developers assume setting `sourceApiVersion` to 63.0 means all their Apex runs at 63.0. It does not. Each class executes at the version in its own `-meta.xml`. The `sourceApiVersion` only affects CLI retrieve/deploy operations.
2. **Apex behavior changes silently between versions** — certain System methods change behavior across versions (e.g., `String.valueOf()` on null, SOQL relationship name resolution, trigger context variable availability). An Apex class at version 40.0 can produce different results than the same code at version 63.0, with no compile-time warning.
3. **Retired API versions cause hard failures, not graceful fallbacks** — when Salesforce retires a version, REST/SOAP calls to that version return `UNSUPPORTED_API_VERSION` errors immediately. There is no automatic forwarding to the next supported version. Metadata components on retired versions may fail to deploy.

---

## Output Artifacts

| Artifact | Description |
|---|---|
| API Version Inventory | Spreadsheet or table listing every component, its type, file path, and current API version |
| Version Drift Report | Summary of components that diverge from `sourceApiVersion`, grouped by severity |
| Upgrade Plan | Prioritized, tiered plan for updating components with test checkpoints |
| CI Gate Configuration | Pipeline step or pre-commit hook that enforces version consistency |

---

## Related Skills

- `unlocked-package-development` — package-level `sourceApiVersion` management and subscriber version considerations
- `scratch-org-management` — scratch org definition files reference API versions for feature availability
- `sf-cli-and-sfdx-essentials` — CLI commands that use `sourceApiVersion` during deploy and retrieve
- `metadata-api-and-package-xml` — `package.xml` version attribute and its relationship to component versions

Related Skills

session-management-and-timeout

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when configuring session timeout values, concurrent session limits, session IP locking, or logout behavior in Salesforce. Covers org-wide session settings, profile-level overrides, Connected App session policies, and Metadata API SecuritySettings deployment. NOT for OAuth token refresh flows, login IP ranges, or MFA/identity-provider configuration.

oauth-token-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when work depends on how Salesforce OAuth access and refresh tokens are issued, refreshed, rotated, revoked, or introspected for a Connected App or API client—including unexpected logouts, invalid_grant after refresh, or designing token incident response. NOT for choosing which OAuth grant or Connected App flow to implement (use integration/oauth-flows-and-connected-apps), Named Credential packaging (use integration/named-credentials-setup), or broad Connected App IP and PKCE policy hardening without a token-lifecycle angle (use security/connected-app-security-policies).

certificate-and-key-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when creating, uploading, or rotating certificates in Salesforce, configuring mutual TLS (mTLS) client authentication, managing the Java KeyStore for CA-signed certificates, diagnosing certificate expiry in JWT OAuth flows, or understanding which certificate types Salesforce supports and how to migrate them between orgs. NOT for Named Credential configuration (use named-credentials-setup skill), NOT for Shield Platform Encryption key management. Trigger keywords: Certificate and Key Management, self-signed certificate, CA-signed certificate, mutual TLS, mTLS, keystore, JKS, PKCS12, certificate rotation, certificate expiry, JWT certificate.

omniscript-versioning

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when managing OmniScript versions: activating new versions, deactivating prior versions, testing a specific version before activation, rolling back to a previous version, or understanding version identity (Type/Subtype/Language triplet). NOT for OmniStudio deployment or DataPack migration (use omnistudio/omnistudio-deployment-datapacks).

flexcard-state-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing FlexCard actions, conditional visibility, and state that must survive navigation, refresh, or parent/child card transitions. Triggers: 'flexcard state', 'flexcard conditional visibility', 'flexcard actions', 'flexcard refresh', 'child flexcard state'. NOT for raw LWC state or for OmniScript step state.

lwc-state-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Share state across LWCs using pub/sub, Lightning Message Service, @wire, and reactive stores. NOT for in-component reactivity.

lwc-focus-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when building LWCs that need to manage focus explicitly — modal dialogs, wizard flows, dynamic inserts, list updates, error summaries, and focus after async work. Covers focus restoration, focus traps, programmatic focus across shadow DOM, and patterns for announcing changes to assistive tech. Does NOT cover general LWC a11y audit (see lwc-accessibility).

revenue-lifecycle-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when implementing or troubleshooting Salesforce Revenue Lifecycle Management (RLM) — the native Revenue Cloud product covering order-to-cash lifecycle, Dynamic Revenue Orchestrator (DRO) fulfillment plan design, asset amendments, billing schedule creation via Connect API, and invoice management. Triggers on: Dynamic Revenue Orchestrator, RLM order decomposition, DRO fulfillment swimlanes, native Revenue Cloud billing schedule, asset lifecycle management Salesforce. NOT for CPQ quoting or pricing rules (use cpq-* skills), not for the legacy Salesforce Billing managed package with blng__* objects (different product entirely), not for standard Order objects without Revenue Cloud features.

loyalty-management-setup

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when setting up or extending Salesforce Loyalty Management — including program and currency creation, tier group design, qualifying vs. non-qualifying point currency separation, DPE batch job activation, partner loyalty configuration, and member portal setup on Experience Cloud. Triggers on: Loyalty Management setup, loyalty tier setup Salesforce, qualifying points vs redemption points, DPE batch job for loyalty, partner loyalty program Salesforce, loyalty member portal. NOT for Marketing Cloud engagement program design (separate product), not for B2B loyalty via Sales Cloud (standard opportunity, not loyalty program), not for general Experience Cloud site setup (use experience-cloud-setup skill).

api-versioning-strategy

8
from PranavNagrecha/AwesomeSalesforceSkills

Design versioning for custom Apex REST endpoints: URI versioning, backward compatibility, deprecation sunset. NOT for consuming external APIs.

flow-versioning-strategy

8
from PranavNagrecha/AwesomeSalesforceSkills

Manage Flow versions: activation policy, paused interview compatibility, cleanup cadence, and breaking-change detection. Trigger keywords: flow version management, activate flow version, paused interview, flow cleanup, flow breaking change, flow rollback. Does NOT cover: FlowDefinition metadata deploy order (see devops skill), Process Builder retirement, or Flow test coverage (separate skill).

scratch-org-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when designing, configuring, or troubleshooting scratch orgs: definition file structure, edition selection, allocation limits, Org Shape, CI automation via ScratchOrgInfo, and lifecycle management from the Dev Hub. NOT for SFDX CLI basics (use sf-cli-and-sfdx-essentials), sandbox management, or production org administration.