Published on: 26-06-2025
Return of Code Snippets
It is 2025. If you are not up to your eyeballs in AI are you a software engineer? A child of the rewrite everything in RUST — SPEED is God — hype train, Zed code editor is fast. One click on the little starburst icon and the built in LLM assistant panel opens. Hype train rails merge. I leverage both in my daily work. Short direct questions to the assistant are helpful. Vibe coding aka LLM babysitting has not proven that useful to me, yet. Now every new project is prefaced with “Should I use an LLM?”.
My personal site use to have a code snippets section. It was backed by Hugo static site generator and markdown files. These days interacting with Zed assistant I come across things I’d like to snippet. Wouldn’t it be cool to ask the assistant to create a snippet for me? MCP Server tool feature should make that possible. Zed supports it. Time to bring snippets back.
git log -p
/snippets
title: "the return of snippets"
date: 2020-01-11T10:19:08+01:00
seo_description: "Blog post of the return of the Snippets section of my site"
draft: false
tags:
- tech
---
When I first started a personal site years ago I maintained a blog post full of
little snippets / tricks I picked up along my journey of learning to program.
Today I had an idea for one to add to that list but that post had since died,
as it was not rolled over in between several iterations of my site.
...
Let’s hope third times the charm on this thrice killed project. mkdir snippets_backend
. npm init woh is this for work? Why am I reaching for Typescript. More Lisp! More Clojure (sorry Racket your are not that practical for writing apps). take src/snippets && touch main.clj
. I’m trying to get into data driven programming. What does that mean? Not sure, but I’m hoping reitit and malli will show me. If we’re going Clojure why not go all the away, make Rich Hickey proud: use Datomic. His captivating talks on the bringing the power of the database application side have me inspired. Abandon Datomic forums over run by spam bots are worrying. No official docker support is painful. Any newer players in the immutable db space? Hello XTDB! It uses a similar data model to Datomic, but more focused on documents, another Docker container for my Nomad homelab cluster.
Getting started by hacking a few .clj
files together. db.clj
to handle the xtdb, api.clj
for the REST API, and config.clj
to handle slurping up a .edn
file. How to organize them? On my last couple work projects I’ve been following the “Clean Architecture” pattern. Named folders 1_core, 2_use_cases, 3_infra
where dependancies flow inward. Use-cases rely on interfaces of concrete implementations in infra folder. IEntityXRepo
is implemented by EntityXSQLiteRepo
for example. Not sounding like idiomatic Clojure. I create separate use-cases files / namespaces, but use-cases import and use the db namespace directly. This will do to get a working app, repo. If I want to add unit testing I’ll need to figure out dependency injection. Booting up the repl I played around and did the backfill from markdown files to the DB. With that done I wrapped up the main use cases in a docker image and now deployed to my homelab where my personal site backend can access it via REST API.
MCP server will be one way to create snippets, but to curate them I’ll need a CMS. Big fan of the browser CMS I built into my cooking notes project that makes it easy to edit cooking notes on my phone while I’m in the kitchen. The code editor is where is where I’ll be interacting with snippets. The CMS should be there. Making CURL request by hand is not practical. Keeping with the Clojure learning I’ll write a simple CMS using Babashka and Gum. Now running snippet-cms edit
pulls up a nice TUI, repo.
Updated the Astro.js backend that powers my personal site to make REST API call and render snippets, changes. Now boom snippets are back!
Wait where is the cool AI integration with MCP server? Well after I realized I’d have to pay 6 cents per prompt after using up my limit in Zed I opted to stick to the cli tool I built. Saving the AI for another project.