Todo + gamification with Taskwarrior & Taskquant
Tags: productivity, python, opensource, showdev
Published: 2022-04-06 13:59:21

If you live and breathe in the terminal, you want as little context switching as possible. For many things (like web browsing and spreadsheet editing) a graphical user interface seems inevitable no matter how great the alternative is (i.e _lynx browser_). 

![gui and terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uw46pu3croz6yj7hfmjf.png)

For everything else, there is almost always a better option, one that allows you to stay within the terminal and _gasp_ optionally works with VIM bindings. As I review my current work and processes, it strikes me that a task manager (todo app) is one such use-case. 

A good todo app is stunning, aesthetically pleasing, and joyous to use. 

But a **great** todo app should be almost the entirely opposite of a good todo app. It shouldn't even be joyous to use, lest you spend too much time in it. I want a todo app that is so minimal, so unobtrusive that it's _barely there_. If I find the todo app enjoyable, I'm spending too much time in it instead of doing the task.

#### Taskwarrior
![taskwarrior](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rb7mzdesmdw8wav8h3gn.png)

Taskwarrior is a free, open source TUI that puts your TODO in the terminal and is as unobtrusive as to-do apps get. 

- [Taskwarrior video introduction](https://www.youtube.com/watch?v=cDYIes9avW4)

It has built-in reporting features (`task burndown.weekly`), a tagging system (`+meeting +report`), a context switcher (`task context office`), project hierarchies (`task project:Startup`), a [robust date system](https://taskwarrior.org/docs/using_dates.html) that blows anything, free or proprietary, out of the water, and a _scriptable_ urgency formula for each task.

> There are many other real-life examples of algorithms that are used to approximate qualities: the Apgar Score that assesses the health of newborns, Google's Page Rank that measures the importance of a web link, or credit ratings. These examples all approximate, but cannot perfectly represent, a complex concept.
> 
> Taskwarrior uses a polynomial expression to calculate urgency. This is a simple sum of terms, where each term represents some measurable quality of a task. 

#### Custom Attributes
The best part of Taskwarrior is its support for user-defined attributes (UDA) beyond what it offers out of the box. No matter what productivity system (e.g GTD system) I choose, I _can make it work_ the way I want to with a bit of customization. 

One theme of my productivity system over the past many years is a way to quantitatively measure my productivity with a `score` attribute. Different apps may come and go, but to make it work for me, I need the `score` attribute as it's integral to how I manage my periodic reviews and longer-term reflections. It also pushes me to work on large projects since they come with bigger rewards (at least psychologically). 

How do I add that to Taskwarrior? Simple. Add the following lines to the end of your `.taskrc` file:

```
uda.score.type=numeric
uda.score.label=Score 🏆 
urgency.uda.score.coefficient=2
```

Now all your task has an extra, optional `score` field (🏆)!
![taskwarrior score](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6np2dlrq4zxt5e4xxdh5.png)
 

#### Productivity Scoresheet
One thing I often do in my periodic review is to collect data-points on  my activities over the last period. This includes data from my work machines, my Mi Band, and Apple Health. 

For example, I know how many hours and minutes I've spent on one specific app, or task, over the last calendar year.

![timing app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/39paphp708zgeg85lais.jpg)
 
For Taskwarrior, all that is left to do is to roll out a Python app that I can install and run. This package weighs less than 8kb (which is really _nothing_) and is available on PyPI. It installs under one second:
```
pip install taskquant
``` 

After which you can issue `tq` to get a productivity breakdown. Add the `-w` flag to have it grouped by week, in a rolling sum fashion:

```
tq -w 
+-------+-------+------------+
| Week# | Score | Cumulative |
+-------+-------+------------+
|  10   |  56   |     56     |
|  11   |  33   |     89     |
|  12   |  26   |    115     |
|  13   |  12   |    127     |
+-------+-------+------------+
```

![taskquant](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/34tv82rng75kce1qwo2n.png)
 
If you want to hack away at your productivity system, the project is available on my GitHub:
- [TaskQuant](https://github.com/onlyphantom/taskquant)

#### Bonus: Watch the whole process in action

I thought it'd be interesting to show how I build out the CLI tool so I've uploaded a recording of that on YouTube as well. If you're a data analyst from the `pandas` world, you may learn a thing or two about:
- group by
- aggregation
- filling missing dates (padding)
- tabular summary
- colorful CLI 
All without any dependencies except tasklib (the Taskwarrior libary itself). This brings the package down to 6.8kb of code, and with its 1 second installation time, is similarly unobtrusive. Gets you your productivity scores, and get out of the way. If you'd like to watch it, here are the links:

- [Building Taskquant ep.1](https://www.youtube.com/watch?v=lT2jqmhRkxo)
- [Building Taskquant, full playlist](https://youtube.com/playlist?list=PLXsFtK46HZxXIVE4tRjwMjwKFVaQSdT5W)

#### What's next
We'll add terminal-based graphs and charts, and maybe more variety in terms of reporting format. **No, there can never be too many ways to see how you're not doing enough**. If you want to follow along the journey, drop by and 👋 on YouTube. 

If you're feeling more driven than that, go ahead and install Taskwarrior and Taskquant and start knocking out some to-do! Collaborators welcomed!