Home | Legal Tech | Projects | Writings

Clauses on Command

Keep a suite of your favourite contract clauses at your fingertips.

The problem

Sometimes when drafting an agreement you just want to have your favourite clauses ready to paste in. Instead of raking through terms of previous agreements you have reviewed, you can paste a selection in to a csv file for quick summoning from the terminal. It also allows you to enter a new clauses from the command line, and list all the clauses available.


  1. Install the required module
  2. Create our script and csv file
  3. Run the script with different 'flags'

1. Install the modules

We are going to install 'fuzzywuzzy' so we can search for clauses without getting the exact spelling (it does a 'fuzzy' match).

We are also going to install 'click', which will let us call the script from the command line including flags to select between listing, searching and adding clauses.

2. Create our script and CSV

In the folder you want to keep the files, create the files we need with:

$ touch clauses.csv clauses.py

to create the two empty files we need.

Paste the python script below in to clauses.py and the csv data into clauses.csv

In the CSV file, you can see we've set 3 variable fields:

Replace the filler examples with a few of your own favourite clauses to get started.

3. Use the Flags

Using the -s flag

When we use the -s flag we must follow it up with the term we are searching for, e.g.:

$ python3 clauses.py -s jurisdicton

This give us the following out - note how this works despite the small typo in 'jurisdiction'.

listed clauses

Using the -l flag

Using the -l flag lists out all of the available clauses and their descriptions.

Then, we can select one by entering the corresponding number, as shown here:

listed clauses

Using the -n flag

The -n flag allows us to enter a new clause by responding to the prompts.

In the example below, we add a clause then select it from our list.

listed clauses