mcpField
H
hexdocs-fetcher

hexdocs-fetcher

github.com/oliver-kriska开发57150 次安装6 天前更新
代码仓库

关于 hexdocs-fetcher

hexdocs-fetcher 是面向 Claude Code 的技能,通过 WebFetch 获取 HexDocs 上的 Elixir 库文档,并以定向提取和缓存支持文档研究。

主要功能

  1. 01通过 WebFetch 获取 HexDocs
  2. 02定向查询模块、指南和 API
  3. 03使用聚焦的提取提示词
  4. 04利用 15 分钟缓存复用结果
  5. 05将研究结果保存到规划文件

适用场景

  1. 01研究 Elixir 库概览
  2. 02提取 API 详情或指南
  3. 03查找故障排查信息
  4. 04保存已获取的文档以供后用

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/oliver-kriska/claude-elixir-phoenix --skill hexdocs-fetcher

安装后在 Claude Code 中输入/hexdocs-fetcher确认已加载。

详细介绍

HexDocs 获取器

使用 Claude Code 的原生 WebFetch 工具,高效获取 hexdocs.pm 上的 Elixir 库文档。

用法

研究库时,使用 WebFetch:

# Fetch library overview
WebFetch(
  url: "https://hexdocs.pm/oban",
  prompt: "Extract the main documentation, including module overview, installation instructions, and key functions. Format as clean markdown."
)

# Fetch specific module docs
WebFetch(
  url: "https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html",
  prompt: "Extract the module documentation including all public functions, their specs, and examples."
)

# Fetch getting started guide
WebFetch(
  url: "https://hexdocs.pm/ecto/getting-started.html",
  prompt: "Extract the complete getting started guide content."
)

Token 效率

WebFetch 会自动将 HTML 转换为 Markdown,并提取相关内容:

来源原始 HTML使用 WebFetch优势
HexDocs 页面~80k tokens~15k tokens减少 80%
Phoenix 文档~120k tokens~25k tokens减少 79%
README~20k tokens~8k tokens减少 60%

与 hex-library-researcher 集成

评估库时,高效获取文档:

# Get library overview with focused extraction
WebFetch(
  url: "https://hexdocs.pm/oban",
  prompt: "Extract: 1) Installation instructions 2) Main features 3) Basic usage example"
)

常见 HexDocs URL

# Library overview
https://hexdocs.pm/{library}

# Module documentation
https://hexdocs.pm/{library}/{Module}.html
https://hexdocs.pm/{library}/{Module.Submodule}.html

# Guides
https://hexdocs.pm/{library}/guides.html
https://hexdocs.pm/{library}/{guide-name}.html

# API reference
https://hexdocs.pm/{library}/api-reference.html

提示词策略

使用有针对性的提示词,以便更好地提取内容:

# For API docs
prompt: "Extract all public function docs with @spec and examples"

# For guides
prompt: "Extract the complete guide content preserving code examples"

# For troubleshooting
prompt: "Extract any troubleshooting sections, common errors, and FAQs"

# For configuration
prompt: "Extract configuration options and their defaults"

缓存

WebFetch 内置自动缓存,缓存时长为 15 分钟。在同一会话中多次获取同一 URL 时,结果会自动缓存。

如需更长时间保留,请保存到规划目录:

# After fetching, write the result to a file
Write(
  file_path: ".claude/plans/{slug}/research/docs/oban.md",
  content: "{extracted content}"
)

Tidewave 替代方案

如果有 Tidewave MCP,请优先使用 mcp__tidewave__get_docs 获取与版本精确匹配的文档:

mcp__tidewave__get_docs(module: "Oban.Worker")

此工具会获取与你的 mix.lock 中精确版本对应的文档。

铁律

  1. 绝不获取整个 HexDocs 站点——始终指定具体模块或指南
  2. 使用有针对性的提示词——通用获取会浪费 token;请明确指定要提取的内容
  3. 有 Tidewave 时优先使用——精确匹配版本优于通用 hexdocs.pm

评论

支持 Markdown