npx skills add ...
npx skills add mulesoft/mulesoft-dx --skill manage-api-version
Read, check for updates, and change the version of one or more API dependencies in a Mule project — the same values the Anypoint Studio Project Properties → API Specs tab sets, stored as <{artifactId}.version> properties in pom.xml. Use when the user asks to "get API version", "show API version", "display version info", "check what version an API is on", "any new versions", "any updates available", "check for updates", "update API version", "change API version", "bump API version", "set API version", or any request to read, check, or modify an API dependency version in a Mule project.
npx skills add mulesoft/mulesoft-dx --skill manage-api-version
Read and change the version of one or more API dependencies in a Mule project — the same values the Anypoint Studio Project Properties → API Specs tab sets. Each API dependency in the project gets its own version property in pom.xml, named by combining the dependency's artifactId with .version:
This skill reads and updates <{artifactId}.version> properties in pom.xml. A Mule project can have one or more API dependencies, each with its own version property. The property name is always {artifactId}.version where artifactId is the Maven artifact ID of the API dependency.
What you'll do: Display all API versions or specific ones by name, check whether newer versions are available (for all APIs or specific ones), or update the version for one or more API dependencies in a single operation and rescaffold the project once all changes are applied.
Before starting, verify these tools are available:
If anypoint-cli-v4 is missing:
The CHECK and CHANGE paths query Exchange. If the CLI is not authenticated or network is unavailable, display-only operations (DISPLAY ALL, DISPLAY SPECIFIC) still work — they read from pom.xml only.
This skill ships one shell helper in its own scripts/ directory:
| Script | Purpose |
|---|---|
scripts/fetch_versions.sh <groupId>:<artifactId>:<currentVersion> [...] | Resolves the full published-version list for one or more API dependencies in a single invocation, firing one Exchange lookup per API in parallel instead of the agent looping and calling anypoint-cli-v4 once per API sequentially. See Version Discovery under Step 7b for full usage and output shape. |
Invoke it with the Bash tool at the absolute path you were given in the "skill is now active" message (the directory containing this SKILL.md) — e.g. <skill-dir>/scripts/fetch_versions.sh .... Do not construct a relative ../scripts/... path; the working directory shifts across turns and relative paths break.
| User intent | Path |
|---|---|
| display/check current version — all APIs or no specific one named | → DISPLAY ALL (Steps 1 → 2 → 3) |
| display/check current version — one or more specific APIs named | → DISPLAY SPECIFIC (Steps 1 → 2 → 4) |
| any new/updated versions available — no specific API named | → CHECK ALL (Steps 1 → 2 → 5) |
| any new/updated versions available — one or more specific APIs named | → CHECK SPECIFIC (Steps 1 → 2 → 6) |
| set, change, adjust, update, bump, switch version | → CHANGE (Steps 1 → 2 → 7 → 8 → 9) |
Resolve the project root using the best available signal, in this order:
find to locate a pom.xml matching that hint and confirm with the user if more than one match is found.pom.xml reachable from context) — before falling back to "current/active project," check whether the named API's <{artifactId}.version> property (or a matching hardcoded <dependency> artifactId) exists in only one of the open projects' pom.xml files:
I couldn't find an API named
<name>in any of the open projects (<list the open project names/paths>). Did you mean a different API name, or is it in a project that isn't open right now? This check only applies when 2+ projects are genuinely in scope. With a single open/reachable project, skip straight to case 4 — never ask when there's nothing to disambiguate.
pom.xml exists in the current directory and use it.What project do you want to work on? You can give me the full path, a folder name, or just tell me it's the current directory.
Confirm pom.xml exists at the resolved path before continuing.
Ask at most once per conversation. Once the user has stated or confirmed which project they mean, keep using it for subsequent requests in the same conversation — don't re-ask on every turn. If the user later names a different project or a different API that resolves elsewhere, switch silently and confirm the switch in the response (e.g. "Switching to <project> for this one.") rather than re-running the full disambiguation question.
STOP (only if the project cannot be resolved from context).
Parse the user's request for intent keywords:
| Keywords | Operation |
|---|---|
| get, show, find, display, what is, current — all / every / no specific API named | → DISPLAY ALL |
| get, show, find, display, what is, current — one or more specific APIs named | → DISPLAY SPECIFIC |
| any new, updates, newer, latest, upgrade — no specific API named | → CHECK ALL |
| any new, updates, newer, latest, upgrade — one or more specific APIs named | → CHECK SPECIFIC |
| set, change, adjust, update, bump, switch | → CHANGE |
If intent is ambiguous, ask:
Do you want to display the current API version(s), or change one?
STOP (only if operation cannot be determined from the request).
pom.xml. Find all properties inside <properties> whose name ends in .version and corresponds to an API spec dependency. To identify API spec dependencies, check the matching <dependency> block:
raml, oas, graphql, protobuf, fat-protobuf, evented-api. Connectors use mule-plugin. If a classifier is present and matches this list, it is an API spec.artifactId contains the word api — this is the common naming convention for API spec artifacts.
Skip any dependency whose classifier is mule-plugin or that matches neither signal.End the skill here for the DISPLAY ALL path.
pom.xml. For each named API, find its <{artifactId}.version> property.End the skill here for the DISPLAY SPECIFIC path.
Read pom.xml and identify all API spec dependencies (same classifier/artifactId logic as DISPLAY ALL).
For each API, discover its full version list using the Version Discovery procedure below.
Report results:
If newer versions exist for any API:
STOP — if the user wants to update, transition to the CHANGE path starting at Step 7 for the APIs they name.
If no newer versions exist for any API:
STOP — if yes, transition to CHANGE path at Step 7.
End the skill here if the user does not want to make any changes.
Extract the API name(s) the user specified.
For each named API, discover its full version list using the Version Discovery procedure below, and compare against the current version to determine if a newer one exists.
Go through each named API one at a time in the order the user asked:
If a newer version exists:
STOP — if yes, proceed with the CHANGE flow for this API (Step 7c onwards). If no, move to the next named API.
If already on the latest version:
STOP — if yes, proceed with the CHANGE flow for this API (Step 7c onwards). If no, move to the next named API.
After all named APIs have been addressed, if any were queued for change, proceed to Step 8.
If the user named the API(s) to update, use those. Otherwise:
pom.xml and list all API dependency version properties.STOP (only if target API(s) not pre-supplied).
Before querying, back up the current pom.xml content in memory so it can be restored if anything fails later.
Read groupId and artifactId from the <dependency> block in pom.xml for every target API, then discover all of their version lists in a single call using the Version Discovery procedure below — pass all target APIs as separate arguments to the same script invocation, never one invocation per API.
If any row comes back with "source": "error" (both list and the describe fallback failed for that API):
error field:
Failed to fetch versions from Exchange for
<artifactId>. Check thatanypoint-cli-v4is authenticated and you have network access, then try again.
Discover versions for ALL target APIs in ONE call to the bundled script — never loop and invoke anypoint-cli-v4 yourself, one API at a time. Each direct anypoint-cli-v4 invocation pays a full Node CLI cold start plus a network round trip; looping that per API serializes N round trips where one script call does them in parallel and returns once. This is the single biggest lever for making this skill feel fast, especially on projects with several API dependencies.
Invoke the script with the Bash tool at its absolute path — <skill-dir>/scripts/fetch_versions.sh, where <skill-dir> is the absolute path you were given in the "skill is now active" message (the directory containing this SKILL.md). Do not construct a relative ../scripts/... path; the working directory shifts across turns and relative paths break.
Pass one <groupId>:<artifactId>:<currentVersion> argument per target API — for Steps 5 and 6 that's every API identified in that step; for Step 7b that's every API in the change set:
The script prints one JSON array to stdout, one object per input API, in input order:
Read each row's source field:
"list" — the normal path. Internally this ran exchange asset list <artifactId> --output json, filtered to rows matching the exact groupId/assetId, sorted by semver (highest first). Trust this fully — it is not anchored to any single version, so it doesn't have the false-negative failure mode described below."describe-fallback" — list returned zero matching rows for this asset, so the script fell back to exchange asset describe <groupId>/<artifactId>/<currentVersion> and parsed its otherVersions field. Surface the row's warning field to the user verbatim — describe's version list is anchored to the version you query with and has been observed to come back empty when that anchor version is not the latest published one, even when newer versions genuinely exist. Since CHECK/CHANGE always query from whatever version is currently pinned in pom.xml (almost never the latest), treat this row's version list as possibly incomplete."error" — both list and the describe fallback failed for this asset. Surface the row's error field. For Step 7b (CHANGE), treat this the same as an Exchange-fetch failure (see below). For Steps 5/6 (CHECK), report the failure for that specific API and continue processing the others — don't abort the whole check over one API's lookup failure.(This mirrors the pattern already used by two sibling skills in this repo — build-mule-integration/scripts/search_templates.sh and manage-global-configurations/scripts/get_latest_connector.sh — which fire multiple exchange asset list calls in parallel rather than looping sequentially, for the same latency reason.)
For each target API, present the available versions as a single AskUserQuestion tool call — do not narrate the version list as plain chat text first and then also call the tool; that produces two renderings of the same question. The tool call itself is the only presentation. If a newer version than the current one exists, mention it in the question text; list every available version as an option (current version included, labeled), plus a "Keep current version" style option is not needed since the current version already appears in the list:
If the current version is already the latest, drop the "newer version available" sentence from the question text but still call the tool the same way:
When changing multiple APIs, handle them one at a time: issue one AskUserQuestion call for the first API, STOP, get the selection, then move to the next API and repeat with a new AskUserQuestion call.
STOP — wait for the tool's response for the current API before presenting the next. Never restate the question or option list as a separate chat message before or after the tool call.
If the user selects the version already applied for a given API, respond:
order-apiis already on version1.0.0— no changes made.
Remove that API from the change set. If all APIs in the request were no-ops, end the skill here. Otherwise continue with the remaining APIs that do have a version change.
pom.xmlFor each API in the change set, determine which case applies:
Case 1 — Property placeholder already exists (<{artifactId}.version> is in <properties>):
Update the value in the <properties> block. The dependency itself (<version>${order-api.version}</version>) does not need to change.
Case 2 — Version is hardcoded directly in the dependency (no <{artifactId}.version> property exists, dependency has a literal <version>1.0.0</version>):
This means the project is not yet using the placeholder pattern. Do both:
<{artifactId}.version>NEW</{artifactId}.version> to the <properties> block.<version>1.0.0</version> inside that dependency's block with <version>${order-api.version}</version>.Repeat for each API in the change set, applying all edits before writing the file.
Print a summary of all changes made:
After all version properties are updated, trigger APIkit to regenerate flows from the new API spec versions — the same operation Anypoint Studio runs when you save changes in the Project Properties → API Specs tab. If multiple APIs were changed in the same operation, flows for all of them are regenerated in this single pass.
Run the following from the project root, exactly as shown — two commands only, joined with &&, nothing else appended:
2>&1, >, >>, or any other redirection to this command, and never pipe it into anything. The tool invocation already captures stdout and stderr in full, so redirection adds nothing — and it has a real side effect: the host IDE's command layer treats stream-redirection operators as unsafe and forces a manual approval prompt even for an otherwise-trusted command, which is exactly what this step must avoid.cd <projectDir> && mvn clean package -DskipTests shape above.pom.xml changes, or the instant the user touches the Project Properties → API Specs tab — with no click-through step for the human. This skill mirrors that: run the command as soon as Step 8's edits are written, without asking.BUILD SUCCESS means APIkit has pulled in the updated spec versions and regenerated the corresponding flows. The project is now consistent with all changed API versions.BUILD FAILURE occurs: automatically restore pom.xml to its pre-change state, then report the Maven error output verbatim so the user can investigate:
Build failed — pom.xml has been restored to its previous state. Maven error: [output here]
One mvn invocation per response. Do not bundle it with any other tool call.
{artifactId}.version — derived from the Maven artifactId of the API dependency, not a hardcoded tag like <apiVersion>.<version> (the Maven artifact version at the top of pom.xml). That is a different field entirely.mvn.mvn. Never rescaffold between individual API updates — one mvn pass at the end covers all of them.mvn clean package -DskipTests and confirming BUILD SUCCESS. A version change without rescaffolding leaves the project inconsistent. Run it immediately after Step 8's edits with no confirmation question, matching how Anypoint Studio itself rescaffolds automatically on a pom.xml change or an API Specs tab edit.mvn command's output. No 2>&1, >, >>, or pipes — the tool call already captures full stdout/stderr, and redirection operators can trip the host IDE's unsafe-command check and force an unwanted manual approval.mvn invocation per response. Do not bundle it with file edits or other commands.jq is required by scripts/fetch_versions.sh for parsing Exchange JSON responses. If jq is not available on the machine running the script, it will fail — there is no separate manual fallback path; install jq rather than reimplementing the script's parsing inline.scripts/fetch_versions.sh covering every target API, never a per-API loop of raw anypoint-cli-v4 invocations. See the Version Discovery procedure under Step 7b. The script runs exchange asset list (not version-anchored) in parallel across all target APIs, falling back to exchange asset describe's otherVersions field only per-API when list finds no match for that asset — describe's version list is anchored to the version you query with and has been observed to return empty/incomplete results when that version isn't the latest, which is exactly the situation CHECK and CHANGE query from..version properties found: The APIs may not be added to the project yet. Use Anypoint Studio's Project Properties → API Specs tab to add the API dependency first, which will create the property in pom.xml.mvn fails after version change: pom.xml is automatically restored. Check the Maven error for the root cause — the selected version may have an incompatible dependency or the Exchange asset may not be fully published.<properties>, update all occurrences to keep the project consistent.scripts/fetch_versions.sh rows come back with "source": "error" due to an auth error: Run anypoint-cli-v4 conf to verify credentials, or re-authenticate with anypoint-cli-v4 conf username <user> / anypoint-cli-v4 conf password <pass>. If ANYPOINT_BEARER is set in the environment alongside ANYPOINT_CLIENT_ID/ANYPOINT_CLIENT_SECRET, unset the client-credential vars — the CLI rejects calls when multiple auth methods are simultaneously active."source": "describe-fallback" and a versions list that looks too short: Expected — exchange asset list found zero rows for that groupId/assetId, so the script fell back to the version-anchored describe lookup, which can under-report versions newer than the current one (see Version Discovery). Confirm the artifactId matches the Exchange assetId exactly (case-sensitive) and that the account is authenticated against the correct organization — a private asset published under a different org than the CLI session's selected org will not appear via list. As a next step, try anypoint-cli-v4 exchange asset list <artifactId> --output json manually (unfiltered) to see whether the asset shows up under a different groupId than what's in pom.xml."source": "error" with no obvious auth/network cause: Both exchange asset list and the describe fallback failed for that specific asset. Re-run just that one API through scripts/fetch_versions.sh in isolation to see the underlying CLI error more clearly, or run the two anypoint-cli-v4 commands by hand to inspect stderr directly.api.id) and other global elements that pair with these API versionsanypoint-cli-v4 --version # must be v4; needs exchange asset list
mvn --version # Maven 3.6+ for rescaffold (CHANGE path only)npm install -g @mulesoft/anypoint-cli-v4
anypoint-cli-v4 conf username <username>
anypoint-cli-v4 conf password <password>API dependency versions (from pom.xml <properties>):
order-api.version → 1.0.0
customer-api.version → 2.1.0order-api.version → 1.0.0
customer-api.version → 2.1.0