home / skills / brettatoms / agent-skills / lib-docs

lib-docs skill

/lib-docs

This skill fetches up-to-date library documentation and code examples from official sources, and presents usage details and code snippets.

npx playbooks add skill brettatoms/agent-skills --skill lib-docs

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
2.4 KB
---
name: lib-docs
description: Fetch library documentation and code examples. Use when user asks about library APIs, needs code examples, or says "use lib-docs", "lookup docs for X", "how does [library] work". Works with any language/framework.
allowed-tools: WebSearch, WebFetch, Read
---

# Library Documentation Skill

Fetch up-to-date documentation for any library using web search and pre-configured sources.

## Quick Reference (Common Sources)

| Library | Primary Source |
|---------|----------------|
| Clojure libs | `cljdoc.org/d/{group}/{artifact}` |
| HTMX | `htmx.org/docs/` |
| Alpine.js | `alpinejs.dev/` |
| Tailwind | `tailwindcss.com/docs/` |
| DaisyUI | `daisyui.com/components/` |
| React | `react.dev/reference/` |

For full list: See [references/sources.md](references/sources.md)

## Workflow

### 1. Resolve Documentation Source

Check if library has a pre-configured source in `references/sources.md`:
- **Known library**: Use configured URL directly
- **Unknown library**: WebSearch for `"[library name] official documentation"`

### 2. Fetch Documentation

Use WebFetch with a focused prompt:
```
WebFetch URL with prompt: "Extract [topic] documentation, API reference, and code examples for [library]"
```

**Tips for effective fetches:**
- Target specific pages (API reference, getting started) over landing pages
- Include version if user specified one
- Request code examples explicitly

### 3. Summarize for User

Return:
- Relevant API/function signatures
- Code examples demonstrating usage
- Link to source for further reading

## Fallback: Unknown Libraries

When no pre-configured source exists:

1. **WebSearch**: `"[library] official documentation site"`
2. **Identify official source** from results (prefer: official site > GitHub > Stack Overflow)
3. **WebFetch** the docs page
4. **Offer to add** the source to `references/sources.md` for future lookups

## Examples

**User**: "How do I use HoneySQL's where clause?"
1. Check sources.md → HoneySQL on cljdoc.org
2. WebFetch `https://cljdoc.org/d/com.github.seancorfield/honeysql/` with prompt about where clauses
3. Return examples and API info

**User**: "lookup docs for some-obscure-lib"
1. Check sources.md → not found
2. WebSearch for official docs
3. WebFetch from search result
4. Return docs + offer to save source

## Token Efficiency

- Only fetch what's needed for the specific question
- Prefer targeted page URLs over index pages
- Use focused prompts to extract relevant sections

Overview

This skill fetches up-to-date library documentation and runnable code examples for any language or framework. It locates official docs, extracts API signatures and usage snippets, and returns concise, copy-pasteable examples plus source links. Use it when you need precise API details, examples, or quick reference material for a library.

How this skill works

The skill first checks a curated list of known documentation sources and uses those when available. For unknown libraries it performs a targeted web search to find the official documentation or authoritative pages, then fetches specific pages (API reference, guides, or examples). It extracts relevant function signatures, parameters, and code samples with a focused prompt and compiles a short, practical summary and a source link. If requested, it can include version-specific docs or offer to add a discovered source to the curated list for future lookups.

When to use it

  • When you ask “use lib-docs” or “lookup docs for X”
  • When you need API signatures, parameters, or return types for a library
  • When you want copy-pasteable code examples and short usage patterns
  • When you need version-specific documentation or a pointer to the official source
  • When you need quick comparisons of how similar functions work across libraries

Best practices

  • Provide the library name and optionally the version to get exact matches
  • Specify the topic you care about (installation, API, examples, migration) to limit fetches
  • Request targeted pages (e.g., “API reference” or “getting started”) rather than the home page
  • Ask for example language/framework if the library supports multiple ecosystems
  • Use follow-up questions to get deeper examples or edge-case behavior

Example use cases

  • "How does react.useEffect work?" — returns signature, common patterns, and examples
  • "lookup docs for tailwind background utilities" — fetches relevant docs and example classes
  • "Show examples for axios retry logic" — returns code snippets and recommended config
  • "Use lib-docs for obscure-lib v1.2" — searches official docs, returns API and offers to save source
  • "How to migrate from lodash _.map to native map" — fetches lodash docs and shows equivalent code

FAQ

Can you fetch docs for any language or framework?

Yes. The skill targets documentation pages regardless of language or framework and returns language-specific examples when available.

What sources do you prefer?

It prefers official documentation sites, then project-maintained docs (e.g., GitHub Pages or Read the Docs), and falls back to authoritative community resources when needed.

Can I request version-specific documentation?

Yes. Provide the version and the skill will target pages or tags for that release when available.