Home | Legal Tech | Projects | Writings

Contract Creator

Create contracts on the fly from the command line.

Automating documents is a piece of cake. We aren't talking about implementing a full contract management workflow here, just blankety-blank with a template contract, but once you can prepare your own templates a whole world of potential opens up - consider combining the below with the STF Consideration script to automate a share sale. In this example, it's literally a matter of inserting curly braces around the parts of your document which you want to replace with a variable, like a company name or a date. This method can be applied to any "docx" document you happen to have handy.


  1. Install the docxtpl module
  2. Create our template in docx (as used by Microsoft Word and other word processors)
  3. Write the script to generate the document
  4. Insert the variables from within the command line

1. Install the module

The module we need to install is called "docxtpl".

If you are unsure how to install this module, check the guide at python basics.

2. Create the template

3. Write the script

This step is as simple as pasting the code below into a new python file.

4. Create the document