clerk-backend-api

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Options context

选项上下文

User Prompt: $ARGUMENTS
用户提示:$ARGUMENTS

API specs context

API规范上下文

Before doing anything, fetch the available spec versions and tags by running:
bash
bash scripts/api-specs-context.sh
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.
在执行任何操作前,请先运行以下命令获取可用的规范版本和标签:
bash
bash scripts/api-specs-context.sh
使用输出结果确定最新版本和可用标签。
缓存规则: 如果您在本次对话中早些时候已经获取过规范上下文,请勿重复获取,直接复用之前调用得到的版本和标签即可。

Rules

规则

  • Always disregard endpoints/schemas related to
    platform
    .
  • Always confirm before performing write requests.
  • For write operations (POST/PUT/PATCH/DELETE), check if
    CLERK_BAPI_SCOPES
    includes the required scope. If not, ask the user upfront: "This is a write/delete operation and your current scopes don't allow it. Run with --admin to bypass?" Do NOT attempt the request first and fail — ask before executing.
  • 始终忽略与
    platform
    相关的端点/模式。
  • 执行写请求前必须始终确认。
  • 对于写操作(POST/PUT/PATCH/DELETE),请检查
    CLERK_BAPI_SCOPES
    是否包含所需的权限范围。如果不包含,请提前询问用户:"这是一个写/删除操作,您当前的权限范围不允许该操作。是否添加--admin参数运行以绕过限制?" 请勿先尝试请求再报错——执行前先询问。

Modes

模式

Determine the active mode based on the user prompt in Options context:
ModeTriggerBehavior
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
根据选项上下文中的用户提示确定激活的模式:
模式触发条件行为
help
提示为空,或仅包含
help
/
-h
/
--help
打印使用示例(第0步)
browse
提示为
tags
,或一个标签名(例如
Users
列出所有标签或对应标签的所有端点
execute
特定端点(例如
GET /users
)或自然语言操作描述(例如"get user john_doe")
查找端点,执行请求
detail
端点 +
help
/
-h
/
--help
(例如
GET /users help
展示端点模式,不执行请求

Your Task

你的任务

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.

默认使用API规范上下文中的最新版本。如果用户指定了其他版本(例如
--version 2024-10-01
),则使用该指定版本。
确定激活模式,然后遵循对应的步骤执行。

0. Print usage

0. 打印使用说明

Modes:
help
only — Skip for
browse
,
execute
, and
detail
.
Print the following examples to the user verbatim:
Browse
  /clerk-backend-api tags                         — list all tags
  /clerk-backend-api Users                        — browse endpoints for the Users tag
  /clerk-backend-api Users version 2025-11-10.yml — browse using a different version

Execute
  /clerk-backend-api GET /users             — fetch all users
  /clerk-backend-api get user john_doe      — natural language works too
  /clerk-backend-api POST /invitations      — create an invitation

Inspect
  /clerk-backend-api GET /users help        — show endpoint schema without executing
  /clerk-backend-api POST /invitations -h   — view request/response details

Options
  --admin                            — bypass scope restrictions for write/delete
  --version [date], version [date]   — use a specific spec version
  --help, -h, help                   — inspect endpoint instead of executing
Stop here.

适用模式:
help
——
browse
execute
detail
模式跳过此步。
逐字向用户打印以下示例:
Browse
  /clerk-backend-api tags                         — list all tags
  /clerk-backend-api Users                        — browse endpoints for the Users tag
  /clerk-backend-api Users version 2025-11-10.yml — browse using a different version

Execute
  /clerk-backend-api GET /users             — fetch all users
  /clerk-backend-api get user john_doe      — natural language works too
  /clerk-backend-api POST /invitations      — create an invitation

Inspect
  /clerk-backend-api GET /users help        — show endpoint schema without executing
  /clerk-backend-api POST /invitations -h   — view request/response details

Options
  --admin                            — bypass scope restrictions for write/delete
  --version [date], version [date]   — use a specific spec version
  --help, -h, help                   — inspect endpoint instead of executing
执行完毕后停止。

1. Fetch tags

1. 获取标签

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:
bash
curl -s https://raw.githubusercontent.com/clerk/openapi-specs/main/bapi/${version_name} | node scripts/extract-tags.js
Otherwise, use the TAGS already in API specs context.
Share tags in a table and prompt the user to select a query.

适用模式:
browse
(当提示为
tags
或未指定标签时) ——
help
execute
detail
模式跳过此步。
如果使用非最新版本,请获取对应版本的标签:
bash
curl -s https://raw.githubusercontent.com/clerk/openapi-specs/main/bapi/${version_name} | node scripts/extract-tags.js
否则,直接使用API规范上下文中已有的TAGS
以表格形式分享标签,并提示用户选择查询内容。

2. Fetch tag endpoints

2. 获取标签对应端点

Modes:
browse
(when a tag name is provided) — Skip for
help
,
execute
, and
detail
.
Fetch all endpoints for the identified tag:
bash
curl -s https://raw.githubusercontent.com/clerk/openapi-specs/main/bapi/${version_name} | bash scripts/extract-tag-endpoints.sh "${tag_name}"
Share the results (endpoints, schemas, parameters) with the user.

适用模式:
browse
(提供了标签名称时) ——
help
execute
detail
模式跳过此步。
获取指定标签对应的所有端点:
bash
curl -s https://raw.githubusercontent.com/clerk/openapi-specs/main/bapi/${version_name} | bash scripts/extract-tag-endpoints.sh "${tag_name}"
将结果(端点、模式、参数)分享给用户。

3. Fetch endpoint detail

3. 获取端点详情

Modes:
execute
,
detail
Skip for
help
and
browse
.
For natural language prompts in
execute
mode, first 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:
bash
curl -s https://raw.githubusercontent.com/clerk/openapi-specs/main/bapi/${version_name} | bash scripts/extract-endpoint-detail.sh "${path}" "${method}"
  • ${path}
    — e.g.
    /users/{user_id}
  • ${method}
    — lowercase, e.g.
    get
detail
mode:
Share the endpoint definition and schemas with the user. Stop here.
execute
mode:
Continue to step 4.

适用模式:
execute
detail
——
help
browse
模式跳过此步。
对于
execute
模式下的自然语言提示,首先通过搜索上下文中的标签确定匹配的端点。如果需要解析准确的路径和方法,可以获取标签对应的端点列表。
提取完整的端点定义:
bash
curl -s https://raw.githubusercontent.com/clerk/openapi-specs/main/bapi/${version_name} | bash scripts/extract-endpoint-detail.sh "${path}" "${method}"
  • ${path}
    — 例如
    /users/{user_id}
  • ${method}
    — 小写,例如
    get
detail
模式:
向用户分享端点定义和模式,执行完毕后停止。
execute
模式:
继续执行第4步。

4. Execute request

4. 执行请求

Modes:
execute
only.
Use the endpoint definition from step 3 to build the request:
  1. Identify required and optional parameters from the spec.
  2. Ask the user for any required path/query/body parameters.
  3. Execute via the request script:
bash
bash scripts/execute-request.sh [--admin] ${METHOD} "${path}" ['${body_json}']
  • --admin
    — pass this if the user confirmed admin bypass (see Rules)
  • ${METHOD}
    — uppercase HTTP method
  • ${path}
    — resolved path with parameters filled in (e.g.
    /users/user_abc123
    )
  • ${body_json}
    — optional JSON body for POST/PUT/PATCH
  1. Share the response with the user.
适用模式:
execute
使用第3步得到的端点定义构建请求:
  1. 从规范中识别必填和可选参数。
  2. 向用户询问所有必填的路径/查询/请求体参数。
  3. 通过请求脚本执行:
bash
bash scripts/execute-request.sh [--admin] ${METHOD} "${path}" ['${body_json}']
  • --admin
    — 如果用户确认要绕过管理员限制则传递该参数(参见规则部分)
  • ${METHOD}
    — 大写的HTTP方法
  • ${path}
    — 参数填充完成后的解析路径(例如
    /users/user_abc123
  • ${body_json}
    — POST/PUT/PATCH请求可选的JSON请求体
  1. 将响应结果分享给用户。