npx skills add ...
npx skills add clerk/skills --skill clerk-backend-api
npx skills add clerk/skills --skill clerk-backend-api
Clerk Backend REST API explorer and executor. Browse tags, inspect endpoint schemas, and execute authenticated requests. Use when listing users, managing organizations, or calling any Clerk API endpoint.
User Prompt: $ARGUMENTS
Before ANY POST / PATCH / PUT / DELETE, you MUST do ALL of the following in your response:
Check CLERK_SECRET_KEY — verify it is set:
If empty, stop and ask the user. Do not proceed without a valid key.
Check CLERK_BAPI_SCOPES — run:
Inspect the output. If scopes are missing or do not include the required write permission, tell the user: "This is a write operation and your current scopes may not allow it. Rerun with --admin to bypass?" Do NOT attempt the request and fail — ask first.
For DELETE requests: warn explicitly that the action is IRREVERSIBLE and list exactly what data will be permanently destroyed (user record, all sessions, all memberships, all associated data). Require explicit confirmation before proceeding. This warning is MANDATORY — never skip it.
For metadata operations: always explain which metadata type is being used and why (see Metadata types section below).
For the operations below, skip spec fetching and execute immediately using these exact templates. Substitute $CLERK_SECRET_KEY, $USER_ID, $ORG_ID, $EMAIL as needed from the user's context.
Roles: use "org:admin" or "org:member" (always prefix with org:).
@clerk/nextjs or @clerk/backend)Always explain the three metadata types before asking which to use:
| Type | Field | Readable by | Writable by | Use for |
|---|---|---|---|---|
| Public | public_metadata | Client + Server | Server only | Plan tier, roles, feature flags the frontend reads |
| Private | private_metadata | Server only | Server only | Stripe IDs, compliance flags, internal identifiers |
| Unsafe | unsafe_metadata | Client + Server | Client + Server | Ephemeral UI state, onboarding steps (client-writable — avoid sensitive data) |
For plan: 'pro' and onboarded: true — use public_metadata (frontend-readable, server-writable):
SDK equivalent:
Note: REST API uses snake_case (public_metadata). SDK uses camelCase (publicMetadata).
Base URL: https://api.clerk.com/v1
Auth: Authorization: Bearer $CLERK_SECRET_KEY on every request.
List users
Get user
Update user
Delete user — IRREVERSIBLE
Always warn the user this is permanent and confirm before proceeding.
Create organization
List organizations
Invite member
ALWAYS execute requests with direct curl commands. Use the spec-extraction scripts (api-specs-context.sh, extract-tags.js, extract-endpoint-detail.sh) to discover endpoints, but make actual API calls with curl. Do NOT use scripts/execute-request.sh — it's a local dev helper, not for agent use.
Template for GET requests:
Template for POST/PATCH requests:
Template for DELETE requests:
After getting the response: Parse and display it clearly. Use python3 -c "import sys,json; data=json.load(sys.stdin); print(json.dumps(data, indent=2))" to pretty-print JSON. Extract key fields (id, email, name, etc.) and summarize them for the user.
Before doing anything outside the FAST PATH, fetch the available spec versions and tags by running:
Use the output to determine the latest version and available tags.
Caching: If you already fetched the spec context earlier in this conversation, do NOT fetch it again. Reuse the version and tags from the previous call.
platform.CLERK_BAPI_SCOPES before attempting the request. If missing or insufficient, ask the user upfront. Do NOT attempt and fail — ask before executing. This check is MANDATORY.limit + offset and mention that results may be paginated for large datasets.scripts/execute-request.sh.| Environment | Limit |
|---|---|
| Production | 1,000 requests / 10 seconds |
| Development | 100 requests / 10 seconds |
| Single invitations | 100 / hour |
| Bulk invitations | 25 / hour |
| Org invitations | 250 / hour |
| Frontend API sign-in creation | 5 / 10 seconds |
| Frontend API sign-in attempts | 3 / 10 seconds |
| List users max per page | 500 |
currentUser() makes a real API call that counts against rate limits. Use auth() for just the session claims — it reads from the token without an API call.
updateUser({ publicMetadata: { role: 'admin' } }) REPLACES all public metadata, not merges. To add a field without losing existing data: read first, spread, then write.
Wrong:
This DELETES all other publicMetadata fields.
Right:
Determine the active mode based on the user prompt in Options context:
| Mode | Trigger | Behavior |
|---|---|---|
help | Prompt is empty, or contains only help / -h / --help | Print usage examples (step 0) |
browse | Prompt is tags, or a tag name (e.g. Users) | List all tags or endpoints for a tag |
execute | Specific endpoint (e.g. GET /users) or natural language action (e.g. "get user john_doe") | Look up endpoint, execute request |
detail | Endpoint + help / -h / --help (e.g. GET /users help) | Show endpoint schema, don't execute |
Use the LATEST VERSION from API specs context by default. If the user specifies a different version (e.g. --version 2024-10-01), use that version instead.
Determine the active mode, then follow the applicable steps below.
Modes: help only — Skip for browse, execute, and detail.
Print the following examples to the user verbatim:
Stop here.
Modes: browse (when prompt is tags or no tag specified) — Skip for help, execute, and detail.
If using a non-latest version, fetch tags for that version:
Otherwise, use the TAGS already in API specs context.
Share tags in a table and prompt the user to select a query.
Modes: browse (when a tag name is provided) — Skip for help, execute, and detail.
Fetch all endpoints for the identified tag:
Share the results (endpoints, schemas, parameters) with the user.
Modes: execute, detail — Skip for help and browse.
For natural language prompts in execute mode, first check if the operation matches a FAST PATH entry above. If it does, skip this step and proceed directly to step 4 using the FAST PATH template.
For other endpoints, identify the matching endpoint by searching the tags in context. Fetch tag endpoints if needed to resolve the exact path and method.
Extract the full endpoint definition:
${path} — e.g. /users/{user_id}${method} — lowercase, e.g. getdetail mode: Share the endpoint definition and schemas with the user. Stop here.
execute mode: Continue to step 4.
Modes: execute only.
scripts/execute-request.sh.Example — list users and parse response:
clerk-setup - Initial Clerk installclerk-orgs - Manage organizations via APIclerk-webhooks - Real-time event sync