nblm

nblm

使用此技能直接從 Claude Code 查詢您的 Google NotebookLM 筆記本,取得基於來源、附有引用的 Gemini 回答。支援瀏覽器自動化、資料庫管理、持久化驗證。透過僅回傳文件內容,大幅減少幻覺。

33星標
3分支
更新於 2026/2/28
SKILL.md
readonlyread-only
name
nblm
description

使用此技能直接從 Claude Code 查詢您的 Google NotebookLM 筆記本,取得基於來源、附有引用的 Gemini 回答。支援瀏覽器自動化、資料庫管理、持久化驗證。透過僅回傳文件內容,大幅減少幻覺。

NotebookLM 快速指令

查詢 Google NotebookLM 以取得基於來源、附有引用的回答。

環境

所有相依套件與驗證皆由 run.py 自動處理:

  • 首次執行會建立 .venv 並安裝 Python/Node.js 相依套件
  • 若 Google 驗證遺失或過期,瀏覽器視窗會自動開啟
  • 無需手動前置步驟

使用方式

/nblm <command> [args]

指令

筆記本管理

指令 說明
login 使用 Google 進行驗證
status 顯示驗證與資料庫狀態
accounts 列出所有 Google 帳號
accounts add 新增 Google 帳號
accounts switch <id> 切換啟用中的帳號(依索引或電子郵件)
accounts remove <id> 移除 Google 帳號
accounts use <id> 設定代理專屬啟用帳號(OpenClaw 隔離)
accounts clear 清除代理專屬帳號覆寫
local 列出本機資料庫中的筆記本
remote 從 NotebookLM API 列出所有筆記本
create <name> 建立新筆記本
delete [--id ID] 刪除筆記本
rename <name> [--id ID] 重新命名筆記本
summary [--id ID] 取得 AI 產生的摘要
describe [--id ID] 取得說明與建議主題
add <url-or-id> 將筆記本加入本機資料庫(自動偵測 URL 或筆記本 ID)
activate <id> 設定啟用中的筆記本

來源管理

指令 說明
sources [--id ID] 列出筆記本中的來源
upload <file> 上傳單一檔案
upload <folder> 同步資料夾中的檔案至 NotebookLM
upload-zlib <url> 從 Z-Library 下載並上傳
upload-url <url> 將 URL 新增為來源
upload-youtube <url> 將 YouTube 影片新增為來源
upload-text <title> [--content TEXT] 將文字新增為來源
source-text <source-id> 取得完整索引文字
source-guide <source-id> 取得 AI 摘要與關鍵字
source-rename <source-id> <name> 重新命名來源
source-refresh <source-id> 重新擷取 URL 內容
source-delete <source-id> 刪除來源

上傳選項:

  • --use-active - 上傳至目前啟用中的筆記本
  • --create-new - 以檔案/資料夾名稱建立新筆記本
  • --notebook-id <id> - 上傳至特定筆記本
  • --dry-run - 顯示同步計畫但不執行(資料夾同步)
  • --rebuild - 強制重建追蹤檔案(資料夾同步)

重要: 當使用者執行上傳但未指定目標時,請先詢問:

「您要上傳到啟用中的筆記本,還是建立新筆記本?」
然後傳入對應的旗標(--use-active--create-new)。

聊天與音訊/媒體

指令 說明
ask <question> 查詢 NotebookLM
podcast [--instructions TEXT] 產生音訊 Podcast
podcast-status <task-id> 檢查 Podcast 產生狀態
podcast-download [output-path] 下載最新的 Podcast
briefing [--instructions TEXT] 產生簡短音訊摘要
debate [--instructions TEXT] 產生辯論風格音訊
slides [--instructions TEXT] 產生簡報投影片
slides-download [output-path] 下載簡報投影片為 PDF
infographic [--instructions TEXT] 產生資訊圖表
infographic-download [output-path] 下載資訊圖表
media-list [--type TYPE] 列出已產生的媒體(音訊/影片/投影片/資訊圖表)
media-delete <id> 刪除已產生的媒體項目

指令路由

根據 $ARGUMENTS,執行對應的指令:

$IF($ARGUMENTS,
從 "$ARGUMENTS" 解析指令

loginpython scripts/run.py auth_manager.py setup --service google

accountspython scripts/run.py auth_manager.py accounts list

accounts addpython scripts/run.py auth_manager.py accounts add

accounts switch <id>python scripts/run.py auth_manager.py accounts switch "<id>"

accounts remove <id>python scripts/run.py auth_manager.py accounts remove "<id>"

accounts use <id>python scripts/run.py auth_manager.py accounts use "<id>"

accounts clearpython scripts/run.py auth_manager.py accounts clear

status → 同時執行:

  • python scripts/run.py auth_manager.py status
  • python scripts/run.py notebook_manager.py list

localpython scripts/run.py notebook_manager.py list

remotepython scripts/run.py nblm_cli.py notebooks

create <name>python scripts/run.py nblm_cli.py create "<name>"

delete [--id ID]python scripts/run.py nblm_cli.py delete <args>

rename <name> [--id ID]python scripts/run.py nblm_cli.py rename "<name>" <args>

summary [--id ID]python scripts/run.py nblm_cli.py summary <args>

describe [--id ID]python scripts/run.py nblm_cli.py describe <args>

add <url-or-id> → 智慧新增流程(自動偵測 URL 或筆記本 ID)

activate <id>python scripts/run.py notebook_manager.py activate --id "<id>"

sources [--id ID]python scripts/run.py nblm_cli.py sources <args>

upload <file> → 先詢問使用者:「上傳到啟用中的筆記本還是建立新筆記本?」然後:
- 啟用中:python scripts/run.py source_manager.py add --file "<file>" --use-active
- 新建:python scripts/run.py source_manager.py add --file "<file>" --create-new

upload <folder> → 同步資料夾:
- 先詢問使用者:「同步到啟用中的筆記本、建立新筆記本,或指定筆記本?」
- 啟用中:python scripts/run.py source_manager.py sync "<folder>" --use-active
- 新建:python scripts/run.py source_manager.py sync "<folder>" --create-new
- 指定:python scripts/run.py source_manager.py sync "<folder>" --notebook-id ID
- 預覽:python scripts/run.py source_manager.py sync "<folder>" --dry-run
- 重建:python scripts/run.py source_manager.py sync "<folder>" --rebuild

upload-zlib <url> → 先詢問使用者:「上傳到啟用中的筆記本還是建立新筆記本?」然後:
- 啟用中:python scripts/run.py source_manager.py add --url "<url>" --use-active
- 新建:python scripts/run.py source_manager.py add --url "<url>" --create-new

upload-url <url>python scripts/run.py nblm_cli.py upload-url "<url>"

upload-youtube <url>python scripts/run.py nblm_cli.py upload-youtube "<url>"

upload-text <title>python scripts/run.py nblm_cli.py upload-text "<title>" <args>

source-text <id>python scripts/run.py nblm_cli.py source-text "<id>"

source-guide <id>python scripts/run.py nblm_cli.py source-guide "<id>"

source-rename <id> <name>python scripts/run.py nblm_cli.py source-rename "<id>" "<name>"

source-refresh <id>python scripts/run.py nblm_cli.py source-refresh "<id>"

source-delete <id>python scripts/run.py nblm_cli.py source-delete "<id>"

ask <question>python scripts/run.py nblm_cli.py ask "<question>"

podcastpython scripts/run.py artifact_manager.py generate --format DEEP_DIVE <args>

podcast-status <task-id>python scripts/run.py artifact_manager.py status --task-id "<task-id>"

podcast-download [output-path]python scripts/run.py artifact_manager.py download "<output-path>"

briefingpython scripts/run.py artifact_manager.py generate --format BRIEF <args>

debatepython scripts/run.py artifact_manager.py generate --format DEBATE <args>

slidespython scripts/run.py artifact_manager.py generate-slides <args>

slides-download [output-path]python scripts/run.py artifact_manager.py download "<output-path>" --type slide-deck

infographicpython scripts/run.py artifact_manager.py generate-infographic <args>

infographic-download [output-path]python scripts/run.py artifact_manager.py download "<output-path>" --type infographic

media-list [--type TYPE]python scripts/run.py artifact_manager.py list <args>

media-delete <id>python scripts/run.py artifact_manager.py delete "<id>"

若指令無法辨識,顯示使用說明。,

顯示可用指令:/nblm(不帶參數)
)

Podcast 選項

/nblm podcast --length DEFAULT --wait --output ./podcast.mp3
/nblm podcast --instructions "Focus on the key findings"
/nblm briefing --wait --output ./summary.mp3
/nblm debate --instructions "Compare the two approaches"
選項
--length SHORT, DEFAULT, LONG
--instructions 自訂內容指示
--wait 等待產生完成
--output 下載路徑(需搭配 --wait

簡報投影片選項

/nblm slides --format DETAILED_DECK --wait --output ./presentation.pdf
/nblm slides --instructions "Focus on key diagrams" --format PRESENTER_SLIDES
選項
--format DETAILED_DECK, PRESENTER_SLIDES
--length SHORT, DEFAULT
--instructions 自訂內容指示
--wait 等待產生完成
--output 下載路徑(需搭配 --wait

資訊圖表選項

/nblm infographic --orientation LANDSCAPE --wait --output ./visual.png
/nblm infographic --instructions "Highlight comparison" --detail-level DETAILED
選項
--orientation LANDSCAPE, PORTRAIT, SQUARE
--detail-level CONCISE, STANDARD, DETAILED
--instructions 自訂內容指示
--wait 等待產生完成
--output 下載路徑(需搭配 --wait

媒體產生

指令 說明 輸出
/nblm podcast 深度音訊討論 MP3
/nblm briefing 簡短音訊摘要 MP3
/nblm debate 辯論風格音訊 MP3
/nblm slides 簡報投影片 PDF
/nblm infographic 視覺資訊圖表 PNG

範例

/nblm podcast --wait --output ./deep-dive.mp3
/nblm briefing --instructions "Focus on chapter 3" --wait
/nblm debate --length LONG --wait --output ./debate.mp3
/nblm slides --instructions "Include key diagrams" --format DETAILED_DECK --wait --output ./presentation.pdf
/nblm infographic --orientation LANDSCAPE --detail-level DETAILED --wait --output ./summary.png

下載與管理

/nblm podcast-download ./my-podcast.mp3
/nblm slides-download ./presentation.pdf
/nblm infographic-download ./visual.png
/nblm media-list                     # 列出所有已產生的媒體
/nblm media-list --type audio        # 僅列出音訊
/nblm media-delete <id>              # 刪除媒體項目

延伸文件

何時使用此技能

當使用者:

  • 明確提及 NotebookLM
  • 分享 NotebookLM URL(https://notebooklm.google.com/notebook/...
  • 要求查詢他們的筆記本/文件
  • 想要將文件加入 NotebookLM 資料庫
  • 使用「問我的 NotebookLM」、「查我的文件」、「查詢我的筆記本」等用語

⚠️ 重要:新增指令 - 智慧探索

新增指令現在會自動探索筆記本的中繼資料

# 智慧新增(自動探索名稱、說明、主題)
python scripts/run.py notebook_manager.py add <notebook-id-or-url>

# 可選覆寫
python scripts/run.py notebook_manager.py add <id> --name "自訂名稱" --topics "自訂,主題"

智慧新增的功能:

  1. 從 NotebookLM API 擷取筆記本標題
  2. 查詢筆記本內容以產生說明與主題
  3. 將探索到的中繼資料加入本機資料庫

支援的輸入格式:

  • 筆記本 ID:5fd9f36b-8000-401d-a7a0-7aa3f7832644
  • 完整 URL:https://notebooklm.google.com/notebook/5fd9f36b-8000-401d-a7a0-7aa3f7832644

除非使用者明確提供,否則絕對不要手動指定 --name--description--topics

重要:務必使用 run.py 包裝器

絕對不要直接呼叫腳本。務必使用 python scripts/run.py [script]

# ✅ 正確 - 一律使用 run.py:
python scripts/run.py auth_manager.py status
python scripts/run.py notebook_manager.py list
python scripts/run.py ask_question.py --question "..."

# ❌ 錯誤 - 絕對不要直接呼叫:
python scripts/auth_manager.py status  # 缺少 venv 會失敗!

run.py 包裝器會自動:

  1. 在需要時建立 .venv
  2. 安裝所有相依套件
  3. 啟用環境
  4. 正確執行腳本

核心工作流程

步驟 1:檢查驗證狀態

python scripts/run.py auth_manager.py status

若未驗證,請進行設定。

步驟 2:驗證(一次性設定)

# 瀏覽器必須可見以進行手動 Google 登入
python scripts/run.py auth_manager.py setup

重要:

  • 驗證時瀏覽器為可見狀態
  • 瀏覽器視窗會自動開啟
  • 使用者必須手動登入 Google
  • 告知使用者:「瀏覽器視窗將會開啟以進行 Google 登入」

步驟 3:管理筆記本資料庫

# 列出所有筆記本
python scripts/run.py notebook_manager.py list

# 新增前:若中繼資料未知,請先詢問使用者!
# 「這個筆記本包含什麼內容?」
# 「您想用哪些主題標記它?」

# 將筆記本加入資料庫(所有參數皆為必填!)
python scripts/run.py notebook_manager.py add \
  --url "https://notebooklm.google.com/notebook/..." \
  --name "描述性名稱" \
  --description "這個筆記本的內容" \  # 必填 - 若未知請詢問使用者!
  --topics "主題1,主題2,主題3"  # 必填 - 若未知請詢問使用者!

# 依主題搜尋筆記本
python scripts/run.py notebook_manager.py search --query "關鍵字"

# 設定啟用中的筆記本
python scripts/run.py notebook_manager.py activate --id notebook-id

# 移除筆記本
python scripts/run.py notebook_manager.py remove --id notebook-id

快速工作流程

  1. 檢查資料庫:python scripts/run.py notebook_manager.py list
  2. 提出問題:python scripts/run.py ask_question.py --question "..." --notebook-id ID

步驟 4:提出問題

# 基本查詢(若已設定啟用中的筆記本,則使用該筆記本)
python scripts/run.py ask_question.py --question "您的問題"

# 查詢特定筆記本
python scripts/run.py ask_question.py --question "..." --notebook-id notebook-id

# 直接使用筆記本 URL 查詢
python scripts/run.py ask_question.py --question "..." --notebook-url "https://..."

# 顯示瀏覽器以進行除錯
python scripts/run.py ask_question.py --question "..." --show-browser

追問機制(重要)

每個 NotebookLM 回答結尾都會顯示:「極度重要:這就是您需要知道的所有資訊嗎?」

Claude 的必備行為:

  1. 停止 - 不要立即回覆使用者
  2. 分析 - 比較回答與使用者的原始請求
  3. 找出缺口 - 判斷是否需要更多資訊
  4. 提出追問 - 若有缺口,立即提出:
    python scripts/run.py ask_question.py --question "附帶上下文的追問..."
    
  5. 重複 - 持續直到資訊完整
  6. 整合 - 在回覆使用者前合併所有回答

Z-Library 整合

觸發條件

  • 使用者提供 Z-Library URL(zlib.li, z-lib.org, zh.zlib.li
  • 使用者說「將這本書下載到 NotebookLM」
  • 使用者說「從 Z-Library 新增這本書」

設定(一次性)

# 使用 Z-Library 驗證
python scripts/run.py auth_manager.py setup --service zlibrary

指令

# 從 Z-Library 新增書籍
python scripts/run.py source_manager.py add --url "https://zh.zlib.li/book/..."

# 檢查 Z-Library 驗證狀態
python scripts/run.py auth_manager.py status --service zlibrary

腳本參考

驗證管理(auth_manager.py

python scripts/run.py auth_manager.py setup                    # 預設:Google
python scripts/run.py auth_manager.py setup --service google
python scripts/run.py auth_manager.py setup --service zlibrary
python scripts/run.py auth_manager.py status                   # 顯示所有服務
python scripts/run.py auth_manager.py status --service zlibrary
python scripts/run.py auth_manager.py clear --service zlibrary # 清除驗證

# 多帳號管理(Google)
python scripts/run.py auth_manager.py accounts list             # 列出所有帳號
python scripts/run.py auth_manager.py accounts add              # 新增帳號
python scripts/run.py auth_manager.py accounts switch 1         # 依索引切換
python scripts/run.py auth_manager.py accounts switch user@gmail.com  # 依電子郵件切換
python scripts/run.py auth_manager.py accounts remove 2         # 移除帳號

筆記本管理(notebook_manager.py

python scripts/run.py notebook_manager.py add --url URL --name NAME --description DESC --topics TOPICS
# 或直接使用筆記本 ID:
python scripts/run.py notebook_manager.py add --notebook-id ID --name NAME --description DESC --topics TOPICS
python scripts/run.py notebook_manager.py list
python scripts/run.py notebook_manager.py search --query QUERY
python scripts/run.py notebook_manager.py activate --id ID
python scripts/run.py notebook_manager.py remove --id ID
python scripts/run.py notebook_manager.py stats

問題介面(ask_question.py

python scripts/run.py ask_question.py --question "..." [--notebook-id ID] [--notebook-url URL] [--show-browser]

來源管理(source_manager.py

# 上傳至啟用中的筆記本
python scripts/run.py source_manager.py add --file "/path/to/book.pdf" --use-active

# 為上傳建立新筆記本
python scripts/run.py source_manager.py add --file "/path/to/book.pdf" --create-new

# 上傳至特定筆記本
python scripts/run.py source_manager.py add --file "/path/to/book.pdf" --notebook-id NOTEBOOK_ID

# Z-Library 下載與上傳
python scripts/run.py source_manager.py add --url "https://zh.zlib.li/book/..." --use-active
python scripts/run.py source_manager.py add --url "https://zh.zlib.li/book/..." --create-new

# 同步資料夾(新功能!)
python scripts/run.py source_manager.py sync "/path/to/docs" --use-active
python scripts/run.py source_manager.py sync "/path/to/docs" --create-new
python scripts/run.py source_manager.py sync "/path/to/docs" --notebook-id NOTEBOOK_ID

# 同步選項(新功能!)
python scripts/run.py source_manager.py sync "/path/to/docs" --dry-run    # 僅預覽
python scripts/run.py source_manager.py sync "/path/to/docs" --rebuild   # 強制重新雜湊所有檔案

資料夾同步:

  • 掃描資料夾中支援的類型:PDF、TXT、MD、DOCX、HTML、EPUB
  • 內部追蹤同步狀態(無需管理每個資料夾的追蹤檔案)
  • 同步策略:新增新檔案、更新已修改檔案(刪除後重新上傳)、跳過未變更檔案
  • 支援多帳號(追蹤使用哪個 Google 帳號)
    注意: --use-active--create-new--notebook-id 三者必選其一。
    上傳會等待 NotebookLM 處理,並以 Ready: N/T 格式顯示進度。按 Ctrl+C 可停止等待。
    本機檔案上傳使用瀏覽器自動化,需要 Google 驗證。
    若瀏覽器自動化不可用,可設定 NOTEBOOKLM_UPLOAD_MODE=text 以上傳擷取的文字(PDF 需要 pypdf)。

資料清理(cleanup_manager.py

python scripts/run.py cleanup_manager.py                    # 預覽清理
python scripts/run.py cleanup_manager.py --confirm          # 執行清理
python scripts/run.py cleanup_manager.py --preserve-library # 保留筆記本

看門狗狀態(auth_manager.py

python scripts/run.py auth_manager.py watchdog-status

環境管理

虛擬環境會自動管理:

  • 首次執行會自動建立 .venv
  • 相依套件會自動安裝
  • Node.js 相依套件會自動安裝
  • agent-browser 守護行程會按需啟動,並將瀏覽器狀態保留在記憶體中
  • 守護行程在閒置 10 分鐘後停止(任何 agent-browser 指令會重設計時器)
  • 設定 AGENT_BROWSER_OWNER_PID 可在代理程序退出時自動停止
  • scripts/run.py 預設將 AGENT_BROWSER_OWNER_PID 設為其父程序 PID
  • 所有內容隔離在技能目錄中

手動設定(僅在自動化失敗時使用):

python -m venv .venv
source .venv/bin/activate  # Linux/Mac
pip install -r requirements.txt
npm install
npm run install-browsers

資料儲存

所有資料儲存在 ~/.claude/skills/notebooklm/data/

  • library.json - 筆記本中繼資料(含帳號關聯)
  • auth/google/ - 多帳號 Google 驗證
    • index.json - 帳號索引(啟用中的帳號、清單)
    • <n>-<email>.json - 各帳號憑證
  • auth/zlibrary.json - Z-Library 驗證狀態
  • agent_browser/session_id - 目前守護行程的工作階段 ID
  • agent_browser/last_activity.json - 閒置關機用的最後活動時間戳
  • agent_browser/watchdog.pid - 閒置看門狗程序 ID

安全性:.gitignore 保護,切勿提交至 git。

設定

技能目錄中的選用 .env 檔案:

HEADLESS=false           # 瀏覽器可見性
SHOW_BROWSER=false       # 預設瀏覽器顯示
STEALTH_ENABLED=true     # 類人行為
TYPING_WPM_MIN=160       # 打字速度
TYPING_WPM_MAX=240
DEFAULT_NOTEBOOK_ID=     # 預設筆記本

決策流程

使用者提及 NotebookLM
    ↓
檢查驗證 → python scripts/run.py auth_manager.py status
    ↓
若未驗證 → python scripts/run.py auth_manager.py setup
    ↓
檢查/新增筆記本 → python scripts/run.py notebook_manager.py list/add(含 --description)
    ↓
啟用筆記本 → python scripts/run.py notebook_manager.py activate --id ID
    ↓
提出問題 → python scripts/run.py ask_question.py --question "..."
    ↓
看到「這就是您需要知道的所有資訊嗎?」→ 持續追問直到完整
    ↓
整合並回覆使用者

疑難排解

問題 解決方案
ModuleNotFoundError 使用 run.py 包裝器
驗證失敗 設定時瀏覽器必須可見!--show-browser
DAEMON_UNAVAILABLE 確認已安裝 Node.js/npm,執行 npm install,重試
AUTH_REQUIRED 執行 python scripts/run.py auth_manager.py setup
ELEMENT_NOT_FOUND 確認筆記本 URL,並重新載入頁面後重試
速率限制(每天 50 次) 等待或使用 accounts add 新增其他 Google 帳號
瀏覽器當機 python scripts/run.py cleanup_manager.py --preserve-library
找不到筆記本 使用 notebook_manager.py list 檢查

最佳實務

  1. 務必使用 run.py - 自動處理環境
  2. 先檢查驗證 - 在任何操作之前
  3. 追問問題 - 不要停留在第一個回答
  4. 驗證時瀏覽器可見 - 需要手動登入
  5. 包含上下文 - 每個問題都是獨立的
  6. 整合回答 - 合併多個回應

限制

  • 無工作階段持久性(每個問題 = 新瀏覽器)
  • 免費 Google 帳號有速率限制(每個帳號每天 50 次查詢;可使用多個帳號提高限制)
  • 需要手動上傳(使用者必須將文件加入 NotebookLM)
  • 瀏覽器開銷(每個問題需數秒)

資源(技能結構)

重要目錄與檔案:

  • scripts/ - 所有自動化腳本(ask_question.py、notebook_manager.py 等)
  • data/ - 驗證與筆記本資料庫的本機儲存
  • references/ - 延伸文件:
    • api_reference.md - 所有腳本的詳細 API 文件
    • troubleshooting.md - 常見問題與解決方案
    • usage_patterns.md - 最佳實務與工作流程範例
  • .venv/ - 隔離的 Python 環境(首次執行時自動建立)
  • .gitignore - 保護敏感資料不被提交