<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator>
  <link href="https://blog.davidburela.com/feed.xml" rel="self" type="application/atom+xml" />
  <link href="https://blog.davidburela.com/" rel="alternate" type="text/html" />
  <id>https://blog.davidburela.com/feed.xml</id>

  
  
    <title type="html">David Burela’s blog</title>
  

  
    <subtitle>Personal blog of David Burela, Software Engineer at Microsoft. Working on Cloud, Decentralised Web, IPFS, Ethereum, Blockchain.</subtitle>
  

  

  

  
    <author>
      <name>David Burela</name>
      
        <email>David.Burela@gmail.com</email>
      
      
    </author>
  

  
  
  
  

  
  
  
    <updated>2026-03-23T00:00:00+00:00</updated>
  

  
    <entry>
      
      <title type="html">Why-What-How: A structure for project knowledge</title>
      <link href="https://blog.davidburela.com/2026/03/23/why-what-how-a-structure-for-project-knowledge/" rel="alternate" type="text/html" title="Why-What-How: A structure for project knowledge" />
      <published>2026-03-23T00:00:00+00:00</published>
      <updated>2026-03-23T00:00:00+00:00</updated>
      <id>https://blog.davidburela.com/2026/03/23/why-what-how-a-structure-for-project-knowledge</id>

      
      
        <content type="html" xml:base="https://blog.davidburela.com/2026/03/23/why-what-how-a-structure-for-project-knowledge/"><![CDATA[<p><strong>❗ DRAFT: This is an early draft that I am sharing. Needs further refinement and editing ❗</strong></p>

<p>In my previous post on <a href="/2026/03/11/capturing-project-knowledge-to-help-coding-agents/">capturing project knowledge to help coding agents</a>, I wrote about the practical first step, getting your implicit standards and conventions into markdown so agents stop guessing. This is a great start on the journey to get more consistent results, but as you build up more and more the focus shifts. <em>Where</em> you put it and <em>how</em> you organise it starts to matter just as much as whether you capture it at all.</p>

<p>This post is about a structure I have built up over time called <strong>Why-What-How</strong>, that organises project knowledge into layers that humans can navigate and agents can progressively load.</p>

<p><strong>Key resources:</strong></p>
<ul>
  <li>This blog post</li>
  <li>The core repo <a href="https://github.com/DavidBurela/why-what-how">why-what-how</a></li>
  <li>The example implementation <a href="https://github.com/DavidBurela/why-what-how-bubbletea-kiosk-example">why-what-how-bubbletea-kiosk-example</a></li>
</ul>

<h2 id="the-problems-i-kept-seeing">The problems I kept seeing</h2>

<p>Even on teams that were writing things down, the same problems kept showing up.</p>

<p><strong>Information was scattered everywhere.</strong> Key decisions about the architecture would appear in research notes, inside SDD (Spec Driven Development) specs, in ADRs (Architecture Decision Records), or buried in pull request descriptions. When an agent needed to understand how the system was designed, it had to search through everything — and it would still miss things. There was a lot of repeated information, and worse, outdated information that contradicted the current state.</p>

<p><strong>Everything sat at the same level.</strong> There was no layering or hierarchy. The business problem statement, a component-level flow diagram, a coding convention, and a technology choice all lived side by side in a flat folder. Developers were trying to tackle everything at the same level of abstraction instead of breaking it into layers. When you read a spec, it might jump from “the customer needs to place an order” to “we use a Redis cache for session state” in the same paragraph.</p>

<p><strong>The approaches were developer-centric.</strong> Most of the spec-driven and planning workflows I was seeing were written by developers, for developers. They worked well for scoping code changes but the solutions they produced kept drifting bottom-up — starting from technical details and working backward to justify them. The business problem that originally motivated the work would get buried or forgotten entirely. And other roles on the team — programme managers doing stakeholder discovery, data scientists running evaluations, designers doing user research — had no clear place in the structure. Their work would live in separate documents that did not connect back to the shared knowledge.</p>

<p><strong>Diagrams did not validate against anything.</strong> I kept seeing teams generate Mermaid diagrams of parts of the system and commit them. Then someone else would generate another diagram, and the names would not match, the flows would differ, and sometimes they would show relationships that did not exist. Each diagram was an independent drawing with no connection to any other diagram. There was no way to know which one was correct when they contradicted each other. Mermaid is a great rendering format, but it is not a modelling tool — it does not validate relationships or enforce consistency across views. This is something I want to explore more in a future post, but the short version is: I started using C4 model DSL as a structural source of truth instead, where the model validates that elements and relationships actually exist before you can render them.</p>

<h2 id="the-shift-that-helped">The shift that helped</h2>

<p>I tried a few different approaches to organising this knowledge before landing on something that worked. The key realisation was that I needed to separate the layers of abstraction and make them explicit.</p>

<p><strong>The business intent needed to be self-contained.</strong> When I pulled out the “why are we building this?” into its own area — the problem context, the people we are serving, the journeys they go through, the scenarios that describe expected behaviour — it became a clean black-box definition. It described what the system must do from the outside without saying anything about how. That meant the business intent stayed stable even when the architecture changed underneath. And it meant anyone on the team — not just developers — could contribute to it and understand it.</p>

<p><strong>The solution structure needed its own space.</strong> What we are concretely building — the system boundary, the applications, how they decompose into components, how interactions flow between them — is the white-box implementation. Pulling this into a separate area made it much easier to reason about structure without getting tangled in business framing or coding conventions.</p>

<p><strong>Cross-cutting constraints needed a home.</strong> Engineering conventions, observability standards, security patterns, testing approaches — these apply across everything but they are not about the business problem or the solution structure. They needed their own area.</p>

<p><strong>Decisions needed to be preserved.</strong> Why did we choose this technology? What alternatives did we reject? What trade-offs did we accept? Without a place for this, teams would re-litigate the same decisions because nobody could find the original reasoning.</p>

<h2 id="the-four-areas">The four areas</h2>

<p>That is the framework. Four areas, each with a clear purpose.</p>

<p><a href="/assets/2026/03/wwh-areas.png"><img src="/assets/2026/03/wwh-areas.png" alt="The 4 areas" /></a></p>

<table>
  <thead>
    <tr>
      <th>Area</th>
      <th>Frame</th>
      <th>What it answers</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><strong>Business</strong></td>
      <td>Why</td>
      <td>Why does this exist? Who are we serving? What outcomes matter?</td>
    </tr>
    <tr>
      <td><strong>Solution</strong></td>
      <td>What</td>
      <td>What are we building? How does it decompose? What owns what?</td>
    </tr>
    <tr>
      <td><strong>Standards</strong></td>
      <td>How</td>
      <td>How do we build consistently? What conventions apply?</td>
    </tr>
    <tr>
      <td><strong>Decisions</strong></td>
      <td>Why This</td>
      <td>Why did we choose this approach? What did we reject?</td>
    </tr>
  </tbody>
</table>

<p>When you are writing something and are not sure where it belongs, the decision tree is simple:</p>

<ul>
  <li>Is it about intent or expected behaviour? → <strong>Business</strong></li>
  <li>Is it about structure or how parts interact? → <strong>Solution</strong></li>
  <li>Is it about how we build consistently? → <strong>Standards</strong></li>
  <li>Is it about why we made a choice? → <strong>Decisions</strong></li>
</ul>

<p>If you cannot answer any of those, it probably does not belong in the canonical knowledge at all — it might be a scratch pad or working document that has not been distilled yet.</p>

<h2 id="validation-at-every-layer">Validation at every layer</h2>

<p>One of the things I have noticed as teams adopt agentic workflows is that we are learning where agents need deterministic guardrails. Most of the focus so far has been on TDD (Test Driven Development) — write tests, let the agent implement, check if the tests pass. That catches implementation bugs. But there are two other classes of error that TDD does not catch.</p>

<p><strong>Are we building the right thing?</strong> BDD (Behaviour Driven Development) tests validate that the scenarios defined in the business layer actually hold. They catch intent errors — “the code works, but it does not do what the business needed.”</p>

<p><strong>Do the pieces fit together?</strong> The C4 model validates the structural integrity of the solution. If a flow references an application or relationship that does not exist in the model, the DSL catches it. It catches structural errors — “the components work individually, but the overall system does not connect the way we described.”</p>

<p>Together with TDD at the implementation layer, this gives you validation at every level: business intent, solution structure, and code correctness. Without all three, agents can produce code that runs but does not match the business need, or structure that compiles but does not align with the agreed architecture.</p>

<h2 id="it-works-with-however-you-already-work">It works with however you already work</h2>

<p>This is probably the most important thing to say: <strong>Why-What-How is not a new process. It is a structure that existing processes feed into.</strong></p>

<p>If you are using SDD or RPI (Research-Plan-Implement) cycles — keep doing that. Your specs and plans can live in a <code class="language-plaintext highlighter-rouge">specs/</code> folder as they always have. The difference is that they can now reference the shared knowledge in <code class="language-plaintext highlighter-rouge">docs/</code> for the business context, solution architecture, and standards. That means each spec carries less repeated background, gets more consistency, and stays aligned with what the team has already agreed.</p>

<p>If you are doing Design Thinking — keep doing your workshops, your user research, your persona development. When those activities produce conclusions that matter, distil them into the Business area. Your personas, journeys, and scenarios become first-class documents that the whole team (and agents) can reference.</p>

<p>If you are starting a new project and having initial meetings with a product owner — start capturing that in Business. The problem context, the vision, the expected outcomes. As you learn where the system will be deployed and which existing systems it will interact with, start capturing that in the Solution context. Then the combination of business understanding and system context can help inform the decomposition — what applications you need, what components they contain, and what flows connect them.</p>

<p>The key principle: <strong>your scratch pads stay wherever your workflow puts them. When those activities produce conclusions that matter, distil them into the right area.</strong> The canonical knowledge stays in <code class="language-plaintext highlighter-rouge">docs/</code>. Research notes, brainstorming artifacts, SDD specs, and working documents stay outside. They feed in; they do not need to live inside.</p>

<p>As teams make decisions that change the design or the standards, they capture those in <code class="language-plaintext highlighter-rouge">docs/</code>. The next spec, the next agent session, the next new team member — they all start from high-signal, up-to-date canonical knowledge instead of searching through everything.</p>

<h2 id="seeing-it-in-practice-bubble-tea-kiosk">Seeing it in practice: bubble tea kiosk</h2>

<p>To make this concrete, I created a reference example: a bubble tea ordering kiosk for a fictional shop called <strong>Compile &amp; Sip</strong>. It is a documentation-only repository — no source code, just the docs layer — so you can see the framework in practice without distraction. The full repo is at <a href="https://github.com/DavidBurela/why-what-how-bubbletea-kiosk-example">why-what-how-bubbletea-kiosk-example</a>.</p>

<p>Here is one thread through the framework, following a single user action end-to-end.</p>

<p><strong>Business layer — the why.</strong> The problem is real: peak-hour queues cause 20–30% of potential customers to walk away, and verbal order relay leads to wrong milk types, forgotten toppings, and wasted drinks. One of the personas is Alex, a regular customer who values order accuracy and speed. Alex’s journey — approaching the kiosk, browsing the menu, customising a drink, paying, and picking up the order — is captured as a narrative. From that journey, specific testable scenarios are derived: “order is accepted with valid customisations”, “payment is processed successfully”, and so on. Each scenario describes what must happen from the outside — no mention of APIs, databases, or services.</p>

<p><strong>Solution layer — the what.</strong> Knowing the business need, the solution decomposes into three applications: a customer-facing kiosk UI, a central order API, and a kitchen display. The system context captures the boundary — what is inside the system and what is external (the payment gateway). Each application has its own folder with a context document explaining its responsibilities. Flows describe how an interaction unfolds across applications — for example, the “submit order” flow traces from the kiosk through the order API and back. These flows are defined in the C4 model, which means the applications and relationships they reference must actually exist in the structural model.</p>

<p><strong>The folder structure</strong> reflects this layering:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docs/
├── business/                    # WHY — intent, people, behaviour
│   ├── business-context.md
│   ├── vision.md
│   ├── personas/                #   Alex (customer), Jamie (kitchen staff)
│   ├── journeys/                #   Customer places order, Staff prepares order
│   └── scenarios/               #   5 testable scenarios
│
├── solution/                    # WHAT — structure, decomposition
│   ├── solution-context.md      #   System boundary and external systems
│   ├── applications/            #   Kiosk UI, Order API, Kitchen Display
│   └── c4-model/                #   Structural source of truth
│
├── standards/                   # HOW — conventions and constraints
│
└── decisions/                   # WHY THIS — ADRs with scope
    ├── ADR-0001-solution-dotnet-platform.md
    ├── ADR-0002-application-order-api-in-memory-storage.md
    └── ADR-0003-solution-rest-http-polling.md
</code></pre></div></div>

<p>Notice that the directory structure matches the abstraction layers. Business is self-contained — you can read it without knowing anything about the solution. Solution references business scenarios but never the other way around. Decisions are scoped by area so an agent working on a specific application only loads the decisions relevant to that application.</p>

<h2 id="progressive-context-loading">Progressive context loading</h2>

<p>This layering also solves the context overload problem.</p>

<p><a href="/assets/2026/03/wwh-context-problem.png"><img src="/assets/2026/03/wwh-context-problem.png" alt="The context problem" /></a></p>

<p>When every markdown file sits at the same level, agents treat them all as equally important. A vision statement, a brainstorming scratch pad, an old spec plan, and half-finished research findings all look the same. The agent loads everything and the signal drowns in noise.</p>

<p>With the layered structure, <strong>directory depth matches abstraction depth.</strong> An agent working on business framing loads the <code class="language-plaintext highlighter-rouge">business/</code> folder — it does not need solution details. An agent working on the order API loads <code class="language-plaintext highlighter-rouge">solution/applications/order-api/</code> — it does not need to read every persona and journey. An agent helping with system-level architecture loads <code class="language-plaintext highlighter-rouge">solution/solution-context.md</code> — it does not need application-level flows.</p>

<p>This is not just about agents. New team members orient faster too. You read the business context to understand the problem, skim the solution context to understand the shape, and dive into the specific application you are working on.</p>

<h2 id="getting-started">Getting started</h2>

<p>You do not need all of this on day one. The framework includes a bootstrap playbook with phases:</p>

<ol>
  <li><strong>Foundation</strong> — four files: <code class="language-plaintext highlighter-rouge">business-context.md</code>, <code class="language-plaintext highlighter-rouge">vision.md</code>, <code class="language-plaintext highlighter-rouge">outcomes.md</code>, <code class="language-plaintext highlighter-rouge">scope.md</code>. Just enough to explain what the project is, who it serves, and what it will do.</li>
  <li><strong>Who and Why</strong> — at least one persona, one journey, one scenario. Enough to ground the work in real user behaviour.</li>
  <li><strong>Solution Structure</strong> — system context, applications identified, first ADR. Enough to see the structural shape.</li>
  <li><strong>Depth</strong> — flows, components, BDD tests, standards. Add these as the project needs them.</li>
</ol>

<p>Start with Phase 1. Copy the <code class="language-plaintext highlighter-rouge">docs/</code> folder from the <a href="https://github.com/DavidBurela/why-what-how">why-what-how</a> framework repository into your project. It contains the guidance files that define the model, conventions, folder structure, and bootstrap playbook. Populate the four Phase 1 files with real content about your project. Build depth incrementally from there.</p>

<p>If you want to see what a fully populated example looks like, explore the <a href="https://github.com/DavidBurela/why-what-how-bubbletea-kiosk-example">bubble tea kiosk example</a>.</p>

<h2 id="closing">Closing</h2>

<p>The core idea is not complicated. Separate the layers of abstraction. Give each one a canonical home. Stop making agents and humans search through everything to find the signal.</p>

<p>Capture the business intent in one place. Capture the solution structure in another. Keep your standards and decisions alongside them. Let your existing workflows feed into the structure, and let the structure give back high-signal, consistent, up-to-date context for everything that comes next.</p>

<ul>
  <li><strong>Framework and guidance files:</strong> <a href="https://github.com/DavidBurela/why-what-how">why-what-how</a></li>
  <li><strong>Worked example:</strong> <a href="https://github.com/DavidBurela/why-what-how-bubbletea-kiosk-example">why-what-how-bubbletea-kiosk-example</a></li>
</ul>]]></content>
      

      
      
      
      
      
      <author>
        <name>[&quot;David Burela&quot;]</name>
        
        
      </author>

      
        
      

      

      
      
        <summary type="html"><![CDATA[❗ DRAFT: This is an early draft that I am sharing. Needs further refinement and editing ❗]]></summary>
      

      
      
    </entry>
  
    <entry>
      
      <title type="html">Capturing project knowledge to help coding agents</title>
      <link href="https://blog.davidburela.com/2026/03/11/capturing-project-knowledge-to-help-coding-agents/" rel="alternate" type="text/html" title="Capturing project knowledge to help coding agents" />
      <published>2026-03-11T00:00:00+00:00</published>
      <updated>2026-03-11T00:00:00+00:00</updated>
      <id>https://blog.davidburela.com/2026/03/11/capturing-project-knowledge-to-help-coding-agents</id>

      
      
        <content type="html" xml:base="https://blog.davidburela.com/2026/03/11/capturing-project-knowledge-to-help-coding-agents/"><![CDATA[<p>When I talk to engineers who are just starting to use coding agents, I often see the same pattern. They use the agent in an interactive way asking for a small refactor, a tweak to a component, or a new feature in a file they are working on. The agent makes a change, but not in the way they expected (it changed multiple files, implemented a different pattern, put things in the wrong place). So they try asking for agent to correct it, the agent tries again, and before long the whole thing starts to feel more frustrating than helpful.</p>

<p>What I have found is that the frustration often is not that the coding agent is bad at coding. It is that we leave too much project knowledge implicit. We know which logging approach the team uses, which packages are preferred, how components are usually structured, how testing is done, what internal standards apply, and which patterns are already considered normal in the repository. We rarely write all of that down when we prompt an agent. But if it is not captured somewhere, the agent still has to do something, so it fills in the gaps with guesses. The more the agent has to guess, the more inconsistent the results feel.</p>

<p>Over time, my workflow has changed. I started with the same prompt-by-prompt approach. Then I got better at describing the specific state change I wanted to make in the repository. But the biggest improvement came when I stopped repeating the same background and standards in every session, and instead started capturing that knowledge in markdown files inside the repository. That gave the agent a much better starting point. It did not need to keep rediscovering how the project works, and it did not need to reinvent patterns each time. The result was not perfection, but it was much more consistent.</p>

<p>That is probably the most useful advice I would give to anyone getting started with coding agents: <strong>capture the project knowledge that Agents should not have to guess.</strong></p>

<h2 id="where-the-frustration-comes-from">Where the frustration comes from</h2>

<p>The request to the Agent is often broad enough that the agent has to interpret what the user meant. It may choose a pattern the user did not want, change more files than expected, or implement the right idea in the wrong way. The user then has to clarify, correct, and redirect. After a few rounds, <strong>it can start to feel like you are spending more time correcting the agent than getting useful work done</strong>.</p>

<p>In an existing codebase, there are usually dozens of unwritten rules and norms. There may be a preferred logging library, a standard testing pattern, an expected way to structure components, internal security requirements, or assumptions about how services interact. Co-workers usually absorb these over time. Coding agents do not. They can only work from what they can infer from the repository and what you give them in context.</p>

<p>When that context is missing, the agent has to guess. Sometimes those guesses are reasonable. Sometimes they are not what you wanted. Either way, the more the agent has to infer from scattered clues, the more variable the results become.</p>

<h2 id="how-my-workflow-changed">How my workflow changed</h2>

<h3 id="stage-1-interactive-prompting">Stage 1: Interactive prompting</h3>

<p>I would ask the agent directly for a small change, look at the result, and then steer it with follow-up messages.</p>

<p>That works up to a point. But it puts a lot of weight on the agent interpreting a short request correctly while also piecing together how the repository already works.</p>

<h3 id="stage-2-better-scoped-state-changes">Stage 2: Better-scoped state changes</h3>

<p>The next shift for me was getting better at describing the intended state change in the repository.</p>

<p>Instead of vaguely asking for a refactor or a feature, I started being more explicit about what should change, what should stay the same, and how I would know the work was done correctly. This is where approaches like SDD (Spec Driven Development), RPI (research-plan-implement) loops, tools like in my previous post on <a href="/2025/10/07/github-spec-kit/">GitHub Spec Kit</a>, or other similar workflows can help. The useful part is not the label. It is that they force you to describe the change more clearly.</p>

<p>That helps a lot. But I found there was still a limit. I kept repeating the same background information, standards, and expectations across different pieces of work. And if I forgot to include one of them, the agent would often fall back to a different interpretation.</p>

<h3 id="stage-3-central-project-knowledge">Stage 3: Central project knowledge</h3>

<p>The biggest improvement came when I realised I could move a lot of that repeated information into a more central place in the repository.</p>

<p>Instead of cramming everything into a prompt or repeating it in every spec, I started capturing recurring knowledge in markdown files. Things like how logging is done, which packages are preferred, what testing patterns the project uses, what internal requirements apply, and even high-level background on what the system does and how the repository is organised.</p>

<p>That changed the role of the prompt. Instead of carrying all the context itself, the prompt could focus more on the specific state change I wanted, while the repository already held the background knowledge and standards the agent should follow.</p>

<h2 id="capture-knowledge-centrally">Capture knowledge centrally</h2>

<p>The practical lesson for me was: <strong>capture the things the agent should not have to guess. Save them as markdown files in your repository so that it is explicit, and the Agent doesn’t need to guess or assume each time.</strong></p>

<p>Which could include:</p>

<ul>
  <li>logging and observability standards</li>
  <li>package and library choices</li>
  <li>testing patterns</li>
  <li>UI conventions</li>
  <li>coding standards and common patterns</li>
  <li>service boundaries and repository structure</li>
  <li>project background and system context</li>
  <li>secrets handling and security requirements</li>
  <li>internal company requirements (internal libraries, internal services that must be used, etc)</li>
</ul>

<p>A lot of this is useful for people too, but it is especially useful for agents. It gives them a clearer baseline for how work is expected to be done in this repository.</p>

<p>It also reduces wasted effort. Instead of traversing the repository from scratch each time and trying to infer the local norms, the agent can start from a clearer understanding of the project.</p>

<h2 id="example-logging">Example: Logging</h2>

<p>Across different changes, I would ask the agent to add a feature, and it would reimplement logging in a different way each time. The agent would see it needed to log, it would implement it again, without realising that it is already available in other parts of the codebase. The Agent was just trying to infer how logging should be done from the local context it had at that moment.</p>

<p>I captured the expected logging approach in markdown, the package we use, and a short code example. Afterwards the results became much more consistent. The agent no longer had to guess which pattern to follow. It had a clear reference point inside the repository.</p>

<p>That was the moment it really clicked for me. A lot of the problem was the missing context.</p>

<h2 id="how-to-get-started-right-now">How to get started right now</h2>

<p>Keep it lightweight.</p>

<p>You do not need a big methodology before this becomes useful. Just start by capturing the things your agent should know so it does not have to keep guessing. That could be logging, testing conventions, preferred packages, service boundaries, security expectations, or a high-level map of the repository.</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code># example folder structure
docs/
  agent-context/
    architecture-overview.md
    repo-conventions.md
    logging.md
    observability.md
    security-practices.md
    testing-and-quality.md
</code></pre></div></div>

<h3 id="use-the-agent-to-help-bootstrap-the-context">Use the Agent to help bootstrap the context</h3>

<p>You can use an agent to inspect the repository and capture useful context such as where the main services live, what the standard code structure looks like, how logging is currently done, how secrets are handled, and which libraries are already used and preferred.</p>

<p>If your tooling supports <code class="language-plaintext highlighter-rouge">AGENTS.md</code>, you can have it point it to where the knowledge files live.</p>

<p>Here are two example prompts you could try to get started quickly. One focused on a single cross-cutting concern, and the other a broader prompt to help bootstrap the entire repository context.</p>

<h3 id="example-prompt---logging-standard">Example prompt - Logging standard</h3>

<p>A focused example of how you could prompt your Agent to generate it for you.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Analyse the repository and determine how logging is implemented across the codebase.

Look for:
- logging frameworks and libraries in use
- log structure and field conventions
- correlation or trace ID handling
- severity levels and naming conventions
- where logging is expected in application flows
- error logging vs informational logging patterns
- any shared wrappers, helper utilities, or middleware
- any gaps, inconsistencies, or duplicate approaches

Capture the findings in `docs/agent-context/logging.md` as reusable guidance for future coding agents.
</code></pre></div></div>

<h3 id="example-prompt---knowledge-bootstrap">Example prompt - Knowledge bootstrap</h3>

<p>A more broad example of prompting to have it pre-process and analyse your implicit standards.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Analyse the repository and prepare reusable context for future coding agents.

Your goal is to pre-process the codebase and capture the most important implementation knowledge into focused markdown files under `docs/agent-context/`.

Inspect the repository for:
- service and application boundaries
- major modules and responsibilities
- key architectural and integration patterns
- primary technologies, frameworks, and libraries
- security-related practices and constraints
- observability patterns such as logging, tracing, metrics, and error handling
- configuration and environment conventions
- testing approach and quality gates
- common coding patterns, abstractions, and shared utilities
- important repo-specific conventions that a new agent should follow

Create a small set of focused markdown files, for example:
- `docs/agent-context/architecture-overview.md`
- `docs/agent-context/service-boundaries.md`
- `docs/agent-context/technology-stack.md`
- `docs/agent-context/security-practices.md`
- `docs/agent-context/observability.md`
- `docs/agent-context/testing-and-quality.md`
- `docs/agent-context/repo-conventions.md`

For each file:
- capture what is actually true in this repository
- write concise guidance that another agent can use later when making changes
- include concrete examples or file references where helpful
- call out inconsistencies, partial migrations, or unclear areas
- avoid repeating the same content across files

Update or create the root `AGENTS.md` so future agents can discover this knowledge easily. Add a short section that:
- explains that repo-specific reusable context lives under `docs/agent-context/`
- lists the most important files
- tells agents to read the relevant files before making changes in those areas

Do not produce a vague documentation dump. Synthesize the repository into practical, repo-specific context that helps future agents make better implementation decisions.
</code></pre></div></div>

<h2 id="closing">Closing</h2>

<p>The main idea is simple: if the project has standards, patterns, and background information that helps, capture them somewhere central. The less the agent has to infer from scratch, the more consistent its work will be.</p>

<p>If you are looking for a better way to work with coding agents, this is probably the first place I would start.</p>]]></content>
      

      
      
      
      
      
      <author>
        <name>[&quot;David Burela&quot;]</name>
        
        
      </author>

      
        
      

      

      
      
        <summary type="html"><![CDATA[When I talk to engineers who are just starting to use coding agents, I often see the same pattern. They use the agent in an interactive way asking for a small refactor, a tweak to a component, or a new feature in a file they are working on. The agent makes a change, but not in the way they expected (it changed multiple files, implemented a different pattern, put things in the wrong place). So they try asking for agent to correct it, the agent tries again, and before long the whole thing starts to feel more frustrating than helpful.]]></summary>
      

      
      
    </entry>
  
    <entry>
      
      <title type="html">GitHub Spec Kit</title>
      <link href="https://blog.davidburela.com/2025/10/07/github-spec-kit/" rel="alternate" type="text/html" title="GitHub Spec Kit" />
      <published>2025-10-07T00:00:00+00:00</published>
      <updated>2025-10-07T00:00:00+00:00</updated>
      <id>https://blog.davidburela.com/2025/10/07/github-spec-kit</id>

      
      
        <content type="html" xml:base="https://blog.davidburela.com/2025/10/07/github-spec-kit/"><![CDATA[<p>GitHub Spec Kit was released in only the past few weeks. I have been experimenting with using it on my projects. As well as trying to stay across the changes and sentiments by consuming a lot of media, tutorials, and reading through the repo discussions &amp; issues. As it is still early days and everyone is learning, I wanted to write up and share the current state of where the project is at, and how we’re all learning to use it.</p>

<h2 id="github-spec-kit-overview">GitHub Spec Kit overview</h2>

<p>Spec Kit is an open‑source toolkit for <strong>spec‑driven development</strong>. Instead of vibe‑coding toward a moving target, you capture intent in a short spec, clarify what’s fuzzy, plan the how, slice it into tasks, and then let your coding agent implement inside clear guardrails.</p>

<p><strong>Spec‑Driven Development (SDD)</strong> puts <em>intent before implementation</em>. You write the <strong>what/why</strong> as a tech‑agnostic spec; the <strong>how</strong> lives in a separate plan. The spec becomes the shared source of truth for humans and agents. When something doesn’t make sense you fix the spec first, not the code.</p>

<p>I’ve been using coding agents, and they are great for quickly experimenting and iterating. But once you get to larger more complex changes I was getting frustrated at the Agent changing unrelated things. I was spending more time correcting the agent than progressing. So far I am enjoying Spec Kit’s hierarchical structured way of directing the Agent.</p>

<h3 id="is-it-too-heavy">Is it too heavy?</h3>

<p>This is the most common question I am asked. For simple demos and test apps it can feel like a lot of overhead. There is a hierarchy of documents, and it does take some time to set up the initial constitution and first spec.</p>

<p>But once you’re working on larger features, or have constraints you need to uphold (security, architectural patterns, compliance) this structure looks to pay for itself quickly. Where I think it really earns its keep is in larger messy, real‑world projects.</p>

<h2 id="main-use-cases-for-spec-kit">Main use cases for Spec Kit</h2>

<ol>
  <li><strong>Greenfield</strong>
    <ul>
      <li>Where I expect most will start playing.</li>
      <li>Allows you to get the guardrails and vocabulary baked in early, getting consistent outcomes from the start.</li>
    </ul>
  </li>
  <li><strong>Existing systems -</strong> Adding new features
    <ul>
      <li>In my opinion this is the best place for people to start playing with it on real projects.</li>
      <li>Planning inside constraints of a large codebase without breaking patterns.</li>
    </ul>
  </li>
  <li><strong>Legacy modernisation</strong>
    <ul>
      <li>(In theory) Modernise a legacy system to a current tech stack and code base.</li>
      <li>Use an agent to capture business intent from an existing system, capture it in the specs. Rebuild from those specs with a fresh architecture plan.</li>
      <li>However I think the tooling still needs to mature before this becomes practical.</li>
    </ul>
  </li>
</ol>

<h2 id="getting-set-up">Getting set up</h2>

<ul>
  <li>Install instructions on <a href="https://github.com/github/spec-kit ">https://github.com/github/spec-kit </a></li>
  <li>Installation CLI allows you to select your coding Agent (Copilot, Claude, Cursor, etc).</li>
  <li>Then it pulls down the Agent‑specific prompts, scripts, and markdown templates into <code class="language-plaintext highlighter-rouge">.github/prompts</code> and <code class="language-plaintext highlighter-rouge">.specify</code>.</li>
  <li>From there you can start using the <code class="language-plaintext highlighter-rouge">/slash</code> commands inside your chosen Agent.</li>
</ul>

<h2 id="the-core-flow">The core flow</h2>

<p>The flow keeps the what and why separate from the how. You set project rules, write the spec, answer clarifying questions, create a plan, turn it into small tasks, run a consistency check, then let the agent implement with review at each step.</p>

<p><a href="/assets/2025/10/spec-kit-flow.png"><img src="/assets/2025/10/spec-kit-flow.png" alt="GitHub Spec Kit flow" /></a></p>

<h3 id="constitution">/constitution</h3>

<ul>
  <li><strong>Purpose:</strong> Set the non‑negotiables, your project’s guardrails.</li>
</ul>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Example prompt:
/constitution Set project law for a web app. Keep the current stack. Library first. Simplicity over abstraction. Integration‑first testing. Enforce auth on all routes. No PII in logs. Encrypt at rest and in transit. Use our design system only. Secrets via env. Allowed regions AU and EU.
</code></pre></div></div>

<p>The constitution defines the boundaries your project operates within. It captures your non‑negotiables: security rules, coding standards, and architectural principles. Everything that follows must stay within these constraints. Keep the constitution short and stable, link out to heavy policy docs.</p>

<p><strong>What belongs in</strong> <code class="language-plaintext highlighter-rouge">constitution.md</code></p>

<ul>
  <li><strong>Security and compliance:</strong> auth, data handling, logging, PII, encryption.</li>
  <li><strong>Coding conventions:</strong> naming, folder layout, code style.</li>
  <li><strong>Architecture rules:</strong> interfaces first, simplicity, integration-first testing.</li>
  <li><strong>Organisational policies:</strong> approved services, geo restrictions, banned libraries, licenses.</li>
</ul>

<h3 id="specify">/specify</h3>

<ul>
  <li><strong>Purpose:</strong> Describe the product goals and outcomes without naming tech.</li>
</ul>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Example prompt:
/specify Add a “favorites” feature so users can star recipes in the cooking app. Keep tech‑agnostic. Include user story, acceptance scenarios, requirements (user + recipe + favorite), and success metrics.
</code></pre></div></div>

<p>Explain the WHAT and WHY, in plain language without naming technology. Put the user story, acceptance criteria, any constraints that matter, dependencies it must respect, and how you will measure success. Then review the draft to tighten scope, remove anything off-mission, and make sure the outcomes are specific and testable before moving on.  <br />
Anything unclear will be marked with <code class="language-plaintext highlighter-rouge">[NEEDS CLARIFICATION]</code> for review.</p>

<p><strong>What belongs in</strong> <code class="language-plaintext highlighter-rouge">spec.md</code></p>

<ul>
  <li>
    <p><strong>User scenarios:</strong> primary story, acceptance scenarios, and critical edge cases.</p>
  </li>
  <li>
    <p><strong>Key entities:</strong> core data concepts and relationships.</p>
  </li>
  <li>
    <p><strong>Review &amp; acceptance checklist:</strong> measurable success criteria, scope bounds, dependencies/assumptions.</p>
  </li>
</ul>

<h3 id="clarify">/clarify</h3>

<ul>
  <li><strong>Purpose:</strong> Resolve the missing or ambiguous details before moving on.</li>
</ul>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Example prompt: invoke directly
/clarify
</code></pre></div></div>

<p>Runs a quick Q&amp;A to surface anything underspecified, ambiguous, or needing clarification. Like answering PM or QA review questions before coding starts. This step reduces rework later by pinning down details early to prevent the Agent going off on a tangent. The prompt helpfully gets the Agent to provide multiple choice suggestions for each clarifying question, to help seed your answer.</p>

<p>e.g. How should the list be ordered? By name or date. How many rows per page?</p>

<p><strong>Notes</strong></p>

<ul>
  <li>This is fun. Doing quickfire questions and selecting from the multiple choice lets you quickly clarify, and shows you how much context we just assume.</li>
</ul>

<h3 id="plan">/plan</h3>

<ul>
  <li><strong>Purpose:</strong> Define how it will be built. Being explicit with tech stack &amp; frameworks.</li>
</ul>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Example prompt:
/plan Use the current stack (React + Node.js + PostgreSQL). Show repo structure, API contracts for add and remove favorite, testing approach, environment setup, and rollback considerations.
</code></pre></div></div>

<p>Time to define the HOW we want this built. Describe the technology choices and implementation details. Specify the stack, frameworks, and dependencies. Outline the repository layout, contracts, data model, environment setup, and test approach.</p>

<p>If something is missed or you change direction later, simply regenerate the plan from the same spec with updated inputs or new tech choices.</p>

<p><strong>What belongs in</strong> <code class="language-plaintext highlighter-rouge">plan.md</code></p>

<ul>
  <li>
    <p><strong>The tech stack:</strong> language, frameworks, dependencies, databases, target platforms.</p>
  </li>
  <li>
    <p><strong>Constitution check &amp; structure:</strong> how the design satisfies the rules and the concrete repo layout.</p>
  </li>
  <li>
    <p><strong>Design outputs:</strong> data-model, API contracts, quickstart guide or setup steps.</p>
  </li>
  <li>
    <p><strong>Testing and tooling:</strong> test approach, coverage goals</p>
  </li>
</ul>

<h3 id="tasks">/tasks</h3>

<ul>
  <li><strong>Purpose:</strong> Break the plan into small manageable chunks of work ready for implementation.</li>
</ul>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Example prompt
/tasks Create phases and small tasks with acceptance criteria. Start with contracts and tests, then implementation, then polish.
</code></pre></div></div>

<p>Breaks the plan down into small, verifiable units of work. Each task is meant to be implemented and tested in isolation, ideally small enough to fit in a single commit. Tasks are grouped into phases such as create tests first, verify tests fail, implement, then polish.</p>

<p><strong>What belongs in</strong> <code class="language-plaintext highlighter-rouge">tasks.md</code></p>

<ul>
  <li><strong>Implementation tasks:</strong> as small atomic pieces of work that can be done in a commit.</li>
  <li><strong>Phases &amp; order:</strong> e.g. setup → tests first (must fail) → implementation → integration → polish.</li>
  <li><strong>Validation gates:</strong> checklist to confirm before Agent progresses.</li>
  <li><strong>Note:</strong> Don’t check this in. Throw it away. Regenerate if needed.</li>
</ul>

<h3 id="analyze">/analyze</h3>

<ul>
  <li><strong>Purpose:</strong> Consistency and compliance check across all the documents before coding.</li>
</ul>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Example prompt: invoke directly, it is a validator
/analyze
</code></pre></div></div>

<p>Checks for any conflicting information or inconsistencies across the documents. It cross‑checks the spec, plan, and tasks against the constitution, flagging conflicts and ambiguities by severity so you know what to act on first. It stays neutral about technology and focuses on your rules and internal consistency. Especially good at spotting naming drift between specs and tasks that would slow code review.</p>

<p><strong>Notes</strong></p>

<ul>
  <li>Think of it as a pre‑flight check.</li>
  <li>When teams are involved, assign each unresolved ambiguity to an owner.</li>
  <li>Re‑run it after big spec edits, plan changes, or updates to included design docs.</li>
</ul>

<h3 id="implement">/implement</h3>

<ul>
  <li><strong>Purpose:</strong> Generate code one task at a time, with human oversight.</li>
</ul>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Example prompt
/implement Run tasks in order. Pause after each for review. If a task fails checks, revise the plan and continue.
</code></pre></div></div>

<p>Steps through the tasks, generating code according to the plan and constitution. Each output is reviewed before moving forward. Code is delivered task by task, with the Agent doing it iteratively not as one big dump.</p>

<p><strong>Notes</strong></p>

<ul>
  <li>Follow task order and stop if a task doesn’t meet its acceptance criteria.</li>
  <li>Keep the constitution in view. Don’t introduce new dependencies or patterns that the plan didn’t allow.</li>
  <li>Re‑run analyze after large refactors or when generated code drifts from the plan.</li>
</ul>

<h2 id="experimenting-with-tech-stacks">Experimenting with tech stacks</h2>

<p>The separation between the What &amp; Why (<code class="language-plaintext highlighter-rouge">spec.md</code>) and the How (<code class="language-plaintext highlighter-rouge">plan.md</code>) allows you to run quick throwaway spikes to experiment with different tech stacks and implementations.</p>

<p>Allows you to experiment implementing a console app in Dotnet, and then Golang.</p>

<ul>
  <li>Start from the same spec. Create alternate implementation plans with different stacks, libraries, or deployment targets.</li>
  <li>Do not worry about completeness; plans are cheap to regenerate from the same spec with new inputs.</li>
  <li>If a spike uncovers something that changes your understanding, write that back into the spec or constitution.</li>
</ul>

<h2 id="handling-spec-kit-on-longterm-projects">Handling Spec Kit on Long‑term projects</h2>

<p>Most of this comes down to how you want to maintain context over time. Pick a strategy and be consistent.</p>

<h3 id="living-specs">Living specs</h3>

<ul>
  <li>
    <p><strong>When to use:</strong> Fast-moving teams; likely re-implementation on new stacks.</p>
  </li>
  <li>
    <p>Keep the spec up to date so it always matches the current state and learnings.</p>
  </li>
  <li>
    <p>Great for cutting edge work where platforms, frameworks, libraries are still in flux. Can reimplement spec on a new tech stack at any time.</p>
  </li>
  <li>
    <p><strong>Cons:</strong> needs discipline. Reviewers must police drift.</p>
  </li>
</ul>

<h3 id="rolling-specs-adr-style">Rolling specs (ADR-style)</h3>

<ul>
  <li>
    <p><strong>When to use:</strong> Long-lived systems wanting the history of changes.</p>
  </li>
  <li>
    <p>Treat specs like ADRs. Write a new spec that supersedes or extends the old one.</p>
  </li>
  <li>
    <p>Clean history, strong traceability, easier audits.</p>
  </li>
  <li>
    <p><strong>Cons:</strong> you must “play back” a sequence of specs to see the final state.</p>
  </li>
</ul>

<h3 id="context-snapshots">Context snapshots</h3>

<ul>
  <li><strong>When to use:</strong> Working with different agents. Short lived specs to make changes.</li>
  <li>Maintain a living summary set e.g. <code class="language-plaintext highlighter-rouge">docs/context.md</code>, <code class="language-plaintext highlighter-rouge">docs/architecture.md</code>.</li>
  <li>For a change, write a feature spec and plan, implement, delete.</li>
  <li>Fold only durable learnings into the summary set.</li>
  <li>A strategy to use Spec Kit to direct single changes, while keeping repo clean with standard agent context files.</li>
</ul>

<h3 id="quick-guide">Quick guide</h3>

<ul>
  <li>
    <p>Will we want to regenerate the app later from specs?</p>

    <ul>
      <li>Yes → Living specs.</li>
    </ul>
  </li>
  <li>
    <p>Do we need strong traceability over time?</p>

    <ul>
      <li>Yes → Rolling specs.</li>
    </ul>
  </li>
  <li>
    <p>Do we mainly need a small, current context for agents?</p>

    <ul>
      <li>Yes → Context snapshots.</li>
    </ul>
  </li>
</ul>

<h2 id="community-feedback">Community feedback</h2>

<p>Early feedback and discussions I’ve seen around ways of using, friction points, and requested features.</p>

<h3 id="forced-branching-strategy">Forced branching strategy</h3>

<p>My biggest friction point. Calling <code class="language-plaintext highlighter-rouge">/specify</code> creates a new branch for your feature. I prefer being in control of my branches.</p>

<p><strong>Roadmap plans:</strong>  Adding flags to opt out of auto-branching or set branch name patterns.</p>

<h3 id="forced-tdd-workflow"><strong>Forced TDD workflow</strong></h3>

<p>Prompts &amp; templates written with a heavy emphasis on TDD. Impractical for many types of work (doc updates, styling, etc).</p>

<p><strong>Roadmap plans:</strong> Acting on the feedback, are creating a set of prompts without the TDD.</p>

<h3 id="monorepo">Monorepo</h3>

<p>Spec Kit assumes a monorepo, with <code class="language-plaintext highlighter-rouge">.specify</code> in the project root. But different projects within repo may want different <code class="language-plaintext highlighter-rouge">constitution.md</code> files (backend, API, front end, etc). </p>

<p><strong>Roadmap plans:</strong> Looking to allow <code class="language-plaintext highlighter-rouge">.specify</code> folders throughout the repo for more specific context.</p>

<h3 id="org-level-constitution--security-docs">Org level Constitution &amp; security docs</h3>

<p>Relevant to all coding Agents. Documenting your organisation’s standards (security, etc) will enhance the context of any Agent. The <code class="language-plaintext highlighter-rouge">constitution.md</code> file can then link to those files.</p>

<p><strong>Tip:</strong> Start capturing your standards around security, compliance, data handling, logging, PII, encryption.</p>

<h2 id="closing">Closing</h2>

<p>I’m enjoying the work flow of Spec Kit and I’ll keep using it on real features. I’ll try the long-term context strategies, then share back what works. </p>

<p>This space is actively developing new strategies weekly. If you’ve found patterns that help, I want to learn from them too.</p>

<h3 id="quick-takeaways">Quick takeaways</h3>

<ul>
  <li>Keep <code class="language-plaintext highlighter-rouge">constitution.md</code> short. Link to org standards.</li>
  <li>Treat <code class="language-plaintext highlighter-rouge">spec.md</code> as the source of truth. Update it while working on the feature.</li>
  <li>Regenerate <code class="language-plaintext highlighter-rouge">plan.md</code> when tech choices change.</li>
  <li>Delete <code class="language-plaintext highlighter-rouge">tasks.md</code> before merging.</li>
</ul>

<hr />
<h2 id="demos">Demos</h2>
<p>For my demos I created this example for a “bubble tea ordering system”.</p>

<h3 id="constitution-1">Constitution</h3>
<p>Set things up for a shop that has bad connectivity, they just want to something standalone.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/constitution for a bubble tea shop.

Context: In-shop use; the system must work without internet access and produce deterministic results.
Constraints: Local-only data/config; no external APIs/services; no telemetry; minimal dependencies; fast startup; small footprint.
Ops: Friendly, actionable errors; simple logs to local disk; clear README quickstart.
</code></pre></div></div>

<h3 id="specify-1">Specify</h3>
<p>Let it infer the model from the catalog</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/specify a "Bubble Tea ordering system"

User can select one of two flows:
1) Signatures: user picks a predefined drink (from catalog.yml) and sees the final total (AUD price, sugar grams, allergen badges). 
2) Build Your Own: step through Size → Base → Milk → Sweetness → Ice → Toppings; show the same final total.

Requirements: 
- Import options from ./data/catalog.yml (sizes, bases, milks, sweetness, ice, toppings, signatures).
- Pricing = size.base_price + milk.price_delta + Σ(topping.price) + sweetness.price_delta; round total to nearest $0.05.
- Sugar(g) = size.sugar_g_base × sweetness.sugar_mult.
- Allergen badges derived from milk/toppings (dairy, egg).

Data model:
- Infer entities/fields from catalog.yml
</code></pre></div></div>

<h3 id="plan-1">Plan</h3>
<p>Showing you can implement the same spec in two completely different technologies and user interfaces</p>

<h4 id="dotnet-9-cli">Dotnet 9 CLI</h4>
<p>Creating it with a terminal UI! Quicker to generate, and usually pretty consistent good results.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/plan we are building a .NET 9 interactive CLI using Spectre.Console; offline-only.

Read ./data/catalog.yml with YamlDotNet.
Keep dependencies minimal; no external APIs/telemetry.
</code></pre></div></div>

<h4 id="vue--vite">Vue + Vite</h4>
<p>Completely client side web app</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/plan Client-only web app with Vue 3 + Vite; no backend. 
Convert data/catalog.yml → public/catalog.json at build; fetch once on load.
Render Signatures &amp; BYO; compute totals in a small utils module; print-friendly receipt.
No external APIs/telemetry; fast startup; vibrant pastel UI.

UI: vibrant pastel cards, big tile buttons, emoji badges; print-friendly receipt. Minimal local CSS.
</code></pre></div></div>

<h4 id="flask--htmx">Flask + HTMX</h4>
<p>Need to provide a bit more of the how, as there is more UI to build and a frontent/backend. This one takes a much agent coding time to complete</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/plan Python web app with Flask + Jinja + HTMX (offline-only). 
No server session/state; No DB/auth/external APIs; deterministic outputs.
Load ./data/catalog.yml at startup (PyYAML).

Server-render full pages with Jinja; use small Jinja partials (e.g., _summary.html, _totals.html) for fragments.
/calc recomputes totals from catalog.yml each time and returns a fragment to swap in.
HTMX requests to include the FULL selection (size, base, milk, sweetness, ice, toppings[]) via form fields (hx-include="form").

UI: vibrant pastel cards, big tile buttons, emoji badges; print-friendly receipt. Minimal local CSS.
</code></pre></div></div>

<h3 id="catalogyml">catalog.yml</h3>
<p>I place this file at <code class="language-plaintext highlighter-rouge">data/catalog.yml</code> to drive the creation.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">schema_version</span><span class="pi">:</span> <span class="s2">"</span><span class="s">bubble-tea-catalog/v1"</span>
<span class="na">currency</span><span class="pi">:</span> <span class="s2">"</span><span class="s">AUD"</span>

<span class="na">defaults</span><span class="pi">:</span>
  <span class="na">milk</span><span class="pi">:</span> <span class="s">none</span>
  <span class="na">ice</span><span class="pi">:</span> <span class="s">normal</span>
  <span class="na">sweetness_pct</span><span class="pi">:</span> <span class="m">100</span>

<span class="na">limits</span><span class="pi">:</span>
  <span class="na">max_toppings</span><span class="pi">:</span> <span class="m">3</span>
  <span class="na">allow_duplicate_toppings</span><span class="pi">:</span> <span class="kc">false</span>

<span class="na">sizes</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">S</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Small</span><span class="nv"> </span><span class="s">360ml"</span><span class="pi">,</span> <span class="nv">base_price</span><span class="pi">:</span> <span class="nv">5.0</span><span class="pi">,</span> <span class="nv">sugar_g_base</span><span class="pi">:</span> <span class="nv">30</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">M</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Medium</span><span class="nv"> </span><span class="s">500ml"</span><span class="pi">,</span> <span class="nv">base_price</span><span class="pi">:</span> <span class="nv">6.0</span><span class="pi">,</span> <span class="nv">sugar_g_base</span><span class="pi">:</span> <span class="nv">40</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">L</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Large</span><span class="nv"> </span><span class="s">700ml"</span><span class="pi">,</span> <span class="nv">base_price</span><span class="pi">:</span> <span class="nv">7.0</span><span class="pi">,</span> <span class="nv">sugar_g_base</span><span class="pi">:</span> <span class="nv">55</span> <span class="pi">}</span>

<span class="na">bases</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">black</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Black</span><span class="nv"> </span><span class="s">Tea"</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">oolong</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Oolong</span><span class="nv"> </span><span class="s">Tea"</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">jasmine</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Jasmine</span><span class="nv"> </span><span class="s">Green</span><span class="nv"> </span><span class="s">Tea"</span> <span class="pi">}</span>

<span class="na">milks</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">none</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">No</span><span class="nv"> </span><span class="s">Milk"</span><span class="pi">,</span> <span class="nv">dairy</span><span class="pi">:</span> <span class="nv">false</span><span class="pi">,</span> <span class="nv">price_delta</span><span class="pi">:</span> <span class="nv">0.0</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">fresh</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Fresh</span><span class="nv"> </span><span class="s">Milk"</span><span class="pi">,</span> <span class="nv">dairy</span><span class="pi">:</span> <span class="nv">true</span><span class="pi">,</span> <span class="nv">price_delta</span><span class="pi">:</span> <span class="nv">0.8</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">oat</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Oat</span><span class="nv"> </span><span class="s">Milk"</span><span class="pi">,</span> <span class="nv">dairy</span><span class="pi">:</span> <span class="nv">false</span><span class="pi">,</span> <span class="nv">price_delta</span><span class="pi">:</span> <span class="nv">1.0</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">creamer</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Non-dairy</span><span class="nv"> </span><span class="s">Creamer"</span><span class="pi">,</span> <span class="nv">dairy</span><span class="pi">:</span> <span class="nv">false</span><span class="pi">,</span> <span class="nv">price_delta</span><span class="pi">:</span> <span class="nv">0.6</span> <span class="pi">}</span>

<span class="na">sweetness</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">pct</span><span class="pi">:</span> <span class="nv">0</span><span class="pi">,</span> <span class="nv">label</span><span class="pi">:</span> <span class="s2">"</span><span class="s">0%"</span><span class="pi">,</span> <span class="nv">sugar_mult</span><span class="pi">:</span> <span class="nv">0.00</span><span class="pi">,</span> <span class="nv">price_delta</span><span class="pi">:</span> <span class="nv">0.0</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">pct</span><span class="pi">:</span> <span class="nv">25</span><span class="pi">,</span> <span class="nv">label</span><span class="pi">:</span> <span class="s2">"</span><span class="s">25%"</span><span class="pi">,</span> <span class="nv">sugar_mult</span><span class="pi">:</span> <span class="nv">0.25</span><span class="pi">,</span> <span class="nv">price_delta</span><span class="pi">:</span> <span class="nv">0.0</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">pct</span><span class="pi">:</span> <span class="nv">50</span><span class="pi">,</span> <span class="nv">label</span><span class="pi">:</span> <span class="s2">"</span><span class="s">50%"</span><span class="pi">,</span> <span class="nv">sugar_mult</span><span class="pi">:</span> <span class="nv">0.50</span><span class="pi">,</span> <span class="nv">price_delta</span><span class="pi">:</span> <span class="nv">0.0</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">pct</span><span class="pi">:</span> <span class="nv">75</span><span class="pi">,</span> <span class="nv">label</span><span class="pi">:</span> <span class="s2">"</span><span class="s">75%"</span><span class="pi">,</span> <span class="nv">sugar_mult</span><span class="pi">:</span> <span class="nv">0.75</span><span class="pi">,</span> <span class="nv">price_delta</span><span class="pi">:</span> <span class="nv">0.0</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">pct</span><span class="pi">:</span> <span class="nv">100</span><span class="pi">,</span> <span class="nv">label</span><span class="pi">:</span> <span class="s2">"</span><span class="s">100%"</span><span class="pi">,</span> <span class="nv">sugar_mult</span><span class="pi">:</span> <span class="nv">1.00</span><span class="pi">,</span> <span class="nv">price_delta</span><span class="pi">:</span> <span class="nv">0.0</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">pct</span><span class="pi">:</span> <span class="nv">125</span><span class="pi">,</span> <span class="nv">label</span><span class="pi">:</span> <span class="s2">"</span><span class="s">125%"</span><span class="pi">,</span> <span class="nv">sugar_mult</span><span class="pi">:</span> <span class="nv">1.25</span><span class="pi">,</span> <span class="nv">price_delta</span><span class="pi">:</span> <span class="nv">0.2</span> <span class="pi">}</span>

<span class="na">ice</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">none</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">No</span><span class="nv"> </span><span class="s">ice"</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">less</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Less</span><span class="nv"> </span><span class="s">ice"</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">normal</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Normal</span><span class="nv"> </span><span class="s">ice"</span> <span class="pi">}</span>

<span class="na">toppings</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">pearls</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Tapioca</span><span class="nv"> </span><span class="s">Pearls"</span><span class="pi">,</span> <span class="nv">price</span><span class="pi">:</span> <span class="nv">0.8</span><span class="pi">,</span> <span class="nv">allergens</span><span class="pi">:</span> <span class="pi">[]</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">grass</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Grass</span><span class="nv"> </span><span class="s">Jelly"</span><span class="pi">,</span> <span class="nv">price</span><span class="pi">:</span> <span class="nv">0.7</span><span class="pi">,</span> <span class="nv">allergens</span><span class="pi">:</span> <span class="pi">[]</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">cheesefoam</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Cheese</span><span class="nv"> </span><span class="s">Foam"</span><span class="pi">,</span> <span class="nv">price</span><span class="pi">:</span> <span class="nv">1.2</span><span class="pi">,</span> <span class="nv">allergens</span><span class="pi">:</span> <span class="pi">[</span><span class="nv">dairy</span><span class="pi">]</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">pudding</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Egg</span><span class="nv"> </span><span class="s">Pudding"</span><span class="pi">,</span> <span class="nv">price</span><span class="pi">:</span> <span class="nv">1.0</span><span class="pi">,</span> <span class="nv">allergens</span><span class="pi">:</span> <span class="pi">[</span><span class="nv">egg</span><span class="pi">]</span> <span class="pi">}</span>
  <span class="pi">-</span> <span class="pi">{</span> <span class="nv">key</span><span class="pi">:</span> <span class="nv">redbean</span><span class="pi">,</span> <span class="nv">display</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Red</span><span class="nv"> </span><span class="s">Bean"</span><span class="pi">,</span> <span class="nv">price</span><span class="pi">:</span> <span class="nv">0.8</span><span class="pi">,</span> <span class="nv">allergens</span><span class="pi">:</span> <span class="pi">[]</span> <span class="pi">}</span>

<span class="na">signatures</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">key</span><span class="pi">:</span> <span class="s">brown-sugar-milk</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Brown</span><span class="nv"> </span><span class="s">Sugar</span><span class="nv"> </span><span class="s">Milk</span><span class="nv"> </span><span class="s">Tea"</span>
    <span class="na">preset</span><span class="pi">:</span> <span class="pi">{</span> <span class="nv">size</span><span class="pi">:</span> <span class="nv">M</span><span class="pi">,</span> <span class="nv">base</span><span class="pi">:</span> <span class="nv">black</span><span class="pi">,</span> <span class="nv">milk</span><span class="pi">:</span> <span class="nv">fresh</span><span class="pi">,</span> <span class="nv">sweetness_pct</span><span class="pi">:</span> <span class="nv">100</span><span class="pi">,</span> <span class="nv">ice</span><span class="pi">:</span> <span class="nv">normal</span><span class="pi">,</span> <span class="nv">toppings</span><span class="pi">:</span> <span class="pi">[</span><span class="nv">pearls</span><span class="pi">]</span> <span class="pi">}</span>
    <span class="na">price_override</span><span class="pi">:</span> <span class="m">8.8</span>

  <span class="pi">-</span> <span class="na">key</span><span class="pi">:</span> <span class="s">jasmine-lychee-jelly</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Jasmine</span><span class="nv"> </span><span class="s">Lychee</span><span class="nv"> </span><span class="s">Jelly</span><span class="nv"> </span><span class="s">Tea"</span>
    <span class="na">preset</span><span class="pi">:</span> <span class="pi">{</span> <span class="nv">size</span><span class="pi">:</span> <span class="nv">L</span><span class="pi">,</span> <span class="nv">base</span><span class="pi">:</span> <span class="nv">jasmine</span><span class="pi">,</span> <span class="nv">milk</span><span class="pi">:</span> <span class="nv">none</span><span class="pi">,</span> <span class="nv">sweetness_pct</span><span class="pi">:</span> <span class="nv">50</span><span class="pi">,</span> <span class="nv">ice</span><span class="pi">:</span> <span class="nv">less</span><span class="pi">,</span> <span class="nv">toppings</span><span class="pi">:</span> <span class="pi">[</span><span class="nv">grass</span><span class="pi">]</span> <span class="pi">}</span>
</code></pre></div></div>]]></content>
      

      
      
      
      
      
      <author>
        <name>[&quot;David Burela&quot;]</name>
        
        
      </author>

      
        
      

      

      
      
        <summary type="html"><![CDATA[GitHub Spec Kit was released in only the past few weeks. I have been experimenting with using it on my projects. As well as trying to stay across the changes and sentiments by consuming a lot of media, tutorials, and reading through the repo discussions &amp; issues. As it is still early days and everyone is learning, I wanted to write up and share the current state of where the project is at, and how we’re all learning to use it.]]></summary>
      

      
      
    </entry>
  
    <entry>
      
      <title type="html">Making more updates to my blog’s infrastructure</title>
      <link href="https://blog.davidburela.com/2025/05/26/more-blog-infra-updates/" rel="alternate" type="text/html" title="Making more updates to my blog’s infrastructure" />
      <published>2025-05-26T00:00:00+00:00</published>
      <updated>2025-05-26T00:00:00+00:00</updated>
      <id>https://blog.davidburela.com/2025/05/26/more-blog-infra-updates</id>

      
      
        <content type="html" xml:base="https://blog.davidburela.com/2025/05/26/more-blog-infra-updates/"><![CDATA[<h2 id="it-is-time-to-update-again">It is time to update again!</h2>
<p>I think it is the hallmark of a proper engineer, when they spend more time on the underlying tech and hosting of their blog, than actually posting any content ;-)</p>

<h2 id="what-happened">What happened?</h2>
<p>A couple years ago <a href="/2020/05/24/why-i-moved-my-blog/">I moved my blog</a> off centralised WordPress hosting, to fully embracing <a href="https://IPFS.tech">IPFS</a> and the decentralised web.
I use a combination of</p>
<ul>
  <li>Jekyll, to generate a static website</li>
  <li>IPFS, to host the website data</li>
  <li>ENS for decentralised lookup</li>
  <li>Cloudflare, to provide a web 2.0 bridge (Allowing you to access via <a href="https://blog.davidburela.com">https://blog.davidburela.com</a>)</li>
</ul>

<p>To simplify building, publishing, and record updates, I had been using <a href="https://fleek.xyz/">https://fleek.xyz/</a> as they had a free tier to get started. Which was fine as I only updated my blog every couple of months.</p>

<p>However Fleek changed their model and the cheapest tier is now $20/month! I am happy paying a couple dollars for hosting, but that is a big cost for a build pipeline…</p>

<h2 id="what-did-i-move-to">What did I move to?</h2>
<p><strong>TL;DR</strong> GitHub actions! With 3 simple steps:</p>
<ul>
  <li>Build the Jekyll site</li>
  <li>Publish to IPFS via Storacha</li>
  <li>Update Cloudflare to point to the new hash</li>
</ul>

<h3 id="building-the-site">Building the site</h3>
<p>GitHub Actions immediately detected the Jekyll project in the repo, and correctly provided a template that uses a docker image for the build.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">jobs</span><span class="pi">:</span>
  <span class="na">build</span><span class="pi">:</span>
    <span class="na">runs-on</span><span class="pi">:</span> <span class="s">ubuntu-latest</span>
    <span class="na">steps</span><span class="pi">:</span>
    <span class="pi">-</span> <span class="na">uses</span><span class="pi">:</span> <span class="s">actions/checkout@v4</span>
    <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">Build the site in the jekyll/builder container</span>
      <span class="na">run</span><span class="pi">:</span> <span class="pi">|</span>
        <span class="s">docker run \</span>
        <span class="s">-v $:/srv/jekyll -v $/_site:/srv/jekyll/_site \</span>
        <span class="s">jekyll/builder:latest /bin/bash -c "chmod -R 777 /srv/jekyll &amp;&amp; jekyll build --future"</span>
</code></pre></div></div>

<h3 id="publishing-to-ipfs">Publishing to IPFS</h3>
<p>There is a GitHub action which will take the static website, and push it to <a href="https://storacha.network/">Storacha</a> who host it on IPFS. Storacha has a much better pricing scheme, and I’m happy to pay for the storage and serving.</p>

<p><a href="https://github.com/ipshipyard/ipfs-deploy-action">https://github.com/ipshipyard/ipfs-deploy-action</a>
I just had to add the step to the action, provide some secrets, and it will publish and return the hash of my website.</p>
<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="pi">-</span> <span class="na">uses</span><span class="pi">:</span> <span class="s">ipfs/ipfs-deploy-action@v1</span>
      <span class="na">name</span><span class="pi">:</span> <span class="s">Deploy to IPFS</span>
      <span class="na">id</span><span class="pi">:</span> <span class="s">deploy</span>
      <span class="na">with</span><span class="pi">:</span>
        <span class="na">path-to-deploy</span><span class="pi">:</span> <span class="s">_site</span>
        <span class="na">storacha-key</span><span class="pi">:</span> <span class="s">$</span>
        <span class="na">storacha-proof</span><span class="pi">:</span> <span class="s">$</span>
        <span class="na">github-token</span><span class="pi">:</span> <span class="s">$</span>
</code></pre></div></div>

<h3 id="updating-cloudflare-record">Updating Cloudflare record</h3>
<p>I am using the <a href="https://developers.cloudflare.com/web3/ipfs-gateway/">Cloudflare IPFS gateway</a> to provide the Web 2.0 bridge to standard browsers. You point it at the hash of your website by updating a <code class="language-plaintext highlighter-rouge">_dnslink</code> TXT record, and your site is served up.</p>

<p>There is a dnslink update tool available <a href="https://github.com/ipshipyard/dnslink-action">https://github.com/ipshipyard/dnslink-action</a> however it doesn’t work with Cloudflare gateways, as they lock the TXT record.</p>

<p>I ended up having to dive into the Cloudflare documentation, and find the API method required to interact directly with the gateway. <a href="https://developers.cloudflare.com/api/resources/web3/subresources/hostnames/methods/edit/">https://developers.cloudflare.com/api/resources/web3/subresources/hostnames/methods/edit/</a></p>

<p>A bunch of messing around with auth keys later, I was able to update my action to do a <code class="language-plaintext highlighter-rouge">PATCH</code> call to update the record</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">Update DNSLink via Cloudflare API</span>
      <span class="na">env</span><span class="pi">:</span>
        <span class="na">CLOUDFLARE_EMAIL</span><span class="pi">:</span> <span class="s">$</span>
        <span class="na">CLOUDFLARE_API_KEY</span><span class="pi">:</span> <span class="s">$</span>
        <span class="na">CLOUDFLARE_ZONE_ID</span><span class="pi">:</span> <span class="s">$</span>
        <span class="na">CLOUDFLARE_IDENTIFIER</span><span class="pi">:</span> <span class="s">$</span>
      <span class="na">run</span><span class="pi">:</span> <span class="pi">|</span>
        <span class="s">curl https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/web3/hostnames/$CLOUDFLARE_IDENTIFIER \</span>
          <span class="s">-X PATCH \</span>
          <span class="s">-H 'Content-Type: application/json' \</span>
          <span class="s">-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \</span>
          <span class="s">-H "X-Auth-Key: $CLOUDFLARE_API_KEY" \</span>
          <span class="s">-d '{"dnslink": "/ipfs/$"}'</span>
</code></pre></div></div>

<h2 id="how-did-it-go">How did it go?</h2>
<p>I am really happy with the results.</p>
<ul>
  <li>Storacha serving is much faster than my previous hosts.</li>
  <li>I now fully own my build pipeline.</li>
  <li>I took the time to update a lot of Jekyll gem packages at the same time.</li>
</ul>

<p>Will this result in more blog posts in the future…. probably. The previous setup had enough friction that it did put me off. This new setup is just write, commit, push.</p>

<p>Let’s see at the end of the year if it actually paid off ;-)</p>]]></content>
      

      
      
      
      
      
      <author>
        <name>[&quot;David Burela&quot;]</name>
        
        
      </author>

      
        
      

      
        <category term="IPFS" />
      

      
      
        <summary type="html"><![CDATA[It is time to update again! I think it is the hallmark of a proper engineer, when they spend more time on the underlying tech and hosting of their blog, than actually posting any content ;-)]]></summary>
      

      
      
    </entry>
  
    <entry>
      
      <title type="html">Connecting a heartrate monitor to Peloton on Android TV</title>
      <link href="https://blog.davidburela.com/2025/01/03/connecting-a-heartrate-monitor-to-Peloton-on-Android-TV/" rel="alternate" type="text/html" title="Connecting a heartrate monitor to Peloton on Android TV" />
      <published>2025-01-03T00:00:00+00:00</published>
      <updated>2025-01-03T00:00:00+00:00</updated>
      <id>https://blog.davidburela.com/2025/01/03/connecting-a-heartrate-monitor-to-peloton-on-android-tv</id>

      
      
        <content type="html" xml:base="https://blog.davidburela.com/2025/01/03/connecting-a-heartrate-monitor-to-Peloton-on-Android-TV/"><![CDATA[<h2 id="background">Background</h2>
<p>I had difficulties recently getting my Garmin watch to broadcast its heartrate monitor to the Peloton app on my Sony Bravia 9, running Android TV.</p>

<p>Normally I do these steps</p>
<ul>
  <li>On my Garmin watch, hold down the settings button. Navigate to “Broadcast HR”, and enable it.</li>
  <li>On my Peloton bike, or the Peloton app on my Android phone, click “Connect HR device”</li>
  <li>It is instantly found and starts displaying my Heartrate</li>
</ul>

<h3 id="issues-with-android-tv">Issues with Android TV</h3>
<p>However, when I installed the Peloton app on my Android TV, I could not get it to detect my watch. 
I confirmed that the app had access to local devices, that Bluetooth was on. The Peloton app also requested to access my location (needed to detect Bluetooth devices), and I  granted it location permissions.</p>

<p>However later when I went into app info, and checked the app permissions. The location setting was not sticking to “allow access while using the app”.</p>
<h2 id="solution">Solution</h2>
<p>Because my TV is a TV,  when I first set it up I told it not to use location services. My thinking was it is a TV that isn’t moving… therefore it wouldn’t need GPS for maps, etc. This seems to have been the issue.</p>

<p>First I changed the setting to allow location services on the TV
<code class="language-plaintext highlighter-rouge">Privacy -&gt; Location -&gt; Location status</code> -&gt; <code class="language-plaintext highlighter-rouge">Use WiFi to estimate location</code></p>

<p>Then I reconfirmed the Peloton app settings that “Allow while using the app” was sticking.
Restarted the TV for good measure, and the Peloton app was able to connect and display my heartrate.</p>]]></content>
      

      
      
      
      
      
      <author>
        <name>[&quot;David Burela&quot;]</name>
        
        
      </author>

      
        
      

      

      
      
        <summary type="html"><![CDATA[Background I had difficulties recently getting my Garmin watch to broadcast its heartrate monitor to the Peloton app on my Sony Bravia 9, running Android TV.]]></summary>
      

      
      
    </entry>
  
    <entry>
      
      <title type="html">Mario 64 decompiled and ported to PC</title>
      <link href="https://blog.davidburela.com/2023/10/28/mario-64-decompiled-and-ported-to-pc/" rel="alternate" type="text/html" title="Mario 64 decompiled and ported to PC" />
      <published>2023-10-28T00:00:00+00:00</published>
      <updated>2023-10-28T00:00:00+00:00</updated>
      <id>https://blog.davidburela.com/2023/10/28/mario-64-decompiled-and-ported-to-pc</id>

      
      
        <content type="html" xml:base="https://blog.davidburela.com/2023/10/28/mario-64-decompiled-and-ported-to-pc/"><![CDATA[<p>Retro gaming and hacking is not just a nostalgic journey, but also a deep dive into the intricacies of software development, optimization, and creativity. Mario 64 stands out as a game that not only defined a generation but also kept sparking interest in the modding and hacking communities. I’ve been following it for years researching and exploring, here are some of my favourite videos and links that I’d love to share.</p>

<h2 id="mario-64-decompilation">Mario 64 decompilation</h2>
<p>Decompiling a game essentially means to reverse-engineer it back to its source code. A few years ago, the Mario 64 decompilation project reached a milestone with a complete source code with annotations. If you take the source code and match it with the original build arguments, it can reproduce the exact original USA ROM file. What does this mean for enthusiasts and modders?</p>
<ul>
  <li>Mario 64 decompilation project - <a href="https://github.com/n64decomp/sm64">https://github.com/n64decomp/sm64</a></li>
</ul>

<h3 id="original-game-was-unoptimised">Original game was unoptimised</h3>

<p>While exploring the depths of the decompiled code, a rather interesting discovery came to light. Nintendo, in their original build, left out the O2 optimisation flag.</p>
<ul>
  <li>MattKC - Nintendo’s big mistake that made Super Mario 64 super slow<br />
[<a href="https://www.youtube.com/watch?v=9_gdOKSTaxM">YouTube</a>] / [<a href="ipfs://bafybeifgg7bnh4rsg5k3w2ido4y32xdegkdgivlpx5kgq5bvtfog7aaxem">IPFS backup</a>]</li>
  <li>Modern Vintage Gamer - Did Nintendo really forget to Optimize Super Mario 64?<br />
[<a href="https://www.youtube.com/watch?v=NKlbE2eROC0">YouTube</a>] / [<a href="ipfs://bafybeibrqasmvz7vhsrrbtyz6kgs6ixw4cvcvblkqdmzewq4onp4yq3fui">IPFS backup</a>]</li>
</ul>

<h2 id="porting-to-pc">Porting to PC</h2>
<p>Unlocking the source code wasn’t just a peek into the past; it was a gateway to the future. With the complete decompiled source in hand, enthusiasts started creating native ports for PCs. No more emulating the Nintendo 64 hardware. Instead, direct ports were created that run seamlessly on DirectX 12, offering enhanced gameplay experiences. Sm64pcbuilder2 is a tool that streamlines the compilation process, integrating mods with ease.</p>
<ul>
  <li>Learn about sm64pcBuilder2 at <a href="https://sm64pc.info/sm64pcbuilder2/">https://sm64pc.info/sm64pcbuilder2/</a></li>
  <li>Tutorial - How to compile Super Mario 64 PC Port with sm64pcBuilder2
    <ul>
      <li>[<a href="https://www.youtube.com/watch?v=rW9IotsB9pA">YouTube</a>] / [<a href="ipfs://bafybeiaobeb35i62hhccaupp3emkk2qqeutswb2efimcj3dfzsiyvsrdiq">IPFS backup</a>]</li>
    </ul>
  </li>
</ul>

<h3 id="mods--patches-for-pc">Mods &amp; patches for PC</h3>
<p>With the transition to PC, the modding community found a new playground. Over the last three years, numerous patches have emerged, introducing enhancements ranging from upscaling and HD textures to intricate details like ray tracing. While altering textures and models is subjective and hinges on individual taste, I’ve shared some videos to show what is possible.</p>
<ul>
  <li>Watch the difference between 30FPS and 60FPS
[<a href="https://www.youtube.com/watch?v=oCmHNRKTGwc">YouTube</a>] / [<a href="ipfs://bafybeigdtcvutip2muf5pn346kakgoc2zbyjx32ndiggyvoqdbj2of22rm">IPFS backup</a>]</li>
  <li>Experience Mario 64 with High Poly Model Pack + Ray Tracing in 4K at 60FPS
[<a href="https://www.youtube.com/watch?v=Yh3TWOwCptQ">YouTube</a>] / [<a href="ipfs://bafybeifuzplr4xamqr7dygw7lz2kvctb2ulr5sviylnwyykyp7orv5i4ia">IPFS backup</a>]</li>
  <li>For a comprehensive list of the latest Mario PC port mods, check out Unreal64’s YouTube channel<br />
[<a href="https://www.youtube.com/@Unreal64/search?query=mario%20pc">YouTube - Unreal64</a>]</li>
</ul>

<p><a href="/assets/2023/10/mario64-penguin.webp"><img src="/assets/2023/10/mario64-penguin.webp" alt="Mario 64 with penguin" /></a>
<a href="/assets/2023/10/mariopc-penguin.webp"><img src="/assets/2023/10/mariopc-penguin.webp" alt="Mario PC with penguin" /></a>
<a href="/assets/2023/10/mariopc-crystal.webp"><img src="/assets/2023/10/mariopc-crystal.webp" alt="Mario PC with crystal" /></a></p>

<h2 id="mario-64-engine-upgrades-on-original-hardware">Mario 64 engine upgrades on original hardware</h2>

<p>While experiencing Mario 64 on modern hardware with enhancements in HD models &amp; graphics is fun, there’s a unique charm in pushing the boundaries of the original Nintendo 64 hardware. Thanks to the decompiled source, developers have found innovative ways to optimize the game to run more smoothly on its native platform.</p>

<p>Enter <a href="https://twitter.com/KazeEmanuar">@KazeEmanuar</a>, a developer who has been pushing the N64 hardware to its limits. Tackling the challenges of memory bandwidth, Kaze has been introducing a plethora of improvements, from FPS boosts to refining base models and textures. If low-level hacking and optimization enthuse you, Kaze’s explorations will eat up hours of your time.</p>

<ul>
  <li>FIXING the ENTIRE SM64 Source Code (INSANE N64 performance. 20-&gt;60 fps)<br />
[<a href="https://www.youtube.com/watch?v=t_rzYnXEQlE">YouTube</a>] / [<a href="ipfs://bafybeifxxecnfbvw4zuprbbyc4dr56cjwdrrl4bbcrzwrwxedh5kx7lliq">IPFS backup</a>]</li>
  <li>How I made the most beautiful N64 Level<br />
[<a href="https://www.youtube.com/watch?v=DUbR8C6svHs">YouTube</a>] / [<a href="ipfs://bafybeicjxoc24bejy7gh2pmp6pdkbr2nqyz3hf5rmtlcbjhoxr6nnsprhy">IPFS backup</a>]</li>
  <li>The Problem with the Grass in Mario 64<br />
[<a href="https://www.youtube.com/watch?v=kOPb0vIuOG4">YouTube</a>] / [<a href="ipfs://bafybeihoxpq5uibjtwain57u6jehyg7fv6orswh63iz2hwwav6pbnhdnrm">IPFS backup</a>]</li>
  <li>Finding the BEST sine function for Nintendo 64<br />
[<a href="https://www.youtube.com/watch?v=xFKFoGiGlXQ">YouTube</a>] / [<a href="ipfs://bafybeifwdbf6t3lclwlstjfeavhuiu4oqfvmg7hgu4s4ptu5lxuu6nhjdi">IPFS backup</a>]</li>
  <li>Low Poly is OVERRATED<br />
[<a href="https://www.youtube.com/watch?v=GC_jLsxZ7nw">YouTube</a>] / [<a href="ipfs://bafybeih6sqk5m6u6sm37c7dtdqqdcc3v2bs46l7hraw2nuu6exjlzlqzxu">IPFS backup</a>]</li>
</ul>

<p>The legacy of Mario 64 goes beyond its initial release. It has evolved and been reimagined by a dedicated community of enthusiasts, hackers, and developers. 
The dedication of the community and developers like Kaze, showcase what can be done when you apply modern techniques to retro hardware and software.</p>]]></content>
      

      
      
      
      
      
      <author>
        <name>[&quot;David Burela&quot;]</name>
        
        
      </author>

      
        
      

      
        <category term="retro" />
      

      
      
        <summary type="html"><![CDATA[Retro gaming and hacking is not just a nostalgic journey, but also a deep dive into the intricacies of software development, optimization, and creativity. Mario 64 stands out as a game that not only defined a generation but also kept sparking interest in the modding and hacking communities. I’ve been following it for years researching and exploring, here are some of my favourite videos and links that I’d love to share.]]></summary>
      

      
      
    </entry>
  
    <entry>
      
      <title type="html">Enterprise Blockchain screening</title>
      <link href="https://blog.davidburela.com/2022/07/17/enterprise-blockchain-screening/" rel="alternate" type="text/html" title="Enterprise Blockchain screening" />
      <published>2022-07-17T00:00:00+00:00</published>
      <updated>2022-07-17T00:00:00+00:00</updated>
      <id>https://blog.davidburela.com/2022/07/17/enterprise-blockchain-screening</id>

      
      
        <content type="html" xml:base="https://blog.davidburela.com/2022/07/17/enterprise-blockchain-screening/"><![CDATA[<p>When engaging with customers on Blockchain projects, I come across a number of red flags that indicate the scenario isn’t ready or suitable for the technology. For example, I would frequently find Enterprises trying to take an existing 3 tier app that they ran internally, and planned to swap the Database with Blockchain to “make it more secure”.</p>

<p>This led me to putting together a quick screening checklist that I would share with account managers, to allow them to do early screening of their accounts. Now when I am eventually brought in, the scenario is in a much better place for me to work with.</p>

<h2 id="attributes-of-a-good-blockchain-engagement">Attributes of a good Blockchain engagement:</h2>

<ul>
  <li><strong>Consortium:</strong> Multiple companies being part of the initial deployment.</li>
  <li><strong>Shared Blockchain:</strong> The Blockchain infrastructure is hosted by all parties, who are all validating the Blocks</li>
  <li><strong>Infrastructure independence:</strong> Each party has their backend systems directly connected to their Blockchain nodes.</li>
  <li><strong>Decentralisation:</strong> One of the founding members could potentially drop out, with the other parties continuing without impact</li>
  <li><strong>Shared API:</strong> The Blockchain is used as a “shared API” that the parties use to communicate through via smart contracts.</li>
</ul>

<h2 id="red-flags">Red flags</h2>
<p>These are not necessarily showstoppers, but do indicate that the technology is not being used optimally.</p>
<ul>
  <li>Scenario is a workflow for a single company.</li>
  <li>Not all consortium members are providing development resources for the development.</li>
  <li>No direct access to the Blockchain to validate underlying data, everything goes through abstractions.</li>
  <li>Other parties all go through party A’s centralised infrastructure and can’t see the Blockchain.</li>
  <li>In the architecture diagram, if you could potentially replace the Blockchain with a SQL database and external parties would not know any difference as they can’t access it.</li>
  <li>Customer is using it as “a chance to play with Blockchain” with no pathway to production.</li>
  <li>Wanting to store PII information e.g. medical records, or access records</li>
  <li>Required supporting systems are not yet implemented e.g. supply chain logging, IoT sensor information.</li>
</ul>

<h2 id="pre-engagement-requirements">Pre-engagement requirements</h2>
<ul>
  <li>Thought about how identity will be handled.</li>
  <li>Agreements from the other companies that they will be part of the Direct Engagement</li>
  <li>Dedicated, ring fenced, development team within each member of the consortium (regardless of my involvement).</li>
  <li>End to end workflow for entire interaction between Party A &amp; B. Including sequence diagrams showing where it will pass between systems.</li>
  <li>Solidity tutorials completed e.g. <a href="https://cryptozombies.io/">Cryptozombies tutorial</a></li>
  <li>Developer environments configured <a href="/2017/05/12/how-to-install-truffle-testrpc-on-ubuntu-or-windows-10-with-windows-subsystem-for-linux/">setup guide</a></li>
</ul>

<h2 id="alternatives-to-blockchain">Alternatives to Blockchain</h2>
<p>If a customer is trying to “make it more secure” without involving other parties, then other services may solve it easier</p>
<ul>
  <li><a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/ledger/ledger-overview">Azure SQL ledger</a>: SQL Database but with tamper-evidence capabilities.</li>
  <li><a href="https://docs.microsoft.com/en-us/azure/storage/blobs/immutable-storage-overview">Azure Immutable blob storage</a>: For customers that require audit trails for regulatory reasons. Targets SEC 17a-4(f) compliance.</li>
  <li><a href="https://azure.microsoft.com/en-us/services/cosmos-db/">Azure CosmosDB</a>: For quick replication of data across regions.</li>
  <li><a href="https://docs.microsoft.com/en-us/rest/api/storageservices/authentication-for-the-azure-storage-services">Azure AD Authentication for storage</a>: For giving conditional access to sensitive resources.</li>
</ul>]]></content>
      

      
      
      
      
      
      <author>
        <name>[&quot;David Burela&quot;]</name>
        
        
      </author>

      
        
      

      
        <category term="blockchain" />
      
        <category term="ethereum" />
      

      
      
        <summary type="html"><![CDATA[When engaging with customers on Blockchain projects, I come across a number of red flags that indicate the scenario isn’t ready or suitable for the technology. For example, I would frequently find Enterprises trying to take an existing 3 tier app that they ran internally, and planned to swap the Database with Blockchain to “make it more secure”.]]></summary>
      

      
      
    </entry>
  
    <entry>
      
      <title type="html">RISC-V turnkey development environment</title>
      <link href="https://blog.davidburela.com/2021/12/31/risc-v-turnkey-dev-environment/" rel="alternate" type="text/html" title="RISC-V turnkey development environment" />
      <published>2021-12-31T00:00:00+00:00</published>
      <updated>2021-12-31T00:00:00+00:00</updated>
      <id>https://blog.davidburela.com/2021/12/31/risc-v-turnkey-dev-environment</id>

      
      
        <content type="html" xml:base="https://blog.davidburela.com/2021/12/31/risc-v-turnkey-dev-environment/"><![CDATA[<blockquote>
  <p>Run the docker container, SSH in, and you’re on an emulated RISC-V core running Debian.</p>
</blockquote>

<p>I wanted to see if I could make a simpler version of the <a href="/2020/11/15/emulating-risc-v-debian-on-wsl2/">RISC-V emulated system on WSL2</a>, allowing anyone to quickly get started without too much setup. I was able to solve by packing it all into a Docker container.</p>

<h2 id="what-is-it">What is it</h2>
<p>A pre-configured QEMU &amp; Debian RISC-V Docker image. Allows you to get started working on an emulated RISC-V environment. Is a quick way to see what libraries and frameworks work on RISC-V without sourcing hardware.</p>

<p>Structure:</p>

<ul>
  <li>Debian host (debian:11)
    <ul>
      <li>QEMU. Running as emulated RISC-V with soft-mmu support
        <ul>
          <li>Debian guest. RISC-V image</li>
          <li>RISC-V u-boot kernel</li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

<h2 id="get-started-immediately-with-dockerhub">Get started immediately with DockerHub</h2>

<ul>
  <li>Image on Dockerhub: <a href="https://hub.docker.com/repository/docker/davidburela/riscv-emulator">https://hub.docker.com/repository/docker/davidburela/riscv-emulator</a></li>
</ul>

<p>To get started, you need to run the Docker image, and SSH in. You’ll then be in a Debian envornment running an emulated RISC-V core, ready to compile and run applications.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># 1 Get the image</span>
docker pull davidburela/riscv-emulator

<span class="c"># 2. </span>
<span class="c"># Run with QEMU default of 2CPU &amp; 2G ram. </span>
<span class="c"># Expose port 2222 which is routed through into the QEMU RISC-V guest</span>
docker run <span class="nt">-d</span> <span class="nt">--publish</span> 127.0.0.1:2222:2222/tcp davidburela/riscv-emulator

<span class="c"># 3. SSH directly into the QEMU RISC-V guest, the default password is "root". (Might take a few minutes for guest to start)</span>
ssh root@localhost <span class="nt">-p</span> 2222
</code></pre></div></div>

<p><a href="/assets/2021/12/ssh-riscv-cpu.png"><img src="/assets/2021/12/ssh-riscv-cpu.png" alt="Seeing RISC-V cores in Debian" /></a></p>

<h3 id="build-the-image-yourself">Build the image yourself</h3>
<p>The docker file is available on GitHub. If you want to see how it is put together. Also allows you to manually upgrade versions of docker base image, QEMU, or the risc-v debian image.</p>
<ul>
  <li>GitHub repository <a href="https://github.com/DavidBurela/riscv-emulator-docker-image">https://github.com/DavidBurela/riscv-emulator-docker-image</a></li>
</ul>

<h2 id="background">Background</h2>
<p>I have been experimenting with getting different projects running on RISC-V. This docker image allowed me to quickly spin up new experiments and validate</p>
<ul>
  <li><a href="/2020/11/16/ipfs-on-risc-v">IPFS running on RISC-V</a></li>
  <li><a href="/2020/12/03/ethereum-on-risc-v/">Ethereum running on RISC-V</a></li>
  <li><a href="/2020/11/21/cross-compiling-golang-for-risc-v/">Cross compiling Golang apps for RISC-V</a></li>
  <li><a href="/2020/11/15/emulating-risc-v-debian-on-wsl2/">Emulating RISC-V Debian on WSL2</a></li>
</ul>

<h2 id="additional-links">Additional links</h2>

<ul>
  <li>GitHub repository <a href="https://github.com/DavidBurela/riscv-emulator-docker-image">https://github.com/DavidBurela/riscv-emulator-docker-image</a></li>
  <li>Docker Hub <a href="https://hub.docker.com/repository/docker/davidburela/riscv-emulator">https://hub.docker.com/repository/docker/davidburela/riscv-emulator</a></li>
  <li>I am utilising <a href="https://www.giovannimascellani.eu/dqib-debian-quick-image-baker.html">Giovanni Mascellani’s prebaked Debian images</a></li>
</ul>]]></content>
      

      
      
      
      
      
      <author>
        <name>David Burela</name>
        
          <email>David.Burela@gmail.com</email>
        
        
      </author>

      
        
      

      
        <category term="RISC-V" />
      
        <category term="Docker" />
      

      
      
        <summary type="html"><![CDATA[Run the docker container, SSH in, and you’re on an emulated RISC-V core running Debian.]]></summary>
      

      
      
        
        <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blog.davidburela.com/assets/2021/12/ssh-riscv-cpu.png" />
        <media:content medium="image" url="https://blog.davidburela.com/assets/2021/12/ssh-riscv-cpu.png" xmlns:media="http://search.yahoo.com/mrss/" />
      
    </entry>
  
    <entry>
      
      <title type="html">Ethereum on RISC-V</title>
      <link href="https://blog.davidburela.com/2020/12/03/ethereum-on-risc-v/" rel="alternate" type="text/html" title="Ethereum on RISC-V" />
      <published>2020-12-03T00:00:00+00:00</published>
      <updated>2020-12-03T00:00:00+00:00</updated>
      <id>https://blog.davidburela.com/2020/12/03/ethereum-on-risc-v</id>

      
      
        <content type="html" xml:base="https://blog.davidburela.com/2020/12/03/ethereum-on-risc-v/"><![CDATA[<p><strong>Background:</strong> I previously talked about <a href="/2020/11/10/risc-v-development-board">my excitement for RISC-V</a>, with one of my goals to see if I can get a decentralised web stack running on top of it. In my my first experiment I was able to get <a href="/2020/11/16/ipfs-on-risc-v">IPFS running on RISC-V</a>.</p>

<p><strong>Today:</strong>  I was able to get <a href="https://ethereum.org">Ethereum</a> running on RISC-V, after finding upstreamed fixes that are not yet in the latest releases of Golang.<br />
I have submitted a GitHub issue to track the progress of <a href="https://github.com/ethereum/go-ethereum/issues/22354">RISC-V support in go-ethereum</a>.</p>

<p><a href="/assets/2020/12/riscv-plus-ethereum.jpg"><img src="/assets/2020/12/riscv-plus-ethereum.jpg" alt="Ethereum running on RISC-V" /></a></p>

<h2 id="checking-geth-codebase-for-incompatibilities">Checking Geth codebase for incompatibilities</h2>

<p>First was to try compiling the <a href="https://github.com/ethereum/go-ethereum">Geth source</a> with the latest version of Go <code class="language-plaintext highlighter-rouge">1.15.8</code>. But I ran into an issue with <code class="language-plaintext highlighter-rouge">cgo</code>.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/usr/bin/ld: <span class="nv">$WORK</span>/b009/_x008.o: <span class="k">in function</span> <span class="sb">`</span>x_cgo_thread_start<span class="s1">':
/usr/lib/go-1.15/src/runtime/cgo/gcc_util.c:21: undefined reference to `_cgo_sys_thread_start'</span>
collect2: error: ld returned 1 <span class="nb">exit </span>status
</code></pre></div></div>

<p>Digging into the Epic to <a href="https://github.com/golang/go/issues/27532">port Golang to RISC-V</a>, there are references to cgo not working.  Following the threads you eventually get to the issue &amp; PR that is tracking and resolving the cgo issues <a href="https://github.com/golang/go/issues/36641">https://github.com/golang/go/issues/36641</a></p>

<p>The PR to fix this has been approved and merged, and is being upstreamed. But as of <code class="language-plaintext highlighter-rouge">go 1.15.8</code> it has not yet been included. Which means for the moment we’ll need to compile Go ourselves from source to get this working</p>

<h2 id="building-with-latest-patches">Building with latest patches</h2>

<h3 id="step-0-prepare-your-risc-v-environment">Step 0: Prepare your RISC-V environment</h3>

<p>This walk-through is assuming you are running on a RISC-V system, or have set up your system for cross compiling.</p>

<p><strong>Easiest: RISC-V emulator docker image</strong>
Use docker to load a pre-built image that has a running RISC-V QEMU guest.<br />
<a href="https://github.com/DavidBurela/riscv-emulator-docker-image">https://github.com/DavidBurela/riscv-emulator-docker-image</a></p>

<p><strong>Emulated environment with QEMU:</strong><br />
I have written a guide on creating your own emulated RISC-V environment with QEMU: <a href="/2020/11/15/emulating-risc-v-debian-on-wsl2.html">Emulating RISC-V Debian</a></p>

<p><strong>Advanced: Cross compiling for RISC-V:</strong><br />
If you are not running an emulated environment, and want to build geth on your current machine. You can cross compile and target RISC-V in order to test out the toolchain, you can view my previous post on <a href="/2020/11/21/cross-compiling-golang-for-risc-v/">Cross compiling Golang for RISC-V</a>.<br />
Once you have <code class="language-plaintext highlighter-rouge">riscv64-linux-gnu-gcc</code> and Go environment set up, the rest of this walk-through will work.<br />
<em>NOTE:</em> If you are cross compiling, you will also need to install libc6, see the bottom of my cross compiling link above, and see the troubleshooting section at the end.</p>

<h3 id="step-1-compile-go-from-source">Step 1: Compile Go from source</h3>

<p>First, compile Go from source to get the cgo fix. The easiest way did this is via bootstrapping toolchain from binary release <a href="https://golang.org/doc/install/source#bootstrapFromBinaryRelease">https://golang.org/doc/install/source#bootstrapFromBinaryRelease</a></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">## Compile Go from source https://golang.org/doc/install/source</span>
<span class="c"># install toolchain</span>
<span class="nb">sudo </span>apt update
<span class="nb">sudo </span>apt <span class="nb">install </span>git golang <span class="nt">-y</span>

<span class="c"># clone source</span>
<span class="nb">cd</span> ~
git clone https://go.googlesource.com/go goroot
<span class="nb">cd </span>goroot
<span class="nb">cd </span>src

<span class="c"># compile golang</span>
./make.bash  <span class="c"># MUCH faster</span>
./all.bash  <span class="c"># run this instead if you want all of the validation tests to run</span>
</code></pre></div></div>

<p>Pay attention to where it installs the commands. in this case they are in <code class="language-plaintext highlighter-rouge">/root/goroot/bin</code>, but will be different on your system.<br />
<a href="/assets/2020/12/riscv-ethereum-go-compiled.png"><img src="/assets/2020/12/riscv-ethereum-go-compiled.png" alt="Go compiled" /></a></p>

<h3 id="step-2-compile-ethereum-with-our-toolchain">Step 2: Compile Ethereum with our toolchain</h3>

<p><a href="https://github.com/ethereum/go-ethereum">https://github.com/ethereum/go-ethereum</a><br />
<a href="https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu">https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu</a></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># install more toolchains</span>
<span class="nb">sudo </span>apt <span class="nb">install </span>git build-essential <span class="nt">-y</span>

<span class="nb">cd</span> ~
git clone https://github.com/ethereum/go-ethereum.git
<span class="nb">cd </span>go-ethereum

<span class="c">## Build geth using our compiled version of golang, targeting RISC-V.</span>
<span class="c"># Pay attention to where your go binary was placed in previous step.</span>
<span class="c"># on my system the built version was placed in /root/goroot/bin/go</span>
<span class="c">## `make geth ` does not work, we need to run ci.go to specify the architecture</span>
/root/goroot/bin/go run build/ci.go <span class="nb">install</span> <span class="nt">-arch</span><span class="o">=</span>riscv64 ./cmd/geth

<span class="c"># run your built geth! (if you are on RISC-V)</span>
build/bin/geth
</code></pre></div></div>

<p><a href="/assets/2020/12/riscv-ethereum-running.png"><img src="/assets/2020/12/riscv-ethereum-running.png" alt="Ethereum running on RISC-V" /></a></p>

<h2 id="just-give-me-a-pre-built-binary">Just give me a pre-built binary</h2>

<p>I have pinned a version of Geth I built for you to try ONLY if you want to see it quickly working on your RISC-V system.<br />
<strong>DO NOT</strong> use it for anything serious, as you should never trust a version of Geth compiled by a random person on the internet ;-)</p>

<ul>
  <li><a href="ipfs://QmWgJ68JocF15aBnsup6tcLnD6DbsMiXMjn4CsufmFuyLA?filename=geth">Risc-V geth download</a></li>
  <li>Easy download command: <code class="language-plaintext highlighter-rouge">wget http://dweb.link/ipfs/QmWgJ68JocF15aBnsup6tcLnD6DbsMiXMjn4CsufmFuyLA -O geth</code></li>
</ul>]]></content>
      

      
      
      
      
      
      <author>
        <name>David Burela</name>
        
          <email>David.Burela@gmail.com</email>
        
        
      </author>

      
        
      

      
        <category term="ethereum" />
      
        <category term="RISC-V" />
      

      
      
        <summary type="html"><![CDATA[Background: I previously talked about my excitement for RISC-V, with one of my goals to see if I can get a decentralised web stack running on top of it. In my my first experiment I was able to get IPFS running on RISC-V.]]></summary>
      

      
      
        
        <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blog.davidburela.com/assets/2020/12/riscv-plus-ethereum.jpg" />
        <media:content medium="image" url="https://blog.davidburela.com/assets/2020/12/riscv-plus-ethereum.jpg" xmlns:media="http://search.yahoo.com/mrss/" />
      
    </entry>
  
    <entry>
      
      <title type="html">Cross compiling Golang apps for RISC-V with cgo</title>
      <link href="https://blog.davidburela.com/2020/11/21/cross-compiling-golang-for-risc-v/" rel="alternate" type="text/html" title="Cross compiling Golang apps for RISC-V with cgo" />
      <published>2020-11-21T00:00:00+00:00</published>
      <updated>2020-11-21T00:00:00+00:00</updated>
      <id>https://blog.davidburela.com/2020/11/21/cross-compiling-golang-for-risc-v</id>

      
      
        <content type="html" xml:base="https://blog.davidburela.com/2020/11/21/cross-compiling-golang-for-risc-v/"><![CDATA[<p>On my adventures in playing with RISC-V (see <a href="/2020/11/15/emulating-risc-v-debian-on-wsl2/">Emulating RISC-V</a>, and <a href="/2020/11/16/ipfs-on-risc-v/">IPFS on RISC-V</a>), I hit on a few issues.<br />
I was struggling to find a guide online on how to cross compile Go code on RISC-V, when cgo is involved. Here is a quick guide and trouble shooting tips to help others.</p>

<p><strong>Important:</strong> the <code class="language-plaintext highlighter-rouge">riscv64</code> architecture was not added until Go version <code class="language-plaintext highlighter-rouge">1.15.x</code>, you will need to make sure you are running a recent release.<br />
Here is the Github issue that tracked the implementation <a href="https://github.com/golang/go/issues/36641">https://github.com/golang/go/issues/36641</a></p>

<h2 id="setting-up-and-compiling">Setting up and compiling</h2>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Install standard GCC for your system</span>
<span class="nb">sudo </span>apt <span class="nb">install </span>build-essential
<span class="c"># Add the RISC-V GCC package</span>
<span class="nb">sudo </span>apt <span class="nb">install </span>g++-riscv64-linux-gnu gcc-riscv64-linux-gnu

<span class="c"># Tell golang what the compilation target is</span>
<span class="c"># Importantly, set the CC (Cross Compiler) to use the riscv64 version of GCC, instead of our system's default</span>
<span class="nb">export </span><span class="nv">GOOS</span><span class="o">=</span>linux
<span class="nb">export </span><span class="nv">GOARCH</span><span class="o">=</span>riscv64
<span class="nb">export </span><span class="nv">CGO_ENABLED</span><span class="o">=</span>1
<span class="nb">export </span><span class="nv">CC</span><span class="o">=</span>riscv64-linux-gnu-gcc
</code></pre></div></div>

<p>Now files will compile when cross compiling for RISC-V</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Code sample from issue https://github.com/golang/go/issues/36641#issuecomment-630204733</span>
<span class="c"># Create a sample app</span>
<span class="nb">cat</span> <span class="o">&gt;</span> cgo.go <span class="o">&lt;&lt;</span> <span class="no">EOF</span><span class="sh">
package main

import "runtime"

/*
#include &lt;stdio.h&gt;

void hello(char *goos, char *goarch) {
        printf("Hi from cgo on %s/%s!</span><span class="se">\n</span><span class="sh">", goos, goarch);
}
*/
import "C"

func main() {
        goos := C.CString(runtime.GOOS)
        goarch := C.CString(runtime.GOARCH)
        C.hello(goos, goarch)
}
</span><span class="no">EOF

</span><span class="c"># build it</span>
go build ./cgo.go
</code></pre></div></div>

<h2 id="troubleshooting">Troubleshooting</h2>

<h3 id="verify-environment-settings">Verify environment settings</h3>
<p>When you run <code class="language-plaintext highlighter-rouge">go env</code> you should see this similar output.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>go <span class="nb">env
</span><span class="nv">GOOS</span><span class="o">=</span><span class="s2">"linux"</span>
<span class="nv">GOARCH</span><span class="o">=</span><span class="s2">"riscv64"</span>
<span class="nv">CGO_ENABLED</span><span class="o">=</span><span class="s2">"1"</span>
<span class="nv">CC</span><span class="o">=</span><span class="s2">"riscv64-linux-gnu-gcc"</span>
...
</code></pre></div></div>

<h3 id="force-env-settings-for-a-single-go-build">Force env settings for a single go build</h3>
<p>You can preface the go command with the environment settings you want, if you cannot <code class="language-plaintext highlighter-rouge">export</code></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">env </span><span class="nv">GOOS</span><span class="o">=</span>linux <span class="nv">GOARCH</span><span class="o">=</span>riscv64 <span class="nv">CGO_ENABLED</span><span class="o">=</span>1 <span class="nv">CC</span><span class="o">=</span>riscv64-linux-gnu-gcc go build
</code></pre></div></div>

<h3 id="older-version-of-go">Older version of Go</h3>
<p>If you see something similar to this, then you have an older version of golang.<br />
<strong>Solution:</strong> Install a version later than <code class="language-plaintext highlighter-rouge">1.15.x</code></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>go build ./cgo.go
/usr/bin/ld: <span class="nv">$WORK</span>/b009/_x008.o: <span class="k">in function</span> <span class="sb">`</span>x_cgo_thread_start<span class="s1">':
/usr/lib/go-1.15/src/runtime/cgo/gcc_util.c:23: undefined reference to `_cgo_sys_thread_start'</span>
collect2: error: ld returned 1 <span class="nb">exit </span>status
</code></pre></div></div>

<h3 id="cross-compiler-not-set">Cross compiler not set</h3>
<p>This is what got me stuck for quite a while. This happens when <code class="language-plaintext highlighter-rouge">CC</code> is still set to your system default gcc.<br />
<strong>Solution:</strong> set <code class="language-plaintext highlighter-rouge">export CC=riscv64-linux-gnu-gcc</code></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ go build ./cgo.go
gcc_riscv64.S: Assembler messages:
gcc_riscv64.S:15: Error: no such instruction: `sd x1,-200(sp)'
gcc_riscv64.S:16: Error: no such instruction: `addi sp,sp,-200'
gcc_riscv64.S:17: Error: no such instruction: `sd x8,8(sp)'
gcc_riscv64.S:18: Error: no such instruction: `sd x9,16(sp)'
gcc_riscv64.S:19: Error: no such instruction: `sd x18,24(sp)'
...
gcc_riscv64.S:29: Error: no such instruction: `fsd f8,104(sp)'
gcc_riscv64.S:30: Error: no such instruction: `fsd f9,112(sp)'
gcc_riscv64.S:31: Error: no such instruction: `fsd f18,120(sp)'
...
gcc_riscv64.S:43: Error: no such instruction: `mv s1,a0'
gcc_riscv64.S:44: Error: no such instruction: `mv s0,a1'
gcc_riscv64.S:45: Error: no such instruction: `mv a0,a2'
gcc_riscv64.S:46: Error: no such instruction: `jalr ra,s0'
gcc_riscv64.S:47: Error: no such instruction: `jalr ra,s1'
gcc_riscv64.S:49: Error: no such instruction: `ld x1,0(sp)'
gcc_riscv64.S:50: Error: no such instruction: `ld x8,8(sp)'
...
gcc_riscv64.S:62: Error: too many memory references for `fld'
gcc_riscv64.S:63: Error: too many memory references for `fld'
gcc_riscv64.S:64: Error: too many memory references for `fld'
...
gcc_riscv64.S:74: Error: no such instruction: `addi sp,sp,200'
gcc_riscv64.S:76: Error: no such instruction: `jr ra'
</code></pre></div></div>

<h3 id="libc6-not-installed">libc6 not installed</h3>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/lib/ld-linux-riscv64-lp64d.so.1: No such file or directory
</code></pre></div></div>
<p><strong>Solution:</strong><br />
Unfortunately I could not figure out a clean way to do this. Apparently you can set <code class="language-plaintext highlighter-rouge">export CGO_LDFLAGS="-L/path/to/the/lib</code> but that did not work for me. So in the short term, copying them into the <code class="language-plaintext highlighter-rouge">/lib</code> folder works after installing.  <a href="http://www.gridengine.eu/index.php/other-stories/232-avoiding-the-ldlibrarypath-with-shared-libs-in-go-cgo-applications-2015-12-21">http://www.gridengine.eu/index.php/other-stories/232-avoiding-the-ldlibrarypath-with-shared-libs-in-go-cgo-applications-2015-12-21</a></p>

<ol>
  <li>Install the libc6 libraries<br />
<code class="language-plaintext highlighter-rouge">apt install libc6-dbg-riscv64-cross</code></li>
  <li>Give CGO access to the libraries<br />
Copy them into your lib folder <code class="language-plaintext highlighter-rouge">cp /usr/riscv64-linux-gnu/lib/*.* /lib</code></li>
</ol>]]></content>
      

      
      
      
      
      
      <author>
        <name>[&quot;David Burela&quot;]</name>
        
        
      </author>

      
        
      

      
        <category term="golang" />
      
        <category term="RISC-V" />
      

      
      
        <summary type="html"><![CDATA[On my adventures in playing with RISC-V (see Emulating RISC-V, and IPFS on RISC-V), I hit on a few issues. I was struggling to find a guide online on how to cross compile Go code on RISC-V, when cgo is involved. Here is a quick guide and trouble shooting tips to help others.]]></summary>
      

      
      
    </entry>
  
</feed>