Fetch web-based development documentation and save it as clean markdown files while preserving the site's directory structure. Use whenever the user wants online documentation or an API reference downloaded, archived, cached, or converted to markdown for local use, including when they paste a docs URL and ask to keep it.
Ships in fetch-docs. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Crawls web-based development documentation and saves it as clean markdown files in a directory structure that mirrors the URL paths.
npx agent-browser --version # verify
npx defuddle --version # verify
URL_UTILS="$(find ~/.claude ~/.local/share/chezmoi/.claude -name url_utils.py -path '*/fetch-docs/*' 2>/dev/null | head -1)"
| Tool | Role |
|---|---|
| agent-browser | Opens pages in a real browser and navigates links (handles SPA/JS rendering) |
| defuddle | Extracts main content from each page and converts it to clean markdown |
| url_utils.py | URL normalization, file path conversion, and scope filtering |
When mapping URLs to file paths, collect the full URL list first, then determine all paths at once using the smart-filepaths command.
If a URL has child URLs, it is saved as path/index.md; otherwise as path.md:
/reference/commands/ (children: /add/, /apply/ exist) → reference/commands/index.md
/reference/commands/add/ (no children) → reference/commands/add.md
/user-guide/daily-ops/ (no children) → user-guide/daily-ops.md
BASE_URL="https://docs.example.com" # Starting URL for crawl (domain root recommended)
OUTPUT_DIR="./docs-example-com" # Output directory
Confirm with the user:
./docs-example-com/)This is the most critical step. Every URL must be collected without omission to determine correct file paths.
agent-browser open "$BASE_URL"
agent-browser wait --load networkidle
Many documentation sites have a collapsed sidebar. All sections must be expanded:
# 1. Take a full snapshot to identify collapsed sections
agent-browser snapshot -i -u
# 2. Click all collapsed sections (toggles/accordions) to expand them
# Find toggles in the form [LabelText], [button], [details summary] in the snapshot
agent-browser click @e5 # e.g. "Advanced" section toggle
agent-browser click @e9 # e.g. "Reference" section toggle
# 3. Take another snapshot after expanding
agent-browser snapshot -i -u
Choose based on the documentation site's navigation pattern:
Pattern A — Full Sidebar Traversal (MkDocs, Docusaurus, etc.):
# Scope to sidebar area only and extract all links
agent-browser snapshot -i -u -s "nav"
agent-browser snapshot -i -u -s ".sidebar"
agent-browser snapshot -i -u -s ".md-nav"
Pattern B — Per-Section Tab Traversal (when each section has its own navigation):
# Navigate to each top-level section page and snapshot its sidebar
for SECTION_URL in "https://docs.ex.com/user-guide/" "https://docs.ex.com/reference/"; do
agent-browser open "$SECTION_URL"
agent-browser wait --load networkidle
agent-browser snapshot -i -u -s "nav"
done
Pattern C — Sitemap (fast and complete collection):
# Many sites provide a sitemap.xml
curl -s "https://docs.example.com/sitemap.xml" | grep -oP '<loc>\K[^<]+'
After saving each page, new links may be discovered on that page:
# Check for additional links on each saved page
agent-browser open "$PAGE_URL"
agent-browser wait --load networkidle
agent-browser snapshot -i -u
# Add newly discovered URLs to the queue
Filter the collected URLs and determine file paths:
# Build all collected links as a JSON array
LINKS='["/guide/install", "https://docs.example.com/guide/usage", ...]'
# Filter in-scope URLs (remove external links, binary files, and duplicates)
VISITED='["https://docs.example.com"]'
FILTERED=$(python3 "$URL_UTILS" filter "$BASE_URL" "$VISITED" "$LINKS")
# Once the full URL list is finalized, determine file paths in batch
# smart-filepaths: automatically chooses path.md vs path/index.md based on whether child URLs exist
echo "$FILTERED" | python3 "$URL_UTILS" smart-filepaths "$BASE_URL"
# Output: {"https://docs.ex.com/guide/": "guide.md", "https://docs.ex.com/reference/": "reference/index.md", ...}
Process each URL using the file path mapping:
PAGE_URL="https://docs.example.com/guide/installation"
REL_PATH="guide/installation.md" # from smart-filepaths output
# Extract markdown with defuddle
npx defuddle parse "$PAGE_URL" --markdown --output /tmp/page_content.md
# Extract page title
PAGE_TITLE=$(npx defuddle parse "$PAGE_URL" --property title 2>/dev/null)
# Save
FULL_PATH="$OUTPUT_DIR/$REL_PATH"
mkdir -p "$(dirname "$FULL_PATH")"
{
printf -- "---\ntitle: %s\nsource: %s\n---\n\n" "$PAGE_TITLE" "$PAGE_URL"
cat /tmp/page_content.md
} > "$FULL_PATH"
echo "Saved: $FULL_PATH"
echo "=== Collection Complete ==="
find "$OUTPUT_DIR" -name "*.md" | sort
echo "Total files: $(find "$OUTPUT_DIR" -name "*.md" | wc -l)"
agent-browser close
When smart-filepaths is applied (based on the full URL list):
| URL | Has Child URLs | Save Path |
|---|---|---|
https://docs.ex.com/ | ✓ | index.md |
https://docs.ex.com/install/ | ✗ | install.md |
https://docs.ex.com/reference/ | ✓ | reference/index.md |
https://docs.ex.com/reference/commands/ | ✓ | reference/commands/index.md |
https://docs.ex.com/reference/commands/add/ | ✗ | reference/commands/add.md |
https://docs.ex.com/user-guide/daily-ops/ | ✗ | user-guide/daily-ops.md |
wait --load networkidle is required# Click all toggles in [LabelText] or [button] form
agent-browser snapshot -i # check ref
agent-browser click @e12 # click toggle
agent-browser snapshot -i -u # verify expanded links
npx defuddle parse "$PAGE_URL" --json | python3 -c "
import json, sys
d = json.load(sys.stdin)
print('length:', len(d.get('content', '')))
"
# If content is too short, log it and move on
agent-browser auth save docs-site --url https://docs.example.com/login \
--username [email protected] --password-stdin
agent-browser auth login docs-site
# URL → file path (single, simple conversion without child URL info)
python3 "$URL_UTILS" filepath "https://docs.ex.com/guide/install" "https://docs.ex.com"
# → guide/install.md
# URL → file path (single, based on full URL list)
python3 "$URL_UTILS" smart-filepath "https://docs.ex.com/guide/" "https://docs.ex.com" \
'["https://docs.ex.com/guide/", "https://docs.ex.com/guide/install/"]'
# → guide/index.md (because child /install/ exists)
# URL → file path batch processing (JSON array via stdin)
echo '["https://docs.ex.com/guide/", "https://docs.ex.com/guide/install/"]' \
| python3 "$URL_UTILS" smart-filepaths "https://docs.ex.com"
# → {"https://docs.ex.com/guide/": "guide/index.md", "https://docs.ex.com/guide/install/": "guide/install.md"}
# URL normalization (remove fragments)
python3 "$URL_UTILS" normalize "https://docs.ex.com/guide#section"
# → https://docs.ex.com/guide
# Filter link array
python3 "$URL_UTILS" filter \
"https://docs.ex.com" \
'["https://docs.ex.com/guide"]' \
'["/api/ref", "https://external.com", "#skip", "/guide"]'
# → ["https://docs.ex.com/api/ref"]
# Check if URL is in scope
python3 "$URL_UTILS" in-scope "https://docs.ex.com/guide/foo" "https://docs.ex.com"
# → true
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/fetch-docs:fetch-docsfrom fetch-docs
npx claudepluginhub rishubil/skills --plugin fetch-docs