Marginal Gain #1: Make Common Tasks Easy

Marginal gains are minor improvements that are relatively easy to make. A single marginal gain does not have a meaningful effect, but several can aggregate into significant progress. I first read about this concept in James Clear’s Atomic Habits, and was inspired to apply this philosophy to software development. For a better understanding of what marginal gains are, read this excerpt from the book.

The most worthwhile marginal gains are the ones that take a little effort to implement and no (or almost no) effort to maintain. I like to think of these as small upfront time investments for guaranteed, long-term returns. This is especially relevant to software development. Marginal gains can be earned by making common tasks easier, altering your workflow, or even simply shifting your mindset.

Make Common Tasks Easy

Automating the mundane is hardly a novel concept. Obviously, things like continuous integration and deployment save a lot of time. Improvements like these are not marginal; they are essential for most projects. However, consider how many steps it takes you to do smaller and more frequent tasks, like start a local server instance or run unit tests. Even if they only take a few steps each, they can add up over time. Although a project will probably not sink or swim based on the number of keystrokes, streamlining tedious development tasks can improve developer morale and efficiency.

Example Workflow

I am currently working on a web application with a Django REST API backend and a React frontend. To get started, I first open a terminal and run the following commands to start the API.

cd Projects/budgetapp/budget-rest-api/  # Change to the project directory
workon budgetapp  # Activate the Python virtual environment
sudo service postgresql start  # Start Postgres
python3 runserver  # Run the Django server

Although this only takes a few seconds, it is tedious. I had to run these steps once or twice per coding session, until I realized I was creating an unnecessary obstacle for myself, however small.

The steps for running the Node.js server are as follows.

cd Projects/budgetapp/budget-app  # Change to the project directory
npm start  # Start the server

Reducing Steps

I use Linux for development when I can, and Windows Subsystem for Linux when I’m stuck with Windows. Either way, .bashrc is a shell script that is run each time Bash is started. We can take advantage of this to create shortcuts for commands or sequences of commands that are tedious to type out otherwise.

First, open your .bashrc for editing by opening a terminal and running vim ~/.bashrc, optionally replacing vim with your favorite text editor (I think vi and nano are generally installed by default). Your .bashrc should already have a lot of code in it. I suggest adding new additions to the bottom with useful comments.

Here is what I added to my .bashrc to make my workflow easier.

export HOME=/home/levi
export PROJECTS_HOME=$HOME/Projects

# Project locations
export BUDGET_API_HOME=$PROJECTS_HOME/budgetapp/budget-rest-api
export BUDGET_APP_HOME=$PROJECTS_HOME/budgetapp/budget-app

# Changes to the Budget API directory and activates python virtual env.
cd-budget-api() {
    workon budgetapp

# Starts the Budget API
start-budget-api() {
    sudo service postgresql start
    python3 runserver

# Changes to the Budget App directory
cd-budget-app() {

# Starts the Budget App
start-budget-app() {
    npm start

Now, I can simply run start-budget-api and start-budget-app to start working on my application. Notice how I kept my functions modular by creating cd-budget-api and cd-budget-app, in case I need to do something other than start server instances. Principles for writing good functions still apply here.

Closing Thoughts

By reducing my ritual for starting server instances from six to two short commands, I have marginally improved my development workflow. Although this has a very small impact on my productivity, this and other small improvements make it so that I can spend less time performing tedious tasks and spend more time writing code.

What kind of tedious tasks do you have to do frequently? How have you or how can you simplify the steps required to complete them? Please share in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.