<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Lionel Draghi</title>
    <description>The latest articles on Forem by Lionel Draghi (@lioneldraghi).</description>
    <link>https://forem.com/lioneldraghi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2373217%2Fe12be37b-ced4-4b2c-a64d-eead2978736a.jpeg</url>
      <title>Forem: Lionel Draghi</title>
      <link>https://forem.com/lioneldraghi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/lioneldraghi"/>
    <language>en</language>
    <item>
      <title>Giving README-Driven Development Superpowers with bbt</title>
      <dc:creator>Lionel Draghi</dc:creator>
      <pubDate>Sun, 26 Apr 2026 10:48:44 +0000</pubDate>
      <link>https://forem.com/lioneldraghi/giving-readme-driven-development-superpowers-with-bbt-2a1h</link>
      <guid>https://forem.com/lioneldraghi/giving-readme-driven-development-superpowers-with-bbt-2a1h</guid>
      <description>&lt;p&gt;Back in 2010, Tom Preston-Werner published his now classic article &lt;a href="https://tom.preston-werner.com/2010/08/23/readme-driven-development.html" rel="noopener noreferrer"&gt;“Readme Driven Development”&lt;/a&gt;. &lt;br&gt;
He starts from a simple idea: good implementation matters, but building the right software matters even more.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A perfect implementation of the wrong specification is worthless.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Tom’s surprising answer is: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;write your README first&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The reasoning will resonate with BDD/TDD practitioners: before it’s a way to communicate with others, a README is a way to communicate with yourself and clarify your intent. It’s a design tool that helps the right product emerge.&lt;/p&gt;

&lt;p&gt;You could jump straight into coding and eventually reach the same result, but you’ll pay for it with many more, and much longer, iterations. And in practice, it often doesn’t go that well: it’s easy to get lost along the way, run into conflicting ideas, and quietly give up on the original intention. Rewriting a section of your README to adjust the specification is trivial; throwing away a code base and starting from scratch is not.&lt;/p&gt;

&lt;p&gt;By contrast, clearly expressing what you need through concrete use cases or usage examples gives you a much sharper vision before you even write the first line of code.&lt;/p&gt;

&lt;p&gt;You might think this sounds obvious, almost embarrassingly so. Yet it clearly isn’t obvious enough, otherwise we wouldn’t keep reinventing the wheel with shiny new labels like &lt;strong&gt;Specification Driven Development — an acronym that manages to be both impressive and perfectly tautological&lt;/strong&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  The Nightmare: No README and No Tests!
&lt;/h2&gt;

&lt;p&gt;Here’s a simple observation: on public repositories, there are way too many utilities with no README at all, and just as many with no tests — and sometimes you get both.&lt;/p&gt;

&lt;p&gt;When you’re focused on your main task, it’s very tempting to hack together a small side tool “quick and dirty”. You tell yourself you’ll write the README and tests &lt;em&gt;later&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Of course, if there were an easy way to describe what your utility does &lt;strong&gt;once&lt;/strong&gt;, and reuse that description &lt;strong&gt;directly as tests&lt;/strong&gt;, the trade‑off would look very different.&lt;/p&gt;


&lt;h2&gt;
  
  
  The Idea: Write One README, Get Both Docs and Tests
&lt;/h2&gt;

&lt;p&gt;The good news: such a solution exists, and it’s surprisingly simple.&lt;/p&gt;

&lt;p&gt;It’s called &lt;a href="https://github.com/LionelDraghi/bbt" rel="noopener noreferrer"&gt;&lt;em&gt;bbt&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let’s take a very simple example. Suppose I want to write a brand new tool that searches for strings in a text file. I’ll call this new tool &lt;code&gt;grep&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A well-structured README will typically include sections like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Introduction&lt;/span&gt;
&lt;span class="gh"&gt;# Installation&lt;/span&gt;
&lt;span class="gh"&gt;# Usage&lt;/span&gt;
&lt;span class="gh"&gt;# Contributing&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;strong&gt;Usage&lt;/strong&gt; section often includes examples showing how to use the tool. That’s a good practice to help users get started quickly.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Usage&lt;/span&gt;

&lt;span class="gu"&gt;## Case-insensitive search&lt;/span&gt;

&lt;span class="sb"&gt;`grep`&lt;/span&gt; can perform case-insensitive search

Given the file &lt;span class="sb"&gt;`Cities.txt`&lt;/span&gt; containing the line &lt;span class="sb"&gt;`Barcelona`&lt;/span&gt;
&lt;span class="gt"&gt;
&amp;gt; grep -i barcelona Cities.txt&lt;/span&gt;

Returns
&lt;span class="gt"&gt;
&amp;gt; Barcelona&lt;/span&gt;

But
&lt;span class="gt"&gt;
&amp;gt; grep barcelona Cities.txt&lt;/span&gt;

Returns nothing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With very little effort, we have a clear description that is useful both for the developer as a specification, and for the user as a user guide.&lt;/p&gt;

&lt;p&gt;The next logical step would be to add tests that check this behavior. Unfortunately, that usually means writing separate test scripts, wiring a test harness, and keeping everything in sync. Because tests largely duplicate what’s already written in the README (or any documentation), the two can easily start to drift apart without anyone noticing.&lt;/p&gt;

&lt;p&gt;The same goes for examples: because they are &lt;strong&gt;not tested&lt;/strong&gt;, they can contain errors or simply be out of sync with the current version of the software.&lt;/p&gt;

&lt;p&gt;This is exactly where &lt;em&gt;bbt&lt;/em&gt; comes into play.&lt;/p&gt;

&lt;p&gt;With &lt;em&gt;bbt&lt;/em&gt;, your example not only works as a specification and as a user guide, but it also becomes a &lt;strong&gt;test script&lt;/strong&gt;. &lt;em&gt;bbt&lt;/em&gt; reads the README, extracts the usage examples, runs them, and checks that the actual results match the expected ones.&lt;/p&gt;




&lt;h2&gt;
  
  
  How &lt;em&gt;bbt&lt;/em&gt; Works: A Light Gherkin-Inspired Syntax
&lt;/h2&gt;

&lt;p&gt;How is that possible?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;bbt&lt;/em&gt; uses a specific syntax for usage examples so it can recognize and execute them. This syntax is directly inspired by Gherkin, and more precisely by &lt;a href="https://github.com/cucumber/gherkin/blob/main/MARKDOWN_WITH_GHERKIN.md#markdown-with-gherkin" rel="noopener noreferrer"&gt;MDG – Markdown with Gherkin&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We’re going to slightly adapt our README so that it becomes compatible with &lt;em&gt;bbt&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Organize Examples as Scenarios
&lt;/h3&gt;

&lt;p&gt;First, we put the examples under sections whose titles use Gherkin terms such as &lt;strong&gt;Scenario&lt;/strong&gt; or &lt;strong&gt;Example&lt;/strong&gt;. (Any header that doesn’t use a Gherkin term is simply ignored.)&lt;/p&gt;

&lt;p&gt;Our README structure becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Introduction&lt;/span&gt;
&lt;span class="gh"&gt;# Installation&lt;/span&gt;
&lt;span class="gh"&gt;# Usage&lt;/span&gt;

&lt;span class="gu"&gt;## Example 1: Case-insensitive search&lt;/span&gt;
&lt;span class="gu"&gt;## Example 2: Recursive search&lt;/span&gt;
etc.

&lt;span class="gh"&gt;# Contributing&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Use Given–When–Then Steps
&lt;/h3&gt;

&lt;p&gt;Next, we use the classic &lt;strong&gt;Given–When–Then&lt;/strong&gt; structure from Gherkin, and we follow &lt;em&gt;bbt&lt;/em&gt;’s simple syntax for the steps.&lt;/p&gt;

&lt;p&gt;Our case-insensitive search example becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="sb"&gt;`grep`&lt;/span&gt; can perform a case-insensitive search.

&lt;span class="gu"&gt;## Example 1: Case-insensitive search&lt;/span&gt;
&lt;span class="p"&gt;
-&lt;/span&gt; Given the file &lt;span class="sb"&gt;`Cities.txt`&lt;/span&gt;
  &lt;span class="p"&gt;~~~&lt;/span&gt;&lt;span class="nl"&gt;
&lt;/span&gt;  Barcelona
  Lima
  Ankara
  Osaka
  Tulsa
  &lt;span class="p"&gt;~~~&lt;/span&gt;
&lt;span class="p"&gt;
-&lt;/span&gt; When I run &lt;span class="sb"&gt;`grep -i barcelona Cities.txt`&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; Then the output is &lt;span class="sb"&gt;`Barcelona`&lt;/span&gt;
&lt;span class="p"&gt;
-&lt;/span&gt; When I run &lt;span class="sb"&gt;`grep barcelona Cities.txt`&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; Then there is no output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The structure is so light that it almost reads like natural language. But it is structured enough for &lt;em&gt;bbt&lt;/em&gt; to parse it and turn it into an automated test.&lt;/p&gt;

&lt;p&gt;And using it is as simple as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bbt README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it. With very little effort, you’ve turned a purely informative README into an &lt;strong&gt;executable README&lt;/strong&gt;.&lt;br&gt;
No test harness, no extra scripts, not even a &lt;code&gt;tests&lt;/code&gt; directory. &lt;br&gt;
And, most importantly, no more silent inconsistencies.&lt;/p&gt;


&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;If there are two things to remember about &lt;em&gt;bbt&lt;/em&gt;, they are these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;First&lt;/strong&gt;, it turns your documentation into a &lt;em&gt;single source of truth&lt;/em&gt;: by making the README executable, it leaves very little room for any gap to appear between what the documentation says and what the code actually does.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Second&lt;/strong&gt;, it does this in a very efficient way: the scripts are quick to write and the tool is easy to use. In practice, you (almost) get documentation &lt;em&gt;plus&lt;/em&gt; tests for the price of documentation alone.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;In short, &lt;em&gt;bbt&lt;/em&gt; gives README-Driven Development a new superpower: it turns READMEs into a living, executable specification.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If it only helped more authors take the small step of actually writing a README — and keeping it correct — that alone would be a huge win.&lt;/p&gt;


&lt;h2&gt;
  
  
  What’s Next?
&lt;/h2&gt;

&lt;p&gt;Getting started with &lt;em&gt;bbt&lt;/em&gt; is straightforward: just follow the instructions on the &lt;a href="https://github.com/LionelDraghi/bbt" rel="noopener noreferrer"&gt;project’s page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For the impatient, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;install &lt;em&gt;bbt&lt;/em&gt; by following the &lt;a href="https://github.com/LionelDraghi/bbt/tree/main?tab=readme-ov-file#installation" rel="noopener noreferrer"&gt;installation section&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;look at another concrete example, such as the &lt;a href="https://github.com/LionelDraghi/bbt/blob/main/docs/examples/gcc_hello_world.md" rel="noopener noreferrer"&gt;GCC “hello world” scenario&lt;/a&gt;, and start from there.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that the tool also comes with a built-in tutorial:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bbt &lt;span class="nb"&gt;help &lt;/span&gt;tutorial
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;If you maintain small command-line tools or libraries, try turning your README into an executable specification. You might find that writing the README first becomes the fastest way to get reliable behavior — almost by accident.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>rdd</category>
      <category>testing</category>
      <category>cli</category>
      <category>devtools</category>
    </item>
    <item>
      <title>Docs that never lie</title>
      <dc:creator>Lionel Draghi</dc:creator>
      <pubDate>Fri, 20 Feb 2026 22:11:06 +0000</pubDate>
      <link>https://forem.com/lioneldraghi/docs-that-never-lie-4df</link>
      <guid>https://forem.com/lioneldraghi/docs-that-never-lie-4df</guid>
      <description>&lt;p&gt;&lt;strong&gt;Turn your README into a living spec&lt;/strong&gt;: bbt embeds executable examples directly into your test suite. &lt;/p&gt;

&lt;p&gt;Docs that &lt;strong&gt;never lie&lt;/strong&gt; — because they run with your code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/LionelDraghi/bbt" rel="noopener noreferrer"&gt;bbt&lt;/a&gt;&lt;/p&gt;

</description>
      <category>runthedoc</category>
      <category>bbd</category>
      <category>testing</category>
      <category>cli</category>
    </item>
    <item>
      <title>My dream way of testing</title>
      <dc:creator>Lionel Draghi</dc:creator>
      <pubDate>Mon, 03 Feb 2025 18:41:08 +0000</pubDate>
      <link>https://forem.com/lioneldraghi/my-dream-way-of-testing-8m9</link>
      <guid>https://forem.com/lioneldraghi/my-dream-way-of-testing-8m9</guid>
      <description>&lt;h2&gt;
  
  
  The dream
&lt;/h2&gt;

&lt;p&gt;Let's not kid ourselves, nobody is interested in writing tests.&lt;br&gt;
It's every software engineer's dream to see tests generated automatically.&lt;br&gt;
But generated from what?&lt;/p&gt;

&lt;p&gt;In most project, there is no formal method used for behavior specification, but at least there is some description in plain english.&lt;/p&gt;

&lt;p&gt;For example, to describe a &lt;code&gt;gcc&lt;/code&gt; simple use case, it could be :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Scenario: compiling and executing an hello word&lt;/span&gt;
&lt;span class="p"&gt;
-&lt;/span&gt; Given the new file &lt;span class="sb"&gt;`main.c`&lt;/span&gt;
&lt;span class="p"&gt;```&lt;/span&gt;&lt;span class="nl"&gt;c
&lt;/span&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;```&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; And given there is no &lt;span class="sb"&gt;`main`&lt;/span&gt; file
&lt;span class="p"&gt;
-&lt;/span&gt; When I successfully run &lt;span class="sb"&gt;`gcc main.c -o main`&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; And  I run &lt;span class="sb"&gt;`main`&lt;/span&gt;
&lt;span class="p"&gt;
-&lt;/span&gt; Then the output is &lt;span class="sb"&gt;`Hello, World!`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's a markdown file, using a classic Gherkin framework, perfectly suitable for documentation.&lt;br&gt;
And it contains all the necessary information to actually run the test.&lt;/p&gt;

&lt;p&gt;So why should I have to rewrite the same story in some test framework using some specific programming language? Not only is it a useless task, but it also creates a constantly problematic second source of truth.&lt;br&gt;
No, I should be able to run it just as is.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;And that's my dream : be able to just &lt;strong&gt;run the doc&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Let's try something...
&lt;/h2&gt;

&lt;p&gt;In spring 2024, I started playing with this idea. &lt;br&gt;
Most of my end-to-end tests use the same framework :  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;setup some input &lt;/li&gt;
&lt;li&gt;run the app with some options&lt;/li&gt;
&lt;li&gt;check the output
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The needed vocabulary being limited in that context, I considered that it was not unrealistic to use an input file in plain english like the example above instead of some script, and decided to build a prototype. It turned out that implementation was... manageably complex, and it wasn't long before the prototype was usable.&lt;/p&gt;

&lt;p&gt;I use (and love) the test first approach. Not because of the usual bullshit "coverage" argument, but because writing a use case is a great help to design, and an effective way to communicate about the behavior. As a consequence, description like the above being already part of my design process, &lt;strong&gt;the test comes for me at zero cost&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Ultimately, the prototype demonstrated not only an immediate boost in productivity, but also a rapid learning curve.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  I want it too!
&lt;/h2&gt;

&lt;p&gt;Good news, this tool, called &lt;code&gt;bbt&lt;/code&gt;, is now available &lt;a href="https://github.com/LionelDraghi/bbt/tree/main" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;br&gt;
It's easy to &lt;a href="https://github.com/LionelDraghi/bbt?tab=readme-ov-file#installation" rel="noopener noreferrer"&gt;install&lt;/a&gt; on Linux and Windows. &lt;br&gt;
(It compiles on MacOS, but isn't tested on my side for now).&lt;/p&gt;

&lt;p&gt;Current version is 0.0.6, meaning that bbt is still in a early development stage, and open to improvement : comments, use cases, good practices, ideas, pain points are all more than welcome &lt;a href="https://github.com/LionelDraghi/bbt/discussions" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Acknowledgments
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Many thanks to &lt;code&gt;bbt&lt;/code&gt;'s early adopters and contributors &lt;a href="https://github.com/pyjarrett" rel="noopener noreferrer"&gt;Paul&lt;/a&gt; and &lt;a href="https://github.com/mgrojo" rel="noopener noreferrer"&gt;Manuel&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Many thanks to &lt;a href="https://blog.adacore.com/" rel="noopener noreferrer"&gt;AdaCore&lt;/a&gt;, who awarded &lt;code&gt;bbt&lt;/code&gt; the &lt;a href="https://blog.adacore.com/ada-spark-crate-of-the-year-2024-winners-announced" rel="noopener noreferrer"&gt;Ada Crate of the Year Prize&lt;/a&gt;!&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>test</category>
      <category>cli</category>
      <category>runthedoc</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
