NotebookLM Claude Code Skill

repository·master·Indexed 27 days ago

https://github.com/pleaseprompto/notebooklm-skill

A local Claude Code CLI skill that enables interaction with Google NotebookLM. It allows Claude to perform source-grounded research by querying uploaded documents in NotebookLM to provide citation-backed answers without high token costs. The skill includes a Python-based architecture for managing notebook libraries, Google authentication via a hybrid browser state strategy, and a set of automation scripts for querying and managing notebooks.

Tokens
6.7K
Snippets
24
Records
39
Agent score
92%

What's inside notebooklm-skill

  1. Understand the NotebookLM hybrid authentication architecture

    master

    The skill uses a hybrid approach to bypass a known limitation in Python's Playwright API where session cookies (cookies without an Expires attribute) are not saved to the user_data_dir profile.

    The Hybrid Strategy:

    1. Persistent Browser Profile (user_data_dir): Maintains consistent browser fingerprinting, cache, and persistent cookies.
    2. Manual Cookie Injection (state.json): Explicitly loads session cookies into the browser context at runtime to prevent authentication failures.

    File Structure for Authentication Data: Located in ~/.claude/skills/notebooklm/data/:

    • auth_info.json: Metadata about authentication.
    • browser_state/state.json: Contains cookies and localStorage for manual injection.
    • browser_state/browser_profile/: The Chrome user profile containing fingerprinting and cache data.
  2. Manage Notebook Access and Selection

    master

    If you cannot find a notebook or encounter access issues, use the notebook_manager.py via the run.py wrapper:

    • List all notebooks:
      python scripts/run.py notebook_manager.py list
    • Search for a notebook by keyword:
      python scripts/run.py notebook_manager.py search --query "keyword"
    • Add a missing notebook:
      python scripts/run.py notebook_manager.py add --url "https://notebooklm.google.com/..." --name "Name" --topics "topics"
    • Activate a specific notebook:
      python scripts/run.py notebook_manager.py activate --id correct-id
    python scripts/run.py notebook_manager.py list
  3. Handle follow-up questions for complete answers

    master

    When NotebookLM responds with the specific prompt: EXTREMELY IMPORTANT: Is that ALL you need to know?, you must not immediately respond to the user. Instead:

    1. Analyze: Determine if the current answer is complete or if there are gaps.
    2. Follow-up: If gaps exist, execute a new ask_question.py command with a specific follow-up question containing context from the previous answer.
    3. Repeat: Continue this loop until the information is complete.
    4. Synthesize: Only after receiving a complete answer should you synthesize the information and respond to the user.
    # Example follow-up
    python scripts/run.py ask_question.py \
      --question "Specific follow-up with context from previous answer"
  4. Execute commands using the run.py wrapper

    master

    Every command in the NotebookLM skill must be executed using the scripts/run.py wrapper. This ensures the correct virtual environment is used and prevents execution failures. Do not attempt to run the script files directly.

    # ✅ CORRECT:
    python scripts/run.py auth_manager.py status
    python scripts/run.py ask_question.py --question "..."
    
    # ❌ WRONG:
    python scripts/auth_manager.py status
  5. Use the run.py wrapper for all commands

    master

    To avoid ModuleNotFoundError and ensure the virtual environment is correctly managed, always use the scripts/run.py wrapper instead of calling scripts directly. The wrapper automatically handles virtual environment creation, dependency installation, and execution.

    CORRECT:

    python scripts/run.py auth_manager.py status
    python scripts/run.py ask_question.py --question "..."

    WRONG:

    python scripts/auth_manager.py status
    python scripts/run.py auth_manager.py status
  6. Add a NotebookLM notebook

    master

    To add a notebook to your library, you can use two methods:

    Query the notebook first to understand its content, then use that information to add it with accurate metadata.

    1. Query content: Use ask_question.py with a prompt asking for an overview and topics.
    2. Add notebook: Use notebook_manager.py add with the discovered name, description, and topics.

    Method 2: Manual Metadata (Fallback)

    If discovery fails, ask the user for the notebook's name, description, and topics, then add it using those details.

    Warning: Never guess notebook contents or use generic descriptions.

    # Smart Discovery Example
    
    # 1. Query the notebook to discover its content
    python scripts/run.py ask_question.py \
      --question "What is the content of this notebook? What topics are covered? Provide a complete overview briefly and concisely" \
      --notebook-url "[URL]"
    
    # 2. Use discovered info to add it
    python scripts/run.py notebook_manager.py add \
      --url "[URL]" \
      --name "[Based on content]" \
      --description "[From discovery]" \
      --topics "[Extracted topics]"
  7. Set up NotebookLM authentication via auth_manager.py

    master

    To authenticate the NotebookLM skill, you must perform a two-phase setup. The first phase involves launching a persistent browser context, manually logging in to your Google account, and saving the session state to both the browser profile and a state.json file. This ensures that both persistent cookies and session cookies (which are otherwise lost due to a Playwright bug) are preserved.

    Run the setup command to begin the manual login process.

  8. Perform initial authentication setup

    master

    Before using the skill, you must check and configure authentication. Note that the browser must be visible for the setup process to work.

    1. Check status: Verify if you are currently authenticated.
    2. Setup/Login: If not authenticated, run the setup command and follow the instructions in the browser window to log in to Google.
    # 1. Check authentication
    python scripts/run.py auth_manager.py status
    
    # 2. If not authenticated, setup (Browser MUST be visible!)
    python scripts/run.py auth_manager.py setup
  9. Debug with Verbose Logging

    master

    To troubleshoot specific execution issues, enable verbose logging and use the --show-browser flag to see what the automation is doing:

    export DEBUG=true
    export LOG_LEVEL=DEBUG
    python scripts/run.py ask_question.py --question "Test" --show-browser
    export DEBUG=true
    export LOG_LEVEL=DEBUG
    python scripts/run.py ask_question.py --question "Test" --show-browser
  10. Authenticate with Google for NotebookLM

    master

    Before querying notebooks, you must perform a one-time authentication. Tell Claude Code to set up authentication. A Chrome window will open, allowing you to log in with your Google account. This authentication persists across sessions.

    "Set up NotebookLM authentication"
  11. Install the NotebookLM Claude Code Skill

    master

    To install this skill, create your Claude skills directory and clone the repository directly into it. This skill is designed for local Claude Code installations only and will not work in the web UI due to network sandbox restrictions.

    Follow these steps:

    1. Create the skills directory if it doesn't exist.
    2. Clone the repository into that directory.
    3. Open Claude Code and verify the installation.

    On first use, the skill automatically creates an isolated Python environment (.venv), installs dependencies, and sets up browser automation using Google Chrome.

    # 1. Create skills directory (if it doesn't exist)
    mkdir -p ~/.claude/skills
    
    # 2. Clone this repository
    cd ~/.claude/skills
    git clone https://github.com/PleasePrompto/notebooklm-skill notebooklm
    
    # 3. That's it! Open Claude Code and say:
    "What are my skills?"
  12. Fix Browser and Chromium Issues

    master

    If the browser crashes or Chromium is missing:

    • Kill hanging processes:
      pkill -f chromium
      pkill -f chrome
    • Clean browser state:
      python scripts/run.py cleanup_manager.py --confirm --preserve-library
    • Install Chromium (Automatic): Running auth_manager.py status via run.py should trigger an automatic installation.
    • Install Chromium (Manual): If automatic installation fails:
      cd ~/.claude/skills/notebooklm
      source .venv/bin/activate
      python -m patchright install chromium
    python scripts/run.py auth_manager.py status