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.
Setup
-
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.
-
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 openpyxlWindowspip install anthropic pypdf openpyxl -
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.
-
Download the script
Use the download button in the sidebar. Save contract_search.py anywhere convenient.
Running the tool
-
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:
Macpython3 contract_search.pyWindowspython contract_search.py -
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.
-
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 -
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
| Error | Fix |
|---|---|
| command not found: python3 | Python 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 / 401 | The 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 cells | That 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 / 429 | You're sending contracts faster than your account tier allows. Wait a minute and re-run, or split a very large folder into batches. |