library-docs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Library Docs

库文档

Overview

概述

This MCP-powered skill provides instant access to up-to-date library documentation through the context7 MCP server. Instead of searching documentation manually or relying on potentially outdated information, this skill fetches current, authoritative documentation directly from library maintainers.
这个MCP驱动的技能可以通过context7 MCP服务器即时访问最新的库文档。你无需手动搜索文档,也不必依赖可能过时的信息,该技能会直接从库维护者处获取最新的权威文档。

When to Use This Skill

何时使用该技能

  • Looking up API references for libraries
  • Understanding how specific features work
  • Finding code examples from official docs
  • Verifying correct usage patterns
  • Checking latest syntax and best practices
  • Comparing different library approaches
  • Complementing the documentation-maintainer agent
  • 查阅库的API参考文档
  • 理解特定功能的工作原理
  • 查找官方文档中的代码示例
  • 验证正确的使用模式
  • 查看最新语法和最佳实践
  • 对比不同库的实现思路
  • 作为documentation-maintainer Agent的补充

MCP Integration

MCP集成

This skill leverages the context7 MCP server which provides access to documentation for hundreds of popular libraries.
该技能依托context7 MCP服务器,可访问上百个流行库的文档。

How It Works

工作原理

  1. MCP Server Connection: Claude Code connects to context7 MCP server
  2. Library Resolution: Convert library name to Context7-compatible ID
  3. Documentation Fetch: Retrieve up-to-date documentation
  4. Context Integration: Load relevant docs into conversation
  1. MCP服务器连接:Claude Code连接到context7 MCP服务器
  2. 库识别:将库名转换为Context7兼容的ID
  3. 文档拉取:检索最新的文档内容
  4. 上下文集成:将相关文档加载到对话中

Available Tools

可用工具

The context7 MCP server provides two tools:
mcp__context7__resolve-library-id
  • Converts a library name to Context7-compatible ID
  • Example: "react" → "/facebook/react"
  • Handles version-specific requests
mcp__context7__get-library-docs
  • Fetches documentation for a library
  • Supports topic-specific queries
  • Configurable token limits
context7 MCP服务器提供两个工具:
mcp__context7__resolve-library-id
  • 将库名转换为Context7兼容的ID
  • 示例:"react" → "/facebook/react"
  • 支持特定版本的请求
mcp__context7__get-library-docs
  • 拉取指定库的文档
  • 支持特定主题的查询
  • 可配置token限制

Common Usage Patterns

常见使用场景

Pattern 1: Basic Library Lookup

场景1:基础库查询

User Request:
"Show me React hooks documentation"
Workflow:
  1. Resolve "react" to library ID using MCP
  2. Fetch React documentation focused on "hooks"
  3. Present relevant hooks documentation
Example MCP Calls:
javascript
// Step 1: Resolve library ID
mcp__context7__resolve-library-id({ libraryName: "react" })
// Returns: "/facebook/react"

// Step 2: Get docs
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "/facebook/react",
  topic: "hooks"
})
用户请求:
"Show me React hooks documentation"
工作流:
  1. 调用MCP将"react"解析为库ID
  2. 拉取React中聚焦于"hooks"的文档
  3. 展示相关的hooks文档
MCP调用示例:
javascript
// Step 1: Resolve library ID
mcp__context7__resolve-library-id({ libraryName: "react" })
// Returns: "/facebook/react"

// Step 2: Get docs
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "/facebook/react",
  topic: "hooks"
})

Pattern 2: Specific Version

场景2:特定版本查询

User Request:
"How does routing work in Next.js 14?"
Workflow:
  1. Resolve "Next.js 14" to version-specific ID
  2. Fetch Next.js v14 routing documentation
  3. Explain routing with v14-specific features
Example MCP Calls:
javascript
// Resolve with version
mcp__context7__resolve-library-id({ libraryName: "Next.js 14" })
// Returns: "/vercel/next.js/v14.x.x"

// Get routing docs
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "/vercel/next.js/v14.x.x",
  topic: "routing"
})
用户请求:
"How does routing work in Next.js 14?"
工作流:
  1. 将"Next.js 14"解析为对应版本的ID
  2. 拉取Next.js v14的路由相关文档
  3. 结合v14的特定特性解释路由功能
MCP调用示例:
javascript
// Resolve with version
mcp__context7__resolve-library-id({ libraryName: "Next.js 14" })
// Returns: "/vercel/next.js/v14.x.x"

// Get routing docs
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "/vercel/next.js/v14.x.x",
  topic: "routing"
})

Pattern 3: API Comparison

场景3:API对比

User Request:
"Compare MongoDB and Supabase query syntax"
Workflow:
  1. Resolve both library IDs
  2. Fetch query documentation for each
  3. Present side-by-side comparison
Example MCP Calls:
javascript
// Fetch MongoDB docs
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "/mongodb/docs",
  topic: "queries"
})

// Fetch Supabase docs
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "/supabase/supabase",
  topic: "queries"
})
用户请求:
"Compare MongoDB and Supabase query syntax"
工作流:
  1. 解析两个库的ID
  2. 分别拉取两个库的查询相关文档
  3. 展示并排对比结果
MCP调用示例:
javascript
// Fetch MongoDB docs
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "/mongodb/docs",
  topic: "queries"
})

// Fetch Supabase docs
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "/supabase/supabase",
  topic: "queries"
})

Pattern 4: Focused Topic Research

场景4:特定主题深度调研

User Request:
"I need comprehensive information on React Server Components"
Workflow:
  1. Resolve React library ID
  2. Fetch docs with larger token limit for depth
  3. Focus specifically on Server Components topic
Example MCP Calls:
javascript
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "/facebook/react",
  topic: "server components",
  tokens: 10000  // More tokens for comprehensive coverage
})
用户请求:
"I need comprehensive information on React Server Components"
工作流:
  1. 解析React的库ID
  2. 调高token限制拉取深度文档
  3. 聚焦于Server Components主题的内容
MCP调用示例:
javascript
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "/facebook/react",
  topic: "server components",
  tokens: 10000  // More tokens for comprehensive coverage
})

Supported Libraries

支持的库

The context7 MCP server supports hundreds of libraries. Common ones include:
Frontend Frameworks:
  • React (
    /facebook/react
    )
  • Vue (
    /vuejs/core
    )
  • Angular (
    /angular/angular
    )
  • Svelte (
    /sveltejs/svelte
    )
  • Next.js (
    /vercel/next.js
    )
  • Nuxt (
    /nuxt/nuxt
    )
Backend & Databases:
  • MongoDB (
    /mongodb/docs
    )
  • PostgreSQL
  • Supabase (
    /supabase/supabase
    )
  • Prisma (
    /prisma/prisma
    )
Tools & Libraries:
  • Tailwind CSS (
    /tailwindlabs/tailwindcss
    )
  • TypeScript (
    /microsoft/TypeScript
    )
  • Vite (
    /vitejs/vite
    )
And hundreds more...
context7 MCP服务器支持上百个库,常见的包括:
前端框架:
  • React (
    /facebook/react
    )
  • Vue (
    /vuejs/core
    )
  • Angular (
    /angular/angular
    )
  • Svelte (
    /sveltejs/svelte
    )
  • Next.js (
    /vercel/next.js
    )
  • Nuxt (
    /nuxt/nuxt
    )
后端与数据库:
  • MongoDB (
    /mongodb/docs
    )
  • PostgreSQL
  • Supabase (
    /supabase/supabase
    )
  • Prisma (
    /prisma/prisma
    )
工具与库:
  • Tailwind CSS (
    /tailwindlabs/tailwindcss
    )
  • TypeScript (
    /microsoft/TypeScript
    )
  • Vite (
    /vitejs/vite
    )
以及上百个其他库...

Integration with Agents

与Agent的集成

documentation-maintainer Agent

documentation-maintainer Agent

Synergy: This skill provides source documentation, while the documentation-maintainer agent creates project-specific docs.
Workflow Example:
User: "Document our authentication system"

1. library-docs skill → Fetch auth library documentation
2. documentation-maintainer agent → Create docs using library patterns
3. Result: Consistent documentation following library conventions
协同效应:该技能提供源文档,而documentation-maintainer Agent负责生成项目特定的文档。
工作流示例:
User: "Document our authentication system"

1. library-docs skill → 拉取认证库的文档
2. documentation-maintainer agent → 基于库的模式创建文档
3. 结果:符合库规范的一致性文档

api-backend Agent

api-backend Agent

Synergy: This skill provides API reference, while api-backend implements the code.
Workflow Example:
User: "Implement Stripe payment integration"

1. library-docs skill → Fetch Stripe API documentation
2. api-backend agent → Implement using current Stripe patterns
3. Result: Correct, up-to-date implementation
协同效应:该技能提供API参考,而api-backend负责实现代码。
工作流示例:
User: "Implement Stripe payment integration"

1. library-docs skill → 拉取Stripe API文档
2. api-backend agent → 基于当前Stripe的模式实现功能
3. 结果:正确、最新的实现

frontend-specialist Agent

frontend-specialist Agent

Synergy: This skill provides component documentation, while frontend-specialist builds UI.
Workflow Example:
User: "Create a data table with React"

1. library-docs skill → Fetch React table library docs
2. frontend-specialist agent → Build component following patterns
3. Result: Modern component using best practices
协同效应:该技能提供组件文档,而frontend-specialist负责构建UI。
工作流示例:
User: "Create a data table with React"

1. library-docs skill → 拉取React表格库的文档
2. frontend-specialist agent → 遵循模式构建组件
3. 结果:符合最佳实践的现代化组件

Best Practices

最佳实践

DO:

推荐做法:

  • ✅ Specify library versions when relevant
  • ✅ Use topic parameter to narrow results
  • ✅ Combine with agents for implementation
  • ✅ Reference official docs for correctness
  • ✅ Check docs when libraries update
  • ✅ 涉及版本时明确指定库的版本
  • ✅ 使用topic参数缩小结果范围
  • ✅ 结合Agent完成实现工作
  • ✅ 参考官方文档保证正确性
  • ✅ 库更新时及时查看文档

DON'T:

不推荐做法:

  • ❌ Assume docs are current without checking
  • ❌ Skip version specifications for major changes
  • ❌ Ignore deprecation warnings in docs
  • ❌ Mix patterns from different library versions
  • ❌ 不做检查就默认文档是最新的
  • ✅ 涉及重大变更时省略版本说明
  • ❌ 忽略文档中的弃用警告
  • ❌ 混用不同库版本的使用模式

Example Workflows

示例工作流

Workflow 1: Learning New Library

工作流1:学习新库

User: "I'm new to Supabase, show me how to get started"

Steps:
1. Use library-docs to fetch Supabase getting started guide
2. Review authentication patterns
3. See database query examples
4. Understand real-time subscriptions

Output: Comprehensive introduction with official examples
User: "I'm new to Supabase, show me how to get started"

步骤:
1. 使用library-docs拉取Supabase的入门指南
2. 梳理认证模式
3. 查看数据库查询示例
4. 理解实时订阅功能

输出:带有官方示例的全面介绍

Workflow 2: Debugging API Usage

工作流2:调试API使用问题

User: "Why isn't my Next.js API route working?"

Steps:
1. Use library-docs to fetch Next.js API routes documentation
2. Compare user's code with official patterns
3. Identify discrepancies
4. Suggest corrections based on docs

Output: Fix based on current Next.js best practices
User: "Why isn't my Next.js API route working?"

步骤:
1. 使用library-docs拉取Next.js API路由的文档
2. 将用户代码与官方模式对比
3. 找出差异点
4. 基于文档给出修正建议

输出:基于Next.js当前最佳实践的修复方案

Workflow 3: Migration Guide

工作流3:迁移指南

User: "Help me migrate from Vue 2 to Vue 3"

Steps:
1. Fetch Vue 2 documentation for current patterns
2. Fetch Vue 3 documentation for new patterns
3. Identify breaking changes
4. Provide migration steps with examples

Output: Detailed migration guide with official references
User: "Help me migrate from Vue 2 to Vue 3"

步骤:
1. 拉取Vue 2的现有模式文档
2. 拉取Vue 3的新模式文档
3. 识别破坏性变更
4. 提供带示例的迁移步骤

输出:带有官方参考的详细迁移指南

MCP Server Setup

MCP服务器设置

Prerequisites

前置要求

The context7 MCP server should be configured in Claude Code settings.
Typical Configuration:
json
{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@context7/mcp-server"]
    }
  }
}
需要在Claude Code设置中配置context7 MCP服务器。
典型配置:
json
{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@context7/mcp-server"]
    }
  }
}

Verification

验证

To verify the MCP server is available, Claude Code should show context7 in the MCP servers list.
Claude Code的MCP服务器列表中会显示context7,即可确认MCP服务器可用。

Limitations & Considerations

限制与注意事项

Token Limits:
  • Default: 5000 tokens
  • Max configurable: Higher for comprehensive topics
  • Balance depth vs context usage
Library Coverage:
  • Most popular libraries supported
  • Some niche libraries may not be available
  • Check context7 documentation for full list
Update Frequency:
  • Documentation refreshed regularly
  • May have slight lag for very recent releases
  • Always verify critical production changes
Token限制:
  • 默认:5000 tokens
  • 最大可配置:可针对全面的主题调高限制
  • 需要平衡内容深度和上下文使用量
库覆盖范围:
  • 支持绝大多数流行库
  • 部分小众库可能暂不支持
  • 查看context7文档获取完整支持列表
更新频率:
  • 文档会定期刷新
  • 非常新的版本可能会有轻微延迟
  • 生产环境的关键变更请务必手动验证

Quick Reference

快速参考

Fetch Library Docs:
javascript
// Resolve library name
mcp__context7__resolve-library-id({
  libraryName: "library-name"
})

// Get documentation
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "/org/project",
  topic: "optional-topic",
  tokens: 5000
})
Common Queries:
  • "Show me {library} {feature} documentation"
  • "How to use {library} for {task}"
  • "What's new in {library} version {X}"
  • "Compare {library A} vs {library B} for {use case}"
拉取库文档:
javascript
// Resolve library name
mcp__context7__resolve-library-id({
  libraryName: "library-name"
})

// Get documentation
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "/org/project",
  topic: "optional-topic",
  tokens: 5000
})
常见查询:
  • "Show me {library} {feature} documentation"
  • "How to use {library} for {task}"
  • "What's new in {library} version {X}"
  • "Compare {library A} vs {library B} for {use case}"

Resources

资源

References

参考

  • Context7 documentation
  • MCP server configuration guide
  • Supported libraries list
  • Context7文档
  • MCP服务器配置指南
  • 支持的库列表

Related Skills

相关技能

  • documentation-maintainer: Create project docs
  • code-review-checklist: Verify against library patterns
  • documentation-maintainer:创建项目文档
  • code-review-checklist:对照库模式验证代码

Related Agents

相关Agent

  • documentation-maintainer: Auto-generate documentation
  • api-backend: Implement backend using library patterns
  • frontend-specialist: Build UI following library conventions

This is an MCP-powered skill - It demonstrates how Skills can leverage MCP servers for enhanced capabilities. The context7 MCP server provides the data source, while this skill provides the knowledge of how to use it effectively.
  • documentation-maintainer:自动生成文档
  • api-backend:基于库模式实现后端功能
  • frontend-specialist:遵循库规范构建UI

这是一个MCP驱动的技能 - 它展示了技能如何依托MCP服务器增强能力。context7 MCP服务器提供数据源,而该技能提供了高效使用该数据源的相关知识。