Thursday, December 3, 2026 | London 11°C · Drizzle
DailyGlimpse

AI

Eliminate Token Waste: Use a SHA-256 State File for Idempotent Claude Code CLI Automation

SystemDR - Scalable System Design 1 min read

Running a Claude Code CLI batch script twice often results in redundant API calls and reprocessing of already completed files, wasting tokens and time. The solution is a simple SHA-256 state file — one JSON record per file tracks its hash. Before each Claude invocation, the script checks the file's current hash against the stored value. If it matches, the script skips that file entirely, consuming zero tokens and producing no duplicate diffs. This approach transforms batch automation into a production-grade, idempotent process, ensuring efficient, repeatable runs. Lesson 3.3 of the Hands-On Claude Code course provides the full implementation.

React