<?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: Scott Havird</title>
    <description>The latest articles on DEV Community by Scott Havird (@scotthavird).</description>
    <link>https://dev.to/scotthavird</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%2F332551%2F93b9e468-db31-44ca-ae57-e692e27ea832.jpg</url>
      <title>DEV Community: Scott Havird</title>
      <link>https://dev.to/scotthavird</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/scotthavird"/>
    <language>en</language>
    <item>
      <title>Lysosome Disk Cleaner</title>
      <dc:creator>Scott Havird</dc:creator>
      <pubDate>Sat, 28 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/scotthavird/lysosome-disk-cleaner-3fgf</link>
      <guid>https://dev.to/scotthavird/lysosome-disk-cleaner-3fgf</guid>
      <description>&lt;p&gt;My laptop filled up again. Cursor and Claude Code had left git worktrees on disk, with &lt;code&gt;node_modules&lt;/code&gt; and &lt;code&gt;target&lt;/code&gt; folders still in them. I wrote &lt;a href="https://github.com/lysosome-dev/cli" rel="noopener noreferrer"&gt;lysosome&lt;/a&gt; to list those and delete the safe ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;The branch gets merged. The worktree stays, dependencies and all. Ollama, Hugging Face, and LM Studio do the same thing with model weights.&lt;/p&gt;

&lt;p&gt;I didn't want another afternoon of &lt;code&gt;du&lt;/code&gt;, or a script that runs &lt;code&gt;rm&lt;/code&gt; and hopes.&lt;/p&gt;

&lt;p&gt;Teams running many agents hit the same leftover worktrees and caches.&lt;/p&gt;

&lt;h2&gt;
  
  
  What
&lt;/h2&gt;

&lt;p&gt;lysosome is a Rust CLI, MIT licensed. The README calls it "The disk cleaner for the agentic coding era."&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lysosome scan       &lt;span class="c"&gt;# artifacts, worktrees, caches&lt;/span&gt;
lysosome worktrees
lysosome caches     &lt;span class="c"&gt;# alias: system&lt;/span&gt;
lysosome clean      &lt;span class="c"&gt;# dry run unless --yes, or you answer y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;scan&lt;/code&gt; labels every row.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;REMOVABLE&lt;/code&gt;: idle and clean. The commits are merged into the default branch, fully pushed, or &lt;code&gt;gh&lt;/code&gt; reports an exact HEAD squash-merge.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;REVIEW&lt;/code&gt;: uncommitted changes, untracked files, a lock, or commits that exist nowhere else.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ORPHAN&lt;/code&gt;: the parent repo was moved or deleted.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ACTIVE&lt;/code&gt;: hidden unless you pass &lt;code&gt;--all&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Build folders count only if &lt;code&gt;git check-ignore&lt;/code&gt; agrees. Symlinks are never followed. Default staleness is &lt;code&gt;--days 30&lt;/code&gt; per project.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;node_modules&lt;/code&gt;, &lt;code&gt;.venv&lt;/code&gt;, &lt;code&gt;venv&lt;/code&gt;, and &lt;code&gt;Pods&lt;/code&gt; are &lt;code&gt;regenerable_expensive&lt;/code&gt;. Other ignored build output is &lt;code&gt;regenerable&lt;/code&gt;: &lt;code&gt;target&lt;/code&gt;, &lt;code&gt;.next&lt;/code&gt;, &lt;code&gt;.nuxt&lt;/code&gt;, &lt;code&gt;.svelte-kit&lt;/code&gt;, &lt;code&gt;.turbo&lt;/code&gt;, &lt;code&gt;dist&lt;/code&gt;, &lt;code&gt;build&lt;/code&gt;, &lt;code&gt;.gradle&lt;/code&gt;, &lt;code&gt;.dart_tool&lt;/code&gt;, &lt;code&gt;.build&lt;/code&gt;, &lt;code&gt;coverage&lt;/code&gt;, &lt;code&gt;.parcel-cache&lt;/code&gt;, &lt;code&gt;.expo&lt;/code&gt;, &lt;code&gt;DerivedData&lt;/code&gt;. &lt;code&gt;clean&lt;/code&gt; removes &lt;code&gt;regenerable&lt;/code&gt; only, unless you pass &lt;code&gt;--tier regenerable_expensive&lt;/code&gt;. That adds dependencies, models, Docker images, and simulators. The &lt;code&gt;review&lt;/code&gt; tier is never cleaned.&lt;/p&gt;

&lt;p&gt;The shots below are a demo. I generated a folder of sample clutter on a Linux test box and pointed lysosome v0.3.0 at it. Not my laptop. Nothing was deleted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmt3rzlx1q74pgphir4wp.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmt3rzlx1q74pgphir4wp.webp" alt="Demo run of lysosome scan against a folder of sample clutter, not my actual laptop" width="800" height="819"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Demo run against a folder of sample clutter, not my actual laptop.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxuixz4jqnpwvvf8rfigq.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxuixz4jqnpwvvf8rfigq.webp" alt="Demo run of lysosome worktrees --all against a folder of sample clutter, not my actual laptop" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Demo run against a folder of sample clutter, not my actual laptop. Passing --all includes the active worktree.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How
&lt;/h2&gt;

&lt;p&gt;Scans do not write. Git is invoked with &lt;code&gt;--no-optional-locks&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Removable worktrees are removed with git, then pruned. The branch is kept. &lt;code&gt;git worktree remove&lt;/code&gt; is called without &lt;code&gt;--force&lt;/code&gt;. &lt;code&gt;REVIEW&lt;/code&gt;, &lt;code&gt;ACTIVE&lt;/code&gt;, and &lt;code&gt;ORPHAN&lt;/code&gt; are never cleaned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git &lt;span class="nt"&gt;-C&lt;/span&gt; &amp;lt;repo&amp;gt; worktree remove &amp;lt;path&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;.env&lt;/code&gt; and other precious ignored files are moved to the Trash before that remove. The home folder is never deleted.&lt;/p&gt;

&lt;p&gt;The default is Trash (macOS Trash, freedesktop trash on Linux). &lt;code&gt;--permanent&lt;/code&gt; has to be paired with &lt;code&gt;--yes&lt;/code&gt;. lysosome checks the target again right before it deletes, and skips the row if anything changed.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;lysosome clean -i&lt;/code&gt; walks the list. On macOS the log is &lt;code&gt;~/Library/Logs/lysosome/actions.log&lt;/code&gt;. &lt;code&gt;--json&lt;/code&gt; prints a versioned schema. It does not send telemetry.&lt;/p&gt;

&lt;p&gt;Squash-merge lookups use &lt;code&gt;gh&lt;/code&gt;, and only if it is installed and you are signed in. &lt;code&gt;--no-gh&lt;/code&gt; or &lt;code&gt;--offline&lt;/code&gt; skips that call.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;lysosome caches&lt;/code&gt; reports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Package caches: npm, pnpm, yarn, bun, pip, uv, conda, cargo, go, gradle, maven, Homebrew, CocoaPods.&lt;/li&gt;
&lt;li&gt;Models: Ollama by name, Hugging Face hub, LM Studio, &lt;code&gt;~/.cache/torch&lt;/code&gt;, whisper.&lt;/li&gt;
&lt;li&gt;Docker images, build cache, and volumes. OrbStack stays in review.&lt;/li&gt;
&lt;li&gt;Xcode DerivedData, iOS DeviceSupport, simulators, Archives.&lt;/li&gt;
&lt;li&gt;Android AVDs and SDK images.&lt;/li&gt;
&lt;li&gt;VS Code, Cursor, and JetBrains caches.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;lysosome caches&lt;/code&gt; on that same demo folder. Each row names the tool's own cleanup command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkbu5eyyxdad6tuy596ll.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkbu5eyyxdad6tuy596ll.webp" alt="Demo run of lysosome caches against a folder of sample clutter, not my actual laptop" width="800" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Same demo folder, not my laptop.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Found a Bug
&lt;/h2&gt;

&lt;p&gt;Unfortunately v0.3.0 under-counts sizes on overlay filesystems. That is what Docker and containers use. Regular files report a different &lt;code&gt;st_dev&lt;/code&gt; than their folders, and the same-filesystem check skipped every file.&lt;/p&gt;

&lt;p&gt;A 20 MB file in an ignored &lt;code&gt;node_modules&lt;/code&gt; showed as 4.1 KB. The demo clutter showed 3.3 MB instead of 3.8 GB. I filed &lt;a href="https://github.com/lysosome-dev/cli/issues/36" rel="noopener noreferrer"&gt;issue #36&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/lysosome-dev/cli/pull/37" rel="noopener noreferrer"&gt;PR #37&lt;/a&gt; only applies the device check to directories. On a real overlay filesystem the fixed build matches &lt;code&gt;du&lt;/code&gt; byte for byte, and it still skips a separately mounted filesystem inside a folder. The PR is open. It is not in a release yet.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbiuzy8t8hcmm5svlgmmd.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbiuzy8t8hcmm5svlgmmd.webp" alt="v0.3.0 scan of a 20 MB node_modules on overlayfs, reported as 4.1 KB" width="800" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;v0.3.0 on the repro. The 20 MB file showed as 4.1 KB.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F49ixw46kv3z6uqpa6tj7.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F49ixw46kv3z6uqpa6tj7.webp" alt="PR #37 build of the same overlayfs repro, reported as 21.0 MB. Not in a release yet." width="800" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Same repro, PR #37 build. It shows 21.0 MB. Not released yet.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The demo shots above are from an ext4 disk image, where this bug does not show up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;macOS (Apple silicon and Intel) and Linux (x86_64 and arm64). &lt;code&gt;git&lt;/code&gt; needs to be on your &lt;code&gt;PATH&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;lysosome-dev/tap/lysosome
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://lysosome.dev/install.sh | sh
cargo &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--locked&lt;/span&gt; lysosome   &lt;span class="c"&gt;# Rust 1.85+&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When I wrote this, &lt;code&gt;lysosome --version&lt;/code&gt; was v0.3.0, published October 10, 2026.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn88ri7c45vrsc3fayj4k.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn88ri7c45vrsc3fayj4k.webp" alt="lysosome --help on v0.3.0" width="800" height="724"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Help from v0.3.0. This is the real command, not the demo folder.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  One Long Day
&lt;/h2&gt;

&lt;p&gt;The GitHub repo went up October 10, 2026, around 03:01 UTC. I did not ship the milestones in number order.&lt;/p&gt;

&lt;p&gt;The worktree scanner landed first (&lt;a href="https://github.com/lysosome-dev/cli/pull/2" rel="noopener noreferrer"&gt;PR #2&lt;/a&gt;, 03:49). Distribution came next, before the rest of the scanner existed: cargo-dist, the install script, Homebrew, and shell completions (&lt;a href="https://github.com/lysosome-dev/cli/pull/6" rel="noopener noreferrer"&gt;PR #6&lt;/a&gt;, 04:52). v0.1.0 went out at 04:56. That release is the worktree scanner and the installers.&lt;/p&gt;

&lt;p&gt;Caches merged before project artifacts. &lt;a href="https://github.com/lysosome-dev/cli/pull/8" rel="noopener noreferrer"&gt;PR #8&lt;/a&gt; at 05:11, then &lt;a href="https://github.com/lysosome-dev/cli/pull/7" rel="noopener noreferrer"&gt;PR #7&lt;/a&gt; (&lt;code&gt;lysosome scan&lt;/code&gt;) at 05:29. I had opened #7 a minute before #8. &lt;a href="https://github.com/lysosome-dev/cli/pull/11" rel="noopener noreferrer"&gt;PR #11&lt;/a&gt; at 05:43 made &lt;code&gt;scan&lt;/code&gt; include the caches.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;lysosome clean&lt;/code&gt; landed at 06:34 (&lt;a href="https://github.com/lysosome-dev/cli/pull/12" rel="noopener noreferrer"&gt;PR #12&lt;/a&gt;). v0.2.0 at 06:39. v0.2.1 at 07:21 stopped a scan from running corepack shims (&lt;a href="https://github.com/lysosome-dev/cli/pull/14" rel="noopener noreferrer"&gt;PR #14&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The afternoon was smaller. Interactive clean, crates.io publishing, squash-merge checks through &lt;code&gt;gh&lt;/code&gt;, parallel sizing, JSON errors, brand colors. &lt;a href="https://github.com/lysosome-dev/cli/pull/31" rel="noopener noreferrer"&gt;PR #31&lt;/a&gt; cut the release. v0.3.0 was published at 16:49.&lt;/p&gt;

&lt;h2&gt;
  
  
  Future Ideas
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A Mac app on the same engine. There is a waitlist at &lt;a href="https://lysosome.dev" rel="noopener noreferrer"&gt;lysosome.dev&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Lysosome lists dormant worktrees, idle build folders, dev caches, and local models. It leaves &lt;code&gt;REVIEW&lt;/code&gt;, &lt;code&gt;ACTIVE&lt;/code&gt;, and &lt;code&gt;ORPHAN&lt;/code&gt; rows alone. &lt;code&gt;clean&lt;/code&gt; waits for a confirmation, and removals go to the Trash.&lt;/p&gt;

&lt;p&gt;The pictures above are that demo folder. Run &lt;code&gt;lysosome scan&lt;/code&gt; on your own machine to see what it finds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Source Code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;CLI: &lt;a href="https://github.com/lysosome-dev/cli" rel="noopener noreferrer"&gt;github.com/lysosome-dev/cli&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Site: &lt;a href="https://lysosome.dev" rel="noopener noreferrer"&gt;lysosome.dev&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Crate: &lt;a href="https://crates.io/crates/lysosome" rel="noopener noreferrer"&gt;crates.io/crates/lysosome&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article was created with the help of AI.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://scotthavird.com/blog/lysosome-disk-cleaner-agents/" rel="noopener noreferrer"&gt;scotthavird.com&lt;/a&gt;. Follow me on &lt;a href="https://x.com/scotthavird" rel="noopener noreferrer"&gt;X&lt;/a&gt; and &lt;a href="https://github.com/scotthavird" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>cli</category>
      <category>git</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Kiro by the numbers: 104 CLI releases | Havoptic</title>
      <dc:creator>Scott Havird</dc:creator>
      <pubDate>Sat, 28 Nov 2026 13:31:00 +0000</pubDate>
      <link>https://dev.to/scotthavird/kiro-by-the-numbers-104-cli-releases-havoptic-5d7c</link>
      <guid>https://dev.to/scotthavird/kiro-by-the-numbers-104-cli-releases-havoptic-5d7c</guid>
      <description>&lt;p&gt;As of November 27, 2026, the latest Kiro CLI version is &lt;strong&gt;3.6.2&lt;/strong&gt;, released November 25. Havoptic's release record holds 104 Kiro CLI releases from 1.20.0 (November 17, 2025) to 3.6.2. They carry 93 different dates, a median of 3 days apart, and October 2026 was the busiest month with 20.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kiro CLI by the numbers
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measure&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Releases in Havoptic's record&lt;/td&gt;
&lt;td&gt;104&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Earliest and latest version&lt;/td&gt;
&lt;td&gt;1.20.0 (Nov 17, 2025) and 3.6.2 (Nov 25, 2026)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Days between those two releases&lt;/td&gt;
&lt;td&gt;373&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Different release dates&lt;/td&gt;
&lt;td&gt;93&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Median gap between release dates&lt;/td&gt;
&lt;td&gt;3 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Longest gap&lt;/td&gt;
&lt;td&gt;24 days (Dec 23, 2025 to Jan 16, 2026)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;x.y.0 releases / patch releases&lt;/td&gt;
&lt;td&gt;54 / 50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Releases dated Oct 29 to Nov 27, 2026 (30 days)&lt;/td&gt;
&lt;td&gt;13, on 12 dates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Releases dated on a weekend&lt;/td&gt;
&lt;td&gt;3 on Saturdays, none on Sundays&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Latest Kiro CLI releases (3.x)
&lt;/h2&gt;

&lt;p&gt;Ten releases shipped between November 3 and November 25. The middle column is a short summary of the release notes Havoptic captured from Kiro.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;What changed&lt;/th&gt;
&lt;th&gt;Date (2026)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;3.6.2&lt;/td&gt;
&lt;td&gt;Turn on Approve for me from a permission prompt; V3 headless runs move closer to V2&lt;/td&gt;
&lt;td&gt;Nov 25&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.6.1&lt;/td&gt;
&lt;td&gt;MCP servers whose identity provider allows only the /oauth/callback redirect path now complete sign-in; you may need to sign in to some MCP servers once more&lt;/td&gt;
&lt;td&gt;Nov 25&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.6.0&lt;/td&gt;
&lt;td&gt;SubagentStop hooks, full saved hook output, instructions for /compact summaries&lt;/td&gt;
&lt;td&gt;Nov 23&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.5.0&lt;/td&gt;
&lt;td&gt;Organization sign-in for MCP servers in V3 sessions; configurable portal for kiro-cli login&lt;/td&gt;
&lt;td&gt;Nov 17&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.4.0&lt;/td&gt;
&lt;td&gt;Hooks can rewrite a tool call's inputs before it runs, or answer its permission prompt, in V3 sessions&lt;/td&gt;
&lt;td&gt;Nov 16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.3.0&lt;/td&gt;
&lt;td&gt;/copy N and /copy last N; you choose the context usage at which automatic compaction starts&lt;/td&gt;
&lt;td&gt;Nov 12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.2.1&lt;/td&gt;
&lt;td&gt;Output details and sign-in fixes&lt;/td&gt;
&lt;td&gt;Nov 11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.2.0&lt;/td&gt;
&lt;td&gt;Output details setting for everyone; fixes sign-in on Linux hosts with no graphical session and with Identity Center flags&lt;/td&gt;
&lt;td&gt;Nov 10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.1.0&lt;/td&gt;
&lt;td&gt;PreCompact and PostCompact hooks; session credits in /usage&lt;/td&gt;
&lt;td&gt;Nov 5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.0.0&lt;/td&gt;
&lt;td&gt;V3 becomes the default agent harness for interactive sessions on hosts that can run it&lt;/td&gt;
&lt;td&gt;Nov 3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Kiro publishes its own notes in the &lt;a href="https://kiro.dev/changelog/cli/?utm_source=blog&amp;amp;utm_medium=content&amp;amp;utm_campaign=blog-havoptic-20261127-3" rel="noopener noreferrer"&gt;Kiro CLI changelog&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kiro CLI releases by month
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Month&lt;/th&gt;
&lt;th&gt;Releases&lt;/th&gt;
&lt;th&gt;x.y.0&lt;/th&gt;
&lt;th&gt;Patches&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Nov 2025 (from Nov 17)&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dec 2025&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jan 2026&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Feb 2026&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mar 2026&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apr 2026&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;May 2026&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jun 2026&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jul 2026&lt;/td&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Aug 2026&lt;/td&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sep 2026&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Oct 2026&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nov 2026 (through Nov 25)&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The pace changed in mid-2026: 77 of the 104 releases are dated June 1 or later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Releases by major version
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Major version&lt;/th&gt;
&lt;th&gt;Releases&lt;/th&gt;
&lt;th&gt;x.y.0&lt;/th&gt;
&lt;th&gt;Patches&lt;/th&gt;
&lt;th&gt;First&lt;/th&gt;
&lt;th&gt;Last&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1.x (from 1.20.0)&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;1.20.0, Nov 17, 2025&lt;/td&gt;
&lt;td&gt;1.28.3, Mar 28, 2026&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2.x&lt;/td&gt;
&lt;td&gt;78&lt;/td&gt;
&lt;td&gt;38&lt;/td&gt;
&lt;td&gt;40&lt;/td&gt;
&lt;td&gt;2.0.0, Apr 13, 2026&lt;/td&gt;
&lt;td&gt;2.37.1, Oct 31, 2026&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.x (so far)&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;3.0.0, Nov 3, 2026&lt;/td&gt;
&lt;td&gt;3.6.2, Nov 25, 2026&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;No minor version has more than four releases in this record. Three have four: 1.28, 2.12 and 2.21.&lt;/p&gt;

&lt;h2&gt;
  
  
  From 2.0 to 3.0
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;April 13, 2026: &lt;a href="https://kiro.dev/changelog/cli/2-0/?utm_source=blog&amp;amp;utm_medium=content&amp;amp;utm_campaign=blog-havoptic-20261127-3" rel="noopener noreferrer"&gt;2.0.0&lt;/a&gt; added native Windows 11 support and headless mode, and made the terminal UI the default.&lt;/li&gt;
&lt;li&gt;June 17, 2026: &lt;a href="https://kiro.dev/changelog/cli/2-8/?utm_source=blog&amp;amp;utm_medium=content&amp;amp;utm_campaign=blog-havoptic-20261127-3" rel="noopener noreferrer"&gt;2.8.0&lt;/a&gt; opened an early access preview of V3, opt-in with &lt;code&gt;kiro-cli --v3&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;November 3, 2026: &lt;a href="https://kiro.dev/changelog/cli/3-0/?utm_source=blog&amp;amp;utm_medium=content&amp;amp;utm_campaign=blog-havoptic-20261127-3" rel="noopener noreferrer"&gt;3.0.0&lt;/a&gt; made V3 the default for interactive sessions on hosts that can run it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3.0.0 came 139 days after the V3 preview opened, and 3.0.0 arrived 204 days after 2.0.0. Kiro kept shipping 2.x in between: 62 releases are dated June 17 through October 31, counting 2.8.0 and 2.8.1.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you update from 2.x
&lt;/h2&gt;

&lt;p&gt;Kiro's 3.0.0 notes list these changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;V3 is the default agent harness for interactive sessions on hosts that can run it, so you no longer need &lt;code&gt;--v3&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Existing V2 users are asked before the default applies.&lt;/li&gt;
&lt;li&gt;Custom agents still in the V2 format are upgraded unless you turn that off.&lt;/li&gt;
&lt;li&gt;Kiro CLI is now a single standalone &lt;code&gt;kiro-cli&lt;/code&gt; binary. The Classic interface, the desktop app and inline autocomplete are retired.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How these numbers are counted
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Havoptic reads Kiro's CLI changelog pages, checking the first index page every hour. Each version number counts as one release, patches included.&lt;/li&gt;
&lt;li&gt;A check on November 27 compared the 104 records with Kiro's changelog: no version was missing or extra, and no calendar date differed.&lt;/li&gt;
&lt;li&gt;"x.y.0" means the third version number is zero. "Patch" means it is above zero. These are Havoptic's groupings.&lt;/li&gt;
&lt;li&gt;The counts cover Kiro CLI only, not the Kiro IDE or Kiro Web.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://havoptic.com/blog/kiro-numbers-2026-11?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=blog-havoptic-20261127-3" rel="noopener noreferrer"&gt;havoptic.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cli</category>
      <category>software</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>What's new in PromptConduit 2026-11 — PromptConduit</title>
      <dc:creator>Scott Havird</dc:creator>
      <pubDate>Sat, 28 Nov 2026 13:30:57 +0000</pubDate>
      <link>https://dev.to/scotthavird/whats-new-in-promptconduit-2026-11-promptconduit-35o</link>
      <guid>https://dev.to/scotthavird/whats-new-in-promptconduit-2026-11-promptconduit-35o</guid>
      <description>&lt;h1&gt;
  
  
  What's new in PromptConduit 2026-11
&lt;/h1&gt;

&lt;p&gt;As of November 27, 2026, PromptConduit's November changelog has 11 releases, 0.33.0 to 0.38.2, with 51 changes. The main ones: a remote MCP server and an OpenAPI 3.1 description for agents, session cost that now counts workflow agents, batched event uploads, and corrected model rates.&lt;/p&gt;

&lt;p&gt;If you run the CLI, upgrade first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;promptconduit upgrade --check
promptconduit upgrade
promptconduit version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  November releases at a glance
&lt;/h2&gt;

&lt;p&gt;The release numbers are the ones on the &lt;a href="https://promptconduit.dev/changelog" rel="noopener noreferrer"&gt;changelog&lt;/a&gt; and do not always match CLI versions, which are written here as "CLI v0.x".&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Release&lt;/th&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Headline&lt;/th&gt;
&lt;th&gt;New&lt;/th&gt;
&lt;th&gt;Improved&lt;/th&gt;
&lt;th&gt;Fixed&lt;/th&gt;
&lt;th&gt;Removed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0.38.2&lt;/td&gt;
&lt;td&gt;Nov 22&lt;/td&gt;
&lt;td&gt;Privacy-first analytics, with a consent choice in Europe&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.38.1&lt;/td&gt;
&lt;td&gt;Nov 22&lt;/td&gt;
&lt;td&gt;Expired sessions sign you out cleanly&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.38.0&lt;/td&gt;
&lt;td&gt;Nov 21&lt;/td&gt;
&lt;td&gt;Team data for AI agents: remote MCP server and OpenAPI&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.37.0&lt;/td&gt;
&lt;td&gt;Nov 14&lt;/td&gt;
&lt;td&gt;Batched uploads and faster spend views&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.36.1&lt;/td&gt;
&lt;td&gt;Nov 13&lt;/td&gt;
&lt;td&gt;A reliable overview, and subagent spend that adds up&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.36.0&lt;/td&gt;
&lt;td&gt;Nov 8&lt;/td&gt;
&lt;td&gt;Your spend, your team's spend&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.35.1&lt;/td&gt;
&lt;td&gt;Nov 8&lt;/td&gt;
&lt;td&gt;Trial reminders&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.35.0&lt;/td&gt;
&lt;td&gt;Nov 5&lt;/td&gt;
&lt;td&gt;Pending invites and honest totals&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.34.1&lt;/td&gt;
&lt;td&gt;Nov 5&lt;/td&gt;
&lt;td&gt;Team billing and invite fixes&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.34.0&lt;/td&gt;
&lt;td&gt;Nov 3&lt;/td&gt;
&lt;td&gt;Claude Code and Cursor first, other tools experimental&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.33.0&lt;/td&gt;
&lt;td&gt;Nov 1&lt;/td&gt;
&lt;td&gt;Skills from your agent&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Total&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;51 changes&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;13&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;21&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;16&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Session cost now counts workflow agents
&lt;/h2&gt;

&lt;p&gt;CLI v0.36.1 fixed an undercount. &lt;code&gt;promptconduit cost&lt;/code&gt; and the &lt;code&gt;session_cost&lt;/code&gt; MCP tool now count workflow agents, which run in a folder the CLI never looked in. A session that runs many agents could have shown a fraction of its real spend.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;promptconduit cost
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also in that release:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Subagent and workflow-agent transcripts sync automatically with their session. Before, only a manual &lt;code&gt;promptconduit sync&lt;/code&gt; uploaded them.&lt;/li&gt;
&lt;li&gt;Session cost shows when a session was last active, not when its last subagent finished.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For why subagent spend is worth watching, see &lt;a href="https://promptconduit.dev/blog/what-a-month-of-claude-code-costs" rel="noopener noreferrer"&gt;what a month of Claude Code costs&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read team spend from a remote MCP server
&lt;/h2&gt;

&lt;p&gt;Release 0.38.0 lets agents read your team's data without the CLI, from &lt;code&gt;https://api.promptconduit.dev/mcp&lt;/code&gt; (Streamable HTTP). In Claude Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add --transport http promptconduit-team https://api.promptconduit.dev/mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run &lt;code&gt;/mcp&lt;/code&gt; inside Claude Code and sign in through the browser with Google or GitHub. A first sign-in creates a free account. The name &lt;code&gt;promptconduit-team&lt;/code&gt; keeps it apart from the CLI's local server, which registers as &lt;code&gt;promptconduit&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;th&gt;Scope&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;team_list&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Your teams and your role in each&lt;/td&gt;
&lt;td&gt;&lt;code&gt;team:read&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;team_spend&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Spend over 7d, 30d or 90d by member, repo, client, model and pull request&lt;/td&gt;
&lt;td&gt;&lt;code&gt;team:read&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;team_members&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Members and roles&lt;/td&gt;
&lt;td&gt;&lt;code&gt;team:read&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;team_budgets&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Monthly budgets with current usage&lt;/td&gt;
&lt;td&gt;&lt;code&gt;team:read&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;team_savings&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Estimated savings over 7d, 30d or 90d&lt;/td&gt;
&lt;td&gt;&lt;code&gt;team:read&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;team_billing&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Plan, subscription status, member cap and usage&lt;/td&gt;
&lt;td&gt;&lt;code&gt;team:read&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;team_billing_checkout&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Returns a Stripe Checkout link for the Team or Growth plan&lt;/td&gt;
&lt;td&gt;&lt;code&gt;team:billing&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The first six are read-only. The checkout tool works only for team owners and admins. The call charges nothing: you review and pay on Stripe's page, and the agent never sees card details. A client that requests no recognized scope gets &lt;code&gt;team:read&lt;/code&gt; only.&lt;/p&gt;

&lt;p&gt;To check the endpoint before connecting anything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -si -X POST https://api.promptconduit.dev/mcp &lt;span class="o"&gt;|&lt;/span&gt; grep -i -E &lt;span class="s1"&gt;'^(HTTP|www-authenticate)'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On November 27 this returned &lt;code&gt;401&lt;/code&gt; with a &lt;code&gt;www-authenticate&lt;/code&gt; header that points to the OAuth resource metadata and lists both scopes. That is the expected answer without a token.&lt;/p&gt;

&lt;p&gt;The REST API also has an OpenAPI 3.1 description. This lists its operations (12 on 11 paths on November 27):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s https://api.promptconduit.dev/openapi.json \
  &lt;span class="o"&gt;|&lt;/span&gt; jq -r &lt;span class="s1"&gt;'.paths | to_entries[] | .key as $path | .value | keys[] | "\(ascii_upcase) \($path)"'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Setup for the local and remote servers is in the &lt;a href="https://promptconduit.dev/docs/agents" rel="noopener noreferrer"&gt;agent docs&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Model rates that changed
&lt;/h2&gt;

&lt;p&gt;Prices are USD per million tokens.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model ID&lt;/th&gt;
&lt;th&gt;Priced before&lt;/th&gt;
&lt;th&gt;Priced now&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Claude Sonnet 5.5, cache read&lt;/td&gt;
&lt;td&gt;$0.20&lt;/td&gt;
&lt;td&gt;$0.10 (0.05× input)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;claude-opus-5-5-fast&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$4 input, $20 output&lt;/td&gt;
&lt;td&gt;$8 input, $40 output, $0.40 cache read&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;claude-opus-4-7-fast&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$5 input, $25 output&lt;/td&gt;
&lt;td&gt;$30 input, $150 output, $3 cache read&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;gpt-5-fast&lt;/code&gt; (including low, medium and high)&lt;/td&gt;
&lt;td&gt;$1.25 input, $10 output&lt;/td&gt;
&lt;td&gt;$2.50 input, $20 output, $0.25 cache read&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Sonnet 5.5 sessions no longer read high. The three Cursor fast-mode rows are now priced at fast-mode rates. Installed CLIs pick up the rate card automatically unless auto-update is off. To download it now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;promptconduit cost refresh-card
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;November also added rates for more models in Cursor's picker, including GPT-5.4 Mini and Nano, GPT-5.2, Gemini 4 Argon, GLM 5.3 and DeepSeek V4.1 Flash. The full list of prices is on &lt;a href="https://promptconduit.dev/model-rates" rel="noopener noreferrer"&gt;model rates&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Since 0.35.0, requests on models without a published price are counted and named next to your spend totals. Those totals are marked as a lower bound, and the requests are no longer silently counted as $0.&lt;/p&gt;

&lt;h2&gt;
  
  
  Batched uploads, retention and the overview
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The CLI batches events, up to 100 per request, and sends them within a few seconds, or right away when a turn ends.&lt;/li&gt;
&lt;li&gt;Team and personal spend, budgets, the savings report, CSV export and digests read pre-computed daily totals, so they no longer slow down with more history.&lt;/li&gt;
&lt;li&gt;Detailed per-event activity is kept for 90 days. Spend totals are kept for good, so cost history, budgets and exports are unaffected.&lt;/li&gt;
&lt;li&gt;Events re-sent more than 90 days after capture are accepted but not counted toward spend.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To turn batching off:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;promptconduit config &lt;span class="nb"&gt;set&lt;/span&gt; --batch-upload=false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you post events yourself, &lt;code&gt;POST /v1/events/raw/batch&lt;/code&gt; takes up to 100 events and 1 MB per request. See the &lt;a href="https://promptconduit.dev/docs/api-reference" rel="noopener noreferrer"&gt;API reference&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;November 13 also fixed an overview that could come up empty, with blank Sessions, Prompts and Active days tiles, for people with a lot of history. If it can't load for a moment, it now retries and then offers a Retry button.&lt;/p&gt;

&lt;h2&gt;
  
  
  Team invites, trials and billing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Admins can see, resend and revoke pending invites, and invites arrive by email.&lt;/li&gt;
&lt;li&gt;Only owners can invite people as owner or admin.&lt;/li&gt;
&lt;li&gt;You can re-invite someone you removed, or resend an expired invite.&lt;/li&gt;
&lt;li&gt;Each team gets one 14-day free trial. A trial that ends without a card drops back to the free plan.&lt;/li&gt;
&lt;li&gt;Owners and admins get an email three days before a trial ends, and the app shows a banner in the last week.&lt;/li&gt;
&lt;li&gt;The retired personal Pro plan can no longer be bought. Existing subscribers keep access.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Current plans are on &lt;a href="https://promptconduit.dev/pricing" rel="noopener noreferrer"&gt;pricing&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tools, skills and sign-in
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Supported tools (CLI v0.33.0):&lt;/strong&gt; Claude Code and Cursor are the supported pair. Gemini CLI, Codex, Copilot and Grok Build need &lt;code&gt;--experimental&lt;/code&gt;, for example &lt;code&gt;promptconduit install codex --experimental&lt;/code&gt;. Hooks you already installed keep working.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skills over MCP (CLI v0.32.0):&lt;/strong&gt; seven tools (&lt;code&gt;skills_list&lt;/code&gt;, &lt;code&gt;skills_patterns&lt;/code&gt;, &lt;code&gt;skills_generate&lt;/code&gt;, &lt;code&gt;skills_approve&lt;/code&gt;, &lt;code&gt;skills_reject&lt;/code&gt;, &lt;code&gt;skills_install&lt;/code&gt;, &lt;code&gt;skills_delete&lt;/code&gt;) plus a &lt;code&gt;skills_review&lt;/code&gt; prompt. Deleting needs explicit confirmation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Team tip (CLI v0.36.0):&lt;/strong&gt; &lt;code&gt;promptconduit cost&lt;/code&gt; can show an occasional one-line tip about team spend, at most once a week and only in an interactive terminal. &lt;code&gt;PROMPTCONDUIT_NO_TIPS=1&lt;/code&gt; hides it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expired sessions:&lt;/strong&gt; the dashboard sends you to sign in, then returns you to your page. The API's 401 carries code &lt;code&gt;session_expired&lt;/code&gt; when the session ran out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Busy sign-in provider:&lt;/strong&gt; if Google or GitHub answers the sign-in exchange with a 429 or a server error, PromptConduit retries once, and an error message names the provider.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Analytics:&lt;/strong&gt; our own product analytics are cookieless and honor Global Privacy Control and Do Not Track. Google Analytics is off until you consent in the EEA, UK and Switzerland. Details are in the &lt;a href="https://promptconduit.dev/privacy" rel="noopener noreferrer"&gt;privacy policy&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the site, the &lt;a href="https://promptconduit.dev/blog/rss.xml" rel="noopener noreferrer"&gt;blog has an RSS feed&lt;/a&gt;, and the guide to &lt;a href="https://promptconduit.dev/blog/track-claude-code-token-usage-and-cost" rel="noopener noreferrer"&gt;Claude Code token usage and cost&lt;/a&gt; now covers usage history, OpenTelemetry and team usage.&lt;/p&gt;

&lt;p&gt;Command details are in the &lt;a href="https://promptconduit.dev/docs/cli-reference" rel="noopener noreferrer"&gt;CLI reference&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://promptconduit.dev/blog/whats-new-2026-11?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=blog-promptconduit-20261127-2" rel="noopener noreferrer"&gt;promptconduit.dev&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>agents</category>
      <category>api</category>
      <category>cli</category>
      <category>mcp</category>
    </item>
    <item>
      <title>PromptConduit Auth Hardening</title>
      <dc:creator>Scott Havird</dc:creator>
      <pubDate>Sat, 21 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/scotthavird/promptconduit-auth-hardening-pcc</link>
      <guid>https://dev.to/scotthavird/promptconduit-auth-hardening-pcc</guid>
      <description>&lt;p&gt;If your company puts an AI coding analytics tool behind SSO or shared accounts, the security questionnaire is only the start. You still need to know what happens when someone is deactivated, when a bot floods sign-in, or when a session token lands in a browser URL.&lt;/p&gt;

&lt;p&gt;PromptConduit is a TypeScript API on Cloudflare Workers with D1. Sign-in is OAuth with Google and GitHub on the web, plus an RFC 8628 device flow for &lt;code&gt;promptconduit login&lt;/code&gt;. There is no password login, no refresh tokens, and no SAML. I still had gaps worth fixing. Three PRs merged in our private platform repo on October 14, 2026: &lt;strong&gt;#244&lt;/strong&gt;, &lt;strong&gt;#245&lt;/strong&gt;, and &lt;strong&gt;#247&lt;/strong&gt;. I cannot link the repo here. This post is what shipped.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;Engineering teams wire Claude Code, Cursor, or Copilot into their workflow, then add something that aggregates prompt metadata. Procurement asks about SSO. Even when the product only offers Google or GitHub login today, the questions overlap: offboarding, automated sign-in floods, and tokens leaking through URLs or logs.&lt;/p&gt;

&lt;p&gt;PromptConduit holds team usage data. It is not the model provider. The failure modes below are the ones I actually hit in code review, not slide-deck hypotheticals.&lt;/p&gt;

&lt;h2&gt;
  
  
  What
&lt;/h2&gt;

&lt;p&gt;Three PRs, three fixes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#244 — Account status on every credential check.&lt;/strong&gt; &lt;code&gt;getUserById&lt;/code&gt; used to ignore &lt;code&gt;is_active&lt;/code&gt; and &lt;code&gt;deleted_at&lt;/code&gt;, so deactivated or soft-deleted users kept working through bearer JWTs, the session cookie, and API keys.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#245 — Per-IP rate limits on unauthenticated auth routes.&lt;/strong&gt; OAuth sign-in starts, device-code creation, device token polling, and device authorize. OAuth callbacks stay unlimited. A later slice in &lt;strong&gt;#247&lt;/strong&gt; added the exchange endpoint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#247 — PKCE on Google/GitHub sign-in, and JWT out of the redirect URL.&lt;/strong&gt; PromptConduit is the OAuth &lt;em&gt;client&lt;/em&gt; of those providers, not an authorization server. The CLI keeps using the device flow; it does not use PKCE. The web callback also stopped putting the session JWT in query parameters.&lt;/p&gt;

&lt;p&gt;If you evaluate SaaS that sits next to AI coding tools, ask vendors to explain these three areas in plain language.&lt;/p&gt;

&lt;h2&gt;
  
  
  How
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Deactivated users (#244)
&lt;/h3&gt;

&lt;p&gt;All three credential types go through &lt;code&gt;authenticateRequest&lt;/code&gt;. Device-flow approval uses it too, so a deactivated user cannot mint new CLI keys. Soft-deleted users do not need a separate API-key revoke pass.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;NULL&lt;/code&gt; &lt;code&gt;is_active&lt;/code&gt; still counts as active, matching the column default, so legacy rows are not locked out. Either &lt;code&gt;is_active === false&lt;/code&gt; or a set &lt;code&gt;deleted_at&lt;/code&gt; blocks access. The user row was already loaded on each request; this fix did not add another database read.&lt;/p&gt;

&lt;p&gt;Trimmed from the real Drizzle path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="cm"&gt;/* … */&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;eq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// A soft-deleted or deactivated user loses access through every credential&lt;/span&gt;
&lt;span class="c1"&gt;// (JWTs, session cookies, API keys), not just new sign-ins. NULL is_active is&lt;/span&gt;
&lt;span class="c1"&gt;// treated as active, matching the column default, so legacy rows keep access.&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isActive&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deletedAt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tests run eleven cases through fake D1 and the real Drizzle stack: three credential types times active, deactivated, and soft-deleted users, plus a legacy &lt;code&gt;NULL&lt;/code&gt; row and an unknown user. Revert the fix and six deactivated-or-deleted cases fail.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rate limits (#245, exchange in #247)
&lt;/h3&gt;

&lt;p&gt;Limits use Cloudflare Workers rate-limit bindings keyed on &lt;code&gt;cf-connecting-ip&lt;/code&gt;, wrapped in a small &lt;code&gt;rateLimited(binding, period, handler, onLimited?)&lt;/code&gt; helper.&lt;/p&gt;

&lt;p&gt;Covered routes: &lt;code&gt;GET /v1/auth/google&lt;/code&gt;, &lt;code&gt;GET /v1/auth/github&lt;/code&gt;, device code creation, device token polling, device authorize, and &lt;code&gt;POST /v1/auth/exchange&lt;/code&gt;. Callbacks from Google and GitHub are not limited.&lt;/p&gt;

&lt;p&gt;The point is flood control. Every sign-in start writes a D1 row; a cheap HTTP flood becomes write amplification. Limits also slow guessing of device-flow &lt;code&gt;user_code&lt;/code&gt; values. This is not a credential-stuffing story; there are no passwords.&lt;/p&gt;

&lt;p&gt;Over the limit, callers get HTTP 429 with &lt;code&gt;Retry-After&lt;/code&gt;. Device token polling is different: RFC 8628 &lt;code&gt;slow_down&lt;/code&gt; instead of 429, because the CLI backs off on &lt;code&gt;slow_down&lt;/code&gt; but treats other non-400 statuses as a failed login. Limits were sized from production traffic so typical office NATs stay clear. I am not publishing thresholds. Counters are approximate per Cloudflare location; they stop floods, not act as a quota.&lt;/p&gt;

&lt;p&gt;Expired, unused OAuth states and device codes are cleaned up on a schedule.&lt;/p&gt;

&lt;h3&gt;
  
  
  PKCE and JWT exchange (#247)
&lt;/h3&gt;

&lt;p&gt;At sign-in start the server generates a &lt;code&gt;code_verifier&lt;/code&gt;, stores it on the pending &lt;code&gt;oauth_states&lt;/code&gt; row (five-minute lifetime), and sends &lt;code&gt;code_challenge&lt;/code&gt; with S256 to Google or GitHub. On callback the server sends &lt;code&gt;code_verifier&lt;/code&gt; with the authorization-code grant. The verifier never leaves the server. Sign-ins already in flight at deploy time had no verifier stored; the five-minute state lifetime closed that window. Deploy smoke tests fail if a provider redirect is missing an S256 challenge.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/** S256 code_challenge = BASE64URL(SHA256(ASCII(code_verifier))). */&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;codeChallengeS256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;verifier&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;base64Url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;verifier&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// sign-in start: the verifier stays server-side with the state&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;codeVerifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;generateCodeVerifier&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// 32 random bytes, base64url&lt;/span&gt;
&lt;span class="c1"&gt;// …stored on the oauth_states row…&lt;/span&gt;
&lt;span class="nx"&gt;authUrl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;searchParams&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;code_challenge&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;codeChallengeS256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;codeVerifier&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;authUrl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;searchParams&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;code_challenge_method&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;S256&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// callback: token exchange with Google/GitHub&lt;/span&gt;
&lt;span class="nl"&gt;grant_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;authorization_code&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;...(&lt;/span&gt;&lt;span class="nx"&gt;stateRecord&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;codeVerifier&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;code_verifier&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;stateRecord&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;codeVerifier&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second half fixes the redirect leak. The session JWT used to come back as &lt;code&gt;/oauth/callback?token=&amp;lt;JWT&amp;gt;&amp;amp;provider=…&amp;amp;email=…&amp;amp;isNewUser=…&lt;/code&gt;, which shows up in history, logs, and &lt;code&gt;Referer&lt;/code&gt;. Now the callback is &lt;code&gt;/oauth/callback?code=&amp;lt;exchange code&amp;gt;&lt;/code&gt;. The page strips the code with &lt;code&gt;history.replaceState&lt;/code&gt;, then &lt;code&gt;POST&lt;/code&gt;s to &lt;code&gt;/v1/auth/exchange&lt;/code&gt;. The exchange code is 32 random bytes, single-use, valid for sixty seconds, stored only as a SHA-256 hash. Redemption uses &lt;code&gt;DELETE … RETURNING&lt;/code&gt; so concurrent posts cannot double-spend. Expired codes and deactivated users get 401. The JWT returns in the response body; email and &lt;code&gt;isNewUser&lt;/code&gt; are not in the URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;redeemExchangeCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Database&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;now&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;oauthExchangeCodes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;eq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;oauthExchangeCodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;codeHash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;hashCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;returning&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;row&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;expiresAt&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;getTime&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;now&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getTime&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;isNewUser&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isNewUser&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Platform PRs &lt;strong&gt;#244&lt;/strong&gt;, &lt;strong&gt;#245&lt;/strong&gt;, and &lt;strong&gt;#247&lt;/strong&gt; hardened PromptConduit auth: live rejection of deactivated or soft-deleted users on JWTs, session cookies, and API keys; per-IP limits on unauthenticated auth endpoints (with &lt;code&gt;slow_down&lt;/code&gt; on device polling); PKCE on Google and GitHub sign-in; and a one-time exchange code so the JWT never sits in the redirect URL. TypeScript snippets above are trimmed from the real code.&lt;/p&gt;

&lt;p&gt;Teams rolling out AI coding analytics behind SSO or shared accounts should expect the same baseline from any vendor, even when login is "just" OAuth today.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/promptconduit-ai-assistant-analytics/" rel="noopener noreferrer"&gt;PromptConduit: Building Analytics for AI Coding Assistants&lt;/a&gt; — What the platform captures and why&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/measure-ai-coding-productivity/" rel="noopener noreferrer"&gt;How to Measure AI Coding Assistant Productivity&lt;/a&gt; — Metrics framework for teams rolling out AI assistants&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article was created with the help of AI.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://scotthavird.com/blog/promptconduit-auth-hardening/" rel="noopener noreferrer"&gt;scotthavird.com&lt;/a&gt;. Follow me on &lt;a href="https://x.com/scotthavird" rel="noopener noreferrer"&gt;X&lt;/a&gt; and &lt;a href="https://github.com/scotthavird" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>development</category>
      <category>security</category>
      <category>oauth</category>
    </item>
    <item>
      <title>Codifying scotthavird.com in Terraform</title>
      <dc:creator>Scott Havird</dc:creator>
      <pubDate>Sat, 14 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/scotthavird/codifying-scotthavirdcom-in-terraform-4b9a</link>
      <guid>https://dev.to/scotthavird/codifying-scotthavirdcom-in-terraform-4b9a</guid>
      <description>&lt;h2&gt;
  
  
  Codifying scotthavird.com in Terraform
&lt;/h2&gt;

&lt;p&gt;For years this site lived in two places at once: the Docusaurus repo and a scattering of Cloudflare dashboard clicks. Pages project settings, custom domains, zone security toggles, and an email signup API that only existed in AWS — none of it was reviewable in a PR.&lt;/p&gt;

&lt;p&gt;That drift is fine until it isn't. I hit the &lt;a href="https://scotthavird.com/blog/cloudflare-pages-redirect-backwards/" rel="noopener noreferrer"&gt;www redirect trap&lt;/a&gt; on my own domain. Preview builds failed because Node 18 was still configured in the dashboard while Docusaurus 3.9 requires Node 20. Each fix was another manual change with no audit trail.&lt;/p&gt;

&lt;p&gt;So I codified the whole stack in &lt;code&gt;iac/&lt;/code&gt; and retired the GitHub Actions deploy workflow in favor of native Cloudflare Pages builds.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Moved Into Terraform
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;iac/&lt;/code&gt; directory now owns four concerns that used to be split across dashboards:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concern&lt;/th&gt;
&lt;th&gt;Resource&lt;/th&gt;
&lt;th&gt;Why codify it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Site hosting&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cloudflare_pages_project&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Build command, Node version, preview branch rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Zone security&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;null_resource&lt;/code&gt; + Cloudflare API&lt;/td&gt;
&lt;td&gt;SSL strict, HSTS preload, TLS 1.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Email signup&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;API Gateway + Lambda + DynamoDB + SES&lt;/td&gt;
&lt;td&gt;Homepage newsletter form&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DNS for email&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;cloudflare_record&lt;/code&gt; (SES verification, DKIM)&lt;/td&gt;
&lt;td&gt;Deliverability without manual TXT records&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The Docusaurus site itself stays in the same repo. Cloudflare Pages builds &lt;code&gt;main&lt;/code&gt; on every push — no separate deploy workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cloudflare Pages: The Important Details
&lt;/h2&gt;

&lt;p&gt;The Pages project resource looks straightforward, but a few fields matter in practice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;build_config&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;build_command&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"yarn build"&lt;/span&gt;
  &lt;span class="nx"&gt;destination_dir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"build"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;deployment_configs&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;production&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;environment_variables&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;NODE_VERSION&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"20"&lt;/span&gt;
      &lt;span class="nx"&gt;SUBSCRIBE_API_URL&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws_apigatewayv2_api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;api_endpoint&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Node 20&lt;/strong&gt; — Docusaurus 3.9.2 requires it. The dashboard was still on 18, which meant every PR preview failed with &lt;code&gt;yarn: command not found&lt;/code&gt; or engine warnings. Setting it in Terraform means preview and production stay aligned.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;SUBSCRIBE_API_URL&lt;/code&gt;&lt;/strong&gt; — Docusaurus reads this at build time via &lt;code&gt;process.env.SUBSCRIBE_API_URL&lt;/code&gt; and exposes it as &lt;code&gt;siteConfig.customFields.apiUrl&lt;/code&gt;. The homepage &lt;code&gt;EmailSignup&lt;/code&gt; component POSTs to &lt;code&gt;${apiUrl}/subscribe&lt;/code&gt;. Wiring the API Gateway endpoint into the Pages env var means the frontend always targets the right backend without hardcoding URLs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Preview branch excludes&lt;/strong&gt; — &lt;code&gt;gh-pages&lt;/code&gt; is excluded from preview builds. That branch is the old peaceiris deploy output; it has no &lt;code&gt;package.json&lt;/code&gt; and will fail every build attempt.&lt;/p&gt;

&lt;p&gt;One gap: &lt;code&gt;build_image_major_version&lt;/code&gt; (v1 → v3) isn't exposed in the Cloudflare provider v4. I set it via a one-time API PATCH and documented the workaround in &lt;code&gt;iac/pages.tf&lt;/code&gt;. Provider v5 adds native support — revisit on upgrade.&lt;/p&gt;

&lt;h2&gt;
  
  
  Zone Security Without the Provider Trap
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;cloudflare_zone_settings_override&lt;/code&gt; resource in provider v4 reads &lt;em&gt;all&lt;/em&gt; zone settings during refresh, including Enterprise-only fields that return HTTP 999 on Free plans. That makes &lt;code&gt;terraform apply&lt;/code&gt; fail even when your target settings are correct.&lt;/p&gt;

&lt;p&gt;The workaround: a &lt;code&gt;null_resource&lt;/code&gt; with &lt;code&gt;local-exec&lt;/code&gt; that PATCHes only the settings we care about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SSL mode: &lt;strong&gt;strict&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Always Use HTTPS: &lt;strong&gt;on&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Minimum TLS: &lt;strong&gt;1.2&lt;/strong&gt;, TLS 1.3: &lt;strong&gt;on&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;HSTS: &lt;strong&gt;2-year max-age&lt;/strong&gt;, include subdomains, preload-ready&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;triggers&lt;/code&gt; block hashes the target values so any change re-applies. It's not elegant, but it's reliable on a Free-plan zone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Email Subscribe API
&lt;/h2&gt;

&lt;p&gt;The homepage newsletter form needs a backend. The stack:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;API Gateway HTTP API&lt;/strong&gt; — &lt;code&gt;POST /subscribe&lt;/code&gt;, &lt;code&gt;GET /confirm?token=...&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lambda&lt;/strong&gt; — validates email, stores pending token in DynamoDB, sends confirmation via SES&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DynamoDB&lt;/strong&gt; — subscribers table + tokens table with TTL for expired confirmations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SES&lt;/strong&gt; — domain-verified sending from &lt;code&gt;scotthavird.com&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All tagged with &lt;code&gt;Project = scotthavird-com&lt;/code&gt; and environment-scoped naming (&lt;code&gt;scotthavird-prod-*&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;The double opt-in flow matters: we don't add addresses to the list until the user clicks the confirmation link. Tokens expire via DynamoDB TTL.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Deliberately Didn't Codify
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;www → apex redirect&lt;/strong&gt; — Cloudflare Pages owns the &lt;code&gt;http_request_dynamic_redirect&lt;/code&gt; ruleset for custom domains. Zone-level Rulesets API tokens can't override it. The fix is documented in &lt;a href="https://scotthavird.com/blog/cloudflare-pages-redirect-backwards/" rel="noopener noreferrer"&gt;Your Cloudflare Pages Redirect Is Probably Backwards&lt;/a&gt;: set the apex as the primary custom domain in Pages, then add a Page Rule for belt-and-suspenders.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub Actions deploy&lt;/strong&gt; — Retired. Cloudflare Pages builds directly from the repo. One less moving part, preview URLs on every PR, and no &lt;code&gt;GITHUB_TOKEN&lt;/code&gt; deploy secret to rotate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Operating It
&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;cd &lt;/span&gt;iac
terraform plan  &lt;span class="nt"&gt;-var-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;prod.tfvars
terraform apply &lt;span class="nt"&gt;-var-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;prod.tfvars
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prod and dev workspaces share the pattern; DNS records for SES are prod-only (&lt;code&gt;local.is_prod&lt;/code&gt;) to avoid conflicts.&lt;/p&gt;

&lt;p&gt;Site-side guardrails run in CI on every PR:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn ci   &lt;span class="c"&gt;# lint:posts → update:llms → build → validate:schema&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Infrastructure changes and content changes can ship in the same PR when needed — but they're reviewed separately because they touch different directories.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Codify the stuff that breaks silently.&lt;/strong&gt; Redirect direction and Node version don't fail loudly until SEO or previews are already damaged.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build-time env vars for frontend API URLs.&lt;/strong&gt; Hardcoding API Gateway endpoints in React is a deploy-order nightmare; Pages env vars solve it cleanly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provider limitations are real.&lt;/strong&gt; When the Terraform resource can't express what you need, document the out-of-band step and add a trigger or comment so the next person doesn't "fix" it back to broken.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the site and the infra in one repo.&lt;/strong&gt; Docusaurus content and Cloudflare/AWS resources share a lifecycle. One PR can add a feature and the API it needs.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/cloudflare-pages-redirect-backwards/" rel="noopener noreferrer"&gt;Your Cloudflare Pages Redirect Is Probably Backwards&lt;/a&gt; — The www/apex trap that motivated part of this work&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/ways-of-working-speed-of-thought/" rel="noopener noreferrer"&gt;Ways of Working at the Speed of Thought&lt;/a&gt; — Why reducing deploy friction matters when engineers ship in hours&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article was created with the help of AI.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://scotthavird.com/blog/cloudflare-pages-terraform-iac/" rel="noopener noreferrer"&gt;scotthavird.com&lt;/a&gt;. Follow me on &lt;a href="https://x.com/scotthavird" rel="noopener noreferrer"&gt;X&lt;/a&gt; and &lt;a href="https://github.com/scotthavird" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>cloudflare</category>
      <category>terraform</category>
      <category>infrastructure</category>
    </item>
    <item>
      <title>Your Cloudflare Pages Redirect Is Probably Backwards</title>
      <dc:creator>Scott Havird</dc:creator>
      <pubDate>Wed, 11 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/scotthavird/your-cloudflare-pages-redirect-is-probably-backwards-18ji</link>
      <guid>https://dev.to/scotthavird/your-cloudflare-pages-redirect-is-probably-backwards-18ji</guid>
      <description>&lt;h2&gt;
  
  
  Your Cloudflare Pages Redirect Is Probably Backwards
&lt;/h2&gt;

&lt;p&gt;Here's a scenario that's more common than it should be: you set up a site on Cloudflare Pages, configure a redirect so that &lt;code&gt;www&lt;/code&gt; points to your apex domain, and everything looks fine. Then six months later you check Google Search Console and your impressions are split across four different URL variants. Half your SEO equity is leaking because both &lt;code&gt;www.yourdomain.com&lt;/code&gt; and &lt;code&gt;yourdomain.com&lt;/code&gt; are being indexed as separate pages.&lt;/p&gt;

&lt;p&gt;The culprit isn't your code. It's Cloudflare Pages silently redirecting your apex domain to &lt;code&gt;www&lt;/code&gt; — the exact opposite of what you intended.&lt;/p&gt;

&lt;p&gt;I ran into this on my own site and spent longer than I'd like to admit tracing it down. Here's exactly what happens and how to fix it permanently.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the Trap Works
&lt;/h2&gt;

&lt;p&gt;When you add custom domains to a Cloudflare Pages project, the first domain you add becomes the &lt;strong&gt;primary domain&lt;/strong&gt;. All other domains redirect to it.&lt;/p&gt;

&lt;p&gt;Most developers add &lt;code&gt;www.yourdomain.com&lt;/code&gt; first — it's the traditional domain, and it's what you're told to set up a CNAME for. Then they add &lt;code&gt;yourdomain.com&lt;/code&gt; (apex) as a second domain. Cloudflare Pages sees this and starts redirecting apex → www, because www was there first.&lt;/p&gt;

&lt;p&gt;You now have two problems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your apex domain (the one you probably want as canonical) is 301-redirecting to www&lt;/li&gt;
&lt;li&gt;Any redirect rule you set up to redirect www → apex creates an infinite loop&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The insidious part: this isn't documented anywhere obvious. There's no warning in the Cloudflare Pages UI that says "this domain will be treated as secondary and will redirect to your primary." It just happens.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the Damage Looks Like in GSC
&lt;/h2&gt;

&lt;p&gt;If this has been running for a while, open Google Search Console → Performance → Pages. You'll see something like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;URL&lt;/th&gt;
&lt;th&gt;Impressions&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;www.yourdomain.com/blog/your-post&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;6,039&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;yourdomain.com/blog/your-post/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2,243&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;yourdomain.com/blog/your-post&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1,749&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;www.yourdomain.com/blog/your-post/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1,268&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The same page, four URLs, ~11K impressions split four ways. Google doesn't know which one is canonical, so it indexes all of them at partial strength instead of consolidating the full authority onto one URL.&lt;/p&gt;

&lt;p&gt;This is a direct hit to your rankings. A page with 11K consolidated impressions at position 6 would rank materially better than four pages averaging 2-3K impressions each.&lt;/p&gt;

&lt;h2&gt;
  
  
  Diagnosing Your Current State
&lt;/h2&gt;

&lt;p&gt;First, check which direction the redirect is actually going:&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="c"&gt;# Check if apex redirects to www (bad)&lt;/span&gt;
curl &lt;span class="nt"&gt;-sI&lt;/span&gt; https://yourdomain.com/ | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; location

&lt;span class="c"&gt;# Check if www redirects to apex (good)&lt;/span&gt;
curl &lt;span class="nt"&gt;-sI&lt;/span&gt; https://www.yourdomain.com/ | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; location
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the first command returns &lt;code&gt;location: https://www.yourdomain.com/&lt;/code&gt;, you have the problem.&lt;/p&gt;

&lt;p&gt;Next, check what's causing it. There are three places Cloudflare can be redirecting you:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Redirect Rules&lt;/strong&gt; (Rules → Redirect Rules) — newer mechanism&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Page Rules&lt;/strong&gt; (Rules → Page Rules) — legacy mechanism, still common&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloudflare Pages custom domain order&lt;/strong&gt; — the silent one&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You might have rules in more than one place creating a loop. Check all three.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fix
&lt;/h2&gt;

&lt;p&gt;The cleanest long-term solution is a Page Rule that handles the www → apex redirect at the DNS level, completely independent of Cloudflare Pages custom domain settings.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Remove www from Cloudflare Pages custom domains
&lt;/h3&gt;

&lt;p&gt;Go to Cloudflare Pages → your project → Custom Domains. Remove &lt;code&gt;www.yourdomain.com&lt;/code&gt;. Keep only the apex domain. This eliminates the Pages-controlled redirect entirely.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Create a proxied DNS record for www
&lt;/h3&gt;

&lt;p&gt;For the Page Rule to intercept www traffic, Cloudflare needs a proxied (orange cloud) DNS record for &lt;code&gt;www&lt;/code&gt;. If you don't have one:&lt;/p&gt;

&lt;p&gt;Go to DNS → Add record:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type&lt;/strong&gt;: A&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Name&lt;/strong&gt;: www&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IPv4&lt;/strong&gt;: &lt;code&gt;192.0.2.1&lt;/code&gt; (discard IP — traffic never reaches this, Cloudflare intercepts it)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proxy status&lt;/strong&gt;: Proxied (orange cloud)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;192.0.2.1&lt;/code&gt; address is intentional. It's a reserved IP that discards traffic. Since Cloudflare proxies the record, your Page Rule fires before any request ever reaches that IP.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Create the Page Rule
&lt;/h3&gt;

&lt;p&gt;Go to Rules → Page Rules → Create Page Rule:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;URL&lt;/strong&gt;: &lt;code&gt;www.yourdomain.com/*&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Setting&lt;/strong&gt;: Forwarding URL&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Status code&lt;/strong&gt;: 301 - Permanent Redirect&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Destination&lt;/strong&gt;: &lt;code&gt;https://yourdomain.com/$1&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;$1&lt;/code&gt; wildcard captures the full path so &lt;code&gt;/blog/my-post/&lt;/code&gt; stays intact through the redirect.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Verify
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# www should 301 to apex&lt;/span&gt;
curl &lt;span class="nt"&gt;-sI&lt;/span&gt; https://www.yourdomain.com/ | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-3&lt;/span&gt;

&lt;span class="c"&gt;# Apex should 200&lt;/span&gt;
curl &lt;span class="nt"&gt;-sI&lt;/span&gt; https://yourdomain.com/ | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="m"&gt;301&lt;/span&gt;
&lt;span class="na"&gt;location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://yourdomain.com/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;
&lt;span class="na"&gt;content-type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;text/html&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why Not Use Cloudflare Redirect Rules Instead?
&lt;/h2&gt;

&lt;p&gt;You might be wondering why I'm using the legacy Page Rules instead of the newer Redirect Rules.&lt;/p&gt;

&lt;p&gt;The reason is that Cloudflare Pages &lt;strong&gt;owns&lt;/strong&gt; the &lt;code&gt;http_request_dynamic_redirect&lt;/code&gt; ruleset for zones where Pages is deployed. When you try to create a Redirect Rule via the API or Terraform, you get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: request is not authorized to modify this ruleset
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is by design — Cloudflare Pages manages that ruleset to handle its own custom domain redirects. You can't touch it with a zone-level API token, even with full Firewall permissions. Page Rules are a separate system that Pages doesn't own, so they work.&lt;/p&gt;

&lt;p&gt;If you manage your infrastructure as code (Terraform, Pulumi, etc.), note this in your DNS config so future you doesn't waste an hour trying to figure out why &lt;code&gt;cloudflare_ruleset&lt;/code&gt; keeps failing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Codifying It in Terraform
&lt;/h2&gt;

&lt;p&gt;If you're managing Cloudflare config in Terraform:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Proxied A record for www — required for Page Rule to fire&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"cloudflare_record"&lt;/span&gt; &lt;span class="s2"&gt;"www"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;zone_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cloudflare_zone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"www"&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"A"&lt;/span&gt;
  &lt;span class="nx"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"192.0.2.1"&lt;/span&gt;
  &lt;span class="nx"&gt;proxied&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="nx"&gt;comment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Dummy record — proxied so Page Rule intercepts www traffic"&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Page Rule: www → apex redirect&lt;/span&gt;
&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"cloudflare_page_rule"&lt;/span&gt; &lt;span class="s2"&gt;"www_redirect"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;zone_id&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cloudflare_zone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;
  &lt;span class="nx"&gt;target&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"www.${var.domain}/*"&lt;/span&gt;
  &lt;span class="nx"&gt;priority&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

  &lt;span class="nx"&gt;actions&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;forwarding_url&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;url&lt;/span&gt;         &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://${var.domain}/$1"&lt;/span&gt;
      &lt;span class="nx"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;301&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add a comment explaining why you're using Page Rules instead of Redirect Rules. The next person (or future you) will thank you.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Happens to Your GSC Data
&lt;/h2&gt;

&lt;p&gt;After the fix, expect 7-14 days before you see it reflected in Google Search Console. Google needs to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Recrawl the www URLs and follow the 301 to apex&lt;/li&gt;
&lt;li&gt;Consolidate the canonical in its index&lt;/li&gt;
&lt;li&gt;Surface the updated data in GSC (there's a 2-3 day lag)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You won't lose impressions — they consolidate onto the canonical URL. The page that was showing fragmented across 4 URLs with 11K total impressions should show up as one URL with ~11K impressions. Rankings typically improve once Google stops splitting authority.&lt;/p&gt;

&lt;p&gt;Submit the canonical URL for re-indexing to speed things up: GSC → URL Inspection → enter the apex URL → Request Indexing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Short Version
&lt;/h2&gt;

&lt;p&gt;If you're using Cloudflare Pages and your apex domain is redirecting to www:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check if www was added to Pages custom domains before apex — if so, remove it&lt;/li&gt;
&lt;li&gt;Add a proxied A record for www pointing to &lt;code&gt;192.0.2.1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create a Page Rule: &lt;code&gt;www.yourdomain.com/*&lt;/code&gt; → 301 → &lt;code&gt;https://yourdomain.com/$1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Verify with curl, then check GSC in a week&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The redirect direction matters more than most developers realize. Every day your apex redirects to www is another day Google's splitting your authority across URL variants you didn't intend to create.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why does Cloudflare Pages redirect my apex domain to www?
&lt;/h3&gt;

&lt;p&gt;Cloudflare Pages treats the first custom domain you add as the primary domain. If you added &lt;code&gt;www.yourdomain.com&lt;/code&gt; before &lt;code&gt;yourdomain.com&lt;/code&gt;, Cloudflare Pages redirects the apex to www automatically. Remove the www domain from Pages custom domains and use a Page Rule instead for explicit control.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why use 192.0.2.1 for the www DNS record?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;192.0.2.1&lt;/code&gt; is a reserved "discard" IP (RFC 5737). Since the DNS record is proxied through Cloudflare (orange cloud), traffic never reaches that IP — Cloudflare intercepts it and applies the Page Rule redirect first. The IP is just a placeholder to satisfy the DNS record requirement.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why can't I use Cloudflare Redirect Rules instead of Page Rules?
&lt;/h3&gt;

&lt;p&gt;Cloudflare Pages owns the &lt;code&gt;http_request_dynamic_redirect&lt;/code&gt; ruleset on zones where it's deployed. Zone-level API tokens and Terraform cannot modify this ruleset — you'll get an authorization error. Page Rules are a separate system that Pages doesn't control, so they work reliably for this use case.&lt;/p&gt;

&lt;h3&gt;
  
  
  How long until Google Search Console shows the fix?
&lt;/h3&gt;

&lt;p&gt;GSC data has a 2-3 day lag, and Google needs to recrawl the redirected URLs before it consolidates the canonical. Expect 7-14 days for the full effect. Use URL Inspection → Request Indexing on the canonical apex URL to accelerate re-crawling.&lt;/p&gt;




&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/measure-ai-coding-productivity/" rel="noopener noreferrer"&gt;How to Measure AI Coding Assistant Productivity&lt;/a&gt; — Framework for measuring AI tool impact&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/claude-code-hooks-guide/" rel="noopener noreferrer"&gt;Claude Code Hooks: A Complete Guide&lt;/a&gt; — Automating your AI coding workflow&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/ai-coding-tool-comparison-2026/" rel="noopener noreferrer"&gt;AI Coding Tool Comparison 2026&lt;/a&gt; — Claude Code vs Cursor vs Copilot vs Windsurf&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article was created with the help of AI.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://scotthavird.com/blog/cloudflare-pages-redirect-backwards/" rel="noopener noreferrer"&gt;scotthavird.com&lt;/a&gt;. Follow me on &lt;a href="https://x.com/scotthavird" rel="noopener noreferrer"&gt;X&lt;/a&gt; and &lt;a href="https://github.com/scotthavird" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>cloudflare</category>
      <category>seo</category>
      <category>infrastructure</category>
    </item>
    <item>
      <title>AI Coding Tools 2026: Claude Code vs Cursor vs Copilot</title>
      <dc:creator>Scott Havird</dc:creator>
      <pubDate>Sun, 08 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/scotthavird/ai-coding-tools-2026-claude-code-vs-cursor-vs-copilot-19bo</link>
      <guid>https://dev.to/scotthavird/ai-coding-tools-2026-claude-code-vs-cursor-vs-copilot-19bo</guid>
      <description>&lt;h2&gt;
  
  
  AI Coding Tool Comparison 2026: Claude Code vs Cursor vs GitHub Copilot vs Windsurf
&lt;/h2&gt;

&lt;p&gt;I use multiple AI coding tools every day. Not because I'm indecisive — because different tools genuinely excel at different tasks. After a year of tracking my usage through &lt;a href="https://scotthavird.com/blog/promptconduit-ai-assistant-analytics/" rel="noopener noreferrer"&gt;PromptConduit&lt;/a&gt; and monitoring releases through &lt;a href="https://havoptic.com" rel="noopener noreferrer"&gt;Havoptic&lt;/a&gt;, I have a data-informed perspective on where each tool shines and where it falls short.&lt;/p&gt;

&lt;p&gt;This isn't a surface-level feature checklist. It's an honest assessment from someone who ships production code with these tools daily, tracks their release velocity, and measures their impact on productivity.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 2026 Landscape
&lt;/h2&gt;

&lt;p&gt;The AI coding tool market has consolidated around a few clear leaders, each with a distinct philosophy:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Philosophy&lt;/th&gt;
&lt;th&gt;Interface&lt;/th&gt;
&lt;th&gt;Pricing&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Claude Code&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Terminal-native, agent-first&lt;/td&gt;
&lt;td&gt;CLI&lt;/td&gt;
&lt;td&gt;Max plan ($100/mo) or API usage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cursor&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;IDE-first, inline AI&lt;/td&gt;
&lt;td&gt;VS Code fork&lt;/td&gt;
&lt;td&gt;$20/mo (Pro), $40/mo (Business)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;GitHub Copilot&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Inline completion + chat&lt;/td&gt;
&lt;td&gt;VS Code/JetBrains extension&lt;/td&gt;
&lt;td&gt;$10/mo (Individual), $19/mo (Business)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Windsurf&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;IDE-first, flow-based&lt;/td&gt;
&lt;td&gt;VS Code fork&lt;/td&gt;
&lt;td&gt;Free tier, $15/mo (Pro)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Gemini CLI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Terminal-native, Google ecosystem&lt;/td&gt;
&lt;td&gt;CLI&lt;/td&gt;
&lt;td&gt;Free with Google account&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Codex CLI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Terminal-native, OpenAI models&lt;/td&gt;
&lt;td&gt;CLI&lt;/td&gt;
&lt;td&gt;API usage-based&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Claude Code
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; Complex multi-file changes, architectural refactoring, project-wide operations, CI/CD integration.&lt;/p&gt;

&lt;p&gt;Claude Code takes a fundamentally different approach from IDE-based tools. It runs in your terminal, reads your entire project structure, and operates as an autonomous agent that can read files, write code, run commands, and iterate on errors — all in a single conversation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I love:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Agent autonomy.&lt;/strong&gt; Give it a complex task and it will read files, plan an approach, implement across multiple files, run tests, and fix failures — all without babysitting. This is the closest thing to having a junior developer who actually follows instructions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hooks and customization.&lt;/strong&gt; The &lt;a href="https://scotthavird.com/blog/claude-code-hooks-guide/" rel="noopener noreferrer"&gt;hooks system&lt;/a&gt; lets you build deterministic automation around the AI — auto-formatting, file protection, quality gates. No other tool has this level of extensibility.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CLAUDE.md project context.&lt;/strong&gt; Drop a CLAUDE.md file in your repo and every session starts with full project context. Combined with hooks, this creates a deeply customized development environment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Git-native workflow.&lt;/strong&gt; It understands git state, can create branches, commit with messages, and even create PRs. The workflow feels natural for terminal-native developers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Trade-offs:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No inline completion.&lt;/strong&gt; It's a conversation-based tool, not an autocomplete engine. If you want suggestions as you type, you need a separate tool.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learning curve.&lt;/strong&gt; The terminal interface and agent-based workflow require a mindset shift from traditional IDE-based AI tools.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost model.&lt;/strong&gt; On the API plan, complex sessions with many tool calls can get expensive. The Max plan ($100/mo) offers better predictability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Release velocity:&lt;/strong&gt; Claude Code ships weekly. &lt;a href="https://havoptic.com" rel="noopener noreferrer"&gt;Havoptic&lt;/a&gt; tracks every release with visual summaries — it's one of the fastest-iterating tools in the space.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cursor
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; Inline code editing, rapid prototyping, visual learners who want AI embedded in their IDE.&lt;/p&gt;

&lt;p&gt;Cursor took the VS Code experience and deeply integrated AI into every interaction. Tab completion, inline edits, multi-file context via @-mentions, and a Composer mode for larger changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I love:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inline edit flow.&lt;/strong&gt; Select code, hit Cmd+K, describe the change, and it edits in-place with a diff view. This is the fastest way to make targeted changes to existing code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tab completion quality.&lt;/strong&gt; The predictive completions are genuinely useful — not just boilerplate, but context-aware suggestions that understand your codebase patterns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Familiar environment.&lt;/strong&gt; It's VS Code. Your extensions, keybindings, and settings carry over. The switching cost from VS Code is near zero.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Composer mode.&lt;/strong&gt; For multi-file changes, Composer provides a chat-based interface similar to Claude Code's agent workflow, but within the IDE.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Trade-offs:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No analytics.&lt;/strong&gt; Cursor provides zero visibility into your usage patterns. No session data, no tool invocation logs, nothing. If you want to measure productivity, you need external tooling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IDE lock-in.&lt;/strong&gt; You're committing to a VS Code fork. JetBrains users, Vim users, and terminal purists are out of luck.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent mode maturity.&lt;/strong&gt; Composer mode is getting better but still isn't as autonomous as Claude Code for complex multi-step tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  GitHub Copilot
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; Teams already invested in the GitHub ecosystem, developers who want lightweight assistance without changing their workflow.&lt;/p&gt;

&lt;p&gt;GitHub Copilot was the pioneer of AI-assisted coding and remains the most widely deployed tool. Its strength is ubiquity — it works in VS Code, JetBrains, Neovim, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I love:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Editor agnostic.&lt;/strong&gt; Works in basically every editor. If you use JetBrains, this is one of your only options for AI assistance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Copilot Chat.&lt;/strong&gt; The chat interface has improved significantly, with support for &lt;a class="mentioned-user" href="https://dev.to/workspace"&gt;@workspace&lt;/a&gt; context and agent-based file editing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub integration.&lt;/strong&gt; PR summaries, code review suggestions, and issue-aware context set it apart for teams using GitHub heavily.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enterprise features.&lt;/strong&gt; Content exclusions, IP indemnity, and admin controls make it the easiest sell for large organizations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Trade-offs:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Completion quality.&lt;/strong&gt; In my experience, the inline completions are less context-aware than Cursor's. They work well for common patterns but struggle with project-specific conventions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent capabilities.&lt;/strong&gt; Copilot Chat's agent mode is functional but less capable than Claude Code or Cursor's Composer for complex, multi-file changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Model limitations.&lt;/strong&gt; Tied to OpenAI models (GPT-4o, o1). No option to use Claude or other models.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Windsurf
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; Developers who want an AI-native IDE experience at a lower price point, teams evaluating alternatives to Cursor.&lt;/p&gt;

&lt;p&gt;Windsurf entered the market as a direct Cursor competitor with its own take on flow-based AI assistance. It emphasizes a collaborative "Cascade" mode where the AI can autonomously work through multi-step tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I love:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Generous free tier.&lt;/strong&gt; Significant free usage makes it accessible for evaluation and personal projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cascade mode.&lt;/strong&gt; Similar to Claude Code's agent workflow but within an IDE — reads files, runs commands, and iterates on errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Competitive pricing.&lt;/strong&gt; At $15/mo for Pro, it undercuts Cursor by $5/month with comparable features.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Trade-offs:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Newer ecosystem.&lt;/strong&gt; Fewer community resources, tutorials, and established patterns compared to Cursor and Copilot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extension compatibility.&lt;/strong&gt; As a VS Code fork, most extensions work, but some niche extensions may have issues.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Release cadence.&lt;/strong&gt; Ships less frequently than Claude Code and Cursor.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Gemini CLI and Codex CLI
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; Developers who want terminal-native AI assistance with different model providers.&lt;/p&gt;

&lt;p&gt;Both Gemini CLI (Google) and Codex CLI (OpenAI) offer Claude Code-style terminal experiences with their respective model families.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gemini CLI&lt;/strong&gt; is notable for its free tier with generous rate limits and strong multimodal capabilities (image understanding, document analysis). If you're in the Google Cloud ecosystem, the integration is natural.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Codex CLI&lt;/strong&gt; provides access to OpenAI's latest models in a terminal workflow. It's open source and highly customizable, but requires API credits and doesn't match Claude Code's agent sophistication.&lt;/p&gt;

&lt;h2&gt;
  
  
  Head-to-Head: What I Use and When
&lt;/h2&gt;

&lt;p&gt;After months of tracking my own patterns, here's how the tools map to my actual workflow:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;My Pick&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Complex refactoring (10+ files)&lt;/td&gt;
&lt;td&gt;Claude Code&lt;/td&gt;
&lt;td&gt;Agent autonomy, git integration, hooks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Quick inline edits&lt;/td&gt;
&lt;td&gt;Cursor&lt;/td&gt;
&lt;td&gt;Cmd+K is unbeatable for targeted changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;New feature implementation&lt;/td&gt;
&lt;td&gt;Claude Code&lt;/td&gt;
&lt;td&gt;Plans, implements, tests in one session&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Code review preparation&lt;/td&gt;
&lt;td&gt;Claude Code&lt;/td&gt;
&lt;td&gt;Reads entire PR diff, suggests improvements&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rapid prototyping&lt;/td&gt;
&lt;td&gt;Cursor&lt;/td&gt;
&lt;td&gt;Tab completion accelerates the iteration loop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Learning unfamiliar codebase&lt;/td&gt;
&lt;td&gt;Claude Code&lt;/td&gt;
&lt;td&gt;Can explore, explain, and map dependencies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Boilerplate generation&lt;/td&gt;
&lt;td&gt;Cursor or Copilot&lt;/td&gt;
&lt;td&gt;Inline completion handles repetitive patterns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CI/CD and DevOps&lt;/td&gt;
&lt;td&gt;Claude Code&lt;/td&gt;
&lt;td&gt;Terminal-native, can run and debug pipelines&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How to Choose
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Choose Claude Code if:&lt;/strong&gt; You're a terminal-native developer, you work on complex projects with multi-file changes, you want deep customization through hooks and CLAUDE.md, or you need an AI tool that can operate autonomously on larger tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Choose Cursor if:&lt;/strong&gt; You prefer an IDE-based workflow, you value inline completions and quick edits, you want the lowest friction path from VS Code, or your work is primarily focused on single-file changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Choose GitHub Copilot if:&lt;/strong&gt; Your team is standardized on GitHub, you need enterprise features and IP indemnity, you use JetBrains IDEs, or you want the most broadly supported option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Choose Windsurf if:&lt;/strong&gt; You want a Cursor-like experience at a lower price, you're evaluating alternatives, or the free tier fits your usage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My recommendation for most developers:&lt;/strong&gt; Use Claude Code for complex work AND an IDE-based tool (Cursor or Copilot) for inline editing. They're complementary, not competing. The best developers I know use 2-3 tools depending on the task.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is the best AI coding tool in 2026?
&lt;/h3&gt;

&lt;p&gt;There is no single best tool — it depends on your workflow. Claude Code excels at complex multi-file refactoring and autonomous agent tasks. Cursor is best for inline editing and rapid prototyping in an IDE. GitHub Copilot offers the broadest editor support and strongest enterprise features. Most productive developers use 2-3 tools depending on the task.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between Claude Code and Cursor?
&lt;/h3&gt;

&lt;p&gt;Claude Code is a terminal-native CLI that operates as an autonomous agent — it reads files, writes code, runs commands, and iterates on errors in a conversation-based workflow. Cursor is a VS Code fork with deeply integrated inline AI — tab completion, Cmd+K edits, and a Composer mode for larger changes. Claude Code is better for complex multi-file changes; Cursor is faster for targeted single-file edits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is GitHub Copilot still worth it in 2026?
&lt;/h3&gt;

&lt;p&gt;Yes, particularly for teams standardized on GitHub and JetBrains IDEs. Copilot offers the broadest editor support, enterprise features (IP indemnity, content exclusions), and tight GitHub integration (PR summaries, code review). However, for complex autonomous coding tasks, Claude Code and Cursor's Composer mode are more capable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can you use Claude Code and Cursor together?
&lt;/h3&gt;

&lt;p&gt;Yes, and many developers do. Claude Code handles complex multi-file changes, architectural refactoring, and CI/CD tasks from the terminal. Cursor handles inline edits, tab completion, and rapid prototyping in the IDE. They're complementary, not competing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Staying Current
&lt;/h2&gt;

&lt;p&gt;These tools ship fast. Claude Code, Cursor, and Windsurf all release at least weekly. If you're not tracking releases, you're missing features that could change your workflow.&lt;/p&gt;

&lt;p&gt;I built &lt;a href="https://havoptic.com" rel="noopener noreferrer"&gt;Havoptic&lt;/a&gt; specifically for this problem — it aggregates releases from all major AI coding tools into a visual timeline with AI-generated infographics. No more reading changelogs. And if you want to measure which tools actually make you more productive, check out &lt;a href="https://scotthavird.com/blog/promptconduit-ai-assistant-analytics/" rel="noopener noreferrer"&gt;PromptConduit&lt;/a&gt; and the &lt;a href="https://scotthavird.com/blog/measure-ai-coding-productivity/" rel="noopener noreferrer"&gt;measurement framework&lt;/a&gt; I've published.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This comparison reflects the state of these tools as of April 2026. Given the rapid pace of development, specific capabilities may have changed. Check &lt;a href="https://havoptic.com" rel="noopener noreferrer"&gt;Havoptic&lt;/a&gt; for the latest releases.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/claude-code-hooks-guide/" rel="noopener noreferrer"&gt;Claude Code Hooks: A Complete Guide&lt;/a&gt; — Automating your AI coding workflow&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/measure-ai-coding-productivity/" rel="noopener noreferrer"&gt;How to Measure AI Coding Productivity&lt;/a&gt; — Framework for measuring AI tool impact&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/havoptic-visual-release-tracker-ai-tools/" rel="noopener noreferrer"&gt;Havoptic: Visual Release Tracker&lt;/a&gt; — Track AI coding tool releases visually&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/promptconduit-ai-assistant-analytics/" rel="noopener noreferrer"&gt;PromptConduit: Building Analytics for AI Coding Assistants&lt;/a&gt; — Analytics for AI coding interactions&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article was created with the help of AI.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://scotthavird.com/blog/ai-coding-tool-comparison-2026/" rel="noopener noreferrer"&gt;scotthavird.com&lt;/a&gt;. Follow me on &lt;a href="https://x.com/scotthavird" rel="noopener noreferrer"&gt;X&lt;/a&gt; and &lt;a href="https://github.com/scotthavird" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>development</category>
      <category>claudecode</category>
      <category>cursor</category>
    </item>
    <item>
      <title>Claude Code Hooks: Automating Your AI Coding Workflow</title>
      <dc:creator>Scott Havird</dc:creator>
      <pubDate>Thu, 05 Nov 2026 18:41:36 +0000</pubDate>
      <link>https://dev.to/scotthavird/claude-code-hooks-automating-your-ai-coding-workflow-agi</link>
      <guid>https://dev.to/scotthavird/claude-code-hooks-automating-your-ai-coding-workflow-agi</guid>
      <description>&lt;h2&gt;
  
  
  Claude Code Hooks: A Complete Guide to Automating Your AI Coding Workflow
&lt;/h2&gt;

&lt;p&gt;If you've been using Claude Code for more than a week, you've probably noticed a pattern: you keep telling it the same things. "Run prettier after editing." "Don't touch the .env file." "Run the tests before you stop." These aren't complex instructions — they're rules. And rules shouldn't depend on an LLM remembering to follow them.&lt;/p&gt;

&lt;p&gt;That's exactly what Claude Code hooks solve. They're deterministic automation that runs at specific points in Claude Code's lifecycle, executed by the harness itself — not by Claude. If you configure a hook to format code after every edit, it will format code after every edit. No exceptions. No "I forgot."&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Hooks, Really?
&lt;/h2&gt;

&lt;p&gt;Hooks are shell commands, HTTP endpoints, or LLM prompts that fire automatically when specific events happen in Claude Code. Think of them like git hooks, but for your AI coding assistant.&lt;/p&gt;

&lt;p&gt;The key distinction is reliability:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CLAUDE.md instructions&lt;/strong&gt; = Claude &lt;em&gt;should&lt;/em&gt; do this (but might forget)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hooks&lt;/strong&gt; = The system &lt;em&gt;will&lt;/em&gt; do this (deterministic, every time)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hooks are configured in &lt;code&gt;settings.json&lt;/code&gt; files at three scopes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Project&lt;/strong&gt; (&lt;code&gt;.claude/settings.json&lt;/code&gt;) — shared with your team via git&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local&lt;/strong&gt; (&lt;code&gt;.claude/settings.local.json&lt;/code&gt;) — personal, gitignored&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Global&lt;/strong&gt; (&lt;code&gt;~/.claude/settings.json&lt;/code&gt;) — applies to all projects&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Hook Lifecycle
&lt;/h2&gt;

&lt;p&gt;Claude Code exposes 27 lifecycle events. Here are the ones that matter most for day-to-day development:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Event&lt;/th&gt;
&lt;th&gt;When It Fires&lt;/th&gt;
&lt;th&gt;Best Use Case&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;PreToolUse&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Before a tool runs&lt;/td&gt;
&lt;td&gt;Block dangerous commands, validate file edits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;PostToolUse&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;After a tool succeeds&lt;/td&gt;
&lt;td&gt;Auto-format code, log activity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;PermissionRequest&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Permission dialog appears&lt;/td&gt;
&lt;td&gt;Auto-approve safe operations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Stop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Claude finishes a response&lt;/td&gt;
&lt;td&gt;Run tests, type checking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Notification&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Claude needs attention&lt;/td&gt;
&lt;td&gt;Desktop notifications, Slack alerts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SessionStart&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Session begins or resumes&lt;/td&gt;
&lt;td&gt;Load environment, re-inject context&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;CwdChanged&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Directory changes&lt;/td&gt;
&lt;td&gt;Reload env vars with direnv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;FileChanged&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Watched file changes&lt;/td&gt;
&lt;td&gt;React to .env or config changes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each event can be filtered with a &lt;strong&gt;matcher&lt;/strong&gt; — a regex pattern that narrows which specific tools or sources trigger the hook.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration Format
&lt;/h2&gt;

&lt;p&gt;Here's the basic structure in &lt;code&gt;.claude/settings.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"EventName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"regex_pattern"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"your-script.sh"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"timeout"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hooks receive JSON context on stdin (tool name, arguments, file paths) and communicate back through exit codes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Exit 0&lt;/strong&gt; = success, allow the action&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exit 2&lt;/strong&gt; = block the action, with feedback to Claude via stderr&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Practical Patterns That Actually Work
&lt;/h2&gt;

&lt;p&gt;I've been running hooks across my projects for months now. Here are the patterns that have stuck.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pattern 1: Auto-Format After Every Edit
&lt;/h3&gt;

&lt;p&gt;This is the single most impactful hook. Claude writes code, and it's immediately formatted to your project's standards. No more "can you run prettier on that?"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"PostToolUse"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Edit|Write"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jq -r '.tool_input.file_path' | xargs npx prettier --write 2&amp;gt;/dev/null"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"timeout"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The hook reads the file path from the tool's JSON input and runs prettier on it. Works with any formatter — swap in &lt;code&gt;black&lt;/code&gt; for Python, &lt;code&gt;gofmt&lt;/code&gt; for Go, &lt;code&gt;rustfmt&lt;/code&gt; for Rust.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pattern 2: Protect Sensitive Files
&lt;/h3&gt;

&lt;p&gt;Some files should never be edited by an AI assistant. Period.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.claude/hooks/protect-files.sh&lt;/code&gt;:&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="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nv"&gt;INPUT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;FILE_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$INPUT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | jq &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'.tool_input.file_path // empty'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;PROTECTED&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;&lt;span class="s2"&gt;".env"&lt;/span&gt; &lt;span class="s2"&gt;".env.local"&lt;/span&gt; &lt;span class="s2"&gt;"secrets.yml"&lt;/span&gt; &lt;span class="s2"&gt;"credentials.json"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;pattern &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PROTECTED&lt;/span&gt;&lt;span class="p"&gt;[@]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$FILE_PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$pattern&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Blocked: &lt;/span&gt;&lt;span class="nv"&gt;$FILE_PATH&lt;/span&gt;&lt;span class="s2"&gt; is a protected file"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="nb"&gt;exit &lt;/span&gt;2
  &lt;span class="k"&gt;fi
done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"PreToolUse"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Edit|Write"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;".claude/hooks/protect-files.sh"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit code 2 blocks the action and sends the stderr message back to Claude as feedback, so it knows &lt;em&gt;why&lt;/em&gt; it was blocked and can adjust.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pattern 3: Desktop Notifications
&lt;/h3&gt;

&lt;p&gt;When Claude finishes a task or needs input, you want to know — especially if you've tabbed away to something else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;macOS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Notification"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"osascript -e 'display notification &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Claude Code needs your attention&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; with title &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Claude Code&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;'"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Notification"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"notify-send 'Claude Code' 'Claude needs your attention'"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pattern 4: Quality Gates Before Stopping
&lt;/h3&gt;

&lt;p&gt;This is where hooks get powerful. Instead of hoping Claude remembers to run tests, you can &lt;em&gt;require&lt;/em&gt; it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Stop"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"agent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Run the project's test suite and type checker. If any tests fail or type errors exist, respond with {&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;ok&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;: false, &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;reason&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;description of failures&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;}. If everything passes, respond with {&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;ok&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;: true}."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"timeout"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;agent&lt;/code&gt; hook type spins up a subagent with full tool access. If it returns &lt;code&gt;ok: false&lt;/code&gt;, Claude continues working to fix the issues instead of stopping. This is a game-changer for code quality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Check the &lt;code&gt;stop_hook_active&lt;/code&gt; field in the Stop event input to prevent infinite loops — if your Stop hook triggers Claude to do more work, which triggers another Stop, you'd loop forever.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pattern 5: Re-inject Context After Compaction
&lt;/h3&gt;

&lt;p&gt;Long sessions hit the context window limit, and Claude compacts (summarizes) the conversation. Critical context can get lost. Fix it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"SessionStart"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"compact"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"cat .claude/critical-context.md"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whatever your hook outputs to stdout gets injected into Claude's context. Keep a &lt;code&gt;.claude/critical-context.md&lt;/code&gt; file with must-remember information, and it survives compaction automatically.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pattern 6: Auto-Approve Safe Operations
&lt;/h3&gt;

&lt;p&gt;Tired of clicking "Allow" for read-only operations? Auto-approve them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"PermissionRequest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Read|Glob|Grep"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"echo '{&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;hookSpecificOutput&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;: {&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;hookEventName&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;PermissionRequest&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;, &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;decision&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;: {&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;behavior&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;allow&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;}}}'"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pattern 7: Environment Management with direnv
&lt;/h3&gt;

&lt;p&gt;If your project uses direnv for environment variables, hooks keep Claude in sync:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"CwdChanged"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"direnv export bash &amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;$CLAUDE_ENV_FILE&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"FileChanged"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;".envrc|.env"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"direnv export bash &amp;gt;&amp;gt; &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;$CLAUDE_ENV_FILE&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;$CLAUDE_ENV_FILE&lt;/code&gt; variable points to a file where you can persist environment variables across the session. Writing to it with &lt;code&gt;direnv export&lt;/code&gt; keeps Claude's environment aligned with your shell.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hook Types: When to Use Each
&lt;/h2&gt;

&lt;p&gt;Claude Code supports four hook types, each suited to different needs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Execution&lt;/th&gt;
&lt;th&gt;Best For&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;command&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shell script&lt;/td&gt;
&lt;td&gt;Formatting, file protection, notifications&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;http&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;HTTP endpoint&lt;/td&gt;
&lt;td&gt;External service integration, webhooks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;prompt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Single LLM turn&lt;/td&gt;
&lt;td&gt;Quick yes/no decisions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agent&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Multi-turn subagent&lt;/td&gt;
&lt;td&gt;Complex verification (running tests, type checking)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;command&lt;/code&gt; handles 90% of use cases. Use &lt;code&gt;agent&lt;/code&gt; for Stop hooks that need to run commands and reason about results. Use &lt;code&gt;http&lt;/code&gt; for integrating with external services like Slack or custom dashboards. Use &lt;code&gt;prompt&lt;/code&gt; for lightweight LLM-based decisions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Team Configuration: What to Share
&lt;/h2&gt;

&lt;p&gt;Here's how I recommend structuring hooks for a team:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;.claude/settings.json&lt;/code&gt; (committed to git):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"PostToolUse"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Edit|Write"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jq -r '.tool_input.file_path' | xargs npx prettier --write 2&amp;gt;/dev/null"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"PreToolUse"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Edit|Write"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;".claude/hooks/protect-files.sh"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are your team's rules — formatting standards, file protection, security gates. Everyone gets them automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;.claude/settings.local.json&lt;/code&gt; (gitignored):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Notification"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"osascript -e 'display notification &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Claude needs you&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; with title &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Claude Code&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;'"&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Personal preferences like notifications and auto-approvals stay local.&lt;/p&gt;

&lt;h2&gt;
  
  
  Debugging Hooks
&lt;/h2&gt;

&lt;p&gt;When a hook isn't working:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check configuration:&lt;/strong&gt; Run &lt;code&gt;/hooks&lt;/code&gt; in Claude Code to see all registered hooks&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enable verbose mode:&lt;/strong&gt; Press &lt;code&gt;Ctrl+O&lt;/code&gt; during a session to see hook output in the transcript&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test manually:&lt;/strong&gt; Pipe sample JSON into your script:
&lt;/li&gt;
&lt;/ol&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="s1"&gt;'{"tool_name":"Edit","tool_input":{"file_path":"src/app.ts"}}'&lt;/span&gt; | .claude/hooks/protect-files.sh
   &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check permissions:&lt;/strong&gt; Ensure hook scripts are executable (&lt;code&gt;chmod +x&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Full debug mode:&lt;/strong&gt; Run &lt;code&gt;claude --debug&lt;/code&gt; for complete execution traces&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Common Pitfalls
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Shell profile noise:&lt;/strong&gt; If your &lt;code&gt;~/.zshrc&lt;/code&gt; or &lt;code&gt;~/.bashrc&lt;/code&gt; prints output (welcome messages, fortune quotes), it can interfere with hook JSON parsing. Guard with &lt;code&gt;[[ $- == *i* ]]&lt;/code&gt; checks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stop hook loops:&lt;/strong&gt; A Stop hook that causes Claude to do more work will trigger another Stop event. Always check &lt;code&gt;stop_hook_active&lt;/code&gt; in the input and return &lt;code&gt;ok: true&lt;/code&gt; if it's already active.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Matcher case sensitivity:&lt;/strong&gt; Tool names are case-sensitive. It's &lt;code&gt;Bash&lt;/code&gt;, not &lt;code&gt;bash&lt;/code&gt;. It's &lt;code&gt;Edit&lt;/code&gt;, not &lt;code&gt;edit&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parallel hook conflicts:&lt;/strong&gt; Multiple hooks on the same event run in parallel. If two PostToolUse hooks both modify the same file, only the last one to finish wins. Keep hooks independent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What are Claude Code hooks?
&lt;/h3&gt;

&lt;p&gt;Claude Code hooks are user-defined shell commands, HTTP endpoints, or LLM prompts that execute automatically at specific points in Claude Code's lifecycle. Unlike CLAUDE.md instructions which Claude may or may not follow, hooks are deterministic — they're executed by the harness, not by the AI, so they always run when triggered.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do Claude Code hooks differ from CLAUDE.md?
&lt;/h3&gt;

&lt;p&gt;CLAUDE.md provides instructions that Claude &lt;em&gt;should&lt;/em&gt; follow but might forget during long sessions or after compaction. Hooks are deterministic automation that the system &lt;em&gt;will&lt;/em&gt; execute every time. Use CLAUDE.md for guidelines and context; use hooks for rules that must never be skipped (formatting, file protection, quality gates).&lt;/p&gt;

&lt;h3&gt;
  
  
  Can Claude Code hooks block dangerous commands?
&lt;/h3&gt;

&lt;p&gt;Yes. PreToolUse hooks can inspect any command before it runs and return exit code 2 to block it. The stderr message is sent back to Claude as feedback, so it understands why the action was blocked and can adjust its approach.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I share hooks with my team?
&lt;/h3&gt;

&lt;p&gt;Configure shared hooks in &lt;code&gt;.claude/settings.json&lt;/code&gt; (committed to git) and personal hooks in &lt;code&gt;.claude/settings.local.json&lt;/code&gt; (gitignored). Team rules like formatting and file protection go in the shared config; personal preferences like notifications stay local.&lt;/p&gt;

&lt;h3&gt;
  
  
  How many hook events does Claude Code support?
&lt;/h3&gt;

&lt;p&gt;Claude Code supports 27 lifecycle events including PreToolUse, PostToolUse, PermissionRequest, Stop, Notification, SessionStart, CwdChanged, FileChanged, and more. The most commonly used are PreToolUse (security), PostToolUse (formatting), and Stop (quality gates).&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;Hooks are one piece of the Claude Code customization puzzle. Combined with &lt;a href="https://scotthavird.com/blog/claude-code-template/" rel="noopener noreferrer"&gt;CLAUDE.md patterns&lt;/a&gt;, &lt;a href="https://modelcontextprotocol.io" rel="noopener noreferrer"&gt;MCP server integrations&lt;/a&gt;, and &lt;a href="https://docs.anthropic.com/en/docs/claude-code/slash-commands" rel="noopener noreferrer"&gt;custom slash commands&lt;/a&gt;, you can build a development environment where AI assistance is deeply integrated with your team's specific workflow.&lt;/p&gt;

&lt;p&gt;The teams I've seen get the most out of AI coding tools aren't the ones with the best prompts — they're the ones who've automated the repetitive parts so they can focus on the creative work. Hooks are the foundation for that.&lt;/p&gt;




&lt;h2&gt;
  
  
  Related Posts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/claude-code-template/" rel="noopener noreferrer"&gt;Claude Code Template&lt;/a&gt; — Starter template for AI-assisted development with CLAUDE.md patterns&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/promptconduit-ai-assistant-analytics/" rel="noopener noreferrer"&gt;PromptConduit: Building Analytics for AI Coding Assistants&lt;/a&gt; — Analytics suite for understanding your AI coding patterns&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://scotthavird.com/blog/ai-agents-future-development-kolo-hackathon/" rel="noopener noreferrer"&gt;AI Agents and the Future of Development&lt;/a&gt; — Lessons from a hackathon on agent-led development&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article was created with the help of AI.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://scotthavird.com/blog/claude-code-hooks-guide/" rel="noopener noreferrer"&gt;scotthavird.com&lt;/a&gt;. Follow me on &lt;a href="https://x.com/scotthavird" rel="noopener noreferrer"&gt;X&lt;/a&gt; and &lt;a href="https://github.com/scotthavird" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>claude</category>
      <category>ai</category>
      <category>development</category>
      <category>hooks</category>
    </item>
  </channel>
</rss>
