Free & open source No login · No subscription · Runs on your computer
View on GitHub →
Home / Tools / Contract Keyword Search
Tool 06 of 07

Search a whole folder of contracts for specific clauses.

Enter keywords like indemnification, change of control, or non-compete, and get one Excel file back: a green/red summary grid showing which contracts contain what, plus an AI-written summary of what each contract says about each term.

What it does

Contract Keyword Search reads an entire folder of contracts and checks each one for the keywords or clauses you specify, like indemnification, change of control, termination for convenience, or non-compete. It outputs a single Excel file with two sheets:

Sheet 1 — Summary grid. Contracts down the side, keywords across the top. Green cell = found, red cell = not found. You can see coverage across the whole set at a glance.

Sheet 2 — Detailed findings. For every hit, an AI-written summary of what that specific contract actually says about that keyword — not just that the word appears, but what the clause does.

Verify before relying. The AI summaries point you to what each contract says, fast — but read the underlying clause before advising on it. Treat the output as a map of where to look, not a substitute for looking.

Setup

  1. Install Python 3 (once)

    Download it free from python.org/downloads and run the installer. On Windows, check the box that says "Add Python to PATH" during installation.

  2. Install the three libraries this tool needs

    Open Terminal (Mac) or Command Prompt (Windows) and paste the command for your system:

    Mac
    /usr/local/bin/pip3 install anthropic pypdf openpyxl
    Windows
    pip install anthropic pypdf openpyxl
  3. Get an Anthropic API key

    Create a free account at console.anthropic.com and generate an API key. Costs run about $0.01–$0.05 per contract depending on length — a 100-contract review typically costs a few dollars.

  4. Download the script

    Use the download button in the sidebar. Save contract_search.py anywhere convenient.

Running the tool

  1. Start the script

    In Terminal or Command Prompt, navigate to the folder holding the script (type cd, a space, then drag the folder into the window and press Enter). Then run:

    Mac
    python3 contract_search.py
    Windows
    python contract_search.py
  2. Point it at your contracts and enter your key

    The script asks for the folder of contracts and your API key. The key is used for this run only and never stored.

  3. Enter your keywords one at a time

    Type each keyword or clause name and press Enter. When you've listed everything, type done and press Enter:

    Keyword: indemnification  ← Enter
    Keyword: change of control  ← Enter
    Keyword: termination for convenience  ← Enter
    Keyword: done  ← finishes the list
  4. Open the Excel report

    Start with the Summary grid to see coverage, then use Detailed Findings for the AI summary of what each contract says about each keyword.

Common errors

ErrorFix
command not found: python3Python isn't installed (or isn't on your PATH). Install it from python.org — on Windows, re-run the installer and check "Add Python to PATH."
No module named 'anthropic'The libraries didn't install. Re-run the install command from Setup step 2. On a Mac, use the full /usr/local/bin/pip3 path shown above.
authentication_error / 401The API key was mistyped or has been revoked. Copy a fresh key from console.anthropic.com and paste it carefully — no extra spaces.
Contract shows all red cellsThat file is probably a scanned image with no text layer, so nothing can be read from it. OCR the file first, then re-run.
rate_limit_error / 429You're sending contracts faster than your account tier allows. Wait a minute and re-run, or split a very large folder into batches.

More tools in the kit