integrate-context-matic

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

API Integration

API集成

When the user asks to integrate a third-party API or implement anything involving an external API or SDK, follow this workflow. Do not rely on your own knowledge for available APIs or their capabilities — always use the context-matic MCP server.
当用户要求集成第三方API或实现任何涉及外部API或SDK的功能时,请遵循此工作流。不要依赖你自身关于可用API及其能力的知识——始终使用context-matic MCP服务器。

When to Apply

适用场景

Apply this skill when the user:
  • Asks to integrate a third-party API
  • Wants to add a client or SDK for an external service
  • Requests implementation that depends on an external API
  • Mentions a specific API (e.g. PayPal, Twilio) and implementation or integration
当用户有以下需求时使用本技能:
  • 要求集成第三方API
  • 想要为外部服务添加客户端或SDK
  • 请求实现依赖外部API的功能
  • 提到具体API(例如PayPal、Twilio)以及相关实现或集成需求

Workflow

工作流

1. Ensure Guidelines and Skills Exist

1. 确认指南和技能已存在

1a. Detect the Project's Primary Language

1a. 检测项目主语言

Before checking for guidelines or skills, identify the project's primary programming language by inspecting the workspace:
File / PatternLanguage
*.csproj
,
*.sln
csharp
package.json
with
"typescript"
dep or
.ts
files
typescript
requirements.txt
,
pyproject.toml
,
*.py
python
go.mod
,
*.go
go
pom.xml
,
build.gradle
,
*.java
java
Gemfile
,
*.rb
ruby
composer.json
,
*.php
php
Use the detected language in all subsequent steps wherever
language
is required.
在检查指南或技能之前,通过检查工作区识别项目的主要编程语言:
文件 / 匹配规则语言
*.csproj
,
*.sln
csharp
包含
"typescript"
依赖的
package.json
.ts
文件
typescript
requirements.txt
,
pyproject.toml
,
*.py
python
go.mod
,
*.go
go
pom.xml
,
build.gradle
,
*.java
java
Gemfile
,
*.rb
ruby
composer.json
,
*.php
php
在后续所有需要填写
language
的步骤中使用检测到的语言。

1b. Check for Existing Guidelines and Skills

1b. 检查现有指南和技能

Check whether guidelines and skills have already been added for this project by looking for their presence in the workspace.
  • {language}-conventions
    is the skill produced by add_skills.
  • {language}-security-guidelines.md
    and
    {language}-test-guidelines.md
    are language-specific guideline files produced by add_guidelines.
  • update-activity-workflow.md
    is a workflow guideline file produced by add_guidelines (it is not language-specific).
  • Check these independently. Do not treat the presence of one set as proof that the other set already exists.
  • If any required guideline files for this project are missing: Call add_guidelines.
  • If
    {language}-conventions
    is missing for the project's language:
    Call add_skills.
  • If all required guideline files and
    {language}-conventions
    already exist:
    Skip this step and proceed to step 2.
通过检查工作区内容,确认该项目是否已经添加了相关指南和技能。
  • {language}-conventions
    add_skills生成的技能文件。
  • {language}-security-guidelines.md
    {language}-test-guidelines.md
    add_guidelines生成的语言特定指南文件。
  • update-activity-workflow.md
    add_guidelines生成的工作流指南文件(不区分语言)。
  • 独立检查以上文件,不要认为其中一类存在就代表另一类也已经存在。
  • 如果项目缺少任何必填的指南文件: 调用add_guidelines
  • 如果项目缺少对应语言的
    {language}-conventions
    调用add_skills
  • 如果所有必填指南文件和
    {language}-conventions
    都已存在:
    跳过此步骤,继续执行步骤2。

2. Discover Available APIs

2. 发现可用API

Call fetch_api to find available APIs — always start here.
  • Provide the
    language
    parameter using the language detected in step 1a.
  • The response returns available APIs with their names, descriptions, and
    key
    values.
  • Identify the API that matches the user's request based on the name and description.
  • Extract the correct
    key
    for the user's requested API before proceeding. This key will be used for all subsequent tool calls related to that API.
If the requested API is not in the list:
  • Inform the user that the API is not currently available in this plugin (context-matic) and stop.
  • Request guidance from user on how to proceed with the API's integration.
调用fetch_api查找可用API——始终从这一步开始。
  • 传入步骤1a中检测到的语言作为
    language
    参数。
  • 响应会返回可用API的名称、描述和
    key
    值。
  • 根据名称和描述识别匹配用户需求的API。
  • 在继续后续步骤前提取用户请求的API对应的正确
    key
    ,该key将用于所有和此API相关的后续工具调用。
如果请求的API不在列表中:
  • 告知用户该API目前不在本插件(context-matic)的支持范围内,终止当前流程。
  • 向用户请求关于如何继续集成该API的指导。

3. Get Integration Guidance

3. 获取集成指南

  • Provide
    ask
    with:
    language
    ,
    key
    (from step 2), and your
    query
    .
  • Break complex questions into smaller focused queries for best results:
    • "How do I authenticate?"
    • "How do I create a payment?"
    • "What are the rate limits?"
  • ask
    传入:
    language
    、(步骤2得到的)
    key
    以及你的
    query
  • 将复杂问题拆分为更小的针对性查询以获得最佳结果:
    • "我该如何进行身份验证?"
    • "我该如何创建支付订单?"
    • "接口的限流规则是什么?"

4. Look Up SDK Models and Endpoints (as needed)

4. 按需查询SDK模型和端点

These tools return definitions only — they do not call APIs or generate code.
  • model_search — look up a model/object definition.
    • Provide:
      language
      ,
      key
      , and an exact or partial case-sensitive model name as
      query
      (e.g.
      availableBalance
      ,
      TransactionId
      ).
  • endpoint_search — look up an endpoint method's details.
    • Provide:
      language
      ,
      key
      , and an exact or partial case-sensitive method name as
      query
      (e.g.
      createUser
      ,
      get_account_balance
      ).
这些工具仅返回定义内容——不会调用API或生成代码。
  • model_search — 查询模型/对象定义。
    • 传入:
      language
      key
      ,以及精确或部分匹配的区分大小写的模型名称作为
      query
      (例如
      availableBalance
      TransactionId
      )。
  • endpoint_search — 查询端点方法的详情。
    • 传入:
      language
      key
      ,以及精确或部分匹配的区分大小写的方法名称作为
      query
      (例如
      createUser
      get_account_balance
      )。

5. Record Milestones

5. 记录里程碑

Call update_activity (with the appropriate
milestone
) whenever one of these is concretely reached in code or infrastructure — not merely mentioned or planned:
MilestoneWhen to pass it
sdk_setup
SDK package is installed in the project (e.g.
npm install
,
pip install
,
go get
has run and succeeded).
auth_configured
API credentials are explicitly written into the project's runtime environment (e.g. present in a
.env
file, secrets manager, or config file) and referenced in actual code.
first_call_made
First API call code written and executed
error_encountered
Developer reports a bug, error response, or failing call
error_resolved
Fix applied and API call confirmed working
当以下里程碑在代码或基础设施中切实达成时调用update_activity(传入对应的
milestone
参数)——仅提到或计划完成不算:
里程碑触发时机
sdk_setup
SDK包已成功安装到项目中(例如
npm install
pip install
go get
已运行并执行成功)。
auth_configured
API凭证已明确写入项目的运行时环境(例如存在于
.env
文件、密钥管理器或配置文件中)已在实际代码中被引用。
first_call_made
首个API调用代码已编写并执行
error_encountered
开发者上报bug、错误响应或调用失败
error_resolved
修复已应用,且API调用已确认可以正常工作

Checklist

检查清单

  • Project's primary language detected (step 1a)
  • add_guidelines
    called if guideline files were missing, otherwise skipped
  • add_skills
    called if
    {language}-conventions
    was missing, otherwise skipped
  • fetch_api
    called with correct
    language
    for the project
  • Correct
    key
    identified for the requested API (or user informed if not found)
  • update_activity
    called only when a milestone is concretely reached in code/infrastructure — never for questions, searches, or tool lookups
  • update_activity
    called with the appropriate
    milestone
    at each integration milestone
  • ask
    used for integration guidance and code samples
  • model_search
    /
    endpoint_search
    used as needed for SDK details
  • Project compiles after each code modification
  • 已检测项目主语言(步骤1a)
  • 如果缺少指南文件已调用
    add_guidelines
    ,否则跳过
  • 如果缺少
    {language}-conventions
    已调用
    add_skills
    ,否则跳过
  • 已使用项目对应的正确
    language
    参数调用
    fetch_api
  • 已识别出请求API对应的正确
    key
    (如果未找到已告知用户)
  • 仅当里程碑在代码/基础设施中切实达成时才调用
    update_activity
    ——查询、搜索、工具查找场景下不调用
  • 每个集成里程碑阶段都已传入对应的
    milestone
    参数调用
    update_activity
  • 已使用
    ask
    获取集成指南和代码示例
  • 按需使用
    model_search
    /
    endpoint_search
    查询SDK详情
  • 每次代码修改后项目都可以正常编译

Notes

注意事项

  • API not found: If an API is missing from
    fetch_api
    , do not guess at SDK usage — inform the user that the API is not currently available in this plugin and stop.
  • update_activity and fetch_api:
    fetch_api
    is API discovery, not integration — do not call
    update_activity
    before it.
  • 未找到API:如果
    fetch_api
    返回结果中没有目标API,不要猜测SDK的使用方法——告知用户该API目前不在本插件的支持范围内并终止流程。
  • update_activity和fetch_api
    fetch_api
    属于API发现环节,不是集成环节——不要在此之前调用
    update_activity