<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Agent Shipped</title>
    <description>The latest articles on DEV Community by Agent Shipped (@agentshipped).</description>
    <link>https://dev.to/agentshipped</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4225406%2F086f6c14-736f-4cac-956b-eb9cc082dbd1.png</url>
      <title>DEV Community: Agent Shipped</title>
      <link>https://dev.to/agentshipped</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/agentshipped"/>
    <language>en</language>
    <item>
      <title>Claude Code hooks: I wired 5 and 2 never fired</title>
      <dc:creator>Agent Shipped</dc:creator>
      <pubDate>Tue, 24 Nov 2026 08:51:31 +0000</pubDate>
      <link>https://dev.to/agentshipped/claude-code-hooks-i-wired-5-and-2-never-fired-4ejp</link>
      <guid>https://dev.to/agentshipped/claude-code-hooks-i-wired-5-and-2-never-fired-4ejp</guid>
      <description>&lt;p&gt;I wired five Claude Code hooks on a demo repo: three of three reads of a secrets file were blocked, and two hooks stayed at zero until I fixed one matcher each.&lt;br&gt;
  &lt;iframe src="https://www.youtube.com/embed/aR5c3T0jqvc" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/agentshipped" rel="noopener noreferrer"&gt;
        agentshipped
      &lt;/a&gt; / &lt;a href="https://github.com/agentshipped/notes-api" rel="noopener noreferrer"&gt;
        notes-api
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Agent Shipped demo repo (notes-api): the public playground used in the channel's videos.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;notes-api&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;A tiny Express notes API. This is a &lt;strong&gt;public demo repo for the Agent Shipped YouTube channel&lt;/strong&gt;
techniques from real projects are shown here, on code anyone can clone.&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;npm install
npm start          &lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; http://localhost:3000/notes&lt;/span&gt;
npm &lt;span class="pl-c1"&gt;test&lt;/span&gt;           &lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; node:test (no tests yet - that is on purpose)&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Endpoints: &lt;code&gt;GET /health&lt;/code&gt;, &lt;code&gt;GET /notes&lt;/code&gt;, &lt;code&gt;GET /notes/:id&lt;/code&gt;, &lt;code&gt;POST /notes {title, body}&lt;/code&gt;, &lt;code&gt;DELETE /notes/:id&lt;/code&gt;.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Shown in&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Videos on the Agent Shipped channel that use this repo:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/8xQ3gWhe1fQ" rel="nofollow noopener noreferrer"&gt;One git hook blocked a fake GitHub token, so no secret hit history #Shorts&lt;/a&gt; · E002 · 2026-11-02&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/t9Ek80jnkV0" rel="nofollow noopener noreferrer"&gt;Claude Code invented one endpoint shape. A 3-line rule fixed it #Shorts&lt;/a&gt; · E001 · 2026-11-03&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/lSzonRoE2ok" rel="nofollow noopener noreferrer"&gt;I let Claude Code test my Express API, then ran it myself three times&lt;/a&gt; · E003 · 2026-11-08 · &lt;a href="https://dev.to/agentshipped/two-prompts-took-an-untested-express-api-to-a-passing-suite-1eeg" rel="nofollow"&gt;write-up&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/l1spi9ot4FU" rel="nofollow noopener noreferrer"&gt;I don't trust an agent's restart. I trust a counter going up by one #Shorts&lt;/a&gt; · E010…&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/agentshipped/notes-api" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;A hook that never matches prints no error, so the settings file cannot tell you which hooks will fire. Counting what each hook did found the two silent ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  A guard hook with a log
&lt;/h2&gt;

&lt;p&gt;A hook is a command that Claude Code runs around a tool call. You register it in &lt;code&gt;.claude/settings.json&lt;/code&gt; under an event name, with a matcher that picks the tools it listens to. Claude Code passes the command a JSON object on standard input with the tool name and the tool input.&lt;/p&gt;

&lt;p&gt;The first hook is a guard that listens before every Bash and Read call. The script reads stdin with &lt;code&gt;jq&lt;/code&gt;, takes &lt;code&gt;tool_input.command&lt;/code&gt; if it exists, otherwise &lt;code&gt;tool_input.file_path&lt;/code&gt;, and calls that the target. If the target mentions &lt;code&gt;.env&lt;/code&gt;, it exits with code 2 and writes one sentence to stderr. That is the whole blocking mechanism. The agent gets the sentence as the reason the call failed.&lt;/p&gt;

&lt;p&gt;The script also appends one line to a log on every call, so you can count what it did instead of trusting it. I told the agent not to run the script, because a test run would add extra lines.&lt;/p&gt;

&lt;h2&gt;
  
  
  A secret to protect
&lt;/h2&gt;

&lt;p&gt;There is no real secret in the repo. The terminal builds a &lt;code&gt;.env&lt;/code&gt; with a random token at run time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'TOKEN=%s\n'&lt;/span&gt; &lt;span class="s2"&gt;"$(openssl rand -hex 18)"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .env &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'created .env'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; cat .claude/hooks/guard.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script parses with &lt;code&gt;jq&lt;/code&gt;, picks the target, logs one line, then decides. A match writes the &lt;code&gt;blocked&lt;/code&gt; line, speaks on stderr and exits 2. Anything else exits 0.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three ways in
&lt;/h2&gt;

&lt;p&gt;In a fresh session, so the hook is loaded, I asked for exactly three attempts at the same file, with no other way around a block:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Read tool on &lt;code&gt;.env&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The Bash tool running &lt;code&gt;cat .env&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The Bash tool running a &lt;code&gt;grep&lt;/code&gt; that would print the token line.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One matcher, &lt;code&gt;Bash|Read&lt;/code&gt;, has to catch three routes. Each attempt came back with the stderr sentence, and no file content appeared.&lt;/p&gt;

&lt;h2&gt;
  
  
  Count the blocks
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grep -c &lt;span class="s1"&gt;'^blocked'&lt;/span&gt; .claude/hooks.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The number is 3: three attempts, three blocked.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE028%2Fs04.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE028%2Fs04.png" alt="A terminal showing the grep count of lines starting with blocked in the hooks log, with the result 3." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The grep count of blocked lines: 3 of 3 attempts. · &lt;a href="https://youtu.be/aR5c3T0jqvc?t=123" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A guard that works is the easy half of the story.&lt;/p&gt;
&lt;h2&gt;
  
  
  Four more hooks, two planted wrong
&lt;/h2&gt;

&lt;p&gt;The second prompt asked for four more scripts, registered next to the guard: a syntax check, a stop marker, an audit log and a change log. Each appends one line with its own label to the same log, which makes it countable.&lt;/p&gt;

&lt;p&gt;I planted two mistakes and told the agent to write the matchers exactly as given. The audit hook got &lt;code&gt;bash&lt;/code&gt; in lower case. The change hook got &lt;code&gt;Write&lt;/code&gt;. A model that tidies a typo would hide the lesson.&lt;/p&gt;

&lt;p&gt;The syntax hook runs after Edit or Write and calls &lt;code&gt;node --check&lt;/code&gt;. The stop hook has no matcher, because the Stop event fires when the agent finishes its turn and there is no tool to match.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is registered
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq .hooks .claude/settings.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;PreToolUse holds the guard on &lt;code&gt;Bash|Read&lt;/code&gt; and the audit hook on &lt;code&gt;bash&lt;/code&gt;. PostToolUse holds the syntax hook on &lt;code&gt;Edit|Write&lt;/code&gt; and the change hook on &lt;code&gt;Write&lt;/code&gt;. Stop holds one entry with no matcher. The paths are right and the JSON is valid. Nothing looks wrong, and that is the trap.&lt;/p&gt;
&lt;h2&gt;
  
  
  A real edit
&lt;/h2&gt;

&lt;p&gt;I asked the agent to edit an existing file with the Edit tool, not rewrite it: change &lt;code&gt;not found&lt;/code&gt; to &lt;code&gt;note not found&lt;/code&gt;, then run &lt;code&gt;node --check src/index.js&lt;/code&gt;. Silence means the file still parses. The screen only shows the edit, not which hooks ran.&lt;/p&gt;
&lt;h2&gt;
  
  
  The count
&lt;/h2&gt;

&lt;p&gt;One count per label, zeros included:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; h &lt;span class="k"&gt;in&lt;/span&gt; guard blocked syntax stop audit changed&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%s %s\n'&lt;/span&gt; &lt;span class="s2"&gt;"$(grep -c "&lt;/span&gt;^&lt;span class="nv"&gt;$h&lt;/span&gt;&lt;span class="s2"&gt;" .claude/hooks.log)"&lt;/span&gt; &lt;span class="s2"&gt;"$h"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE028%2Fs08.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE028%2Fs08.png" alt="A terminal listing one count per hook label, with blocked at 3 and audit and changed at 0." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Look at the two zeros: audit and changed. Blocked is 3. · &lt;a href="https://youtu.be/aR5c3T0jqvc?t=248" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;blocked&lt;/code&gt; is still 3. &lt;code&gt;guard&lt;/code&gt;, &lt;code&gt;syntax&lt;/code&gt; and &lt;code&gt;stop&lt;/code&gt; are above zero. &lt;code&gt;audit&lt;/code&gt; and &lt;code&gt;changed&lt;/code&gt; are 0, each for its own reason.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;audit:&lt;/strong&gt; matchers are case sensitive. The tool is &lt;code&gt;Bash&lt;/code&gt; and the matcher says &lt;code&gt;bash&lt;/code&gt;. No error, no warning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;changed:&lt;/strong&gt; the agent never used Write. Changing an existing file is an Edit call, and Write is for creating a file or replacing it whole. The syntax hook has &lt;code&gt;Edit&lt;/code&gt; in its matcher, which is why it has a count.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The one-line fix
&lt;/h2&gt;

&lt;p&gt;Two substitutions in the settings file, then a list of every matcher:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sed -i -E &lt;span class="s1"&gt;'s/("matcher" *: *)"bash"/\1"Bash"/; s/("matcher" *: *)"Write"/\1"Edit|Write"/'&lt;/span&gt; .claude/settings.json &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; jq -c &lt;span class="s1"&gt;'[.hooks[][].matcher]'&lt;/span&gt; .claude/settings.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE028%2Fs09.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE028%2Fs09.png" alt="A terminal showing the compact list of matchers in the settings file after the sed fix." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The matcher list after the fix; the Stop entry shows null. · &lt;a href="https://youtu.be/aR5c3T0jqvc?t=297" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The pattern only touches a matcher whose whole value is that word, so the syntax hook stays as it was. The scripts are untouched: the only wrong thing was the line that tells Claude Code when to call them. The Stop entry shows null because it has no matcher by design.&lt;/p&gt;

&lt;h2&gt;
  
  
  Edit once more
&lt;/h2&gt;

&lt;p&gt;Same kind of task in a fresh session, so the fixed settings load: change &lt;code&gt;note not found&lt;/code&gt; to &lt;code&gt;Note not found&lt;/code&gt; in the same file, then run &lt;code&gt;node --check src/index.js&lt;/code&gt;. Only the two matchers differ.&lt;/p&gt;

&lt;h2&gt;
  
  
  The verdict
&lt;/h2&gt;

&lt;p&gt;The same count loop again:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE028%2Fs11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE028%2Fs11.png" alt="A terminal listing one count per hook label after the fix, with audit and changed above zero." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Same count loop after the fix: audit and changed are no longer zero. · &lt;a href="https://youtu.be/aR5c3T0jqvc?t=362" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;audit&lt;/code&gt; and &lt;code&gt;changed&lt;/code&gt; are above zero. &lt;code&gt;blocked&lt;/code&gt; is still 3, because nothing tried to read the secrets file this time. All five hooks have now run.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to copy
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Give every hook script a one-line log with its own label, then print a count per hook. Trust that number, not the settings file.&lt;/li&gt;
&lt;li&gt;Blocking is exit code 2 plus one sentence on stderr.&lt;/li&gt;
&lt;li&gt;Write matchers as exact tool names: &lt;code&gt;Bash&lt;/code&gt;, not &lt;code&gt;bash&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Match the tool the agent really uses: &lt;code&gt;Edit|Write&lt;/code&gt; for a change hook.&lt;/li&gt;
&lt;li&gt;Do not switch a hook off to make a demo pass. Fix the line that decides when it runs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Not just JavaScript
&lt;/h2&gt;

&lt;p&gt;The same hook contract works in any stack. In a Python repo, use &lt;code&gt;python -m py_compile&lt;/code&gt; instead of &lt;code&gt;node --check&lt;/code&gt;, and &lt;code&gt;ruff&lt;/code&gt; or &lt;code&gt;mypy&lt;/code&gt; instead of a JS linter. The guard reads the same stdin JSON.&lt;/p&gt;

&lt;p&gt;Video with the full run: &lt;a href="https://youtu.be/aR5c3T0jqvc" rel="noopener noreferrer"&gt;https://youtu.be/aR5c3T0jqvc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Techniques from my real projects, shown on a public demo repo.&lt;br&gt;
Narration: AI voice. The sessions, code and errors are real. Not affiliated with Anthropic or any tool vendor.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>agents</category>
      <category>testing</category>
    </item>
    <item>
      <title>Scope gate for subagents: 3 tasks, 1 blocked write</title>
      <dc:creator>Agent Shipped</dc:creator>
      <pubDate>Sun, 15 Nov 2026 15:57:59 +0000</pubDate>
      <link>https://dev.to/agentshipped/scope-gate-for-subagents-3-tasks-1-blocked-write-34pa</link>
      <guid>https://dev.to/agentshipped/scope-gate-for-subagents-3-tasks-1-blocked-write-34pa</guid>
      <description>&lt;p&gt;A PM agent planned three tasks with disjoint file scopes and wrote no code, and a PreToolUse hook blocked the one write I forced outside its scope, after my first version of the hook blocked a legal write.&lt;br&gt;
  &lt;iframe src="https://www.youtube.com/embed/-_t_ZsufwvU" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/agentshipped" rel="noopener noreferrer"&gt;
        agentshipped
      &lt;/a&gt; / &lt;a href="https://github.com/agentshipped/agent-starter" rel="noopener noreferrer"&gt;
        agent-starter
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Agent Shipped demo repo (agent-starter): the public playground used in the channel's videos.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;agent-starter&lt;/h1&gt;

&lt;/div&gt;
&lt;p&gt;A minimal Claude Code project skeleton: &lt;code&gt;CLAUDE.md&lt;/code&gt; with working rules plus a reviewer subagent.
Public demo repo for the &lt;strong&gt;Agent Shipped&lt;/strong&gt; channel; clone it and try the prompts from the videos.&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;CLAUDE.md                 project rules the agent reads on every session
.claude/agents/reviewer.md  read-only reviewer subagent
.claude/settings.json     hook that blocks commits containing obvious secrets
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Shown in&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;Videos on the Agent Shipped channel that use this repo:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/qoobDT2fCYE" rel="nofollow noopener noreferrer"&gt;My subagent stopped halfway. One missing path was why #Shorts&lt;/a&gt; · E007 · 2026-11-07&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/EfsRjxtHwpc" rel="nofollow noopener noreferrer"&gt;My subagent hook read an empty field. Now a bad report exits 2 #Shorts&lt;/a&gt; · E004 · 2026-11-14&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/agentshipped/agent-starter" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;Multi-agent work rarely fails because the agents are dumb. It fails because they collide: two tasks touch the same module and one overwrites the other. This build tries one fix. A PM agent writes only a plan, every task gets a disjoint file scope, and a hook reads the plan on every write.&lt;/p&gt;

&lt;h2&gt;
  
  
  The skeleton
&lt;/h2&gt;

&lt;p&gt;The starting point is &lt;code&gt;agent-starter&lt;/code&gt;, a bare Claude Code skeleton: working rules in &lt;code&gt;CLAUDE.md&lt;/code&gt;, one reviewer subagent, and one hook that blocks commits with obvious secrets. Nothing in it stops two agents from editing the same file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Write the first gate
&lt;/h2&gt;

&lt;p&gt;I asked Claude for the simplest gate on purpose: compare the path to the scope entries exactly as written. Three decisions went into the prompt:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The active task id comes from the env var &lt;code&gt;ACTIVE_TASK&lt;/code&gt;, or else from a file the agent cannot rewrite from inside a scope.&lt;/li&gt;
&lt;li&gt;The hook exits with code 2, which blocks the tool call and sends the reason back to the agent.&lt;/li&gt;
&lt;li&gt;The gate stays off when no task is active, so setup work is not locked out.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The PM is itself a task in the plan, with exactly one writable file: the plan.&lt;/p&gt;

&lt;h2&gt;
  
  
  First failure
&lt;/h2&gt;

&lt;p&gt;I fed the hook a write inside task T0's scope, &lt;code&gt;docs/a.md&lt;/code&gt;, as an absolute path, the way Claude Code sends it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq -n --arg p &lt;span class="s2"&gt;"$PWD/docs/a.md"&lt;/span&gt; &lt;span class="s1"&gt;'{tool_input:{file_path:$p}}'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nv"&gt;ACTIVE_TASK&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;T0 node .claude/hooks/scope-gate.js&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"exit=$?"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The gate blocked it with exit 2. The scope says &lt;code&gt;docs/&lt;/code&gt;, the payload carries the full path from the filesystem root, and a string comparison never matches. Live, this would have blocked every write by every subagent. I would rather find that with a fake payload in a terminal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE008%2Fs03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE008%2Fs03.png" alt="Terminal showing the gate run on an in-scope absolute path and printing exit=2." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Look at the exit code: a legal write to docs/ was blocked by the first gate. · &lt;a href="https://youtu.be/-_t_ZsufwvU?t=94" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Fix the paths
&lt;/h2&gt;

&lt;p&gt;The fix is one idea: normalize before comparing. The prompt asked the hook to resolve &lt;code&gt;tool_input.file_path&lt;/code&gt; against the project dir (&lt;code&gt;CLAUDE_PROJECT_DIR&lt;/code&gt;, falling back to &lt;code&gt;process.cwd()&lt;/code&gt;), make it relative with forward slashes, and treat any result starting with &lt;code&gt;..&lt;/code&gt; as outside scope. Without that last rule, &lt;code&gt;src/../secrets&lt;/code&gt; would slip past a prefix check.&lt;/p&gt;

&lt;p&gt;Five tests pin the behaviour: absolute and relative inputs agree, out-of-scope is blocked, traversal is blocked, and no active task means the gate is off. They write to a temporary log, so they do not pollute the count taken at the end.&lt;/p&gt;
&lt;h2&gt;
  
  
  Prove the gate
&lt;/h2&gt;

&lt;p&gt;Same fake payload, twice. The legal write to &lt;code&gt;docs/&lt;/code&gt; passes with exit 0. A write to &lt;code&gt;src/evil.js&lt;/code&gt; is refused with exit 2, and the message names the task, the path and what is allowed, so the agent can report instead of looping. Then I committed the hook and its tests. When the gate was wrong, I fixed the gate rather than switching it off.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE008%2Fs05.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE008%2Fs05.png" alt="Terminal showing the in-scope write passing and the out-of-scope write refused, followed by a commit." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Two runs of the same payload: one exit code for the legal path, one for src/evil.js. · &lt;a href="https://youtu.be/-_t_ZsufwvU?t=184" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Start the clock
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;: &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .claude/blocked.log&lt;span class="o"&gt;;&lt;/span&gt; date +%s &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .claude/run-start&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; PM &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .claude/active-task
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Emptying the log means every line in it from now on is a real block. The active task is set from the terminal, outside the agent. If the agent could change that file, it could promote itself to another scope.&lt;/p&gt;
&lt;h2&gt;
  
  
  PM writes the plan
&lt;/h2&gt;

&lt;p&gt;The prompt starts: "You are the PM. You write only .claude/plan.json and no code." It asks for three small tasks: T1 a slug helper, T2 a word counter, T3 usage docs. The PM prints an overlap check, so disjointness is shown, not assumed.&lt;/p&gt;
&lt;h2&gt;
  
  
  Review the plan
&lt;/h2&gt;

&lt;p&gt;This is the human checkpoint. The plan is small enough to read in five lines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq -r &lt;span class="s1"&gt;'.tasks[] | .id + ": " + (.scope | join(", "))'&lt;/span&gt; .claude/plan.json&lt;span class="o"&gt;;&lt;/span&gt; git add .claude/plan.json&lt;span class="o"&gt;;&lt;/span&gt; git commit -m &lt;span class="s1"&gt;'PM plan: three disjoint tasks'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; T1 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .claude/active-task
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Committing it before any code exists makes the plan the contract.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE008%2Fs08.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE008%2Fs08.png" alt="Terminal listing each task id with its file scope, then the plan commit." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The whole division of labour in a few lines: check that no file appears twice. · &lt;a href="https://youtu.be/-_t_ZsufwvU?t=289" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Task T1
&lt;/h2&gt;

&lt;p&gt;The main agent hands a self-contained brief to a subagent through the Task tool: what to build, which commands to run, which files it may commit. The brief fixes the hand-back at four lines: result, commit, tests, open items. Both files are inside scope, so the gate stays silent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Switch to T2
&lt;/h2&gt;

&lt;p&gt;The hash in the hand-back should match the top of &lt;code&gt;git log --oneline -3&lt;/code&gt;. Prose can claim anything; a hash exists or it does not. Then &lt;code&gt;echo T2 &amp;gt; .claude/active-task&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Forced violation
&lt;/h2&gt;

&lt;p&gt;The T2 agent builds the word counter, its tests and a commit. Then it is told to also edit the slug file, which belongs to T1. The hook reads the plan, sees task T2 and a path outside its scope, and returns exit 2 with the reason. The edit never happens. The agent is told to report the block under open items rather than look for a back door.&lt;/p&gt;

&lt;h2&gt;
  
  
  Switch to T3
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat .claude/blocked.log&lt;span class="o"&gt;;&lt;/span&gt; git status --short&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; T3 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .claude/active-task
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two signals should agree: the blocked log shows the time, task and path, and &lt;code&gt;git status&lt;/code&gt; shows nothing changed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE008%2Fs12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE008%2Fs12.png" alt="Terminal showing the blocked log entry and the git status output." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The log names the blocked path; git status is the second, independent signal. · &lt;a href="https://youtu.be/-_t_ZsufwvU?t=439" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Task T3
&lt;/h2&gt;

&lt;p&gt;The third subagent reads both modules and writes the usage doc. Examples must come from real &lt;code&gt;node -e&lt;/code&gt; output, not from the model's memory. It commits one file and reports tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure the run
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"elapsed: $(( $(date +%s) - $(cat .claude/run-start) ))s"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"blocked writes: $(wc -l &amp;lt; .claude/blocked.log)"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; git log --oneline -6&lt;span class="o"&gt;;&lt;/span&gt; node --test test/*.test.js 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1 &lt;span class="o"&gt;|&lt;/span&gt; grep -E &lt;span class="s1"&gt;'^# (tests|pass|fail)'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result: three subagent tasks completed in one run, with one deliberate out-of-scope write blocked. The plan is the first commit, then one commit per task. The limit: the gate watches Edit, Write and MultiEdit, not Bash, so a shell redirect could still write anywhere.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE008%2Fs14.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fagentshipped.github.io%2Fvideos%2FE008%2Fs14.png" alt="Terminal showing elapsed time, blocked write count, the commit list and test totals." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The measured numbers: elapsed time, blocked writes, commits, test pass and fail. · &lt;a href="https://youtu.be/-_t_ZsufwvU?t=511" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What to copy
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A plan file with one task per agent and a scope list per task, committed before any code.&lt;/li&gt;
&lt;li&gt;Disjoint scopes, with an overlap check the PM must print.&lt;/li&gt;
&lt;li&gt;An exit-2 PreToolUse hook that prints the task, the path and what is allowed.&lt;/li&gt;
&lt;li&gt;A task id that lives outside the agent's reach, set from the terminal.&lt;/li&gt;
&lt;li&gt;A four-line hand-back (result, commit, tests, open items) checked against git.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Not just JavaScript
&lt;/h2&gt;

&lt;p&gt;Write the gate in Python and test it with pytest instead of &lt;code&gt;node --test&lt;/code&gt;, or enforce the same scope at commit time with a pre-commit hook instead of a PreToolUse hook.&lt;/p&gt;

&lt;p&gt;Video with the full run: &lt;a href="https://youtu.be/-_t_ZsufwvU" rel="noopener noreferrer"&gt;https://youtu.be/-_t_ZsufwvU&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Techniques from my real projects, shown on a public demo repo.&lt;/p&gt;

&lt;p&gt;Narration: AI voice. The sessions, code and errors are real. Not affiliated with Anthropic or any tool vendor.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claudecode</category>
      <category>agents</category>
      <category>testing</category>
    </item>
    <item>
      <title>Two prompts took an untested Express API to a passing suite</title>
      <dc:creator>Agent Shipped</dc:creator>
      <pubDate>Wed, 04 Nov 2026 16:30:47 +0000</pubDate>
      <link>https://dev.to/agentshipped/two-prompts-took-an-untested-express-api-to-a-passing-suite-1eeg</link>
      <guid>https://dev.to/agentshipped/two-prompts-took-an-untested-express-api-to-a-passing-suite-1eeg</guid>
      <description>&lt;p&gt;Two prompts and three manual &lt;code&gt;npm test&lt;/code&gt; runs took an untested Express API from 0 tests to a passing node:test suite, and the source diff review was the check that mattered.&lt;br&gt;
  &lt;iframe src="https://www.youtube.com/embed/lSzonRoE2ok" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/agentshipped" rel="noopener noreferrer"&gt;
        agentshipped
      &lt;/a&gt; / &lt;a href="https://github.com/agentshipped/notes-api" rel="noopener noreferrer"&gt;
        notes-api
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Agent Shipped demo repo (notes-api): the public playground used in the channel's videos.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;notes-api&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;A tiny Express notes API. This is a &lt;strong&gt;public demo repo for the Agent Shipped YouTube channel&lt;/strong&gt;
techniques from real projects are shown here, on code anyone can clone.&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;npm install
npm start          &lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; http://localhost:3000/notes&lt;/span&gt;
npm &lt;span class="pl-c1"&gt;test&lt;/span&gt;           &lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; node:test (no tests yet - that is on purpose)&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Endpoints: &lt;code&gt;GET /health&lt;/code&gt;, &lt;code&gt;GET /notes&lt;/code&gt;, &lt;code&gt;GET /notes/:id&lt;/code&gt;, &lt;code&gt;POST /notes {title, body}&lt;/code&gt;, &lt;code&gt;DELETE /notes/:id&lt;/code&gt;.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Shown in&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Videos on the Agent Shipped channel that use this repo:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/8xQ3gWhe1fQ" rel="nofollow noopener noreferrer"&gt;One git hook blocked a fake GitHub token, so no secret hit history #Shorts&lt;/a&gt; · E002 · 2026-11-02&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/t9Ek80jnkV0" rel="nofollow noopener noreferrer"&gt;Claude Code invented one endpoint shape. A 3-line rule fixed it #Shorts&lt;/a&gt; · E001 · 2026-11-03&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/lSzonRoE2ok" rel="nofollow noopener noreferrer"&gt;I let Claude Code test my Express API, then ran it myself three times&lt;/a&gt; · E003 · 2026-11-08 · &lt;a href="https://dev.to/agentshipped/two-prompts-took-an-untested-express-api-to-a-passing-suite-1eeg" rel="nofollow"&gt;write-up&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/l1spi9ot4FU" rel="nofollow noopener noreferrer"&gt;I don't trust an agent's restart. I trust a counter going up by one #Shorts&lt;/a&gt; · E010…&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/agentshipped/notes-api" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;The demo is notes-api, a small Express notes API. The technique is a prompt that treats the README as the contract, plus a review routine that does not trust a green run on its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  The untested API
&lt;/h2&gt;

&lt;p&gt;The repo has two source files, five endpoints and no tests. The README says so on purpose. &lt;code&gt;package.json&lt;/code&gt; already has a test script, and the Node built-in test runner is available, so there is no framework to install. Fewer moving parts make it easier to tell a bad test from bad code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cat &lt;/span&gt;package.json &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; src/&lt;span class="k"&gt;*&lt;/span&gt;.js &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; git log &lt;span class="nt"&gt;--oneline&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The git log is short, so the final diff shows exactly what the agent touched. The plan is two prompts: the first asks for tests based on the documented behavior, the second makes the agent triage whatever the first run exposes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read the store
&lt;/h2&gt;

&lt;p&gt;Before the agent writes anything, I read &lt;code&gt;src/store.js&lt;/code&gt; myself. It holds the notes and decides how ids are created and what a lookup returns. When a test fails later, I need to tell quickly whether the test or the code is wrong. That is easier to judge now, while nothing is broken.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read the routes
&lt;/h2&gt;

&lt;p&gt;Next is &lt;code&gt;src/index.js&lt;/code&gt;: health, list, get by id, create, delete. Two things to watch.&lt;/p&gt;

&lt;p&gt;First, how the server starts. If the app begins listening as soon as the file loads, a test cannot import it cleanly. The agent may need one small change for that. I allow exactly that and nothing more.&lt;/p&gt;

&lt;p&gt;Second, the validation on create and what happens with an unknown id. The README is the contract: a title and a body go in, a note comes out, and an unknown id should not blow up. The tests must check that, not what the code happens to do today.&lt;/p&gt;

&lt;h2&gt;
  
  
  Baseline run
&lt;/h2&gt;

&lt;p&gt;Record a baseline before the agent touches the repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With no test files the runner has nothing to report. Without this starting point you cannot say later what the agent changed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpdjxzsvbz8p8tnj66jf6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpdjxzsvbz8p8tnj66jf6.png" alt="Terminal showing the output of npm install and npm test on the repo before any test file exists." width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The baseline: the test command works but there are no tests to report yet. · &lt;a href="https://youtu.be/lSzonRoE2ok?t=119" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Prompt one: write tests
&lt;/h2&gt;

&lt;p&gt;The first prompt opens like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Write a test suite for this Express API using only the built-in node:test runner and node:assert, no new dependencies. Put it in test/api.test.js. Base the tests on the contract in README.md, not on what the code currently does.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rest of the prompt covers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;one task: write the tests&lt;/li&gt;
&lt;li&gt;cases that include the unhappy paths, such as an unknown id, because agents like to test only the sunny day&lt;/li&gt;
&lt;li&gt;a rule about state, so tests do not depend on each other&lt;/li&gt;
&lt;li&gt;one narrow permission to make the app importable, and a ban on changing anything else&lt;/li&gt;
&lt;li&gt;an acceptance criterion: run it and show the output&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The agent reads the repo, writes the file and runs it. It checks its own result, and that is the habit worth copying.&lt;/p&gt;

&lt;h2&gt;
  
  
  First honest run
&lt;/h2&gt;

&lt;p&gt;Then I run the suite myself, because the agent's summary can misread its own output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;test &lt;/span&gt;2&amp;gt;&amp;amp;1 | &lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 45
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm7ri4adlf7ijejy2wb0e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm7ri4adlf7ijejy2wb0e.png" alt="Terminal showing the end of the npm test output after the first run, with the runner's summary lines." width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Read the summary lines at the bottom: tests, passes and failures from my own run. · &lt;a href="https://youtu.be/lSzonRoE2ok?t=177" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If anything fails, the question is always the same: is the test wrong or the code? A test that fails because the agent guessed a status code is a bad test. A test that fails because the code breaks its own documented contract is a bug found. Decide whose fault it is before fixing anything.&lt;/p&gt;
&lt;h2&gt;
  
  
  Prompt two: the review rule
&lt;/h2&gt;

&lt;p&gt;The second prompt starts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Run npm test in this repo. For every failing test in test/api.test.js, decide whether the test or the source is wrong by checking it against the contract in README.md. If the source breaks the documented contract, fix the source with the smallest possible change.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It continues with the guardrail I care about most: never weaken, skip or delete a test to get green. Without that sentence, an agent under pressure can make the test easier instead of fixing the code. It is not malice, just the shortest path to a passing run.&lt;/p&gt;

&lt;p&gt;Here the first run was already green, so there was nothing to triage. The rule still earned its place, because the agent has to report what it did not change. It flagged two things: the test script it edited in &lt;code&gt;package.json&lt;/code&gt;, and a README line that is now out of date. I compare that report against the diff. If they disagree, I stop and look closer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Second run
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;test &lt;/span&gt;2&amp;gt;&amp;amp;1 | &lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Green alone proves little, because a green run can hide a test that was quietly made weaker. Compare the totals with the first run: the test count should have grown or stayed the same. A drop means something was deleted, even when nothing fails.&lt;/p&gt;

&lt;h2&gt;
  
  
  Review the diff
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git status &lt;span class="nt"&gt;--short&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; git diff &lt;span class="nt"&gt;--stat&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; git diff &lt;span class="nt"&gt;--&lt;/span&gt; src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The status shows which files are new or changed, the stat shows the size of the change, and the last command shows only the diff in the source folder. That last one I never skip.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe486ayq6e2okm1gqronk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe486ayq6e2okm1gqronk.png" alt="Terminal showing git status, git diff --stat and an empty git diff for the src folder." width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Check the source diff at the end: nothing printed means no source file changed. · &lt;a href="https://youtu.be/lSzonRoE2ok?t=290" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here it is empty. The agent changed no source file, only the test script in &lt;code&gt;package.json&lt;/code&gt;, and the test folder is new and untracked. When the diff is not empty, I read every line: does it match the reported failure, is it the smallest change the README justifies, did anything else sneak in?&lt;/p&gt;

&lt;h2&gt;
  
  
  Final measurement
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff &lt;span class="nt"&gt;--stat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; npm &lt;span class="nb"&gt;test &lt;/span&gt;2&amp;gt;&amp;amp;1 | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"(tests|pass|fail|duration_ms) [0-9]"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The filter reads straight from the runner: the number of tests, passes, failures and the duration of the whole suite.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0ado23fgxb90z4b8mbb9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0ado23fgxb90z4b8mbb9.png" alt="Terminal showing the git diff stat and the filtered npm test lines with tests, pass, fail and duration_ms." width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The final numbers read straight from the runner: tests, pass, fail, duration_ms. · &lt;a href="https://youtu.be/lSzonRoE2ok?t=334" rel="noopener noreferrer"&gt;watch this step&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The measured result: 2 prompts and 3 manual &lt;code&gt;npm test&lt;/code&gt; runs took notes-api from 0 tests to a passing node:test suite.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to copy
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Write the prompt against the written contract (the README), not against the current code.&lt;/li&gt;
&lt;li&gt;Put the acceptance command inside the prompt, and name the runner so no dependency sneaks in.&lt;/li&gt;
&lt;li&gt;Run the tests yourself and compare the totals between runs.&lt;/li&gt;
&lt;li&gt;Forbid weakening, skipping or deleting tests, and ask the agent to report what it did not change.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;git diff -- src&lt;/code&gt; and read it line by line. The judgment about whose bug it is stays with you.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Not just JavaScript
&lt;/h2&gt;

&lt;p&gt;The same technique works on other stacks: pytest instead of &lt;code&gt;node --test&lt;/code&gt;, or &lt;code&gt;go test&lt;/code&gt; with Go's testing package. Both are driven by the written contract and a no-weakening rule.&lt;/p&gt;

&lt;p&gt;Video with the full run: &lt;a href="https://youtu.be/lSzonRoE2ok" rel="noopener noreferrer"&gt;https://youtu.be/lSzonRoE2ok&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Techniques from my real projects, shown on a public demo repo.&lt;br&gt;
Narration: AI voice. The sessions, code and errors are real. Not affiliated with Anthropic or any tool vendor.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claudecode</category>
      <category>testing</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
