--- name: defuddle description: "Extract clean markdown content from web pages using Defuddle CLI. ALWAYS use this instead of WebFetch when the user provides a URL to read or analyze. TRIGGER when: user provides any URL to a webpage, documentation, article, blog post, PDF link, DOI, arXiv, SSRN, Academia.edu page, publisher article page (ScienceDirect, Wiley, Springer, etc.), PubMed/NBER/bioRxiv page, university repository page, or local PDF file path. DO NOT use WebFetch for these — use defuddle." --- # Defuddle Use Defuddle CLI to extract clean readable content from any web page — including YouTube videos (transcript + chapters), Apple Podcasts episodes (transcript + chapters), academic papers and books (PDF → markdown via DOI, arXiv, SSRN, Academia.edu, publisher article links like ScienceDirect, Wiley and Springer, paper indexes like PubMed and NBER, or university repository pages), plain PDF URLs, and local PDF file paths. ## Fetch and present ```bash python3 ~/.claude/skills/defuddle/defuddle.py "" ["" ...] ``` > [!important] Several links → one command > Pass all links — and local PDF paths — to **one** `defuddle.py` call. The script runs them in parallel (`PARALLEL_JOBS` at a time, default 4, shared by all defuddle runs, and only while enough memory is free) and prints each link's output under `=== [n] url ===`. Never loop over links in the shell or start them one after another, not even to give each its own name or DOI: `--filename`, `--doi`, `--as`, `--pages` and `--method` can be given once per link (see below). For papers and batches, run that one command in the background. > Never filter its output (`| grep saved`, `| tail -2`): the `WARNING:` lines (incomplete conversion, missing pages, skipped PDFs) only reach the user through you. Read the full output, or save it to a log and check that for `WARNING` too. Use the output to answer the user's question or complete the task. The script automatically detects the source type (article, YouTube, podcast, paper) and handles fetching accordingly. For articles, it falls back to a Googlebot fetch and archived copies (Wayback Machine, archive.is, Arquivo.pt, Common Crawl) if the page is JS-rendered, paywalled or shows an error page ("Page Not Found", "Page Not Available", ...). > [!warning] User Action Required — STOP > If stderr contains "captcha" or "archive it" (from `--method archive-is` or `--method wayback`), **STOP immediately. Do not try other URLs or workarounds.** Show the user the URL printed in the message and ask them to visit it and let you know when done — then retry with the same command. Alternatively, ask the user if WebFetch should be used instead. > [!warning] Apple Podcasts — Transcript Not Cached > If stderr contains "Podcast transcript not found locally", **STOP immediately.** Show the user the `podcasts://` deep link printed in the message and ask them to open it, view the transcript in the Podcasts app, then let you know when done. Once confirmed, retry with the exact same command — the transcript will now be cached locally. ## Save to Vault 1. Ask: "Want to save this to the vault?" 2. If yes: determine a folder name from context (e.g. a project or topic name), or ask if unclear. 3. Run the script — it writes the file and prints the saved path: ```bash python3 ~/.claude/skills/defuddle/defuddle.py \ "" ["" ...] --project "{folder}" --created "{YYYY-MM-DD}" \ [--filename "kebab-case-name"] [--method native|native-md|native-page|google|wayback|archive-is|arquivo|common-crawl] \ [--download] [--video-quality 720p] [--audio-quality 64k] [--keep-pdf | --no-keep-pdf] [--doi ""] ``` - `--project`: subfolder name inside your vault (e.g. `my-project`, `research`) - `--filename`: optional override; script auto-generates from the title via AI if omitted; with several links, give one `--filename` per link in the same order (see “Several links” below) - `--method`: force a specific fetch method instead of the auto-cascade (articles only) - `--keep-pdf` / `--no-keep-pdf` (papers and PDFs): save the original PDF next to the note, with the same name (`{filename}.pdf`), compressed when `ENABLE_PDF_COMPRESSION` is on. The default comes from `KEEP_PDF` in `defuddle.py`; pass `--keep-pdf` or `--no-keep-pdf` when the user asks otherwise. - `--download` (YouTube only): also save the video to `vid/{filename}-001.mp4` next to the note (subtitles, chapters, metadata, thumbnail embedded) and embed the local file instead of YouTube. Use only when the user asks to download/keep a local copy. Takes several minutes for long videos — run it in the background. - `--video-quality` / `--audio-quality`: optional caps (max height e.g. `720p`; max audio kbps e.g. `64k` — ~48–64k is plenty for speech). `0` skips that track: `--video-quality 0` saves audio only to `aud/{filename}-001.m4a`; `--audio-quality 0` saves video without sound. Either option implies `--download`. Omitted → highest quality. - Several links: one command with all of them (see “Several links → one command” above). Progress lines are prefixed with the link's number. `--filename`, `--doi`, `--as`, `--pages` and `--method` are given either **once** (applies to every link; not `--filename`) or **once per link, in the same order as the links**; `''` means none for that link (e.g. `--doi '' --doi 10.1/x`). Every other option applies to the whole batch. Example: `defuddle.py a.pdf "b c.pdf" --project kurisu --as doc --filename iso-a --filename iso-b`. - `--doi` (local PDFs and PDF links): when you know the paper's DOI — e.g. the user already saved the PDF for a DOI you gave them, or named the paper — pass it, and the PDF is saved as a paper with full metadata without any search. - `--as doc|paper|book` (PDFs): save the PDF as that type instead of letting defuddle decide; only when the user asks or the detection gets it wrong. It applies to every link in the command: with several links, each is detected on its own, so a mix of docs, papers and books needs no `--as`; to override some of them, put those in a separate command with their `--as`. Without it: a PDF with a DOI (printed on its first pages, or found in Crossref) is a **paper**; a PDF with an ISBN and 50+ pages, or 100+ pages with chapters, is a **book**; anything else is a **doc**. `doc` skips the DOI/Crossref lookup and book detection; `paper` saves to papers/ even without a DOI; `book` gives the book treatment: structure from the PDF's bookmarks and printed table of contents (Part / chapter / section headings, lost section headings put back), a linked Contents table with page numbers, the back-of-book index rebuilt as a nested list, code listings repaired from the PDF, exercises as text, blank pages left out, and author, publisher, year and ISBN-13 from the printed ISBN (Open Library, Library of Congress, Google Books) or, failing that, read from the title and copyright pages by the AI model; the note is named `{author}-{a few words}` like a paper. - `--pages FIRST-LAST` (PDFs): convert only those pages (1-based, as in a PDF viewer), e.g. to fill in pages a conversion lost or to test a few pages of a long book before converting all of it. Book mode still reads the structure from the whole PDF. - PDFs without a printed DOI are looked up in Crossref (file name IDs, Elsevier PIIs, then title; for scans without a text layer, again with the converted text) and saved as papers when the found title appears on the PDF's first pages; a local PDF is reused, not downloaded again. A `WARNING: conversion looks incomplete` line means the note has under 70% of the words in the PDF's text layer — tell the user. Likewise relay `WARNING:` lines about missing equations, missing appendices or equations with unbalanced brackets, and offer to re-convert the affected pages. A `WARNING: PDF pages X–Y seem to be missing` line means that stretch of the PDF is not in the note (the conversion stopped or skipped it): offer to convert just those pages with `--pages X-Y` (save it under another `--filename`, e.g. in a test folder) and merge the result into the note at the right place. - Before running defuddle on a paper (DOI, publisher, index or repository link, or a PDF without a known DOI), tell the user first, in one line: *"If a browser tab opens, save the PDF to your Downloads folder — I'll continue automatically."* defuddle may open a page (e.g. a free version) that the user has to save the PDF from, and the tab should never come as a surprise. Skip this for arXiv links and local PDFs given with `--doi`. - Papers that the user has to download: the script opens the page (e.g., for a site that blocks scripts) in the user's browser and waits (up to `SHADOW_WAIT`; 0 = until the PDF appears) for a new PDF in their downloads folder, then continues. In a batch every link fetches its paper first, so all pages open at the start. Run paper commands in the background and check their output after about 30 seconds: each opened page shows as `Browser opened for DOI …`, and a batch sums them up in one line, `Browser: N pages opened, for DOIs …`. Tell the user how many pages opened and for which DOIs, in one line. The PDF is left in their downloads folder. - Relay any `WARNING:` lines to the user: a failed download (note keeps the YouTube embed), or a non-H.264 video — the warning includes a ready-made ffmpeg command converting to H.264 (<1080p) or H.265 (1080p+); offer to run it. Notes are saved to `{vault}/{folder}/defuddle/` (or sorted into `docs/`, `papers/`, `books/` and `transcripts/` when `SAVE_SUBFOLDER = ''` in `defuddle.py`). The vault path is set via `VAULT_PATH` in `defuddle.py`. See README for setup. 4. Confirm the path printed by the script: "Saved to `{path}`"