| name | ref-api |
|---|---|
| description | Search documentation and read URLs via Ref's REST API with automatic session tracking for optimized multi-step searches. Use when you need to search technical docs or fetch URL content. Sessions are auto-managed - subsequent calls automatically reuse the same session to avoid duplicate results. |
Direct API access to Ref's documentation search and URL reading tools. More context-efficient than MCP protocol for documentation workflows.
The scripts automatically manage sessions to minimize token usage:
- First call - Auto-generates a session ID and saves it to
~/.cache/ref/session - Subsequent calls - Automatically reuse the stored session
- New research topic - Use
--new-sessionto start fresh
The active session is printed to stderr so you can see which session is being used.
# Search for documentation
./scripts/ref-search.js "python fastapi dependency injection"
# Read a result URL
./scripts/ref-read.js "https://fastapi.tiangolo.com/tutorial/dependencies/"
# Refine your search (auto-uses same session, no duplicates)
./scripts/ref-search.js "fastapi depends callable"./scripts/ref-search.js "<query>"Options:
--session-id <id>- Use a specific session ID--new-session- Start a new research session (clears stored session)
Query tips:
- Include programming language and framework names
- Add
ref_src=privateto search user's private docs/repos
Example workflow:
# First search - creates session automatically
./scripts/ref-search.js "react hooks"
# [Using stored session: ref-abc-123]
# → Returns results
# Follow-up search - reuses session, avoids duplicates
./scripts/ref-search.js "react useEffect cleanup"
# [Using stored session: ref-abc-123]
# → Returns only NEW results
# New topic - clear session
./scripts/ref-search.js "python asyncio" --new-session
# [New session: ref-xyz-789]./scripts/ref-read.js "<url>"Important: Pass the EXACT url from a search result. Content is returned as markdown.
# Read a doc from search results
./scripts/ref-read.js "https://react.dev/reference/react/useEffect"
# Use specific session
./scripts/ref-read.js "https://react.dev/reference/react/useEffect" --session-id ref-abc-123Required:
export REF_API_KEY="your-api-key" # Get your key at https://ref.tools/dashboardOptional:
export REF_URL="https://api.ref.tools" # Custom API endpoint
export REF_SESSION_ID="my-session" # Override stored session# 1. Search for FastAPI middleware info
$ ./scripts/ref-search.js "fastapi middleware"
[Using stored session: ref-a1b2c3d4]
overview: Middleware - FastAPI
url: https://fastapi.tiangolo.com/tutorial/middleware/
moduleId: fastapi-official
---
overview: CORSMiddleware - FastAPI
url: https://fastapi.tiangolo.com/tutorial/cors/
moduleId: fastapi-official
---
# 2. Read the CORS middleware docs
$ ./scripts/ref-read.js "https://fastapi.tiangolo.com/tutorial/cors/"
[Using stored session: ref-a1b2c3d4]
# CORSMiddleware
FastAPI provides a CORS middleware...
# 3. Refine search - reuses session, skips already-seen results
$ ./scripts/ref-search.js "fastapi cors origin regex"
[Using stored session: ref-a1b2c3d4]
# → Only returns new results not shown in previous searches
# 4. New topic - clear session
$ ./scripts/ref-search.js "django middleware" --new-session
[New session: ref-e5f6g7h8]| Error | Solution |
|---|---|
| 401 Unauthorized | Verify email at https://ref.tools/dashboard |
| No API key | Set REF_API_KEY environment variable |
| No results | Try broader search terms |
| Aspect | Direct API (this skill) | MCP Protocol |
|---|---|---|
| Context usage | Low - direct text output | Higher - JSON-RPC overhead |
| Session handling | Automatic via file storage | Managed by MCP server |
| Setup complexity | None - just run scripts | Requires MCP server connection |
| Best for | Documentation lookups in scripts | Complex multi-tool workflows |
Use this skill when you need efficient documentation searches with minimal context overhead.