fetch-library-docs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Library Documentation Skill

库文档Skill

Fetches official library documentation with 60-90% token savings.

可获取官方库文档,且能节省60-90%的token。

WHEN TO INVOKE (Auto-Detection)

调用时机(自动检测)

INVOKE AUTOMATICALLY when:
ContextDetection SignalContent Type
ImplementingAbout to write code using library API
examples,api-ref
DebuggingError contains library name (e.g.,
PrismaClientError
)
troubleshooting
InstallingAdding new package,
npm install
, setup task
setup
IntegratingConnecting libraries ("use X with Y")
examples,setup
UpgradingVersion migration, breaking changes
migration
UncertainFirst use of library feature, unsure of pattern
examples
DO NOT INVOKE when:
  • Already have sufficient knowledge from training
  • User pasted docs or has them open
  • Task is about local/private code (use codebase search)
  • Comparing libraries (use web search)

在以下场景自动调用:
场景检测信号内容类型
功能实现即将编写使用库API的代码
examples,api-ref
调试错误信息中包含库名称(如
PrismaClientError
troubleshooting
安装添加新包、执行
npm install
、搭建任务
setup
集成连接多个库(如“将X与Y配合使用”)
examples,setup
版本升级版本迁移、破坏性变更
migration
不确定用法首次使用库的某项功能、对实现模式存疑
examples
以下场景请勿调用:
  • 已从训练中掌握足够相关知识
  • 用户已粘贴文档或已打开文档
  • 任务针对本地/私有代码(使用代码库搜索)
  • 对比不同库(使用网页搜索)

DECISION LOGIC

决策逻辑

1. Identify Library

1. 识别库

Priority: User mention → Error message → File imports → package.json → Ask user
Examples:
  • PrismaClientKnownRequestError
    → library = "prisma"
  • import { useState } from 'react'
    → library = "react"
  • from fastapi import FastAPI
    → library = "fastapi"
优先级:用户提及 → 错误信息 → 文件导入 → package.json → 询问用户
示例:
  • PrismaClientKnownRequestError
    → 库 = "prisma"
  • import { useState } from 'react'
    → 库 = "react"
  • from fastapi import FastAPI
    → 库 = "fastapi"

2. Identify Topic

2. 识别主题

Priority: User specifies → Error message → Feature being implemented → "getting started"
优先级:用户指定 → 错误信息 → 正在实现的功能 → "入门指南"

3. Select Content Type

3. 选择内容类型

TaskContent Type
Implementing code
examples,api-ref
Debugging error
troubleshooting,examples
Installing/setup
setup
Integrating libs
examples,setup
Upgrading version
migration
Understanding why
concepts
Best practices
patterns

任务内容类型
编写代码实现功能
examples,api-ref
调试错误
troubleshooting,examples
安装/搭建
setup
集成多个库
examples,setup
版本升级
migration
理解原理
concepts
最佳实践
patterns

EXECUTION

执行方式

bash
undefined
bash
undefined

With known library ID (faster - saves 1 API call)

使用已知的库ID(更快 - 节省1次API调用)

bash scripts/fetch-docs.sh --library-id <id> --topic "<topic>" --content-type <types>
bash scripts/fetch-docs.sh --library-id <id> --topic "<topic>" --content-type <types>

With library name (auto-resolves)

使用库名称(自动解析ID)

bash scripts/fetch-docs.sh --library <name> --topic "<topic>" --content-type <types>
undefined
bash scripts/fetch-docs.sh --library <name> --topic "<topic>" --content-type <types>
undefined

Quick Library IDs

常用库ID

LibraryID
React
/reactjs/react.dev
Next.js
/vercel/next.js
Prisma
/prisma/docs
Tailwind
/tailwindlabs/tailwindcss.com
FastAPI
/tiangolo/fastapi
See references/library-ids.md for complete list.

ID
React
/reactjs/react.dev
Next.js
/vercel/next.js
Prisma
/prisma/docs
Tailwind
/tailwindlabs/tailwindcss.com
FastAPI
/tiangolo/fastapi
完整列表请查看references/library-ids.md

ERROR HANDLING (Quick Reference)

错误处理(速查)

ErrorAction
[LIBRARY_NOT_FOUND]
Try spelling variations
[LIBRARY_MISMATCH]
Use --library-id directly
[EMPTY_RESULTS]
Broaden topic or use
--content-type all
[RATE_LIMIT_ERROR]
Check API key setup
Call Budget: Context7 allows 3 calls/question. Use
--library-id
to save 1 call.
See references/context7-tools.md for full error handling.

错误操作
[LIBRARY_NOT_FOUND]
尝试拼写变体
[LIBRARY_MISMATCH]
直接使用--library-id参数
[EMPTY_RESULTS]
扩大主题范围或使用
--content-type all
[RATE_LIMIT_ERROR]
检查API密钥配置
调用配额:Context7允许每个问题调用3次。使用
--library-id
可节省1次调用。
完整错误处理请查看references/context7-tools.md

REFERENCES

参考资料

  • Library IDs - Complete library ID list
  • Usage Patterns - Real-world examples
  • Context7 Tools - API details, error codes, setup
  • 库ID列表 - 完整的库ID清单
  • 使用模式 - 真实场景示例
  • Context7工具 - API详情、错误码、搭建说明