index-library
How to Install
Claude Code:
git clone --depth 1 https://github.com/hoyvoh/project-based-agent-kit.git && cp project-based-agent-kit/.claude/skills/index-library ~/.claude/skills/index-library -r---
name: index-library
description: "Index a library's documentation into a queryable local knowledge base. Invoke with /index-library to fetch and index API docs, guides, and patterns. Prevents Claude from inventing APIs or missing features. After indexing, the library knowledge is available to /research and /solution-design skills. Check if already indexed before fetching (skip unless --force)."
allowed-tools:
- Bash
- WebFetch
- WebSearch
- Read
metadata:
token-cost-tier: context-heavy
token-cost-estimate: 10000
---
# /index-library — Library Documentation Indexer
## Usage
```
/index-library Index from official docs URL
/index-library Search for official docs then index
/index-library --force Re-index even if already indexed
/index-library --list List all currently indexed libraries
/index-library --search Search across all indexed libraries
```
---
## Step 0 — Check Existing Index
```bash
ls .claude/lib-index/ 2>/dev/null || echo "no index yet"
```
If `--list`: show all indexed libraries with their index dates and entry counts. Exit.
If `--search `:
```bash
grep -rl "" .claude/lib-index/ 2>/dev/null | head -10
grep -r "" .claude/lib-index/ --include="*.md" -l 2>/dev/null | head -10
```
Show matching sections. Exit.
**Dedup check:** Before indexing, derive a slug from the library name/URL:
- `https://fastapi.tiangolo.com` → `fastapi`
- `https://docs.sqlalchemy.org` → `sqlalchemy`
- `redis` → `redis`
Check if `.claude/lib-index//` exists:
```bash
ls ".claude/lib-index//" 2>/dev/null && echo "EXISTS"
```
If exists and no `--force`:
```
Library '' is already indexed.
Last indexed:
Entries:
To re-index: /index-library --force
To search: /index-library --search
```
Exit.
---
## Step 1 — Resolve Entry Point
If URL provided → use directly.
If name provided (e.g., `fastapi`, `sqlalchemy`, `redis`):
```
Search: " official documentation site:docs..io OR .tiangolo.com OR .io/docs"
```
Pick the first official docs URL.
Announce:
```
Indexing:
Entry point:
Target: .claude/lib-index//
Estimated: ~ tokens
```
---
## Step 2 — Fetch Entry Point
```
WebFetch:
```
Extract:
1. Page title → library name + version
2. Navigation links → identify key sections to fetch
3. Short description (first 2-3 sentences)
**Prioritize sections for fetching (max 10 pages total):**
1. Getting Started / Quick Start / Installation
2. API Reference (if exists as a single page — fetch it; if it's paginated, skip and note it)
3. Key concepts / Core concepts / Overview
4. Configuration reference
5. Examples / Cookbook / Recipes
Skip: changelog, release notes, contributing guides, translation pages.
---
## Step 3 — Fetch Key Pages
For each priority page (max 10, depth capped):
```
WebFetch:
```
Extract per page:
- Section name
- Key classes/functions/methods with signatures
- Configuration options
- Code examples (keep, they're high-value)
- Important caveats or version notes
- Links to sub-pages (if relevant API reference)
**Token budget per page:** Extract ~500 chars of key content. Don't dump full page.
---
## Step 4 — Build Index
Create `.claude/lib-index//`:
**File: `.claude/lib-index//index.md`** (main knowledge file, ~2000 chars)
```markdown
# Index
Version:
Indexed:
Source:
Pages fetched:
## Quick Reference
### Installation
``````
### Core Concept
<1-2 sentence explanation of what this library does>
### Key Classes / Functions
| Name | Purpose | Signature |
|------|---------|-----------|
| `ClassName` | what it does | `ClassName(param1, param2)` |
| `function_name()` | what it does | `function_name(arg, kwarg=default) -> ReturnType` |
### Configuration Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
### Common Patterns
#### Pattern 1:
```
```
#### Pattern 2:
...
### Gotchas & Common Mistakes
-
-
### What's NOT in this index
-
- API reference: — too large to index, fetch specific methods on demand
```
**File: `.claude/lib-index//index-meta.json`**
```json
{
"library": "",
"version": "",
"slug": "",
"entry_url": "",
"indexed_at": "",
"pages_fetched": ,
"entry_count":
}
```
---
## Step 5 — Report
```
Library indexed: v
Location: .claude/lib-index//
Pages fetched:
Key entries: classes/functions, config options, examples
Quick search: /index-library --search
Use in research: /research "" (will auto-load this index)
Use in code review: agent will check this index before suggesting APIs
```
---
## Integration with Other Skills
The `research` skill automatically checks `.claude/lib-index/` at Step 1.
The `code-review` skill can reference indexed libraries to verify API usage.
The `solution-design` skill can use indexed libraries to enumerate real options.
**Claude should check the index before suggesting any API from an indexed library:**
```bash
grep -r "" .claude/lib-index/ 2>/dev/null | head -5
```
If not found → do not assume it exists. Fetch the specific docs page first.
---
## Limits
- Max 10 pages per library (prevents runaway fetching)
- Max entry point depth: 2 levels (don't follow links of links)
- Index file max size: ~3000 chars (keep it queryable, not a raw dump)
- If API reference is paginated (100+ pages): index only the overview, note `"full API reference not indexed — fetch on demand"`
Details
| Category | Coding → code-review |
| Source | hoyvoh/project-based-agent-kit |
| SKILL.md | View on GitHub → |
| Repo Stars | N/A |
| Est. per Skill | N/A (shared across 17 skills from this repo) |
| Difficulty | Beginner |
| Risk Level | Safe |
Related Skills
create-pr
Alias: create-pr This skill name is kept for compatibility. When to Use The user explicitly asks for
md-review
Converts a markdown PR writeup or code review (one with diff fenced blocks and severity-tagged > !BL
status
--- name: drill-status description: Show drill-me learning progress — topics studied, cards due for
forget
--- name: forget description: > Delete a memory from Origin by ID. Destructive and cannot be undone
Works Well With
Skills from the same repository — often designed to work together
qa
--- name: qa description: "Run tests, fix failures, verify. Invoke when user asks to run tests, chec
ui-ux-pro-max
--- name: ui-ux-pro-max description: "UI/UX design intelligence. 50 styles, 21 palettes, 50 font pai
code-review
--- name: code-review description: "Review code with structured findings and optional reviewer perso