A typical development pattern might look something like this:
- Pick a new feature to implement or a bug to fix
- Write some code and test it locally
- Have someone else review your code and make comments
- Iterate steps 2 and 3 as necessary
- Deploy your changes to a staging server (where more tests are run)
- Watch the production release and make sure everything is going well
The time spent testing and reviewing code in this process helps ensure that we ship high quality code. Sometimes, however, we need to respond to things that go wrong in production very quickly. When urgency outweighs the risks of bypassing the development pattern outlined above, the best option is to change code live in production, i.e. cowboy coding. To make cowboy coding less dangerous, only one person should be changing production code at a time. For that reason, effective communication among the engineering team is essential.
Until recently, our engineers passed around a physical cowboy hat to designate a cowboy coder in these situations. This was inconvenient for people in the office, and impossible for those working from home. Because of that, some people either did dangerous things without being sure they were the only one taking action, or they tried to work around the issue when the best thing to do was to jump in and get stuff done. As our team continued to grow, using a physical cowboy hat became less feasible, so we sought a digital alternative — a cowboy robot, if you will.
For Jana’s quarterly hackathon, I built a custom Slack integration that lets our engineers put on a virtual cowboy hat in Slack if they need to change code live in production. Some of the available Slack integrations, like Giphy for example, are ready to go out of the box. Others require some coding, but provide even more flexibility. In case you aren’t familiar with Slack, if the beginning of a message starts with a slash (like
/giphy puppy), Slack will look for that command and execute it if it exists. My cowboy robot, affectionately dubbed the John Wayne Bot, is built on the custom slash commands integration. We have a server that listens for someone to type the command
/cowboy, parses the arguments, does some cowboy logic, and sends a message to our engineering Slack channel accordingly.
Using the bot is pretty simple. If you type
/cowboy anywhere in Slack, the bot tells you who (if anyone) has the hat on and how long they’ve been wearing it. Type
/cowboy on to put the hat on, and
/cowboy off to take it off. The bot will only let one person wear the cowboy hat at a time. Here it is in action:
Since I joined Jana only a few months ago, I didn’t have time to develop an emotional attachment to the physical cowboy hat, but I think I can safely say that what we lose in tangibility and sentimental value with this change, we make up for in efficiency and practicality.
Interested in this Slack integration? Let us know. We might open-source it.
By the way, we’re hiring.