<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Tabish Hassan]]></title><description><![CDATA[Tabish Hassan]]></description><link>https://tabishhassan.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6afbda933e52ffe551ce07fc/2d61ee90-2f93-411a-8f69-13e6e7662ca1.png</url><title>Tabish Hassan</title><link>https://tabishhassan.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 18 Nov 2026 15:31:11 GMT</lastBuildDate><atom:link href="https://tabishhassan.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[I tested 3 "anti AI slop" design skills on the same page. Only one changed the design]]></title><description><![CDATA[Originally published at tabishapps.com/blog/ai-slop-design-skills-test. The first screen of each version at 1440 px wide. Score = signs of AI slop out of…]]></description><link>https://tabishhassan.hashnode.dev/i-tested-3-anti-ai-slop-design-skills-on-the-same-page-only-one-changed-the-design</link><guid isPermaLink="true">https://tabishhassan.hashnode.dev/i-tested-3-anti-ai-slop-design-skills-on-the-same-page-only-one-changed-the-design</guid><category><![CDATA[Web Design]]></category><category><![CDATA[Artificial Intelligence]]></category><category><![CDATA[frontend]]></category><dc:creator><![CDATA[Tabish Hassan]]></dc:creator><pubDate>Wed, 18 Nov 2026 11:53:02 GMT</pubDate><content:encoded><![CDATA[<p><em>Originally published at <a href="https://tabishapps.com/blog/ai-slop-design-skills-test/">tabishapps.com/blog/ai-slop-design-skills-test</a>.</em></p>
<ul>
<li><strong>The test:</strong> one landing page for a made-up coffee roaster, built 4 times by an AI agent: once with a plain prompt, and once with each of 3 popular design skills.</li>
<li><strong>The result:</strong> the plain prompt and two of the skills gave almost the same page: same fonts, same colours, same emoji cards. Only Anthropic's Frontend Design skill produced a different design, and it took our "AI slop" count from 5 out of 10 to 0.</li>
<li><strong>The advice:</strong> install one skill for the look (Frontend Design) and one for the details (Vercel's Web Design Guidelines). The other skill is good, but it is about animation, not looks.</li>
</ul>
<p><img src="https://tabishapps.com/blog/ai-slop-design-skills-test/comparison.jpg" alt="Four screenshots of the same coffee roaster landing page. A, C and D share a cream background, a serif headline with an orange italic phrase and a picture of a cup. B has a dark teal hero, tall condensed type and a chalkboard list of this week's coffees." /></p>
<p><em>The first screen of each version at 1440 px wide. Score = signs of AI slop out of 10.</em></p>
<p>You can usually tell when a website was made by AI. The same cream background, the same serif headline with one word in italics, the same row of cards with an emoji on top. People call it "AI slop". Skills are text files you give to a coding agent to change how it works, and some of them promise to fix exactly this. So I tested three.</p>
<p>The idea came from a post by <a href="https://x.com/BenjaminUIX/status/2122286309855338953">@BenjaminUIX on X</a> listing "10 skills that kill AI slop" (it has about 7,600 likes). The post ends with good advice: "Install 2 or 3, not all 10." But which 2 or 3? The post doesn't show what the skills actually do. So I picked three from the list that are plain text instructions and ran the same job with each.</p>
<h2>The test</h2>
<p>The brief was one sentence, the kind a busy person would really type: build a single-file HTML landing page for <em>Harbour Coffee Roasters</em>, a small local coffee roaster with a cafe and an online shop for beans. No details about colours, hours or prices. The AI had to decide everything.</p>
<p>I built it four times. Each version was made by a fresh agent (Claude Opus 5.5 in Claude Code) that saw only the brief, plus one skill file for B to D. No agent could see the others' work. The same rules applied to all four: one HTML file, no photos (only CSS, inline SVG or emoji), and Google Fonts allowed.</p>
<table>
<thead>
<tr>
<th>Version</th>
<th>What the agent got</th>
<th>What the skill is about</th>
</tr>
</thead>
<tbody><tr>
<td>A</td>
<td>The brief only</td>
<td>Nothing, this is the baseline</td>
</tr>
<tr>
<td>B</td>
<td>Brief + <a href="https://github.com/anthropics/skills">Anthropic's Frontend Design</a> skill</td>
<td>Making a distinct visual design. It even lists the looks AI tends to repeat and asks the agent to avoid them.</td>
</tr>
<tr>
<td>C</td>
<td>Brief + <a href="https://github.com/vercel-labs/agent-skills">Vercel's Web Design Guidelines</a></td>
<td>A long checklist of interface rules: accessibility, focus states, forms, typography details. It is written for reviewing code, so I asked the agent to follow it while building and then check its own file once.</td>
</tr>
<tr>
<td>D</td>
<td>Brief + <a href="https://github.com/emilkowalski/skills">Emil Kowalski's design engineering</a> skill</td>
<td>Mostly animation and interaction: easing curves, timing, press states, when not to animate.</td>
</tr>
</tbody></table>
<p>Then I took screenshots of every version with headless Chrome at desktop size (1440 px wide) and phone size (390 px wide), in light mode.</p>
<h2>The checklist (written before I saw any result)</h2>
<p>Before looking at the pages, I wrote down 10 signs of AI slop. Each sign present is one point. Lower is better.</p>
<ol>
<li>A gradient used as decoration in the hero</li>
<li>Emoji used as icons</li>
<li>Vague marketing copy ("elevate your experience", "more than just coffee")</li>
<li>Everything centered</li>
<li>A row of identical cards, each with an icon, a title and one line</li>
<li>Low-contrast text</li>
<li>No real details: missing at least two of opening hours, address and prices</li>
<li>Broken or cramped on a phone</li>
<li>Fade-in on every section, or every card lifting on hover</li>
<li>A small ALL-CAPS label above every section heading</li>
</ol>
<h2>The results</h2>
<table>
<thead>
<tr>
<th>Sign</th>
<th>A: plain</th>
<th>B: Frontend Design</th>
<th>C: Vercel</th>
<th>D: Emil</th>
</tr>
</thead>
<tbody><tr>
<td>Decorative gradient in hero</td>
<td>yes</td>
<td>no</td>
<td>yes</td>
<td>yes</td>
</tr>
<tr>
<td>Emoji as icons</td>
<td>yes</td>
<td>no</td>
<td>yes</td>
<td>yes</td>
</tr>
<tr>
<td>Vague marketing copy</td>
<td>no</td>
<td>no</td>
<td>no</td>
<td>no</td>
</tr>
<tr>
<td>Everything centered</td>
<td>no</td>
<td>no</td>
<td>no</td>
<td>no</td>
</tr>
<tr>
<td>Identical icon cards</td>
<td>yes (4)</td>
<td>no</td>
<td>yes (4)</td>
<td>yes (3)</td>
</tr>
<tr>
<td>Low-contrast text</td>
<td>no</td>
<td>no</td>
<td>no*</td>
<td>no</td>
</tr>
<tr>
<td>No hours, address or prices</td>
<td>no</td>
<td>no</td>
<td>no</td>
<td>no</td>
</tr>
<tr>
<td>Cramped on phone</td>
<td>no</td>
<td>no</td>
<td>yes</td>
<td>no</td>
</tr>
<tr>
<td>Motion or hover lift everywhere</td>
<td>yes</td>
<td>no</td>
<td>yes</td>
<td>yes</td>
</tr>
<tr>
<td>ALL-CAPS label on every section</td>
<td>yes</td>
<td>no</td>
<td>no</td>
<td>yes</td>
</tr>
<tr>
<td><strong>Total (lower is better)</strong></td>
<td><strong>5</strong></td>
<td><strong>0</strong></td>
<td><strong>5</strong></td>
<td><strong>5</strong></td>
</tr>
</tbody></table>
<ul>
<li>C has a dark mode. In dark mode, its cafe section turns light blue while the text stays near-white, which is very hard to read. I scored the light mode, which is what most visitors see.</li>
</ul>
<p>Two things surprised me. First, the plain prompt was not bad. None of the four versions wrote anything like "elevate your experience", and all four invented useful details: opening hours, an address, prices per 250 g bag. The old slop signs are gone. New ones took their place.</p>
<p>Second, A, C and D are almost the same page. Look at the fonts: all three picked <strong>Fraunces</strong> for headings and <strong>Inter</strong> for text. All three have a cream background, a dark serif headline with an orange italic phrase, two rounded buttons and a row of three stats under them ("48h", "12 kg"). Here are their feature cards side by side:</p>
<p><img src="https://tabishapps.com/blog/ai-slop-design-skills-test/feature-cards.jpg" alt="The feature card rows from versions A, C and D. All three use rounded cards on cream with a seedling, a flame and a box emoji in the same order, then a serif title and a short line of grey text." /></p>
<p><em>A, C and D each built a row of emoji cards. Same seedling, flame and box, in the same order.</em></p>
<p>Three agents, three different skill files, no contact between them, and they all reached for 🌱 🔥 📦. That is what "AI slop" really is: not ugly, just the same.</p>
<h2>What each skill changed</h2>
<h3>A: plain prompt</h3>
<p><img src="https://tabishapps.com/blog/ai-slop-design-skills-test/a-desktop-phone.jpg" alt="Version A on desktop and phone: cream page, serif headline 'Coffee roasted by the water, poured with care', orange circle with a coffee cup." /></p>
<p>A clean, friendly page that would be fine for a real cafe. It has a menu with prices, opening hours and an address. But it uses the default kit: a gradient circle behind a cup, emoji icons, a small uppercase label above every heading, and cards that lift when you hover them.</p>
<h3>B: Anthropic Frontend Design</h3>
<p><img src="https://tabishapps.com/blog/ai-slop-design-skills-test/b-desktop-phone.jpg" alt="Version B on desktop and phone: dark teal hero with very tall condensed headline 'Roasted on the quay, poured at the counter' and a chalkboard listing this week's roasts by day." /></p>
<p>The only version that looks like someone made a choice. The agent picked a harbour-and-chalkboard idea and ran with it: tall condensed headings, a teal and yellow palette, and a "roasted this week" board with the day each coffee is roasted. The coffee bags are flat colour blocks, not emoji. The order steps are numbered 1 to 4 because they really are steps.</p>
<p>This makes sense when you read the skill. It asks the agent to start from the subject (a harbour, a roaster) instead of a template, to plan the colours and fonts first, and then to check that plan against a list of looks that AI repeats. That list describes A, C and D quite closely. It also asks for restraint: one bold idea, the rest quiet.</p>
<p>It isn't perfect. On a phone, the four coffee bags become very tall coloured blocks, which is a lot of scrolling. And there is a small bug: the empty "added to bag" message box peeks up from the bottom edge of the screen before you click anything.</p>
<h3>C: Vercel Web Design Guidelines</h3>
<p><img src="https://tabishapps.com/blog/ai-slop-design-skills-test/c-desktop-phone.jpg" alt="Version C on desktop and phone: cream page with serif headline 'Small-Batch Coffee, Roasted by the Sea' and a sunset illustration of a cup by the sea." /></p>
<p>Visually, almost the same as A. Under the hood, it's the most careful version. It is the only one with a "skip to content" link for keyboard users, balanced line breaks in headings, numbers formatted with the browser's own locale tools, and clear focus outlines. Following the guidelines' "Title Case" rule made the buttons read "Shop Fresh Beans" and "Add to Bag", which is fine but slightly stiff.</p>
<p>On a phone, the header is cramped: the shop name is cut off as "Harbour Coffee Ro…". And as noted above, its dark mode has a real contrast bug. So the checklist didn't catch everything, but that's expected: it's a list of rules, not a design brief.</p>
<h3>D: Emil Kowalski's design engineering</h3>
<p><img src="https://tabishapps.com/blog/ai-slop-design-skills-test/d-desktop-phone.jpg" alt="Version D on desktop and phone: cream page with serif headline 'Small-batch coffee, roasted by the water' and a teal sea scene with a cup and a fresh-roast badge." /></p>
<p>Again the same family as A. What changed is how it moves. Buttons shrink slightly when pressed, transitions use custom easing curves, hover effects only run on devices with a mouse, and motion is turned down for people who ask for less. There is also a filter for the bean list and a weekly / fortnightly / monthly switch for the subscription. Those details feel nice when you use the page, but they don't show in a screenshot.</p>
<p>It also fades in each section as you scroll, which is the one animation habit most likely to feel "AI". And a small layout slip: prices like "£11.50 / 250 g" break so the "g" lands on its own line.</p>
<h2>What you can't see in the screenshots</h2>
<p>I also searched each file for a few things the skills talk about. Numbers are how many times each appears in the code.</p>
<table>
<thead>
<tr>
<th>Detail</th>
<th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
</tr>
</thead>
<tbody><tr>
<td>"Skip to content" link</td>
<td>0</td>
<td>0</td>
<td>2</td>
<td>0</td>
</tr>
<tr>
<td>Visible keyboard focus styles</td>
<td>1</td>
<td>2</td>
<td>4</td>
<td>2</td>
</tr>
<tr>
<td>Respects "reduce motion"</td>
<td>yes</td>
<td>yes</td>
<td>yes</td>
<td>yes</td>
</tr>
<tr>
<td>Custom easing curves</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>3</td>
</tr>
<tr>
<td>Press feedback on buttons</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>4</td>
</tr>
<tr>
<td>Hover effects only on mouse devices</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>4</td>
</tr>
<tr>
<td>Even-width numbers for prices</td>
<td>0</td>
<td>1</td>
<td>4</td>
<td>1</td>
</tr>
<tr>
<td>Fonts</td>
<td>Fraunces + Inter</td>
<td>Big Shoulders + Source Serif</td>
<td>Fraunces + Inter</td>
<td>Fraunces + Inter</td>
</tr>
</tbody></table>
<p>So each skill did its own job. It's just that only one of them has "make it look different" as its job.</p>
<h2>Verdict: which 2 to install</h2>
<ol>
<li><strong>Anthropic's Frontend Design</strong>, if your problem is "it looks like every other AI site". In this test it was the only skill that changed the design, and it was the only page with zero slop signs.</li>
<li><strong>Vercel's Web Design Guidelines</strong>, as a second pass. Run it as it was meant to be used: ask the agent to review the finished page against it. It catches accessibility and detail problems that a design skill ignores.</li>
</ol>
<p>Emil Kowalski's skill is worth having when you build interactive parts: menus, drawers, toasts, anything that moves. For a mostly static landing page, it changes very little you can see.</p>
<h2>Limits of this test</h2>
<ul>
<li>One run per version. AI output varies, and a second run could look different. Treat this as one honest sample, not a benchmark.</li>
<li>I wrote the checklist and judged the pages myself. I wrote it before seeing any page, but some of my signs overlap with the list inside Anthropic's skill, which gives B an advantage on my scorecard.</li>
<li>Two of the skills are not designed to change visual style. Vercel's is a review checklist, and Emil's is mostly about motion. They did what they say; they just aren't "make it look different" tools.</li>
<li>One model (Claude Opus 5.5) and one kind of page. Other models, and apps instead of landing pages, may behave differently.</li>
</ul>
<h2>Sources</h2>
<ul>
<li>@BenjaminUIX on X, 16 November 2026: <a href="https://x.com/BenjaminUIX/status/2122286309855338953">10 skills that kill AI slop</a>.</li>
<li>Anthropic: <a href="https://github.com/anthropics/skills">anthropics/skills</a> (frontend-design).</li>
<li>Vercel: <a href="https://github.com/vercel-labs/agent-skills">vercel-labs/agent-skills</a> (web-design-guidelines) and the <a href="https://github.com/vercel-labs/web-interface-guidelines">Web Interface Guidelines</a> it reads.</li>
<li>Emil Kowalski: <a href="https://github.com/emilkowalski/skills">emilkowalski/skills</a> (emil-design-eng).</li>
</ul>
<p>Let me know in the comments: which design skills do you use, and did they change your results?</p>
]]></content:encoded></item><item><title><![CDATA[Why AI coding agents slow down in long sessions, and 5 prompt-caching mistakes to avoid]]></title><description><![CDATA[Originally published at tabishapps.com/blog/prompt-caching-coding-agents. If you use Claude Code, Codex or an open model through Ollama, you've probably…]]></description><link>https://tabishhassan.hashnode.dev/why-ai-coding-agents-slow-down-in-long-sessions-and-5-prompt-caching-mistakes-to-avoid</link><guid isPermaLink="true">https://tabishhassan.hashnode.dev/why-ai-coding-agents-slow-down-in-long-sessions-and-5-prompt-caching-mistakes-to-avoid</guid><category><![CDATA[Artificial Intelligence]]></category><category><![CDATA[llm]]></category><category><![CDATA[#ai-tools]]></category><dc:creator><![CDATA[Tabish Hassan]]></dc:creator><pubDate>Tue, 17 Nov 2026 10:29:39 GMT</pubDate><content:encoded><![CDATA[<p><em>Originally published at <a href="https://tabishapps.com/blog/prompt-caching-coding-agents/">tabishapps.com/blog/prompt-caching-coding-agents</a>.</em></p>
<p>If you use Claude Code, Codex or an open model through Ollama, you've probably seen an agent that was quick at the start get slower and more expensive as the session went on. Often the reason isn't the model. It's the prompt cache being thrown away, sometimes by something as small as a timestamp.</p>
<p>This week <a href="https://x.com/ollama/status/2122531964154712541">Ollama shared three lessons</a> on this, from a longer <a href="https://www.together.ai/blog/making-open-models-work-for-long-horizon-agentic-workloads">write-up by Together AI and Ollama</a>. I read it, then tested the main claim on my own Mac. Here's what's going on, in plain words, and what to do about it.</p>
<h2>Every turn, the agent sends everything again</h2>
<p>A coding agent doesn't "remember" your session the way a person does. On every step, the tool you use (the <em>harness</em>: Claude Code, Codex, Cursor, Pi and so on) sends the model the whole conversation again: the system prompt, every tool definition, your request, every file it has read and every command it has run. The model usually answers with a short tool call, like "read this file". Then the next turn sends all of that again, plus a bit more.</p>
<p>So for agents, the expensive part is reading the input, not writing the answer. Without help, turn 100 would mean re-reading 100 turns of history.</p>
<h2>Prefix caching: only read what's new</h2>
<p>Inference engines (Ollama, vLLM, MLX, and hosted APIs like Anthropic's and OpenAI's) keep the work they did on a prompt for a while. If the next request <strong>starts with exactly the same tokens</strong>, they reuse that work and only process the new part at the end.</p>
<p>The Together write-up gives the simple maths: if each turn adds about the same amount, ten turns without a cache process 1 + 2 + … + 10 = 55 units of prompt, and with a cache only 10. At a hundred turns it's 5,050 against 100.</p>
<p>But there's one rule that everything else follows from:</p>
<p><strong>The cache matches from the very first token up to the first token that's different, and stops there.</strong> Adding text at the end is cheap. Changing anything earlier, even one character, means everything after that point is processed again.</p>
<h2>I tested it on a Mac</h2>
<p>I wanted to see this rule in real numbers, so I ran a small test with Apple's MLX and Google's Gemma 3 12B (4-bit) on a MacBook Pro with an M3 Pro chip and 36 GB of memory. The script builds a fake agent session: a system prompt with tool definitions, then a few turns where the agent reads files. It then times how long the model takes to read the prompt for the next turn in three cases:</p>
<table>
<thead>
<tr>
<th>Case</th>
<th>Tokens the model had to read</th>
<th>Time before the first word</th>
</tr>
</thead>
<tbody><tr>
<td>No cache (fresh start)</td>
<td>10,275 (the whole prompt)</td>
<td>about 2–4 minutes</td>
</tr>
<tr>
<td>Cache kept, new turn added at the end</td>
<td>2,513 (only the new turn)</td>
<td>about 1 minute (66 s)</td>
</tr>
<tr>
<td>Cache kept, but the system prompt has a new timestamp</td>
<td>10,244 (only the first 32 tokens matched)</td>
<td>about 2–4 minutes</td>
</tr>
</tbody></table>
<p>The token counts are the important part, because they don't depend on what else the laptop was doing. With the cache kept, the model read 2,513 tokens instead of 10,275, about four times less, and that gap keeps growing as the session gets longer. With one changed timestamp near the top, only the first 32 tokens matched, so the cache saved almost nothing: the model read 10,244 tokens, the same as starting fresh. (The times are rough. My two full re-reads took 134 and 234 seconds because the Mac was busy with other apps, which is why I show a range.)</p>
<p>A cloud model on big GPUs is much faster than a laptop, but the shape is the same: a broken cache means paying again, in time and money, for the whole session.</p>
<p>The test script is short and at the end of this post if you want to try it.</p>
<h2>5 things that break the cache</h2>
<h3>1. Anything in the system prompt that changes each turn</h3>
<p>A current time, the <code>git status</code>, the current folder, "turn 14 of 40". It feels helpful to keep the model up to date, but the system prompt sits at the very top, so a new value there means the whole session is read again on every turn. That's the "timestamp" row in my test.</p>
<p><strong>Fix:</strong> keep the system prompt identical for the whole session (and ideally across sessions). Put changing information in a new message at the end instead. If you write your own agent or prompt templates, check for <code>datetime.now()</code> or similar in the system prompt first.</p>
<h3>2. Changing reasoning effort in the middle of a session</h3>
<p>For some open models, the chat template writes the reasoning-effort setting into the first system block. Ollama found this with GLM. So switching from "low" to "high" halfway through a long task changes the prompt almost at the first token, and the whole session is processed again.</p>
<p><strong>Fix:</strong> choose the effort level at the start and leave it. If you really need more thinking, it's often cheaper to start a fresh session (or compact the old one first) than to flip the setting on a long one.</p>
<h3>3. Adding tools near the top</h3>
<p>Newer harnesses load tools only when the agent searches for them, which saves context. But if the new tool definition is added to the tool list at the top, everything after it is re-read. The better place is the end of the conversation. Not every model's chat template accepts that, so this depends on the harness and model.</p>
<p><strong>Fix (if you build tools or MCP servers):</strong> avoid changing the tool list during a session, and prefer harnesses that add late-loaded tools at the end.</p>
<h3>4. Huge tool results</h3>
<p>A file the agent reads becomes part of every request after it. If it reads 3,000 lines when it needed 40, you carry those 3,000 lines for the rest of the session. Even cached, they fill the context window and memory.</p>
<p><strong>Fix:</strong> ask the agent to search before it reads, and to read line ranges. If you build tools, return less by default.</p>
<h3>5. Cutting output without saying so</h3>
<p>This one isn't about speed, but it's the third point in Ollama's post and it matters. Many tools trim long output. If a tool returns the first 100 lines of a 640-line file without saying it stopped, the model doesn't know the rest exists and will happily edit code it never saw.</p>
<p><strong>Fix:</strong> when output is cut, add one line like <code>[showing lines 1–100 of 640; search or ask for another range]</code>. With that hint, the model goes and reads the part it needs.</p>
<h2>A quick checklist</h2>
<ul>
<li>System prompt: no dates, times, git status or folder paths that change. Put those in the latest message.</li>
<li>Pick model, reasoning effort and tools at the start of a session and don't change them midway.</li>
<li>Long, messy session? Start fresh or compact, rather than changing settings.</li>
<li>Read files by searching and line ranges, not whole files.</li>
<li>Truncated output should always say it was truncated.</li>
<li>For subagents: give them a short brief instead of the whole history when they only need a few files. A cached prefix is cheap, but not free.</li>
</ul>
<h2>The test script</h2>
<p>It needs a Mac with Apple silicon and Python. Install <code>mlx-lm</code> with <code>pip install mlx-lm</code>; the first run downloads the model (about 8 GB for the 12B, under 1 GB for <code>mlx-community/gemma-3-1b-it-4bit</code>).</p>
<pre><code class="language-python">"""Measure how prefix caching behaves for an agent-style prompt with mlx_lm.

Scenarios (all time only prefill + 1 token):
  cold      : whole prompt for turn N+1, empty cache
  append    : cache holds turn N, only the new turn is processed
  timestamp : same as append, but the system prompt has a new timestamp -&gt; first
              differing token is near the top, so nothing after it can be reused
"""
import sys, time, random
from mlx_lm import load, stream_generate
from mlx_lm.models.cache import make_prompt_cache

MODEL = sys.argv[1] if len(sys.argv) &gt; 1 else "mlx-community/gemma-3-1b-it-4bit"
TURNS = int(sys.argv[2]) if len(sys.argv) &gt; 2 else 12
model, tok = load(MODEL)

TOOLS = "\n".join(
    f"- {n}(path: str, start: int = 1, end: int = 200): {d}"
    for n, d in [("read_file", "Read part of a file and return numbered lines."),
                 ("search", "Search the project for a string and return matching lines."),
                 ("run", "Run a shell command and return stdout and stderr."),
                 ("edit_file", "Replace an exact string in a file with new text."),
                 ("list_dir", "List the files in a directory.")])

random.seed(7)
def fake_file(i):
    rnd = random.Random(i)
    lines = []
    for j in range(60):
        lines.append(f"{j+1:4d}  def handler_{i}_{j}(event, tz='UTC'):  # export step {j}")
        lines.append(f"      return convert(event['start'], tz) + {rnd.randint(1, 999)}")
    return "\n".join(lines)

def messages(turns, stamp):
    sys_prompt = f"You are a coding agent.\nCurrent time: {stamp}\nTools:\n{TOOLS}"
    msgs = [{"role": "user", "content": sys_prompt + "\n\nTask: fix the timezone bug in the calendar export."}]
    for t in range(turns):
        msgs.append({"role": "assistant", "content": f'read_file(path="src/module_{t}.py")'})
        msgs.append({"role": "user", "content": f"Tool result:\n{fake_file(t)}"})
    return msgs

def ids(turns, stamp):
    return tok.apply_chat_template(messages(turns, stamp), add_generation_prompt=True)

def prefill(tokens, cache):
    t0 = time.perf_counter()
    for r in stream_generate(model, tok, prompt=tokens, max_tokens=1, prompt_cache=cache):
        pass
    return time.perf_counter() - t0

def lcp(a, b):
    n = 0
    for x, y in zip(a, b):
        if x != y: break
        n += 1
    return n

# warm up the GPU kernels so the first timing is fair
prefill(ids(1, "warmup"), make_prompt_cache(model))

S1, S2 = "2026-11-17 10:04:11", "2026-11-17 10:04:52"
prev = ids(TURNS, S1)
nxt_same = ids(TURNS + 1, S1)
nxt_new_stamp = ids(TURNS + 1, S2)
print(f"model {MODEL}")
print(f"turn {TURNS} prompt: {len(prev)} tokens; turn {TURNS+1}: {len(nxt_same)} tokens")
print(f"shared prefix, same system prompt: {lcp(prev, nxt_same)} tokens")
print(f"shared prefix, new timestamp:      {lcp(prev, nxt_new_stamp)} tokens")

# chat templates may re-render the end of the previous prompt (generation prompt),
# so reuse exactly the shared prefix: prime the cache with it, then send the rest.
def warm(prev_ids, new_ids):
    n = lcp(prev_ids, new_ids)
    c = make_prompt_cache(model)
    if n &gt; 1:
        prefill(new_ids[: n - 1], c)       # what the server already has from turn N
        return prefill(new_ids[n - 1:], c), len(new_ids) - (n - 1)
    return prefill(new_ids, c), len(new_ids)

cold = prefill(nxt_same, make_prompt_cache(model))
app, app_n = warm(prev, nxt_same)
ts, ts_n = warm(prev, nxt_new_stamp)
print(f"cold      : {cold:6.2f}s  ({len(nxt_same)} tokens processed)")
print(f"append    : {app:6.2f}s  ({app_n} tokens processed)")
print(f"timestamp : {ts:6.2f}s  ({ts_n} tokens processed)")
</code></pre>
<p>Run it with <code>python cache_test.py mlx-community/gemma-3-12b-it-4bit 3</code>. The last number is how many file-reading turns to put in the session.</p>
<h2>Sources</h2>
<ul>
<li>Ollama on X, 17 November 2026: <a href="https://x.com/ollama/status/2122531964154712541">lessons on keeping coding agents fast</a>.</li>
<li>Together AI and Ollama: <a href="https://www.together.ai/blog/making-open-models-work-for-long-horizon-agentic-workloads">Making open models work for long-horizon agentic workloads</a>.</li>
<li><a href="https://github.com/ml-explore/mlx-lm">mlx-lm</a>, used for the test.</li>
</ul>
<p><em>Written by Tabish Hassan, a software developer. Found a mistake or got different numbers on your machine? Let me know in the comments.</em></p>
]]></content:encoded></item><item><title><![CDATA[How to add subtitles to a video on your Mac, offline, in 100 languages]]></title><description><![CDATA[Originally published at tabishapps.com Most subtitle tools upload your video to a server and charge by the minute. If you have an Apple silicon Mac, you…]]></description><link>https://tabishhassan.hashnode.dev/how-to-add-subtitles-to-a-video-on-your-mac-offline-in-100-languages</link><guid isPermaLink="true">https://tabishhassan.hashnode.dev/how-to-add-subtitles-to-a-video-on-your-mac-offline-in-100-languages</guid><category><![CDATA[macOS]]></category><category><![CDATA[AI]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Subtitles]]></category><dc:creator><![CDATA[Tabish Hassan]]></dc:creator><pubDate>Tue, 17 Nov 2026 05:37:49 GMT</pubDate><content:encoded><![CDATA[<p><em>Originally published at <a href="https://tabishapps.com/blog/add-subtitles-to-video-offline-mac/">tabishapps.com</a></em></p>
<p>Most subtitle tools upload your video to a server and charge by the minute. If you have an Apple silicon Mac, you can do the whole job on your own machine instead: transcribe the speech, split it into readable subtitles, translate them, and export files that YouTube and every major editor accept.</p>
<p>This guide walks through that process with <a href="https://tabishapps.com/mlx-caption/">MLX Caption</a>, a Mac app I built for exactly this job. The first five videos are free, so you can follow along without paying. Near the end I also explain what happens under the hood, for anyone curious about running AI models locally.</p>
<h2>Why do it offline?</h2>
<ul>
<li><strong>Privacy.</strong> Client footage, unreleased videos and internal recordings never leave your Mac.</li>
<li><strong>Cost.</strong> Online services usually charge per minute of video, and translation into extra languages costs more again. A local tool costs the same whether you caption one video or a thousand.</li>
<li><strong>No waiting on uploads.</strong> Large video files don't need to travel anywhere.</li>
</ul>
<h2>What you need</h2>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody><tr>
<td><strong>Mac</strong></td>
<td>Apple silicon: M1, M2, M3, M4 or newer. Intel Macs can't run it.</td>
</tr>
<tr>
<td><strong>macOS</strong></td>
<td>14 Sonoma or newer</td>
</tr>
<tr>
<td><strong>Memory</strong></td>
<td>16 GB recommended. 8 GB works with smaller models, chosen automatically.</td>
</tr>
<tr>
<td><strong>Disk</strong></td>
<td>8 to 15 GB free for the AI models, downloaded once</td>
</tr>
<tr>
<td><strong>Video</strong></td>
<td>MP4, MOV, MKV, WebM, AVI, or an audio file</td>
</tr>
</tbody></table>
<h2>Step 1: Download and open the app</h2>
<p>Download the free trial from the <a href="https://tabishapps.com/mlx-caption/">MLX Caption page</a> and unzip it. No account, email address or card is needed.</p>
<p>Because the app is sold outside the Mac App Store, macOS asks you to confirm the first time you open it. Open <strong>System Settings → Privacy &amp; Security</strong>, scroll down and click <strong>Open Anyway</strong>. You only do this once, and the download includes a short guide with the exact steps.</p>
<h2>Step 2: Let it download the models</h2>
<p>On first launch the app installs its components and downloads the AI models: about 6.5 GB on Macs with 8 to 16 GB of memory, and about 13 GB on Macs with 24 GB or more. This is the only step that needs the internet. After that, everything works offline.</p>
<h2>Step 3: Drop in a video and choose languages</h2>
<p><img src="https://tabishapps.com/mlx-caption/upload.jpg" alt="The start screen: drop a file, pick languages, press start" /></p>
<p>Drag your video onto the window. The spoken language is detected automatically. Then pick the subtitle languages you want. Fifteen common languages are selected by default, and there are buttons for "All core" (54 languages) and "All 100".</p>
<p>If your video has names or jargon the speech model might mishear, add them as a vocabulary hint. Then press start.</p>
<h2>Step 4: Check the result</h2>
<p><img src="https://tabishapps.com/mlx-caption/subtitles.jpg" alt="A video playing with Hindi subtitles next to the transcript" /></p>
<p>When it finishes you can play the video with any subtitle language, read the transcript, and compare a translation side by side with the original. It is worth a quick read before you publish, especially for names and for the less common languages.</p>
<p>For a sense of speed: on an M3 Pro, a 28-second clip was transcribed in 5.2 seconds. Translating that same clip into all 100 languages, plus scene descriptions and a summary, took 6 minutes 35 seconds. Older Macs and 8 GB machines are slower.</p>
<h2>Step 5: Export and use the subtitles</h2>
<p>Each job produces a folder with:</p>
<ul>
<li><strong>SRT and VTT files</strong> for every language, the formats every platform and editor understands</li>
<li><strong>An MP4 with every language embedded</strong> as a selectable subtitle track, without re-encoding the video</li>
<li>Optionally, <strong>a copy with one language burned in</strong>, for social media where viewers don't turn captions on</li>
<li><strong>A plain-text transcript</strong>, plus a <strong>summary with chapter timestamps</strong> you can paste into a video description</li>
</ul>
<h3>YouTube</h3>
<p>In YouTube Studio, open <strong>Subtitles</strong>, choose your video, click <strong>Add language</strong>, then <strong>Add</strong> under Subtitles and choose <strong>Upload file → With timing</strong>. Select the matching <code>.srt</code> file. Repeat for each language. Viewers in other countries can then pick their own language.</p>
<h3>Premiere Pro</h3>
<p>Import the <code>.srt</code> file into your project like any other media, then drag it onto the timeline. It becomes a caption track you can restyle.</p>
<h3>Final Cut Pro</h3>
<p>Choose <strong>File → Import → Captions</strong> and pick the <code>.srt</code> file. Recent versions of Final Cut Pro import SRT directly.</p>
<h3>DaVinci Resolve</h3>
<p>Import the <code>.srt</code> file into the Media Pool, then drag it onto the timeline to create a subtitle track.</p>
<h2>What happens under the hood</h2>
<p>Everything runs on the Mac's GPU through <a href="https://github.com/ml-explore/mlx">MLX</a>, Apple's machine learning framework for Apple silicon. Four models do the work, one at a time so memory stays manageable:</p>
<table>
<thead>
<tr>
<th>Job</th>
<th>Model</th>
</tr>
</thead>
<tbody><tr>
<td>Speech to text</td>
<td>Whisper large-v3 turbo, with timing for every word</td>
</tr>
<tr>
<td>Translation and summary</td>
<td>Gemma 3 12B, 4-bit</td>
</tr>
<tr>
<td>Scene descriptions</td>
<td>Qwen3-VL, one keyframe per shot</td>
</tr>
<tr>
<td>Silence and shot detection</td>
<td>Small custom routines written directly in MLX</td>
</tr>
</tbody></table>
<p>The interesting trick is in translation. Generating text on a GPU is limited by memory bandwidth, not by raw compute, so translating into 16 languages in one batch costs little more than translating into one. The app reads the shared part of each prompt once, then decodes all the target languages together. That is why adding languages is cheap.</p>
<p>Two smaller details make the output usable. Silent stretches are skipped, because speech models tend to invent text in silence. And every translated line is checked for letters from the wrong writing system, for example Hindi script inside Urdu, and translated again if needed.</p>
<h2>Limits worth knowing</h2>
<ul>
<li>54 "core" languages translate at high quality. The other 46 are lower-resource languages where quality varies, so review them before publishing.</li>
<li>It needs an Apple silicon Mac. There is no Windows or Intel version.</li>
<li>Machine translation is a strong first draft, not a certified translation. For legal or medical content, have a native speaker check it.</li>
</ul>
<p><strong>Disclosure:</strong> I am the developer of MLX Caption. After the five free videos it costs $49 once, with a 14-day refund. There is no subscription.</p>
<p><strong><a href="https://tabishapps.com/mlx-caption/">Download the free trial</a></strong>: your first 5 videos are free, with every feature, and nothing is uploaded.</p>
<hr />
<p><em>I'm Tabish Hassan, a software developer in Pakistan. I build websites, apps and business systems: <a href="https://tabishapps.com/">tabishapps.com</a>.</em></p>
]]></content:encoded></item></channel></rss>