<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
    xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>René Kulik - Freelance Software Developer</title>
        <description>Freelance Software Developer from Hamburg, Germany ✓ Node.js ✓ React ✓ Angular ✓ TypeScript ✓ PHP</description>
        <link>https://www.kulik.io/</link>
        <atom:link href="https://www.kulik.io/feed.xml" rel="self" type="application/rss+xml" /><item>
            <title>Then, Now, Next: My Agentic Coding Setup</title>
            <description>&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#then-claude-code-inside-visual-studio-code&quot;&gt;Then: Claude Code Inside Visual Studio Code&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#now-tmux-and-claude-code&quot;&gt;Now: tmux and Claude Code&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#sessions-that-outlive-the-terminal&quot;&gt;Sessions That Outlive the Terminal&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#my-tmux-configuration&quot;&gt;My tmux Configuration&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#why-not-herdr&quot;&gt;Why Not Herdr&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#next-guis-instead-of-terminals&quot;&gt;Next: GUIs Instead of Terminals&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#next-agents-on-remote-servers&quot;&gt;Next: Agents on Remote Servers&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;How I write code has changed a lot over the last months, and the tools around it changed with it. In &lt;a href=&quot;/2026/09/30/the-system-around-the-agent-what-i-learned-setting-up-claude-code/&quot;&gt;my post about setting up Claude Code&lt;/a&gt;, I wrote about the system I built around the agent: instructions, skills, and boundaries. This post is about the layer below that: where the agent runs and how I talk to it.&lt;/p&gt;

&lt;p&gt;I will go through it in three steps: what I used, what I am using now, and what I think will be used in the future.&lt;/p&gt;

&lt;h2 id=&quot;then-claude-code-inside-visual-studio-code&quot;&gt;Then: Claude Code Inside Visual Studio Code&lt;/h2&gt;

&lt;p&gt;When I started with agentic coding, I stayed in the editor I already knew. I opened Visual Studio Code, started Claude Code in its integrated terminal, and worked side by side with the agent. It generated code, and I adjusted that code myself in the editor right next to it.&lt;/p&gt;

&lt;p&gt;That setup made sense at the time. The editor was still the center of my work, and the agent was one more tool inside it. I read every change in the file tree, fixed the parts I did not like by hand, and moved on.&lt;/p&gt;

&lt;p&gt;This is no longer how I work. Today, I generate the code and almost never write it myself. In 99 percent of the cases, a change goes through the agent, including the small corrections I used to make by hand. Once that happened, the editor lost its place in the middle. I still read code, but I do not need a full editor open all day to do that.&lt;/p&gt;

&lt;h2 id=&quot;now-tmux-and-claude-code&quot;&gt;Now: tmux and Claude Code&lt;/h2&gt;

&lt;p&gt;My current setup is &lt;a href=&quot;https://github.com/tmux/tmux&quot;&gt;tmux&lt;/a&gt; and Claude Code, nothing else. tmux is a terminal multiplexer: it lets me split one terminal into several windows and panes, and it keeps them running independently of the terminal window I see them in.&lt;/p&gt;

&lt;h3 id=&quot;sessions-that-outlive-the-terminal&quot;&gt;Sessions That Outlive the Terminal&lt;/h3&gt;

&lt;p&gt;Two things make tmux the right fit for me.&lt;/p&gt;

&lt;p&gt;First, I can run multiple Claude Code sessions in parallel. One session works on a feature in one project, another one answers a question in a different project, and I switch between them with a key binding. Together with &lt;a href=&quot;/2026/10/19/a-sound-when-it-is-done-desktop-notifications-for-claude-code/&quot;&gt;desktop notifications&lt;/a&gt;, I know which one needs me without checking each of them.&lt;/p&gt;

&lt;p&gt;Second, the sessions are not lost. They belong to the tmux server, not to the terminal window, so closing the window does not end them. When I close the terminal window, or the laptop goes to sleep, I reattach later and everything is where I left it: the running sessions, their history, and the panes around them.&lt;/p&gt;

&lt;h3 id=&quot;my-tmux-configuration&quot;&gt;My tmux Configuration&lt;/h3&gt;

&lt;p&gt;My tmux configuration lives in my &lt;a href=&quot;https://github.com/rkulik/dotfiles&quot;&gt;dotfiles repository&lt;/a&gt;. It is deliberately small: a key binding to reload the configuration, Vim-style keys to move between panes, and mouse support for the moments when scrolling or clicking into a pane is simply faster. Everything else is tmux’s default behavior. I never needed more than that.&lt;/p&gt;

&lt;h3 id=&quot;why-not-herdr&quot;&gt;Why Not Herdr&lt;/h3&gt;

&lt;p&gt;There is a promising alternative built specifically for this way of working: &lt;a href=&quot;https://herdr.dev/&quot;&gt;Herdr&lt;/a&gt;. It is an agent multiplexer for the terminal. Like tmux, it gives you panes, tabs, and workspaces that keep running when you detach. On top of that, it knows about the agents running inside them and shows in a sidebar whether each one is working, blocked, done, or idle.&lt;/p&gt;

&lt;p&gt;That is a real improvement over plain tmux, especially for people who run many agents in parallel on the same project, each in its own git worktree. That is not how I work. I rarely run parallel work in one single project, so I do not use worktrees much, and the sessions I run side by side are usually spread across different projects. For that, tmux with my few customizations is enough, and I am used to it.&lt;/p&gt;

&lt;p&gt;If you are starting in this direction today and want to use a terminal for agentic coding, I would skip tmux and try Herdr right from the start. It solves the same problems tmux solves for me and adds the parts that only matter once agents are involved, without years of habits pulling you towards something else.&lt;/p&gt;

&lt;h2 id=&quot;next-guis-instead-of-terminals&quot;&gt;Next: GUIs Instead of Terminals&lt;/h2&gt;

&lt;p&gt;Even though I am happy with my terminal setup, I do not think terminals will be the main way to work with coding agents in the long run. I expect GUI applications like &lt;a href=&quot;https://code.claude.com/docs/en/desktop&quot;&gt;Claude Desktop&lt;/a&gt; or &lt;a href=&quot;https://github.com/pingdotgg/t3code&quot;&gt;T3 Code&lt;/a&gt; to take over that role.&lt;/p&gt;

&lt;p&gt;The terminal is a good fit for developers who already live in it. But when you no longer write the code yourself, the interface you need is a different one. It is mostly a conversation: writing or talking to an agent, reviewing what it did, and keeping an overview of what several agents are doing at the same time. A GUI built for exactly that can do this better than a grid of terminal panes.&lt;/p&gt;

&lt;p&gt;I am not there yet myself. I am too used to my tmux setup, and I also do other things in the terminal besides talking to agents: organizing files, running scripts, managing my dotfiles. As long as the terminal is where the rest of my work happens, it is also where my agents run.&lt;/p&gt;

&lt;h2 id=&quot;next-agents-on-remote-servers&quot;&gt;Next: Agents on Remote Servers&lt;/h2&gt;

&lt;p&gt;The second shift I expect goes further: I think most agents will stop running on our local machines.&lt;/p&gt;

&lt;p&gt;Running an agent locally made sense when I was writing code alongside it. The editor, the language server, the tests, and the agent all needed the same machine. With Claude Code, the model already runs on Anthropic’s servers. What still runs on my laptop is the agent itself and everything it does: editing files, installing dependencies, running builds and tests. When I mostly review instead of writing code, none of that has to happen on the machine in front of me.&lt;/p&gt;

&lt;p&gt;So instead of a powerful laptop, you can rent a server and run your agents there. You connect to it from wherever you are, through a terminal or through a GUI, and write or talk to the agents running on that server. The session lives on the server, so closing the laptop does not matter at all. This is something my local tmux setup cannot do: tmux keeps my sessions from getting lost, but when my laptop goes to sleep, the agents inside them pause too. On a server, they keep working while the laptop is closed, and the results are waiting when I open it again.&lt;/p&gt;

&lt;p&gt;None of this is new. People already run their agents on rented servers, and &lt;a href=&quot;https://code.claude.com/docs/en/claude-code-on-the-web&quot;&gt;Claude Code on the web&lt;/a&gt; runs sessions in the cloud out of the box. So the shift is not about something that does not exist yet. Today, running agents remotely is something you choose deliberately. I expect it to become the default, and running an agent on your own laptop to become the exception.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;My setup went from an editor with a terminal inside it to a terminal with agents inside it. The reason was not the tools themselves but how I work: once I stopped writing code by hand, the editor moved out of the center, and the ability to run several long-lived sessions moved in.&lt;/p&gt;

&lt;p&gt;For now, tmux and Claude Code cover everything I need. If you are starting from scratch with a terminal, I would point you to Herdr instead. And looking further ahead, I think both will be replaced by something that already exists today but is not yet the default: GUI applications as the way we talk to agents, and remote servers as the place where those agents run.&lt;/p&gt;
</description>
            <pubDate>Mon, 02 Nov 2026 00:00:00 +0000</pubDate>
            <link>https://www.kulik.io/2026/11/02/then-now-next-my-agentic-coding-setup/</link>
            <guid isPermaLink="true">https://www.kulik.io/2026/11/02/then-now-next-my-agentic-coding-setup/</guid>
        </item><item>
            <title>A Sound When It Is Done: Desktop Notifications for Claude Code</title>
            <description>&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#two-hooks-one-script&quot;&gt;Two Hooks, One Script&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-script&quot;&gt;The Script&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#reading-the-hook-input&quot;&gt;Reading the Hook Input&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#different-sounds-for-different-events&quot;&gt;Different Sounds for Different Events&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#respecting-do-not-disturb&quot;&gt;Respecting Do Not Disturb&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#filtering-out-the-idle-prompt&quot;&gt;Filtering Out the Idle Prompt&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#trying-it-out&quot;&gt;Trying It Out&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Once an agent can work on its own for a few minutes, watching it becomes a waste of time. I switch to another window, read something, or start a second session in a different project. The problem is knowing when to come back. Either I check too early and interrupt myself for nothing, or I check too late and the agent has been waiting for a permission prompt for ten minutes.&lt;/p&gt;

&lt;p&gt;In &lt;a href=&quot;/2026/09/30/the-system-around-the-agent-what-i-learned-setting-up-claude-code/&quot;&gt;my post about setting up Claude Code&lt;/a&gt;, I mentioned that a hook sends me a desktop notification when the agent is done or needs my input. This post shows how that works: two hooks, one small shell script and one filter.&lt;/p&gt;

&lt;p&gt;My machine runs Ubuntu with GNOME, so the tools below are the ones that ship with that desktop. The idea carries over to any system with a notification daemon.&lt;/p&gt;

&lt;h2 id=&quot;two-hooks-one-script&quot;&gt;Two Hooks, One Script&lt;/h2&gt;

&lt;p&gt;Claude Code &lt;a href=&quot;https://code.claude.com/docs/en/hooks&quot;&gt;hooks&lt;/a&gt; run a command when a certain event happens in a session. Two events are relevant here:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Stop&lt;/code&gt; fires when the agent finishes its turn and hands control back to me.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Notification&lt;/code&gt; fires when Claude Code wants my attention, for example because it needs permission to run a tool.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both point to the same script in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.claude/settings.json&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;hooks&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Notification&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;matcher&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;permission_prompt|auth_success|elicitation_dialog|elicitation_complete|elicitation_response|agent_needs_input|agent_completed&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;hooks&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;command&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;command&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;bash ~/.claude/notify-command.sh&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Stop&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;hooks&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;command&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;command&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;bash ~/.claude/notify-command.sh&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;matcher&lt;/code&gt; on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Notification&lt;/code&gt; hook filters which notifications get through. I will come back to it &lt;a href=&quot;#filtering-out-the-idle-prompt&quot;&gt;below&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;the-script&quot;&gt;The Script&lt;/h2&gt;

&lt;p&gt;Here is the complete &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;notify-command.sh&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$input&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | jq &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;.hook_event_name // &quot;&quot;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$input&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | jq &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;.message // &quot;&quot;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;directory&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$input&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | jq &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;.cwd // &quot;&quot;&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$event&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in
  &lt;/span&gt;Notification&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;summary&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:-&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;Claude&lt;/span&gt;&lt;span class=&quot;p&quot;&gt; needs your attention&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;sound&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;window-attention&quot;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
  Stop&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;summary&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Ready in &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;directory&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;##*/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;sound&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;complete&quot;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;exit &lt;/span&gt;0
    &lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;esac&lt;/span&gt;

notify-send &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; dialog-information &lt;span class=&quot;s2&quot;&gt;&quot;Claude Code&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$summary&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# canberra bypasses the notification daemon, so do-not-disturb has to be checked by hand&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;gsettings get org.gnome.desktop.notifications show-banners&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then
  &lt;/span&gt;canberra-gtk-play &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$sound&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It needs three tools: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jq&lt;/code&gt; to parse JSON, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;notify-send&lt;/code&gt; from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;libnotify-bin&lt;/code&gt; for the popup and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;canberra-gtk-play&lt;/code&gt; from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gnome-session-canberra&lt;/code&gt; for the sound. On Ubuntu, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;notify-send&lt;/code&gt; is usually already installed.&lt;/p&gt;

&lt;h3 id=&quot;reading-the-hook-input&quot;&gt;Reading the Hook Input&lt;/h3&gt;

&lt;p&gt;Claude Code passes the event to the hook as JSON on standard input. The script reads it once and pulls out three fields with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jq&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hook_event_name&lt;/code&gt; tells it whether this is a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Stop&lt;/code&gt; or a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Notification&lt;/code&gt; event, so one script can handle both.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;message&lt;/code&gt; holds the text Claude Code would show for a notification, like a request for permission to use a tool.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cwd&lt;/code&gt; is the working directory of the session.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;// &quot;&quot;&lt;/code&gt; fallback makes &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jq&lt;/code&gt; print an empty string instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;null&lt;/code&gt; when a field is missing. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Stop&lt;/code&gt; events, for example, have no &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;message&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Stop&lt;/code&gt;, the notification reads “Ready in” followed by the name of the project folder. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;${directory##*/}&lt;/code&gt; strips everything up to the last slash, so &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/home/user/projects/my-app&lt;/code&gt; becomes &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;my-app&lt;/code&gt;. When I have sessions running in several projects, this tells me which one is done without switching to the terminal.&lt;/p&gt;

&lt;p&gt;Any other event ends the script with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exit 0&lt;/code&gt;. The script should only ever be wired to these two hooks, but if it ends up somewhere else, it stays silent instead of sending a notification with an empty text.&lt;/p&gt;

&lt;h3 id=&quot;different-sounds-for-different-events&quot;&gt;Different Sounds for Different Events&lt;/h3&gt;

&lt;p&gt;The popup alone is easy to miss, especially on a second screen. A sound is what actually pulls me back. The two events get different sounds, so I can tell them apart without looking:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete&lt;/code&gt; for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Stop&lt;/code&gt;: the agent is done, and I can come back whenever it suits me.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;window-attention&lt;/code&gt; for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Notification&lt;/code&gt;: the agent is blocked until I respond.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both names come from the &lt;a href=&quot;https://www.freedesktop.org/wiki/Specifications/sound-theme-spec/&quot;&gt;freedesktop sound theme&lt;/a&gt;, which ships with Ubuntu. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;canberra-gtk-play -i&lt;/code&gt; takes such a name and plays the matching file from the active theme. The files live in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/share/sounds/freedesktop/stereo/&lt;/code&gt;, so it is easy to listen through them and pick different ones.&lt;/p&gt;

&lt;h3 id=&quot;respecting-do-not-disturb&quot;&gt;Respecting Do Not Disturb&lt;/h3&gt;

&lt;p&gt;This is the one gotcha in the script. GNOME has a do not disturb mode, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;notify-send&lt;/code&gt; respects it: the popup simply does not appear. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;canberra-gtk-play&lt;/code&gt; does not. It talks to the sound system directly and never goes through the notification daemon, so without an extra check, my laptop would chime in the middle of a call even though notifications are switched off.&lt;/p&gt;

&lt;p&gt;GNOME stores the state of do not disturb in a setting. When it is on, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show-banners&lt;/code&gt; is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gsettings get org.gnome.desktop.notifications show-banners
&lt;span class=&quot;c&quot;&gt;# true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The script only plays the sound when this returns &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;true&lt;/code&gt;. That is why the comment above the check exists: without it, the condition looks unrelated to the line it guards.&lt;/p&gt;

&lt;h2 id=&quot;filtering-out-the-idle-prompt&quot;&gt;Filtering Out the Idle Prompt&lt;/h2&gt;

&lt;p&gt;Without a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;matcher&lt;/code&gt;, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Notification&lt;/code&gt; hook fires for every notification Claude Code sends. One of them is noise to me: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;idle_prompt&lt;/code&gt;. Claude Code sends it when the agent has been waiting for input for a while.&lt;/p&gt;

&lt;p&gt;In my setup, that notification never tells me anything new. When the agent finishes, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Stop&lt;/code&gt; has already notified me. If I have not come back yet, it is because I am busy with something else, and a second ping a minute later does not change that. It only teaches me to ignore the sound, which defeats the purpose of having one.&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Notification&lt;/code&gt; hook supports a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;matcher&lt;/code&gt; that is checked against the notification type. Instead of excluding &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;idle_prompt&lt;/code&gt;, the matcher lists the types I do want. This way, the agent notifies me in exactly two situations: when it is done, and when it is blocked on me.&lt;/p&gt;

&lt;h2 id=&quot;trying-it-out&quot;&gt;Trying It Out&lt;/h2&gt;

&lt;p&gt;Since the script only reads from standard input, it can be tested without starting a session:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;hook_event_name&quot;:&quot;Stop&quot;,&quot;cwd&quot;:&quot;/tmp/demo&quot;}&apos;&lt;/span&gt; | bash ~/.claude/notify-command.sh
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;hook_event_name&quot;:&quot;Notification&quot;,&quot;message&quot;:&quot;Claude needs your permission to use Bash&quot;}&apos;&lt;/span&gt; | bash ~/.claude/notify-command.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The first command shows “Ready in demo” with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;complete&lt;/code&gt; sound. The second shows the message with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;window-attention&lt;/code&gt; sound. With do not disturb on, both stay silent.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;A notification hook takes a few lines of configuration and a shell script of about 25 lines, and it changes how I work with the agent. I no longer check on it. I start a task, move on to something else, and come back when I hear the sound. Which sound it is tells me whether I need to come back now or can finish what I am doing first.&lt;/p&gt;

&lt;p&gt;Two details made the difference between a useful notification and an annoying one. The sound has to respect do not disturb, which &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;canberra-gtk-play&lt;/code&gt; does not do on its own. And the hook should only fire when there is actually something to do. A notification that fires all the time is one I would quickly learn to ignore.&lt;/p&gt;
</description>
            <pubDate>Mon, 19 Oct 2026 00:00:00 +0000</pubDate>
            <link>https://www.kulik.io/2026/10/19/a-sound-when-it-is-done-desktop-notifications-for-claude-code/</link>
            <guid isPermaLink="true">https://www.kulik.io/2026/10/19/a-sound-when-it-is-done-desktop-notifications-for-claude-code/</guid>
        </item><item>
            <title>One URL, Two Formats: A Business Card for Browsers and Terminals</title>
            <description>&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-idea&quot;&gt;The Idea&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#project-setup&quot;&gt;Project Setup&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#detecting-the-terminal-at-the-edge&quot;&gt;Detecting the Terminal at the Edge&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#why-user-agent-and-not-accept&quot;&gt;Why User-Agent and Not Accept&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#rewrite-not-redirect&quot;&gt;Rewrite, Not Redirect&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#telling-caches-what-changed&quot;&gt;Telling Caches What Changed&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#why-the-command-needs--l&quot;&gt;Why the Command Needs -L&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#short-links-with-302&quot;&gt;Short Links with 302&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#headers-for-the-text-card&quot;&gt;Headers for the Text Card&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#trade-offs&quot;&gt;Trade-offs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;I wanted a digital business card: one short domain I can put on a slide, in an email signature or say out loud, that leads to everything else. I registered &lt;a href=&quot;https://kulik.tech&quot;&gt;kulik.tech&lt;/a&gt; for it.&lt;/p&gt;

&lt;p&gt;A plain HTML page would have done the job. But most people I hand this card to are developers, so I wanted it to work in the place they spend their day as well: the terminal.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt; kulik.tech
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This post walks through how it works. The whole project is one edge function, one redirects file and two static files, but a few of the details are easy to get wrong.&lt;/p&gt;

&lt;h2 id=&quot;the-idea&quot;&gt;The Idea&lt;/h2&gt;

&lt;p&gt;The same URL serves two formats:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;In a &lt;strong&gt;browser&lt;/strong&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kulik.tech&lt;/code&gt; shows an HTML page styled like a terminal session.&lt;/li&gt;
  &lt;li&gt;In a &lt;strong&gt;terminal&lt;/strong&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl -L kulik.tech&lt;/code&gt; prints a plain-text card.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  René Kulik
  Freelance Software Developer · Hamburg, Germany

  I build AI-powered applications, backend systems,
  user interfaces and agent workflows.

  website   https://kulik.tech/website
  blog      https://kulik.tech/blog
  email     rene@kulik.io
  github    https://kulik.tech/gh
  linkedin  https://kulik.tech/li
  ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;On top of that, short links like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kulik.tech/gh&lt;/code&gt; forward to my profiles.&lt;/p&gt;

&lt;h2 id=&quot;project-setup&quot;&gt;Project Setup&lt;/h2&gt;

&lt;p&gt;The site runs on &lt;a href=&quot;https://www.netlify.com/&quot;&gt;Netlify&lt;/a&gt; and has no build step. The repository looks like this:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;netlify/edge-functions/card.ts
public/_redirects
public/card.txt
public/index.html
netlify.toml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netlify.toml&lt;/code&gt; sets &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;public&lt;/code&gt; as the publish directory. The only dependency is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@netlify/edge-functions&lt;/code&gt; for its types. For local development, I run the Netlify CLI through &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pnpm dlx&lt;/code&gt; with a pinned version, so it never ends up in the lockfile:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;scripts&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;dev&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;pnpm --package=netlify-cli@27.12.0 dlx netlify dev --offline&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The HTML page inlines its CSS and uses an inline SVG as its favicon, so a visit is a single request.&lt;/p&gt;

&lt;h2 id=&quot;detecting-the-terminal-at-the-edge&quot;&gt;Detecting the Terminal at the Edge&lt;/h2&gt;

&lt;p&gt;The interesting part is deciding which format to serve. That happens in a &lt;a href=&quot;https://docs.netlify.com/edge-functions/overview/&quot;&gt;Netlify Edge Function&lt;/a&gt; that runs on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-ts highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Context&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;@netlify/edge-functions&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;CLI_USER_AGENT&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sr&quot;&gt;/^&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;curl|wget|httpie|xh&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;)\/&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;isCliRequest&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;userAgent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;user-agent&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;CLI_USER_AGENT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;userAgent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Promise&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;URL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;isCliRequest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;URL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/card.txt&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Vary&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;User-Agent&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Config&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Command-line HTTP clients identify themselves with a user agent like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl/8.5.0&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Wget/1.21.4&lt;/code&gt;. The regex is anchored to the start of the string and expects a slash after the name, so a browser user agent never matches by accident. If someone fakes their user agent, they get the text card in their browser. That is fine.&lt;/p&gt;

&lt;h3 id=&quot;why-user-agent-and-not-accept&quot;&gt;Why User-Agent and Not Accept&lt;/h3&gt;

&lt;p&gt;The textbook way to pick a format is &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation&quot;&gt;content negotiation&lt;/a&gt; through the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Accept&lt;/code&gt; header: the client says what it wants, and the server responds accordingly.&lt;/p&gt;

&lt;p&gt;In practice, that does not help here. curl sends &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Accept: */*&lt;/code&gt; by default, which means “anything is fine”. So does wget. The header carries no information about whether the client is a terminal, so the user agent is the more useful signal.&lt;/p&gt;

&lt;h3 id=&quot;rewrite-not-redirect&quot;&gt;Rewrite, Not Redirect&lt;/h3&gt;

&lt;p&gt;When an edge function returns a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;URL&lt;/code&gt; instead of a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Response&lt;/code&gt;, Netlify treats it as a &lt;strong&gt;rewrite&lt;/strong&gt;. It serves the content of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/card.txt&lt;/code&gt;, but the client never sees a different URL. There is no extra round trip and no &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Location&lt;/code&gt; header. The terminal gets the text card directly at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For every other request, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;context.next()&lt;/code&gt; passes the request on to the static &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;index.html&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;telling-caches-what-changed&quot;&gt;Telling Caches What Changed&lt;/h2&gt;

&lt;p&gt;This is the detail that is easiest to forget. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt; now returns different bodies depending on a request header. Any cache sitting between the client and the server, like a corporate proxy, keys its entries by URL. Without further information, it could store the text card and hand it to the next visitor’s browser, or the other way around.&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vary&lt;/code&gt; header solves this. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vary: User-Agent&lt;/code&gt; tells caches that the user agent is part of the cache key. Netlify itself does not need it, because the edge function runs before its cache on every request. But a cache further down the line only gets the full picture if &lt;strong&gt;both&lt;/strong&gt; responses carry the header.&lt;/p&gt;

&lt;p&gt;The HTML branch appends it in the edge function. The text branch is trickier: it returns a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;URL&lt;/code&gt;, not a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Response&lt;/code&gt;, so there is no response object to set a header on. Instead, the header goes into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netlify.toml&lt;/code&gt;. Headers defined for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/card.txt&lt;/code&gt; also apply when &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt; is rewritten to it:&lt;/p&gt;

&lt;div class=&quot;language-toml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;[[headers]]&lt;/span&gt;
  &lt;span class=&quot;py&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/card.txt&quot;&lt;/span&gt;
  &lt;span class=&quot;nn&quot;&gt;[headers.values]&lt;/span&gt;
    &lt;span class=&quot;py&quot;&gt;Content-Type&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;text/plain; charset=utf-8&quot;&lt;/span&gt;
    &lt;span class=&quot;py&quot;&gt;Vary&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;User-Agent&quot;&lt;/span&gt;
    &lt;span class=&quot;py&quot;&gt;X-Robots-Tag&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;noindex&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Requests to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/card.txt&lt;/code&gt; itself carry the header too, which is harmless. A quick check confirms both branches:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl &lt;span class=&quot;nt&quot;&gt;-sI&lt;/span&gt; https://kulik.tech/ | &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; vary
&lt;span class=&quot;c&quot;&gt;# vary: User-Agent&lt;/span&gt;

curl &lt;span class=&quot;nt&quot;&gt;-sI&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Mozilla/5.0&quot;&lt;/span&gt; https://kulik.tech/ | &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; vary
&lt;span class=&quot;c&quot;&gt;# vary: Accept-Encoding, User-Agent&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;why-the-command-needs--l&quot;&gt;Why the Command Needs -L&lt;/h2&gt;

&lt;p&gt;Without a scheme, curl requests &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://kulik.tech&lt;/code&gt;. Netlify answers with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;301&lt;/code&gt; to the HTTPS version, and curl does not follow redirects by default:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl &lt;span class=&quot;nt&quot;&gt;-sI&lt;/span&gt; kulik.tech
&lt;span class=&quot;c&quot;&gt;# HTTP/1.1 301 Moved Permanently&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Location: https://kulik.tech/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-L&lt;/code&gt; flag tells curl to follow it. That is why the HTML page shows &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl -L kulik.tech&lt;/code&gt; as its prompt line: it is the shortest command that actually works.&lt;/p&gt;

&lt;h2 id=&quot;short-links-with-302&quot;&gt;Short Links with 302&lt;/h2&gt;

&lt;p&gt;The short links live in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;public/_redirects&lt;/code&gt;, which Netlify reads at deploy time:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# 302 so targets can change later without browsers caching the old one forever
/website  https://www.kulik.io/                     302
/blog     https://www.kulik.io/blog/                302
/gh       https://github.com/rkulik                 302
/li       https://www.linkedin.com/in/rene-kulik/   302
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;302&lt;/code&gt; instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;301&lt;/code&gt; is deliberate. Browsers may cache a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;301&lt;/code&gt; indefinitely. If I ever change where &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/li&lt;/code&gt; points, anyone who visited it before would keep going to the old target, and there is nothing I can do about it from the server side. A &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;302&lt;/code&gt; is checked again on every visit.&lt;/p&gt;

&lt;p&gt;The text card uses these short links as well. That keeps its lines short enough for a narrow terminal, and the targets only live in one place.&lt;/p&gt;

&lt;h2 id=&quot;headers-for-the-text-card&quot;&gt;Headers for the Text Card&lt;/h2&gt;

&lt;p&gt;Besides &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vary&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netlify.toml&lt;/code&gt; sets two more headers on the text card:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Content-Type: text/plain; charset=utf-8&lt;/code&gt;. Without an explicit charset, the “é” in my name can show up as garbage, depending on the client.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;X-Robots-Tag: noindex&lt;/code&gt;. Search engines should index the HTML page, not a text file with the same content.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;trade-offs&quot;&gt;Trade-offs&lt;/h2&gt;

&lt;p&gt;The text card and the HTML page contain the same information, maintained in two files. I could generate both from one source, but that would mean adding a build step to a project that currently has none. With eight links that rarely change, keeping two files in sync is the simpler option.&lt;/p&gt;

&lt;p&gt;User agent detection is also a heuristic. A client I did not list, or a curl with a custom user agent, gets the HTML page. For a business card, that is an acceptable failure mode: the HTML is still readable in a terminal, just not pretty.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;A business card that works in the browser and the terminal takes very little code on Netlify: an edge function that checks the user agent and rewrites to a text file, a redirects file for the short links and a few headers. The part worth paying attention to is caching. Whenever one URL serves different content based on a request header, every variant needs a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vary&lt;/code&gt; header for that request header.&lt;/p&gt;

&lt;p&gt;Try it yourself:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt; kulik.tech
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
            <pubDate>Thu, 15 Oct 2026 00:00:00 +0000</pubDate>
            <link>https://www.kulik.io/2026/10/15/one-url-two-formats-a-business-card-for-browsers-and-terminals/</link>
            <guid isPermaLink="true">https://www.kulik.io/2026/10/15/one-url-two-formats-a-business-card-for-browsers-and-terminals/</guid>
        </item><item>
            <title>Just Answer the Question: When I Want to Talk and the Agent Wants to Act</title>
            <description>&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#a-question-is-not-a-request&quot;&gt;A Question Is Not a Request&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#why-the-agent-acts&quot;&gt;Why the Agent Acts&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-skill&quot;&gt;The Skill&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#how-i-use-it&quot;&gt;How I Use It&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;My usual workflow with &lt;a href=&quot;https://code.claude.com/docs/en/overview&quot;&gt;Claude Code&lt;/a&gt; is simple. I talk to the agent about what I want, and then I expect it to implement it. When I describe a bug, I want it fixed. When I describe a feature, I want it built. Most of my messages end in code changes.&lt;/p&gt;

&lt;p&gt;But sometimes I just want to ask something, and then nothing should get implemented.&lt;/p&gt;

&lt;p&gt;A while ago, I was in the middle of a feature when I looked at a piece of the code and wondered whether a different approach would be cleaner. So I asked: “Wouldn’t it make more sense to do it this way?”&lt;/p&gt;

&lt;p&gt;I expected an answer. Maybe a yes, maybe a no, ideally a few reasons either way. What I got was “You’re right, that is cleaner”, followed by the agent rewriting the code. Before I had even decided whether I liked the idea, it was already implemented.&lt;/p&gt;

&lt;p&gt;It was not the only time, and over the following weeks it kept happening. In this post, I want to share why I think it happens and the very small skill I wrote to stop it.&lt;/p&gt;

&lt;h2 id=&quot;a-question-is-not-a-request&quot;&gt;A Question Is Not a Request&lt;/h2&gt;

&lt;p&gt;When I ask a colleague “wouldn’t it make more sense to do it this way?”, I am not telling them to change the code. I am thinking out loud. I want them to push back, point out something I missed, or confirm that my idea holds up. The decision comes after the discussion, not before it.&lt;/p&gt;

&lt;p&gt;That is the conversation I wanted to have with the agent. Instead, the question skipped the discussion and went straight to the implementation. This causes a few problems:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;The decision was made without me.&lt;/strong&gt; I had not agreed to the change. I had only asked about it.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;The agent agreed too quickly.&lt;/strong&gt; An answer that starts with “you’re right” and ends in a diff is not an evaluation of my idea. Sometimes my idea was worse, and I only found out after reading the new code.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;I have to clean up.&lt;/strong&gt; If I decide to keep the original approach, I now have to ask the agent to revert its changes, and check that it actually did.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;It costs focus.&lt;/strong&gt; Instead of thinking about the trade-off, I am suddenly reviewing a diff I did not ask for.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;why-the-agent-acts&quot;&gt;Why the Agent Acts&lt;/h2&gt;

&lt;p&gt;I do not think the model misunderstands me. It is an agent with tools to edit files and run commands, and it is built to be helpful. Read in that context, “wouldn’t it make more sense to do it this way?” is easy to interpret as a polite instruction. And the most helpful thing an agent can do with an instruction is to carry it out.&lt;/p&gt;

&lt;p&gt;To be fair, that matches my usual workflow. Most of my messages end in code changes, so that eagerness is exactly what I want most of the time. The messages where I only want to ask something look a lot like the others. From the wording alone, the agent cannot reliably tell whether I want to talk or to act.&lt;/p&gt;

&lt;p&gt;Claude Code has a &lt;a href=&quot;https://code.claude.com/docs/en/permission-modes#analyze-before-you-edit-with-plan-mode&quot;&gt;plan mode&lt;/a&gt; for read-only work. But plan mode is built for planning an implementation and ends with a plan to approve. For a quick question in the middle of a session, I do not want a plan. I want an answer.&lt;/p&gt;

&lt;h2 id=&quot;the-skill&quot;&gt;The Skill&lt;/h2&gt;

&lt;p&gt;So I made the difference explicit. I wrote a &lt;a href=&quot;https://code.claude.com/docs/en/skills&quot;&gt;skill&lt;/a&gt; called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;answer&lt;/code&gt;. Here is the complete file:&lt;/p&gt;

&lt;div class=&quot;language-markdown highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;answer&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Answer the request with an explanation, diagnosis, or recommendation only.&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;disable-model-invocation&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;

Answer the user&apos;s request; do not implement it. If the answer is a change, describe it instead of making it.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That is all. Two sentences of instructions.&lt;/p&gt;

&lt;p&gt;The first sentence is the obvious rule. The second one covers the case that kept happening: when the answer to my question is “yes, change the code”, the agent should describe the change instead of making it. That way I still get the useful part, a concrete proposal, but I decide whether it happens.&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;disable-model-invocation: true&lt;/code&gt; line matters as well. It means the agent can never load this skill on its own. Only I can start it. The skill is a signal from me about how I want this specific message to be handled, so it would make no sense for the agent to decide when it applies.&lt;/p&gt;

&lt;h2 id=&quot;how-i-use-it&quot;&gt;How I Use It&lt;/h2&gt;

&lt;p&gt;I put &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/answer&lt;/code&gt; in front of the question:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/answer wouldn&apos;t it make more sense to move the validation into the service?
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The agent now looks at the code, weighs the two approaches, and tells me what it thinks. If it agrees, it explains why and describes what the change would look like. If it disagrees, it tells me that too. Either way, no file is touched.&lt;/p&gt;

&lt;p&gt;I use it for more than design questions:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Diagnosis.&lt;/strong&gt; “Why does this test fail?” When I want to understand the cause before I decide how to fix it.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Review.&lt;/strong&gt; “Is there anything wrong with this approach?” When I want an opinion, not a refactoring.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Recommendations.&lt;/strong&gt; “Which of these two libraries would you pick?” When I want the reasoning, not a new entry in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;package.json&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The skill only applies to the message I use it with. If the answer convinces me, my next message is simply “do it”, and the agent implements the change it just described. The discussion and the decision happen first, the implementation second.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;The fix for an agent that acts too eagerly was not a long prompt or a complicated rule. It was a way for me to say, in one word, that this message is a question and not a request.&lt;/p&gt;

&lt;p&gt;It also reminded me of something I wrote about in &lt;a href=&quot;/2026/09/30/the-system-around-the-agent-what-i-learned-setting-up-claude-code/&quot;&gt;The System Around the Agent&lt;/a&gt;: write the rule at the point of failure. I kept getting implementations when I wanted answers, so now there is a skill that names exactly that.&lt;/p&gt;
</description>
            <pubDate>Wed, 14 Oct 2026 00:00:00 +0000</pubDate>
            <link>https://www.kulik.io/2026/10/14/just-answer-the-question-when-i-want-to-talk-and-the-agent-wants-to-act/</link>
            <guid isPermaLink="true">https://www.kulik.io/2026/10/14/just-answer-the-question-when-i-want-to-talk-and-the-agent-wants-to-act/</guid>
        </item><item>
            <title>Baking Your Own Bread: Who Should Build Software Now That Everyone Can</title>
            <description>&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#from-engineer-to-manager&quot;&gt;From Engineer to Manager&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#everyone-can-build-software&quot;&gt;Everyone Can Build Software&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#a-personal-website&quot;&gt;A Personal Website&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#a-small-online-shop&quot;&gt;A Small Online Shop&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#software-at-scale&quot;&gt;Software at Scale&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#hey-is-the-exception-not-the-rule&quot;&gt;HEY Is the Exception, Not the Rule&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#what-this-means-for-jobs&quot;&gt;What This Means for Jobs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#do-we-really-need-more-software&quot;&gt;Do We Really Need More Software?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;At &lt;a href=&quot;https://www.youtube.com/watch?v=vDjW_dRyKXY&quot;&gt;Rails World 2026&lt;/a&gt;, DHH opened the conference with a keynote that boils down to two words: pencils down. At 37signals, writing code by hand is no longer the normal way of working. It is the exception. He compared the current moment to the Kodak Brownie, the cheap camera that turned photography from a craft for professionals into something everyone could do.&lt;/p&gt;

&lt;p&gt;I agree with him. Not because the keynote was provocative, but because it matches what I have seen at my own desk over the last months.&lt;/p&gt;

&lt;p&gt;In this post, I want to share how my own work has changed, where I think the line runs between building software yourself and getting a professional involved, and what I expect for our profession.&lt;/p&gt;

&lt;h2 id=&quot;from-engineer-to-manager&quot;&gt;From Engineer to Manager&lt;/h2&gt;

&lt;p&gt;Over the last months, I wrote less and less code myself. I acted more like a manager than a software engineer. I tell the model what I want, not how to implement it, and it does the implementation.&lt;/p&gt;

&lt;p&gt;I still read and review the code thoroughly. But as the models got better, they more and more often one-shotted a feature and the code quality was something I would happily merge. The models even handled edge cases I had not thought of myself. My aha moment came with Opus 5.5. For the first time, my review mostly confirmed the result instead of correcting it.&lt;/p&gt;

&lt;p&gt;That does not mean I skip the work around the code. Describing the requirements, deciding on the approach, and checking the outcome are still my job. I wrote about the setup that makes this possible in &lt;a href=&quot;/2026/09/30/the-system-around-the-agent-what-i-learned-setting-up-claude-code/&quot;&gt;The System Around the Agent&lt;/a&gt;. What changed is that the typing is no longer the part I spend my time on.&lt;/p&gt;

&lt;h2 id=&quot;everyone-can-build-software&quot;&gt;Everyone Can Build Software&lt;/h2&gt;

&lt;p&gt;I am not the only one experiencing this. More and more people create their own software projects, many of them without a technical background. The question is no longer whether they can. The question is how far they should take it.&lt;/p&gt;

&lt;p&gt;I find it helpful to compare it to other crafts. I can bake my own bread, cut my own hair, or build my own dining table. Nobody would stop me, and for simple cases the result is perfectly fine. But there is a threshold of complexity where it makes sense to get a professional involved. Software now works the same way.&lt;/p&gt;

&lt;h3 id=&quot;a-personal-website&quot;&gt;A Personal Website&lt;/h3&gt;

&lt;p&gt;Can someone without technical knowledge create their own website and put it on the internet? Definitely. It takes an hour, maybe even minutes. Should they do it? Yes, why not. For a personal website, I do not see the need to hire a professional anymore.&lt;/p&gt;

&lt;h3 id=&quot;a-small-online-shop&quot;&gt;A Small Online Shop&lt;/h3&gt;

&lt;p&gt;Can a small business without technical knowledge build its own online shop and put it out into the world? Yes, that is possible. Should they do it themselves? It depends.&lt;/p&gt;

&lt;p&gt;Using a website builder with AI assistance is a great option. The hard parts like payments, hosting, and security are already solved by the platform. But if the shop needs to be custom because the business has very specific needs, a professional should steer, or at least review what the model produced before it goes live. A shop handles money and customer data. A mistake there is not just embarrassing, it is expensive.&lt;/p&gt;

&lt;h3 id=&quot;software-at-scale&quot;&gt;Software at Scale&lt;/h3&gt;

&lt;p&gt;Should bigger companies vibe code their software from now on without looking at the code? In my opinion, no. There should still be a professional who looks at the structure and the architecture of what the model produced. Someone who knows what a hook is, what a context is, and how the authentication flow works in detail.&lt;/p&gt;

&lt;p&gt;The model can write all of that. But someone has to be able to tell whether it wrote the right thing, and that person needs to understand the code on a higher level, even if they did not type it.&lt;/p&gt;

&lt;h2 id=&quot;hey-is-the-exception-not-the-rule&quot;&gt;HEY Is the Exception, Not the Rule&lt;/h2&gt;

&lt;p&gt;DHH’s showcase was HEY. 37signals moved it from a web app to native applications and rebuilt the backend in Rust. That fits their vision of HEY being native, and Rust is fast and works well with AI agents.&lt;/p&gt;

&lt;p&gt;But this was a rewrite. They already had all the requirements, and they knew exactly how the application should look and behave from top to bottom. I would also bet they have end-to-end tests they could run against the new version to verify it behaves exactly like the old one. That is close to the ideal setup for an agent: a complete specification and a way to check the result automatically.&lt;/p&gt;

&lt;p&gt;Most projects do not start there. Requirements are unclear, they change halfway through, and nobody knows yet what the finished product should look like. So for me, HEY is an exception. I have yet to see another large application that was mostly built or rewritten by an AI model.&lt;/p&gt;

&lt;h2 id=&quot;what-this-means-for-jobs&quot;&gt;What This Means for Jobs&lt;/h2&gt;

&lt;p&gt;Will there be fewer software development jobs? Yes. We can already see it.&lt;/p&gt;

&lt;p&gt;Will it be hard for junior developers to enter the industry? Yes. If you have just finished your studies or are early in your career, finding a job is very hard right now. Many of the tasks juniors used to learn on are exactly the tasks models now do well.&lt;/p&gt;

&lt;p&gt;On top of that, the economic situation is not great. Companies seem afraid to hire and to start new projects because they are unsure about the future. That makes it harder for experienced developers to find a new position as well.&lt;/p&gt;

&lt;h2 id=&quot;do-we-really-need-more-software&quot;&gt;Do We Really Need More Software?&lt;/h2&gt;

&lt;p&gt;So if we stop looking at the code, talk to a model in plain English, and everyone can build software, does that mean developers will not be needed anymore?&lt;/p&gt;

&lt;p&gt;Some argue the opposite. Since software becomes cheaper and faster to build, demand will grow, and we will need even more people to build it. Robert C. Martin made this point recently:&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;By continuing to engineer software, and by realizing that engineering software now means the management of agents to produce that software.&lt;br /&gt;&lt;br /&gt;Using agents will make you X times more productive. This does not mean that companies will require fewer programmers. It means that…&lt;/p&gt;&amp;mdash; Uncle Bob Martin (@unclebobmartin) &lt;a href=&quot;https://x.com/unclebobmartin/status/2105715756746903610?ref_src=twsrc%5Etfw&quot;&gt;October 1, 2026&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.x.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;p&gt;I agree with the first half. Engineering software now means managing agents, and that matches my own experience. But I am not convinced that more productivity per developer leads to the same number of developers. Does an online shop need new features every week? Does an internal company application need to be extended every week? Most software I know has a natural size. Once it does its job, it needs maintenance, not constant growth. Faster production does not automatically create more demand for the product.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Everyone can build software now, and that is a good thing. For a personal website or a small side project, you do not need a professional anymore, the same way you do not need a baker to make bread at home.&lt;/p&gt;

&lt;p&gt;But complexity has a threshold. Once money, customer data, or a large codebase is involved, someone needs to understand what the model built and take responsibility for it.&lt;/p&gt;

&lt;p&gt;I believe there will always be demand for highly skilled developers who know how to work with models and can steer entire software projects. There will just be fewer of us, and the job will look a lot more like managing than typing.&lt;/p&gt;
</description>
            <pubDate>Fri, 02 Oct 2026 00:00:00 +0000</pubDate>
            <link>https://www.kulik.io/2026/10/02/baking-your-own-bread-who-should-build-software-now-that-everyone-can/</link>
            <guid isPermaLink="true">https://www.kulik.io/2026/10/02/baking-your-own-bread-who-should-build-software-now-that-everyone-can/</guid>
        </item><item>
            <title>The System Around the Agent: What I Learned Setting Up Claude Code</title>
            <description>&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-setup-is-code&quot;&gt;The Setup Is Code&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#standards-before-prompts&quot;&gt;Standards Before Prompts&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#small-skills-for-models-that-keep-getting-better&quot;&gt;Small Skills for Models That Keep Getting Better&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#spec-driven-development-the-way-i-already-worked&quot;&gt;Spec-Driven Development, the Way I Already Worked&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#why-not-an-existing-framework&quot;&gt;Why Not an Existing Framework&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#from-ticket-to-commit&quot;&gt;From Ticket to Commit&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#i-stay-in-the-loop&quot;&gt;I Stay in the Loop&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#context-is-a-budget&quot;&gt;Context Is a Budget&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#room-to-act-hard-boundaries&quot;&gt;Room to Act, Hard Boundaries&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#what-carries-over-to-building-ai-products&quot;&gt;What Carries Over to Building AI Products&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;My first few months with &lt;a href=&quot;https://code.claude.com/docs/en/overview&quot;&gt;Claude Code&lt;/a&gt; went like this. I opened a session, described what I wanted, and got code back that mostly worked. Then I read it and found default exports where I use named ones, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;any&lt;/code&gt; sprinkled through the types, comments restating what the line below already said, and a caret range in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;package.json&lt;/code&gt;. So I typed the correction, the agent fixed it, and the next day I typed the same correction again in a fresh session.&lt;/p&gt;

&lt;p&gt;The model was not the problem. The agent simply had no way to know my standards, because I had never written them down anywhere it could read. Every session started from zero, and I spent part of it re-explaining how I write code.&lt;/p&gt;

&lt;p&gt;Over time I stopped treating the agent as a chat window and started treating it as a tool I configure. In this post, I will share what I learned along the way and the setup I ended up with: what I write down, what I deliberately leave out, and how a feature moves from an idea to a commit.&lt;/p&gt;

&lt;h2 id=&quot;the-setup-is-code&quot;&gt;The Setup Is Code&lt;/h2&gt;

&lt;p&gt;My Claude Code configuration lives in its own git repository: the global &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CLAUDE.md&lt;/code&gt;, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;settings.json&lt;/code&gt;, my skills, and two small shell scripts for the status line and notifications. A &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;make install&lt;/code&gt; symlinks everything into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.claude&lt;/code&gt;. When I change how the agent behaves, I change it in the repository, and the change is live in the next session. On a new machine, one command sets up everything.&lt;/p&gt;

&lt;p&gt;This turned out to matter more than I expected. Because the setup is a repository, every change to how the agent behaves has a diff, a commit message, and a history. When the agent starts doing something odd, I can look at what I changed recently. When something starts working well, I can see why. Without that history, I would be tuning the setup by memory.&lt;/p&gt;

&lt;h2 id=&quot;standards-before-prompts&quot;&gt;Standards Before Prompts&lt;/h2&gt;

&lt;p&gt;The base layer is the global &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CLAUDE.md&lt;/code&gt;, an instruction file that Claude Code reads at the start of every session in every project. It holds the rules I would otherwise repeat forever: how I name things, how I type things, how I handle dependencies, and what the agent may and may not do. A few lines from it:&lt;/p&gt;

&lt;div class=&quot;language-markdown highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; Avoid &lt;span class=&quot;sb&quot;&gt;`any`&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; Use named exports wherever possible; no default exports
&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; Minimize comments. Comment only non-obvious &lt;span class=&quot;ge&quot;&gt;*why*&lt;/span&gt; (tradeoff, workaround, gotcha), never &lt;span class=&quot;ge&quot;&gt;*what*&lt;/span&gt;.
&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; When installing new dependencies, pin exact versions (no &lt;span class=&quot;sb&quot;&gt;`^`&lt;/span&gt;/&lt;span class=&quot;sb&quot;&gt;`~`&lt;/span&gt; ranges)
&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; NEVER push, force-push, or open a PR unless explicitly asked.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Two principles shaped that file more than anything else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Write the rule at the point of failure.&lt;/strong&gt; A rule like “prefer clean code” does not change anything. A rule that names the exact thing I keep correcting changes the next file that gets written. Most lines in that file exist because I once corrected the same thing twice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rules about behavior matter as much as rules about syntax.&lt;/strong&gt; The style rules make the output look like my code. The git rules, like never pushing on its own, are what allow me to leave the agent running without watching it.&lt;/p&gt;

&lt;h2 id=&quot;small-skills-for-models-that-keep-getting-better&quot;&gt;Small Skills for Models That Keep Getting Better&lt;/h2&gt;

&lt;p&gt;The instruction file says how to write code. It does not say how to do a specific job. That is what &lt;a href=&quot;https://code.claude.com/docs/en/skills&quot;&gt;skills&lt;/a&gt; are for: short procedures the agent loads when a task calls for them. I have skills for commit messages, for my &lt;a href=&quot;/2025/04/09/rest-api-design-best-practices-and-lessons-learned/&quot;&gt;REST API conventions&lt;/a&gt;, for setting up linting and git hooks, for pinning and updating dependencies, and for writing new skills.&lt;/p&gt;

&lt;p&gt;All of them are small. Many are a single paragraph. Here is the complete commit message skill:&lt;/p&gt;

&lt;div class=&quot;language-markdown highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;gcc&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Write a commit message for staged git changes. Use whenever a commit is about to be made&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;when the user asks to commit, asks for a commit message, invokes /gcc, or you are about to commit your own work.&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;---&lt;/span&gt;

Read the staged changes (&lt;span class=&quot;sb&quot;&gt;`git diff --cached`&lt;/span&gt;) and stop if there are none. Read &lt;span class=&quot;sb&quot;&gt;`git log --oneline -20`&lt;/span&gt; and follow whatever format those commits use; fall back to conventional commits if there is no clear one. Add a scope, body, or footer only when the subject genuinely cannot carry the meaning alone. Commit with the message only if committing was asked for; otherwise present it and stop.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Keeping them this short is a deliberate choice, and it comes from watching the models change. Every few months the model knows more than it did before. It already knows how to write a good commit message, how to set up ESLint, and how to structure a test. A skill that spells all of that out was useful once. With a newer model it is mostly noise, and in the worst case it pins the model to an older, worse way of doing something it would do better on its own. Long skills age with the model they were written for.&lt;/p&gt;

&lt;p&gt;So a skill holds only the difference between general competence and my situation: my conventions, my exact commands, and the traps I already fell into. The model brings the rest, and that part keeps improving without me touching a file.&lt;/p&gt;

&lt;p&gt;One more decision matters for every skill: who may start it. Some skills should trigger on their own. The commit message skill runs whenever a commit is near, including when the agent commits its own work, so I do not have to think about commit format anymore. Other skills should only run when I ask for them, which Claude Code supports with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;disable-model-invocation: true&lt;/code&gt; in the skill’s frontmatter. Setting up tooling, for example, is a deliberate step at the start of a project, not something the agent should decide to do halfway through fixing a bug.&lt;/p&gt;

&lt;h2 id=&quot;spec-driven-development-the-way-i-already-worked&quot;&gt;Spec-Driven Development, the Way I Already Worked&lt;/h2&gt;

&lt;p&gt;The individual skills are useful on their own, but the workflow they form together is what changed how I work the most.&lt;/p&gt;

&lt;p&gt;Think about how a feature reaches a developer on a team. You get a ticket that says what to build and why. You think about how to approach it in general. Then you get technical: which modules, which data, which decisions. You break that down into steps, and then you implement them one at a time.&lt;/p&gt;

&lt;p&gt;That routine is not new, and it is not specific to AI. It is how I worked long before I used an agent. So when I set up spec-driven development, I did not want a new process. I wanted the one I already had, with the agent doing most of the typing.&lt;/p&gt;

&lt;h3 id=&quot;why-not-an-existing-framework&quot;&gt;Why Not an Existing Framework&lt;/h3&gt;

&lt;p&gt;I tried the established options first. I used &lt;a href=&quot;https://github.com/mattpocock/skills&quot;&gt;Matt Pocock’s skills&lt;/a&gt; for a while, and I tried &lt;a href=&quot;https://github.com/github/spec-kit&quot;&gt;GitHub’s Spec Kit&lt;/a&gt; and &lt;a href=&quot;https://github.com/Fission-AI/OpenSpec&quot;&gt;OpenSpec&lt;/a&gt;. All three are good work, and I learned something from each of them.&lt;/p&gt;

&lt;p&gt;But they all felt heavyweight for how I work: more steps, more files, and more ceremony than a feature usually needs, plus more text the agent has to read before it writes a single line. Every extra artifact is another thing to keep in sync, and every extra instruction is another thing a better model might handle well without it.&lt;/p&gt;

&lt;p&gt;So I kept the idea and dropped most of the machinery. My version consists of four small skills that follow my own routine.&lt;/p&gt;

&lt;h3 id=&quot;from-ticket-to-commit&quot;&gt;From Ticket to Commit&lt;/h3&gt;

&lt;p&gt;Each step writes one document into the project, and each document is the input for the next step:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Specify, the ticket.&lt;/strong&gt; The feature description, or the conversation so far, becomes a spec: the problem, prioritized user stories with acceptance criteria, requirements, edge cases, and what is out of scope. It holds only the what and the why, no implementation details. Every user story has to be shippable on its own, so implementing only the first one still leaves something to demo.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Plan, the general approach.&lt;/strong&gt; The agent reads the spec, explores the codebase, and decides how the feature fits in. The plan has to describe this codebase, not a generic one. It prefers extending what exists over introducing something new, and every design decision names the alternative it rejected.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Tasks, the breakdown.&lt;/strong&gt; Spec and plan become a task list, grouped by user story, where every task is small enough to finish and verify in one sitting. Each story ends with a checkpoint.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Implement, one step at a time.&lt;/strong&gt; The agent works through the list top to bottom, test-first, and runs the tests as it goes. At every checkpoint it verifies that story on its own. At the end it reviews its own work before anything is committed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each step has a specific purpose. The spec moves knowledge out of a conversation, which is temporary, and into a file, which is permanent. The plan forces the agent to read the codebase before it decides anything. The task list cuts the work into pieces a fresh session can finish. And the implementation relies on types and tests as a feedback loop, so the agent can tell whether it is done without asking me.&lt;/p&gt;

&lt;h2 id=&quot;i-stay-in-the-loop&quot;&gt;I Stay in the Loop&lt;/h2&gt;

&lt;p&gt;Spec-driven development does not mean I hand over a ticket and come back to a finished pull request. The workflow is built around the points where my judgment matters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I review between the steps.&lt;/strong&gt; After the spec, I check the stories and the assumptions. After the plan, I check the design decisions. After the task list, I check the granularity. Correcting the direction at this stage is cheap, because it is still a paragraph of text and not yet a pile of code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The task list is the boundary.&lt;/strong&gt; Work the agent discovers along the way gets added as a new task and shown to me. It is never done silently, and it is never skipped silently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tests are agreed on before they are written.&lt;/strong&gt; The plan names the seams where the feature is tested: the public boundaries where behavior can be observed without reaching inside. The agent does not invent its own. Expected values come from the spec, not from the code under test. That rules out the kind of tests agents tend to write, the ones that are coupled to implementation details or pass by construction because they compute the expected result the same way the code does.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I own the result.&lt;/strong&gt; The agent writes most of the code, but the architecture, the trade-offs, and the quality bar stay with me. Everything that gets committed goes out under my name, so I read it as if I had written it myself.&lt;/p&gt;

&lt;h2 id=&quot;context-is-a-budget&quot;&gt;Context Is a Budget&lt;/h2&gt;

&lt;p&gt;The one piece of tooling I would recommend to anyone is a &lt;a href=&quot;https://code.claude.com/docs/en/statusline&quot;&gt;custom status line&lt;/a&gt; that shows how much of the context window is used, as a bar that goes from green to yellow to red.&lt;/p&gt;

&lt;p&gt;It is a small script, but watching that bar all day changed how I work. Context is a limited resource, like memory or a rate limit, and the quality of the output drops well before you actually run out. When the bar turns yellow, I stop starting new things and focus on finishing the current one. When it turns red, I finish, commit, and open a fresh session.&lt;/p&gt;

&lt;p&gt;That is also why the spec, the plan, and the tasks live in files. A fresh session reads them and continues exactly where the last one stopped, without depending on a conversation that no longer fits into the context.&lt;/p&gt;

&lt;h2 id=&quot;room-to-act-hard-boundaries&quot;&gt;Room to Act, Hard Boundaries&lt;/h2&gt;

&lt;p&gt;Claude Code runs in auto mode for me, so it can work without asking me to approve every single step. That is only reasonable because of the git rules in my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CLAUDE.md&lt;/code&gt;. Nothing leaves my machine without me, so the worst case is a diff I throw away. If you loosen the permissions, tighten the boundaries first.&lt;/p&gt;

&lt;p&gt;Since the agent can work on its own for a while, I do not sit and watch it. A notification hook sends a desktop notification when it is done or when it actually needs my input, and nothing else. A notification that fires all the time is one I would quickly learn to ignore.&lt;/p&gt;

&lt;h2 id=&quot;what-carries-over-to-building-ai-products&quot;&gt;What Carries Over to Building AI Products&lt;/h2&gt;

&lt;p&gt;Looking back, most of what I learned while building this setup is not specific to coding agents. It applies just as much to building products on top of language models:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Writing a skill is writing a tool definition.&lt;/strong&gt; It has a name, a description that decides whether the model picks it correctly, and a body that gives just enough context. I have debugged skills that never triggered because the description was too vague. That is the same bug as a tool the model never calls.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Keeping skills small is designing for a moving model.&lt;/strong&gt; Anything you build around a model’s current weaknesses becomes a liability once the next model no longer has them.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Cutting work into tasks a fresh session can finish is context engineering.&lt;/strong&gt; You decide what the model needs to see, what it does not, and where a job has to be split because it will not fit.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Specify, plan, tasks, implement is orchestration.&lt;/strong&gt; Decompose, sequence by dependency, execute in isolated contexts, and verify at checkpoints.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Permissions plus boundaries is guardrail design.&lt;/strong&gt; Give the component room to act, then keep the blast radius small enough that a mistake is cheap.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The interesting work has moved for me. It is less about generating code quickly and more about designing the system the model runs inside: what it knows, what it may do, how the work is cut, and how the output gets verified.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;If you take one thing from this post, let it be the first step: put your agent configuration into a git repository, even if it starts as a single, almost empty instruction file.&lt;/p&gt;

&lt;p&gt;Everything else can grow from there, and in my experience it grows from friction. If you correct the same thing twice, the rule belongs in the instruction file. If you explain the same procedure twice, it belongs in a skill. If you notice the agent doing something you did not sanction, a boundary belongs in the rules.&lt;/p&gt;

&lt;p&gt;Keep the skills small and let the model handle the rest. And before you adopt someone else’s process, write down the one you already follow. It may be all the framework you need.&lt;/p&gt;
</description>
            <pubDate>Wed, 30 Sep 2026 00:00:00 +0000</pubDate>
            <link>https://www.kulik.io/2026/09/30/the-system-around-the-agent-what-i-learned-setting-up-claude-code/</link>
            <guid isPermaLink="true">https://www.kulik.io/2026/09/30/the-system-around-the-agent-what-i-learned-setting-up-claude-code/</guid>
        </item><item>
            <title>One Entity, Many Contexts: How I Structure Blocks and Content Types in Storyblok</title>
            <description>&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-naive-approach-and-why-it-hurts&quot;&gt;The naive approach and why it hurts&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-fix-model-the-entity-as-a-content-type&quot;&gt;The fix: model the entity as a Content Type&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-schema&quot;&gt;The schema&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#rendering-the-same-entity-in-different-contexts&quot;&gt;Rendering the same entity in different contexts&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#resolving-references-without-over-fetching&quot;&gt;Resolving references without over-fetching&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Every Storyblok project I have worked on eventually runs into the same question: I have a piece of content that shows up in more than one place, looking different each time. How do I model it so I do not end up copying the same data all over the space?&lt;/p&gt;

&lt;p&gt;Take a blog. An article appears on its own page with the full story: the body, images, code blocks, everything. The same article also shows up in a “featured posts” carousel on the homepage, this time as a small card with just a title, an excerpt, and a cover image. It appears again in a “related posts” strip at the bottom of other articles, and once more in a category listing. Same article, four different presentations.&lt;/p&gt;

&lt;p&gt;The tempting first move is to build an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;articleCard&lt;/code&gt; block, drop it into the carousel, and type the title, excerpt, and cover image straight into it. It works immediately, so it feels right. Then you feature the same article in a second place, and a third. Now the same article lives in several places: its page and every card. When you rename the article, you are hunting through the whole space to update every copy, and you will miss one. This is a plain &lt;a href=&quot;https://en.wikipedia.org/wiki/Don%27t_repeat_yourself&quot;&gt;DRY&lt;/a&gt; violation, and it is the villain of this post.&lt;/p&gt;

&lt;p&gt;The deeper lesson underneath the blog example is this: &lt;strong&gt;an article is data, and how it is displayed is presentation.&lt;/strong&gt; Once you separate the two, the same entity can wear different clothes in every context without ever being duplicated.&lt;/p&gt;

&lt;h2 id=&quot;the-naive-approach-and-why-it-hurts&quot;&gt;The naive approach and why it hurts&lt;/h2&gt;

&lt;p&gt;It is worth being precise about how you end up duplicating data, because the mistake is subtle. You rarely set out to copy an article. You reach for a &lt;em&gt;block&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Blocks in Storyblok are inline content. When you place a nestable block, you are creating a fresh, self-contained copy of its fields right there in the parent story. An &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;articleCard&lt;/code&gt; block with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;title&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;excerpt&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;coverImage&lt;/code&gt; fields feels reusable, but every placement is a new copy with no link back to a shared source. Two carousels featuring “the same” article actually hold two independent snapshots that drift apart the moment one is edited.&lt;/p&gt;

&lt;p&gt;That is the tell: &lt;strong&gt;a block is a copy, not a reference.&lt;/strong&gt; The instant you need the same content in two places and want it to stay in sync, a block is the wrong tool.&lt;/p&gt;

&lt;h2 id=&quot;the-fix-model-the-entity-as-a-content-type&quot;&gt;The fix: model the entity as a Content Type&lt;/h2&gt;

&lt;p&gt;An article is not a piece of layout. It is an entity with an identity, and in Storyblok entities are Content Types, not blocks.&lt;/p&gt;

&lt;p&gt;So I create an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;article&lt;/code&gt; Content Type. It is routable and lives under its own path, for example &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/blog/one-entity-many-contexts&lt;/code&gt;, because every article has a page anyway. It holds two kinds of fields:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Its &lt;strong&gt;key figures&lt;/strong&gt; as data fields: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;title&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;excerpt&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;coverImage&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;publishedAt&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;A &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;content&lt;/code&gt; field of type Blocks, which holds the article body, exactly like the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;content&lt;/code&gt; field on a regular &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;page&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The article &lt;em&gt;is&lt;/em&gt; the page. There is no separate “article page” story pointing at the content, and no place where the body is duplicated. Everything an article owns lives in one story, in one place.&lt;/p&gt;

&lt;p&gt;The rule I follow to decide what goes where:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The entity owns everything that is one-to-one with it. The context owns everything that varies by context.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The title, excerpt, cover image, and body are all one-to-one with the article, so they live on the article. The card layout varies by context (a featured carousel, a related-posts strip, a category listing all look different), so it is derived by each context from the article’s data, never stored on the article.&lt;/p&gt;

&lt;p&gt;This pattern comes in two flavors, depending on whether the entity has a page of its own:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Routable entity&lt;/strong&gt; when it has a page. An article has its own URL, so it is a routable Content Type at its own path.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Global folder entity&lt;/strong&gt; when it does not. An &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;author&lt;/code&gt; has no page of its own but is referenced from every article they wrote, so it lives as a non-routable story in a dedicated folder such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_global/authors&lt;/code&gt; and is referenced wherever it is needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Either way the principle is the same: model the entity once, reference it everywhere. An article references its author. A carousel references its articles. Nothing is copied.&lt;/p&gt;

&lt;h2 id=&quot;the-schema&quot;&gt;The schema&lt;/h2&gt;

&lt;p&gt;Here is the whole structure. Four components carry the example: the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;article&lt;/code&gt; Content Type, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;author&lt;/code&gt; it references, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;articleCarousel&lt;/code&gt; block, and the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;page&lt;/code&gt; Content Type that hosts the carousel.&lt;/p&gt;

&lt;div class=&quot;container container--scrollable&quot;&gt;
  &lt;table class=&quot;table&quot;&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Component&lt;/th&gt;
        &lt;th&gt;Kind&lt;/th&gt;
        &lt;th&gt;Field&lt;/th&gt;
        &lt;th&gt;Field Type&lt;/th&gt;
        &lt;th&gt;Purpose&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;article&lt;/td&gt;
        &lt;td&gt;Content Type&lt;/td&gt;
        &lt;td&gt;title&lt;/td&gt;
        &lt;td&gt;Text&lt;/td&gt;
        &lt;td&gt;Key figure&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;article&lt;/td&gt;
        &lt;td&gt;Content Type&lt;/td&gt;
        &lt;td&gt;excerpt&lt;/td&gt;
        &lt;td&gt;Textarea&lt;/td&gt;
        &lt;td&gt;Key figure&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;article&lt;/td&gt;
        &lt;td&gt;Content Type&lt;/td&gt;
        &lt;td&gt;coverImage&lt;/td&gt;
        &lt;td&gt;Asset&lt;/td&gt;
        &lt;td&gt;Key figure&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;article&lt;/td&gt;
        &lt;td&gt;Content Type&lt;/td&gt;
        &lt;td&gt;publishedAt&lt;/td&gt;
        &lt;td&gt;Date/Time&lt;/td&gt;
        &lt;td&gt;Key figure&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;article&lt;/td&gt;
        &lt;td&gt;Content Type&lt;/td&gt;
        &lt;td&gt;author&lt;/td&gt;
        &lt;td&gt;Multi-Options (References), max 1&lt;/td&gt;
        &lt;td&gt;Points at an author story&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;article&lt;/td&gt;
        &lt;td&gt;Content Type&lt;/td&gt;
        &lt;td&gt;content&lt;/td&gt;
        &lt;td&gt;Blocks&lt;/td&gt;
        &lt;td&gt;Article body&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;author&lt;/td&gt;
        &lt;td&gt;Content Type&lt;/td&gt;
        &lt;td&gt;name, avatar, bio&lt;/td&gt;
        &lt;td&gt;Text, Asset, Textarea&lt;/td&gt;
        &lt;td&gt;Global, non-routable&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;articleCarousel&lt;/td&gt;
        &lt;td&gt;Nestable block&lt;/td&gt;
        &lt;td&gt;articles&lt;/td&gt;
        &lt;td&gt;Multi-Options (References)&lt;/td&gt;
        &lt;td&gt;Points at article stories&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;page&lt;/td&gt;
        &lt;td&gt;Content Type&lt;/td&gt;
        &lt;td&gt;body&lt;/td&gt;
        &lt;td&gt;Blocks&lt;/td&gt;
        &lt;td&gt;Hosts the carousel&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;articleCarousel&lt;/code&gt; holds no article data at all. Its &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;articles&lt;/code&gt; field is a Multi-Options reference that stores the UUIDs of the article stories it points at. There is a single source of truth for every article, and every context borrows from it.&lt;/p&gt;

&lt;h2 id=&quot;rendering-the-same-entity-in-different-contexts&quot;&gt;Rendering the same entity in different contexts&lt;/h2&gt;

&lt;p&gt;With one entity in place, each context simply picks the fields it needs:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;The article page&lt;/strong&gt; renders the full story: the key figures, the resolved &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;author&lt;/code&gt;, and the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;content&lt;/code&gt; blocks.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;The featured carousel&lt;/strong&gt; renders a card from the key figures only: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;coverImage&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;title&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;excerpt&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;The related-posts strip&lt;/strong&gt; renders the same card shape with a different heading.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;A category listing&lt;/strong&gt; renders an even thinner row: just &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;title&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;publishedAt&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;author&lt;/code&gt; entity earns its keep the same way. It is rendered as a full byline with avatar and bio on the article page, and as a plain name in a compact “written by” line inside a card. One author story, two presentations, no duplication.&lt;/p&gt;

&lt;p&gt;This is the payoff. When you add a fifth context tomorrow, you do not touch the article at all. You write a new presentation that reads the fields it cares about. The context decides which fields to render, and the entity never changes.&lt;/p&gt;

&lt;h2 id=&quot;resolving-references-without-over-fetching&quot;&gt;Resolving references without over-fetching&lt;/h2&gt;

&lt;p&gt;A reference field stores UUIDs, not the referenced content. To turn those UUIDs into real data you have to resolve them, and &lt;em&gt;how&lt;/em&gt; you resolve them matters a lot for payload size.&lt;/p&gt;

&lt;p&gt;The obvious way is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;resolve_relations&lt;/code&gt;. You pass the component and field you want resolved, in the form &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;componentName.fieldName&lt;/code&gt;. On the article page, resolving the author is exactly right, because you render it and it is small:&lt;/p&gt;

&lt;div class=&quot;language-ts highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;StoryblokClient&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;storyblok-js-client&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;storyblok&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;StoryblokClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;accessToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;STORYBLOK_TOKEN&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;storyblok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;cdn/stories/blog/one-entity-many-contexts&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;published&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;resolve_relations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;article.author&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Because &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;author&lt;/code&gt; is a Multi-Options field capped at one, it resolves to an array with a single author object, so you read it as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;author[0]&lt;/code&gt; rather than as a bare object.&lt;/p&gt;

&lt;p&gt;The same technique on a carousel is where it goes wrong. Resolving &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;articleCarousel.articles&lt;/code&gt; inlines the &lt;em&gt;entire&lt;/em&gt; referenced story, including the heavy &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;content&lt;/code&gt; blocks. A carousel of ten articles pulls ten full article bodies just to render ten small cards, even though the cards need only three fields each. You are downloading the whole article ten times to show a thumbnail and an excerpt.&lt;/p&gt;

&lt;p&gt;Storyblok also caps the number of relations it resolves per request, so leaning on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;resolve_relations&lt;/code&gt; for large lists is a trap on both payload and completeness.&lt;/p&gt;

&lt;p&gt;The fix is to not resolve at all in list contexts. Instead, fetch exactly the articles you need, ordered, and strip the field you do not want:&lt;/p&gt;

&lt;div class=&quot;language-ts highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;uuids&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;carousel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;articles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// array of article UUIDs from the reference field&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;storyblok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;cdn/stories&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;published&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;by_uuids_ordered&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;uuids&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;excluding_fields&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;by_uuids_ordered&lt;/code&gt; returns the articles in the order the editor arranged them in the carousel, which a plain UUID lookup would not guarantee. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;excluding_fields: &apos;content&apos;&lt;/code&gt; tells the CDN to leave the heavy Blocks field out of the response entirely, server-side. What comes back is just the key figures: exactly what a card needs and nothing more.&lt;/p&gt;

&lt;p&gt;So the division of labor is:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;The article page&lt;/strong&gt; fetches the full story, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;content&lt;/code&gt; included, because it renders it.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;List contexts&lt;/strong&gt; (carousel, related posts, category listing) fetch the articles by UUID with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;excluding_fields: &apos;content&apos;&lt;/code&gt;, paying for two requests instead of one but keeping every payload lean.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Co-locating the body and the key figures on a single entity costs you nothing at read time, as long as you resolve deliberately.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;The blog is just a vehicle. The pattern is the point: when a piece of content shows up in more than one place, model it once as an entity, reference it everywhere, and let each context choose which of its fields to render. Reach for a Content Type when you need identity and reuse, a routable one when the entity has a page and a global folder one when it does not, and a block only for genuinely inline, one-off layout.&lt;/p&gt;

&lt;p&gt;Separate the data from its presentation and duplication simply has nowhere to live. One entity, many contexts.&lt;/p&gt;
</description>
            <pubDate>Fri, 24 Jul 2026 00:00:00 +0000</pubDate>
            <link>https://www.kulik.io/2026/07/24/one-entity-many-contexts-how-i-structure-blocks-and-content-types-in-storyblok/</link>
            <guid isPermaLink="true">https://www.kulik.io/2026/07/24/one-entity-many-contexts-how-i-structure-blocks-and-content-types-in-storyblok/</guid>
        </item><item>
            <title>Making Sense of DMARC Reports with a CLI Tool</title>
            <description>&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#why-dmarc-exists&quot;&gt;Why DMARC Exists&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#how-to-configure-dmarc-reports&quot;&gt;How to Configure DMARC Reports&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#1-publish-a-dmarc-record&quot;&gt;1. Publish a DMARC Record&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#2-create-a-mailbox-for-reports&quot;&gt;2. Create a Mailbox for Reports&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#3-optional-publish-a-dns-delegation-record&quot;&gt;3. (Optional) Publish a DNS Delegation Record&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#4-collect-and-process-reports&quot;&gt;4. Collect and Process Reports&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#what-a-dmarc-report-looks-like&quot;&gt;What a DMARC Report Looks Like&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-challenge-xml-fatigue&quot;&gt;The Challenge: XML Fatigue&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-dmarc-report-viewer-cli&quot;&gt;The DMARC Report Viewer CLI&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#features&quot;&gt;Features&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#example-output&quot;&gt;Example Output&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#lessons-learned&quot;&gt;Lessons Learned&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;If you own a domain and use it for email, you might want to receive &lt;strong&gt;DMARC aggregate reports&lt;/strong&gt;. These reports are sent by receiving mail servers to let you know who is sending mail claiming to be from your domain, whether legitimate or not.&lt;/p&gt;

&lt;p&gt;The problem: DMARC reports arrive as bulky XML files, often compressed into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.gz&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.zip&lt;/code&gt; archives. They are detailed but hard to read by hand.&lt;/p&gt;

&lt;p&gt;To make sense of them, I built a &lt;strong&gt;CLI tool&lt;/strong&gt; that parses DMARC reports and turns them into human-friendly tables right in the terminal. This post explains the basics of DMARC, why the reports matter, and how this CLI can make them much easier to work with.&lt;/p&gt;

&lt;p&gt;👉 Check it out here: &lt;a href=&quot;https://github.com/rkulik/dmarc-report-viewer&quot;&gt;DMARC Report Viewer&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;why-dmarc-exists&quot;&gt;Why DMARC Exists&lt;/h2&gt;

&lt;p&gt;Email was not originally designed with authentication in mind, which makes it easy for attackers to send emails that look like they came from your domain. This is called &lt;strong&gt;spoofing&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To fight this, three mechanisms are commonly used together:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;SPF (Sender Policy Framework)&lt;/strong&gt;: Defines which mail servers are authorized to send email for your domain.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;DKIM (DomainKeys Identified Mail)&lt;/strong&gt;: Cryptographically signs messages to prove they have not been altered and were sent by an authorized server.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;DMARC (Domain-based Message Authentication, Reporting, and Conformance)&lt;/strong&gt;: Ties SPF and DKIM together, and tells receiving mail servers what to do when a message fails (ignore, quarantine, reject).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With DMARC, you can also request &lt;strong&gt;aggregate reports&lt;/strong&gt; (via the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rua&lt;/code&gt; tag) so you know exactly who is trying to send as you.&lt;/p&gt;

&lt;h2 id=&quot;how-to-configure-dmarc-reports&quot;&gt;How to Configure DMARC Reports&lt;/h2&gt;

&lt;p&gt;To receive DMARC aggregate reports, you need to:&lt;/p&gt;

&lt;h3 id=&quot;1-publish-a-dmarc-record&quot;&gt;1. Publish a DMARC Record&lt;/h3&gt;

&lt;p&gt;Add a TXT record in DNS at:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;_dmarc.&amp;lt;your-domain&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;DMARC1&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;reject&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;rua&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;mailto:dmarc-reports@your-domain.com&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;ruf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;mailto:dmarc-failures@your-domain.com&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;adkim&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;r&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;aspf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;r
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Key tags:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;v=DMARC1&lt;/code&gt;: Version&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p=reject&lt;/code&gt;: Policy (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;none&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;quarantine&lt;/code&gt;, or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reject&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rua=&lt;/code&gt;: Where aggregate reports are sent (daily XML summaries)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ruf=&lt;/code&gt;: Where failure (forensic) reports are sent (less common, optional)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;adkim&lt;/code&gt; / &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aspf&lt;/code&gt;: Alignment modes (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;r&lt;/code&gt; = relaxed, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;s&lt;/code&gt; = strict)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;2-create-a-mailbox-for-reports&quot;&gt;2. Create a Mailbox for Reports&lt;/h3&gt;

&lt;p&gt;Set up a dedicated address such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dmarc-reports@your-domain.com&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;It just needs to handle attachments (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.xml.gz&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.xml.zip&lt;/code&gt;).&lt;/li&gt;
  &lt;li&gt;Reports are often daily per provider (Google, Microsoft, Yahoo, etc.).&lt;/li&gt;
  &lt;li&gt;Expect volume to grow with your email traffic. The more mail you send, the more reports you will receive.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;3-optional-publish-a-dns-delegation-record&quot;&gt;3. (Optional) Publish a DNS Delegation Record&lt;/h3&gt;

&lt;p&gt;If reports are sent to a different domain (e.g. a third-party service), you may need to publish a DNS delegation record to prove that domain is authorized to receive reports.&lt;/p&gt;

&lt;h3 id=&quot;4-collect-and-process-reports&quot;&gt;4. Collect and Process Reports&lt;/h3&gt;

&lt;p&gt;At this point, you’ll start receiving compressed XML reports with information about:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Source IPs sending as your domain&lt;/li&gt;
  &lt;li&gt;SPF/DKIM pass/fail results&lt;/li&gt;
  &lt;li&gt;The receiver’s disposition (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;none&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;quarantine&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reject&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;what-a-dmarc-report-looks-like&quot;&gt;What a DMARC Report Looks Like&lt;/h2&gt;

&lt;p&gt;Here is an example DMARC Report:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;feedback&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;report_metadata&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;org_name&amp;gt;&lt;/span&gt;ExampleOrg&lt;span class=&quot;nt&quot;&gt;&amp;lt;/org_name&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;email&amp;gt;&lt;/span&gt;dmarc-reports@example.com&lt;span class=&quot;nt&quot;&gt;&amp;lt;/email&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;report_id&amp;gt;&lt;/span&gt;123456789&lt;span class=&quot;nt&quot;&gt;&amp;lt;/report_id&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;date_range&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;begin&amp;gt;&lt;/span&gt;1622505600&lt;span class=&quot;nt&quot;&gt;&amp;lt;/begin&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;end&amp;gt;&lt;/span&gt;1622592000&lt;span class=&quot;nt&quot;&gt;&amp;lt;/end&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/date_range&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/report_metadata&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;policy_published&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;domain&amp;gt;&lt;/span&gt;your-domain.com&lt;span class=&quot;nt&quot;&gt;&amp;lt;/domain&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;reject&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;sp&amp;gt;&lt;/span&gt;reject&lt;span class=&quot;nt&quot;&gt;&amp;lt;/sp&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;adkim&amp;gt;&lt;/span&gt;r&lt;span class=&quot;nt&quot;&gt;&amp;lt;/adkim&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;aspf&amp;gt;&lt;/span&gt;r&lt;span class=&quot;nt&quot;&gt;&amp;lt;/aspf&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/policy_published&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;record&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;row&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;source_ip&amp;gt;&lt;/span&gt;192.0.2.1&lt;span class=&quot;nt&quot;&gt;&amp;lt;/source_ip&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;count&amp;gt;&lt;/span&gt;1&lt;span class=&quot;nt&quot;&gt;&amp;lt;/count&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;policy_evaluated&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;disposition&amp;gt;&lt;/span&gt;none&lt;span class=&quot;nt&quot;&gt;&amp;lt;/disposition&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;dkim&amp;gt;&lt;/span&gt;pass&lt;span class=&quot;nt&quot;&gt;&amp;lt;/dkim&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;spf&amp;gt;&lt;/span&gt;pass&lt;span class=&quot;nt&quot;&gt;&amp;lt;/spf&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/policy_evaluated&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/row&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;identifiers&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;header_from&amp;gt;&lt;/span&gt;your-domain.com&lt;span class=&quot;nt&quot;&gt;&amp;lt;/header_from&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/identifiers&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;auth_results&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;spf&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;domain&amp;gt;&lt;/span&gt;your-domain.com&lt;span class=&quot;nt&quot;&gt;&amp;lt;/domain&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;result&amp;gt;&lt;/span&gt;pass&lt;span class=&quot;nt&quot;&gt;&amp;lt;/result&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/spf&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;dkim&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;domain&amp;gt;&lt;/span&gt;your-domain.com&lt;span class=&quot;nt&quot;&gt;&amp;lt;/domain&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;result&amp;gt;&lt;/span&gt;pass&lt;span class=&quot;nt&quot;&gt;&amp;lt;/result&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dkim&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/auth_results&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/record&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/feedback&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This means:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;An email claiming to be from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;your-domain.com&lt;/code&gt; came from IP &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.0.2.1&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Both SPF and DKIM passed and aligned.&lt;/li&gt;
  &lt;li&gt;Even though the policy is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reject&lt;/code&gt;, aligned authentication means the message is delivered normally, so the disposition is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;none&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is what a legitimate, correctly configured email looks like in a DMARC report.&lt;/p&gt;

&lt;h2 id=&quot;the-challenge-xml-fatigue&quot;&gt;The Challenge: XML Fatigue&lt;/h2&gt;

&lt;p&gt;Reading one of these XML files by hand is manageable. Reading dozens quickly becomes overwhelming.&lt;/p&gt;

&lt;p&gt;That is why it makes sense to build tooling that can:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Decompress &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.gz&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.zip&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Parse the XML&lt;/li&gt;
  &lt;li&gt;Display results in a human-friendly way&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;the-dmarc-report-viewer-cli&quot;&gt;The DMARC Report Viewer CLI&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;DMARC Report Viewer&lt;/strong&gt; is a small CLI written in Node.js + TypeScript.&lt;/p&gt;

&lt;h3 id=&quot;features&quot;&gt;Features&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Supports &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.xml&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.gz&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.zip&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Lets you select reports from the current directory&lt;/li&gt;
  &lt;li&gt;Displays results as a table in the terminal&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;example-output&quot;&gt;Example Output&lt;/h3&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;┌─────────┬─────────────┬───────┬────────┬────────┬─────────────┬───────────────────┬────────────┬─────────────┬────────────────┐
│ &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;index&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; │ IP          │ Count │ SPF    │ DKIM   │ Disposition │ From              │ SPF Result │ DKIM Result │ Status         │
├─────────┼─────────────┼───────┼────────┼────────┼─────────────┼───────────────────┼────────────┼─────────────┼────────────────┤
│ 0       │ &lt;span class=&quot;s1&quot;&gt;&apos;192.0.2.1&apos;&lt;/span&gt; │ &lt;span class=&quot;s1&quot;&gt;&apos;1&apos;&lt;/span&gt;   │ &lt;span class=&quot;s1&quot;&gt;&apos;pass&apos;&lt;/span&gt; │ &lt;span class=&quot;s1&quot;&gt;&apos;pass&apos;&lt;/span&gt; │ &lt;span class=&quot;s1&quot;&gt;&apos;none&apos;&lt;/span&gt;      │ &lt;span class=&quot;s1&quot;&gt;&apos;your-domain.com&apos;&lt;/span&gt; │ &lt;span class=&quot;s1&quot;&gt;&apos;pass&apos;&lt;/span&gt;     │ &lt;span class=&quot;s1&quot;&gt;&apos;pass&apos;&lt;/span&gt;      │ &lt;span class=&quot;s1&quot;&gt;&apos;✅ Delivered&apos;&lt;/span&gt; │
└─────────┴─────────────┴───────┴────────┴────────┴─────────────┴───────────────────┴────────────┴─────────────┴────────────────┘
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;👉 Source: &lt;a href=&quot;https://github.com/rkulik/dmarc-report-viewer&quot;&gt;GitHub - DMARC Report Viewer&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;lessons-learned&quot;&gt;Lessons Learned&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Spoofing attempts are &lt;strong&gt;normal&lt;/strong&gt;. You can not stop people from trying, but you &lt;em&gt;can&lt;/em&gt; stop their emails from being delivered.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;SPF&lt;/strong&gt;, &lt;strong&gt;DKIM&lt;/strong&gt;, and &lt;strong&gt;DMARC&lt;/strong&gt; work best together.&lt;/li&gt;
  &lt;li&gt;DMARC aggregate reports give you &lt;strong&gt;real-world visibility&lt;/strong&gt; into how your domain is being used.&lt;/li&gt;
  &lt;li&gt;With the right tooling, even daily XML dumps can be turned into something easy to read.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;DMARC reports may look intimidating at first, but once you configure DNS correctly and have a way to parse them, they become a powerful tool for protecting your domain.&lt;/p&gt;

&lt;p&gt;That is why I built the &lt;strong&gt;DMARC Report Viewer&lt;/strong&gt;. A simple CLI to help make sense of those reports.&lt;/p&gt;

&lt;p&gt;👉 Try it here: &lt;a href=&quot;https://github.com/rkulik/dmarc-report-viewer&quot;&gt;DMARC Report Viewer on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do not ignore your DMARC reports. They are your window into the health and safety of your domain’s email ecosystem.&lt;/p&gt;
</description>
            <pubDate>Tue, 14 Jul 2026 00:00:00 +0000</pubDate>
            <link>https://www.kulik.io/2026/07/14/making-sense-of-dmarc-reports-with-a-cli-tool/</link>
            <guid isPermaLink="true">https://www.kulik.io/2026/07/14/making-sense-of-dmarc-reports-with-a-cli-tool/</guid>
        </item><item>
            <title>Beyond the API: How I Structure the Backend Logic of My Applications</title>
            <description>&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#controllers-keep-them-focused&quot;&gt;Controllers: Keep Them Focused&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#my-preferred-controller-methods&quot;&gt;My Preferred Controller Methods&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#actions-over-services&quot;&gt;Actions Over Services&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#real-example-blog-system-routing&quot;&gt;Real Example: Blog System Routing&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;In my previous &lt;a href=&quot;/2025/04/09/rest-api-design-best-practices-and-lessons-learned/&quot;&gt;blog post&lt;/a&gt;, I shared my approach to structuring REST APIs effectively, focusing on clarity, convention, and scalability. That post emphasized how to keep API surface areas predictable and maintainable. Now, I want to take you a layer deeper into what happens behind the API.&lt;/p&gt;

&lt;p&gt;In this post, I will break down how I structure the backend logic that powers my APIs, drawing from 14+ years of experience building backend applications in Node.js and PHP. The goal? Keep things simple, explicit, and future-proof.&lt;/p&gt;

&lt;h2 id=&quot;controllers-keep-them-focused&quot;&gt;Controllers: Keep Them Focused&lt;/h2&gt;

&lt;p&gt;Taylor Otwell, the creator of Laravel, has a rule I fully embrace: controllers should stick to the 7 standard RESTful methods. If you need to handle more complex or domain-specific behavior, you do not expand the controller. You create a new one.&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;One of my Laravel ✨ best practices ✨ is only using the 7 &amp;quot;restful&amp;quot; methods in my controllers.&lt;br /&gt;&lt;br /&gt;Controllers only have: index, show, create, store, edit, update, delete.&lt;br /&gt;&lt;br /&gt;Think you need another method? You really need another controller. Built *all* of Vapor like this.&lt;/p&gt;&amp;mdash; Taylor Otwell (@taylorotwell) &lt;a href=&quot;https://twitter.com/taylorotwell/status/1651593413140287488?ref_src=twsrc%5Etfw&quot;&gt;April 27, 2023&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;p&gt;This philosophy aligns perfectly with a principle I have come to live by in object-oriented environments:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;You can’t have too many classes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It might feel like overkill at first, but clear separation of concerns pays dividends as your codebase grows. By using smaller, well-named classes, you make the system easier to reason about, test, and evolve.&lt;/p&gt;

&lt;h2 id=&quot;my-preferred-controller-methods&quot;&gt;My Preferred Controller Methods&lt;/h2&gt;

&lt;p&gt;When I am not using a framework like NestJS or Laravel, which often scaffold controllers for you, I still stick to a minimal set of controller methods. Here is what I use by default:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;create&lt;/li&gt;
  &lt;li&gt;read&lt;/li&gt;
  &lt;li&gt;readAll&lt;/li&gt;
  &lt;li&gt;update&lt;/li&gt;
  &lt;li&gt;delete&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These method names map closely to the intentions of a typical RESTful resource.&lt;/p&gt;

&lt;p&gt;If my applications should also provide routes for create and edit views, I include two preparatory methods that do not mutate data but instead return the necessary data for the UI:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;prepareCreate&lt;/li&gt;
  &lt;li&gt;prepareUpdate&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These two methods make it clear when a controller is only preparing a form or UI versus actually performing a data-changing operation. This keeps responsibilities clean and intuitive, while maintaining a consistent verb-based naming style across all actions.&lt;/p&gt;

&lt;h2 id=&quot;actions-over-services&quot;&gt;Actions Over Services&lt;/h2&gt;

&lt;p&gt;One pattern I have moved toward is using action classes instead of large service classes. Services tend to grow unchecked, morphing into god-objects that do way too much. Actions, on the other hand, are lean, purpose-driven, and easy to test.&lt;/p&gt;

&lt;p&gt;Each controller method delegates to a single action class that handles the actual business logic. This makes responsibilities explicit and avoids bloated controllers or service layers.&lt;/p&gt;

&lt;h2 id=&quot;real-example-blog-system-routing&quot;&gt;Real Example: Blog System Routing&lt;/h2&gt;

&lt;p&gt;Let us revisit the blog system I used in &lt;a href=&quot;/2025/04/09/rest-api-design-best-practices-and-lessons-learned/&quot;&gt;my last post&lt;/a&gt;. Here is how I would structure the backend logic using my approach:&lt;/p&gt;

&lt;div class=&quot;container container--scrollable&quot;&gt;
  &lt;table class=&quot;table&quot;&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;HTTP Route&lt;/th&gt;
        &lt;th&gt;Controller&lt;/th&gt;
        &lt;th&gt;Method&lt;/th&gt;
        &lt;th&gt;Action Class&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;GET /posts/create&lt;/td&gt;
        &lt;td&gt;PostsController&lt;/td&gt;
        &lt;td&gt;prepareCreate&lt;/td&gt;
        &lt;td&gt;PrepareCreatePostAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;POST /posts&lt;/td&gt;
        &lt;td&gt;PostsController&lt;/td&gt;
        &lt;td&gt;create&lt;/td&gt;
        &lt;td&gt;CreatePostAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;GET /posts&lt;/td&gt;
        &lt;td&gt;PostsController&lt;/td&gt;
        &lt;td&gt;readAll&lt;/td&gt;
        &lt;td&gt;ReadPostsAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;GET /posts/:id&lt;/td&gt;
        &lt;td&gt;PostsController&lt;/td&gt;
        &lt;td&gt;read&lt;/td&gt;
        &lt;td&gt;ReadPostAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;GET /posts/:id/edit&lt;/td&gt;
        &lt;td&gt;PostsController&lt;/td&gt;
        &lt;td&gt;prepareUpdate&lt;/td&gt;
        &lt;td&gt;PrepareUpdatePostAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;PATCH /posts/:id&lt;/td&gt;
        &lt;td&gt;PostsController&lt;/td&gt;
        &lt;td&gt;update&lt;/td&gt;
        &lt;td&gt;UpdatePostAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;PUT /posts/:id/title&lt;/td&gt;
        &lt;td&gt;PostTitleController&lt;/td&gt;
        &lt;td&gt;update&lt;/td&gt;
        &lt;td&gt;UpdatePostTitleAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;DELETE /posts/:id&lt;/td&gt;
        &lt;td&gt;PostsController&lt;/td&gt;
        &lt;td&gt;delete&lt;/td&gt;
        &lt;td&gt;DeletePostAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;POST /published-posts&lt;/td&gt;
        &lt;td&gt;PublishedPostsController&lt;/td&gt;
        &lt;td&gt;create&lt;/td&gt;
        &lt;td&gt;PublishPostAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;DELETE /published-posts/:id&lt;/td&gt;
        &lt;td&gt;PublishedPostsController&lt;/td&gt;
        &lt;td&gt;delete&lt;/td&gt;
        &lt;td&gt;UnpublishPostAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;POST /posts/:id/comments&lt;/td&gt;
        &lt;td&gt;PostCommentsController&lt;/td&gt;
        &lt;td&gt;create&lt;/td&gt;
        &lt;td&gt;CreatePostCommentAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;GET /posts/:id/comments&lt;/td&gt;
        &lt;td&gt;PostCommentsController&lt;/td&gt;
        &lt;td&gt;readAll&lt;/td&gt;
        &lt;td&gt;ReadPostCommentsAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;GET /comments/:id&lt;/td&gt;
        &lt;td&gt;CommentsController&lt;/td&gt;
        &lt;td&gt;read&lt;/td&gt;
        &lt;td&gt;ReadCommentAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;PATCH /comments/:id&lt;/td&gt;
        &lt;td&gt;CommentsController&lt;/td&gt;
        &lt;td&gt;update&lt;/td&gt;
        &lt;td&gt;UpdateCommentAction&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;DELETE /comments/:id&lt;/td&gt;
        &lt;td&gt;CommentsController&lt;/td&gt;
        &lt;td&gt;delete&lt;/td&gt;
        &lt;td&gt;DeleteCommentAction&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Notice how:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Each action is named after exactly what it does.&lt;/li&gt;
  &lt;li&gt;Controllers remain lean and follow a consistent pattern.&lt;/li&gt;
  &lt;li&gt;Even sub-resources like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;comments&lt;/code&gt; of a post, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;title&lt;/code&gt; of a post, and operations like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;publish&lt;/code&gt;/&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unpublish&lt;/code&gt; are given their own controllers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This structure makes it easy to trace behavior, enforce boundaries, and introduce changes without fear of breaking unrelated parts of the app.&lt;/p&gt;

&lt;p&gt;If you would like to see the blog system example in action, I have published the &lt;a href=&quot;https://github.com/rkulik/nodejs-backend-skeleton&quot;&gt;code on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Backends grow. It is inevitable. But complexity does not have to be messy. By leaning into object-oriented principles, limiting controller scope, and favoring single-purpose action classes, you can build backends that are as robust and scalable as the APIs they serve.&lt;/p&gt;

&lt;p&gt;If you liked this post, check out my previous one on &lt;a href=&quot;/2025/04/09/rest-api-design-best-practices-and-lessons-learned/&quot;&gt;designing REST APIs&lt;/a&gt;.&lt;/p&gt;
</description>
            <pubDate>Tue, 22 Apr 2025 00:00:00 +0000</pubDate>
            <link>https://www.kulik.io/2025/04/22/beyond-the-api-how-i-structure-the-backend-logic-of-my-applications/</link>
            <guid isPermaLink="true">https://www.kulik.io/2025/04/22/beyond-the-api-how-i-structure-the-backend-logic-of-my-applications/</guid>
        </item><item>
            <title>REST API Design: Best Practices and Lessons Learned</title>
            <description>&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#http-request-methods&quot;&gt;HTTP Request Methods&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#url-structure-and-naming-conventions&quot;&gt;URL Structure and Naming Conventions&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#posts&quot;&gt;Posts&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#comments&quot;&gt;Comments&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#response-structure&quot;&gt;Response Structure&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#data-types&quot;&gt;Data Types&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#single-resource-response&quot;&gt;Single Resource Response&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#multiple-resources-response-with-pagination&quot;&gt;Multiple Resources Response with Pagination&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#fail-response&quot;&gt;Fail Response&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#error-response&quot;&gt;Error Response&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#communication-between-backend-and-frontend-teams&quot;&gt;Communication Between Backend and Frontend Teams&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;With over 14 years of experience in designing REST APIs, I have learned quite a bit about what works and what does not. This blog post is a collection of those lessons, distilled into best practices that I have developed over time. It focuses exclusively on RESTful API design, not GraphQL or other paradigms. These are the bread and butter of solid REST API design and represent the fundamentals that every developer should know. Whether you are building APIs for internal applications or public consumption, these principles will help you create a clean, consistent, and maintainable API.&lt;/p&gt;

&lt;h2 id=&quot;http-request-methods&quot;&gt;HTTP Request Methods&lt;/h2&gt;

&lt;p&gt;A well-designed API makes proper use of HTTP methods. Here is a breakdown of each method and how it should be used:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;GET&lt;/strong&gt;: Used to retrieve resources. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET&lt;/code&gt; requests are designed to be safe and idempotent. A successful &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET&lt;/code&gt; request usually returns a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;200 OK&lt;/code&gt; status code.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;POST&lt;/strong&gt;: Used to create new resources. This method is not idempotent, meaning multiple identical requests could create multiple resources. A successful &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;POST&lt;/code&gt; request typically returns a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;201 Created&lt;/code&gt; status code along with the newly created resource.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;PUT&lt;/strong&gt;: Used to fully replace a resource. This method expects the complete resource representation, and anything missing from the request might be deleted. Even if certain fields (like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;id&lt;/code&gt;) are not meant to be updated, it is still common practice to include the entire resource object in a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PUT&lt;/code&gt; request, including those unchangeable fields. A successful &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PUT&lt;/code&gt; request returns a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;201 Created&lt;/code&gt; status code if a new resource is created, and a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;200 OK&lt;/code&gt; status code if an existing resource is updated, along with the created/updated resource in the response.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;PATCH&lt;/strong&gt;: Used for partial updates. Unlike &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PUT&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATCH&lt;/code&gt; allows updating only specific fields without sending the entire resource. A successful PATCH request should return a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;200 OK&lt;/code&gt; status code along with the updated resource.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;DELETE&lt;/strong&gt;: Used to remove a resource. If the deletion is successful, the response should reflect that by returning a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;204 No Content&lt;/code&gt; status code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Methods that are designed to transport data, such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;POST&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PUT&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATCH&lt;/code&gt;, should use the request body to send data instead of relying on query parameters. Query parameters are typically reserved for filtering or specifying resources in the URL, while the body is the proper place for submitting data, especially when dealing with complex or large payloads. Using the body ensures better organization, clarity, and adherence to HTTP semantics.&lt;/p&gt;

&lt;p&gt;While &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET&lt;/code&gt; technically supports a request body, this is not considered best practice. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET&lt;/code&gt; is designed to be a safe, idempotent method primarily used for retrieving resources. Including a body with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET&lt;/code&gt; request is unconventional and can lead to confusion about the request’s intent. Additionally, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET&lt;/code&gt; requests are often cached, and including a body could break caching mechanisms, leading to inconsistent results or performance issues. For this reason, it is best to pass parameters via the URL (i.e., query parameters) in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET&lt;/code&gt; requests.&lt;/p&gt;

&lt;h2 id=&quot;url-structure-and-naming-conventions&quot;&gt;URL Structure and Naming Conventions&lt;/h2&gt;

&lt;p&gt;When designing URLs, follow conventions that enhance clarity and scalability. The following examples are based on a blog system. Here are a few practical tips to keep in mind:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Ensure each URL uniquely identifies a resource&lt;/strong&gt;: A well-structured REST API uses URLs that clearly and uniquely reference a specific resource or collection. For example, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET /posts/1&lt;/code&gt; should return to the post with ID 1, whereas &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET /posts&lt;/code&gt; refers to the entire collection of posts. This improves clarity, consistency, and enables more predictable caching.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Reflect nested resources in the route&lt;/strong&gt;: This makes the parent-child relationship explicit. For example, instead of using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;POST /comments&lt;/code&gt;, prefer &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;POST /posts/:id/comments&lt;/code&gt; to make it clear that the comment belongs to a specific post.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Isolate properties that should be edited independently&lt;/strong&gt;: If a certain property of a resource is commonly updated on its own, consider making it a sub-resource. For example, to update only the title of a post, use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PUT /posts/:id/title&lt;/code&gt;. Since you are replacing the entire title, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PUT&lt;/code&gt; is the appropriate HTTP method here.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Treat different states of a resource as separate resources&lt;/strong&gt;: State transitions can be modeled with separate endpoints. For instance, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;POST /published-posts&lt;/code&gt; is used to publish a post. Although this is an update action and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATCH /posts/:id&lt;/code&gt; would also work, it is cleaner and more expressive to give this new state (a “published” post) its own resource and URL. To unpublish a post, use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DELETE /published-posts/:id&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Use pluralized endpoints&lt;/strong&gt;: Pluralized endpoints make sense because they represent collections of resources, ensuring consistency across the API.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;posts&quot;&gt;Posts&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;POST /posts&lt;/code&gt;: Create a post&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET /posts&lt;/code&gt;: Retrieve all posts&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET /posts/:id&lt;/code&gt;: Retrieve a specific post by ID&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATCH /posts/:id&lt;/code&gt;: Update a specific post&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PUT /posts/:id/title&lt;/code&gt;: Update the title of a post (Isolated property that can be edited independently)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DELETE /posts/:id&lt;/code&gt;: Delete a specific post&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;POST /published-posts&lt;/code&gt;: Publish a post (Different state is treated as a separate resource)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DELETE /published-posts/:id&lt;/code&gt;: Unpublish a post&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;comments&quot;&gt;Comments&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;POST /posts/:id/comments&lt;/code&gt;: Create a comment (This is a nested resource belonging to the post, so the URL reflects that relationship)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET /posts/:id/comments&lt;/code&gt;: Retrieve all comments for a post&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GET /comments/:id&lt;/code&gt;: Retrieve a specific comment&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATCH /comments/:id&lt;/code&gt;: Update a comment&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DELETE /comments/:id&lt;/code&gt;: Delete a comment&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;response-structure&quot;&gt;Response Structure&lt;/h2&gt;

&lt;p&gt;Consistency in API responses makes integration easier for frontend developers. Here are some best practices for API responses:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;This API’s response structure is based on the &lt;a href=&quot;https://github.com/omniti-labs/jsend&quot;&gt;JSend specification&lt;/a&gt;, which promotes a consistent format for successful, failed, and error responses.&lt;/li&gt;
  &lt;li&gt;Every response includes a top-level &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;status&lt;/code&gt; field indicating the outcome:
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;success&quot;&lt;/code&gt; for successful requests, typically including a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data&lt;/code&gt; object with the resource(s).&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;fail&quot;&lt;/code&gt; for client-side input validation failures, with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data&lt;/code&gt; object describing the problems.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;error&quot;&lt;/code&gt; for unexpected server-side issues, including a human-readable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;message&lt;/code&gt; and optional &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;code&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data&lt;/code&gt; fields.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Always return the full resource representation, including &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;null&lt;/code&gt; values.
    &lt;ul&gt;
      &lt;li&gt;Even &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;null&lt;/code&gt; values provide meaningful information. For example, a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;publishedAt&lt;/code&gt; field being &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;null&lt;/code&gt; signals that a post has not been published, and a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;verifiedAt&lt;/code&gt; field being &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;null&lt;/code&gt; indicates that a user has not verified their email yet.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Avoid redundant prefixes in property names. Instead of using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;postId&lt;/code&gt;, simply use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;id&lt;/code&gt; when inside a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;post&lt;/code&gt; resource.&lt;/li&gt;
  &lt;li&gt;Ensure that the &lt;a href=&quot;#data-types&quot;&gt;data types&lt;/a&gt; in your API responses match their expected types, such as using numbers for numerical values and strings for text, to maintain consistency and avoid errors.&lt;/li&gt;
  &lt;li&gt;Wrap successful responses in a &lt;a href=&quot;#single-resource-response&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data&lt;/code&gt; object&lt;/a&gt;, as this allows easy extension with additional information, such as a &lt;a href=&quot;#multiple-resources-response-with-pagination&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;meta&lt;/code&gt; object&lt;/a&gt; for pagination.&lt;/li&gt;
  &lt;li&gt;I prefer using camelCase for property names because it aligns with the way most of my application code is written. This consistency makes it easier to map data between backend and frontend without any transformation. It also improves readability and reduces friction during integration, especially in JavaScript-heavy environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;data-types&quot;&gt;Data Types&lt;/h3&gt;

&lt;p&gt;It is important to ensure that the types in your API responses match the expected data types. For example, if a value is a number in your system, it should be returned as a number in the response, not as a string. This helps maintain consistency and prevents type mismatches during integration.&lt;/p&gt;

&lt;p&gt;For dates, always use the &lt;strong&gt;ISO 8601 format&lt;/strong&gt; (YYYY-MM-DDTHH:MM:SSZ). This format is widely accepted and helps avoid confusion, as it clearly represents both the date and the time, along with time zone information.&lt;/p&gt;

&lt;p&gt;In JavaScript, you can easily generate this ISO 8601 format with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;new Date().toISOString()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Using the correct types and formats ensures clarity, better interoperability, and a more predictable API.&lt;/p&gt;

&lt;h3 id=&quot;single-resource-response&quot;&gt;Single Resource Response&lt;/h3&gt;

&lt;p&gt;This is an example of a response when retrieving a single resource. The resource is wrapped in a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data&lt;/code&gt; object.&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;status&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;id&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;First post&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;This is the content of the first post.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;createdAt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2025-04-08T13:00:00Z&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;updatedAt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;publishedAt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
 &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;multiple-resources-response-with-pagination&quot;&gt;Multiple Resources Response with Pagination&lt;/h3&gt;

&lt;p&gt;This is an example of a response when retrieving multiple resources. The resources are wrapped in a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data&lt;/code&gt; array, and additional metadata, such as pagination information, is included under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;meta&lt;/code&gt; object.&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;status&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;id&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;First post&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;This is the content of the first post.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;createdAt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2025-04-08T13:00:00Z&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;updatedAt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;publishedAt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;id&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Second post&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;This is the content of the second post.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;createdAt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2025-04-09T12:34:56Z&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;updatedAt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;publishedAt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;meta&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;currentPage&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;perPage&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;totalPages&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;totalItems&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;fail-response&quot;&gt;Fail Response&lt;/h3&gt;

&lt;p&gt;This is an example of a response when the request fails due to invalid input. The response contains a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;status&lt;/code&gt; of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;fail&quot;&lt;/code&gt; and a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data&lt;/code&gt; object with field-specific error messages.&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;status&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;fail&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Title is required.&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;error-response&quot;&gt;Error Response&lt;/h3&gt;

&lt;p&gt;This is an example of a response when an unexpected server error occurs. The response contains a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;status&lt;/code&gt; of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;error&quot;&lt;/code&gt; and a human-readable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;message&lt;/code&gt; explaining the problem.&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;status&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;error&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;message&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Internal server error. Please try again later.&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;communication-between-backend-and-frontend-teams&quot;&gt;Communication Between Backend and Frontend Teams&lt;/h2&gt;

&lt;p&gt;One of the biggest API design pitfalls happens when backend and frontend teams communicate in example requests and responses rather than schemas. Define clear JSON schemas that outline the exact structure of requests and responses. This eliminates ambiguity and ensures smooth collaboration.&lt;/p&gt;

&lt;p&gt;Tools like &lt;strong&gt;Swagger&lt;/strong&gt; can be extremely helpful in this regard. Swagger allows both backend and frontend teams to work from a common definition, providing an interactive documentation interface. It ensures that both teams are on the same page regarding the structure of the API and makes it easy to update documentation as the API evolves. Swagger even allows automatic generation of client libraries and server stubs, further simplifying the development process.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Designing a well-structured REST API requires attention to detail, adherence to best practices, and clear communication between teams. By following these principles, you can build APIs that are intuitive, maintainable, and easy to work with. Whether you are a seasoned developer or just starting, these guidelines will help you create APIs that stand the test of time.&lt;/p&gt;
</description>
            <pubDate>Wed, 09 Apr 2025 00:00:00 +0000</pubDate>
            <link>https://www.kulik.io/2025/04/09/rest-api-design-best-practices-and-lessons-learned/</link>
            <guid isPermaLink="true">https://www.kulik.io/2025/04/09/rest-api-design-best-practices-and-lessons-learned/</guid>
        </item></channel>
</rss>
