<?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: Michael Chuang</title>
    <description>The latest articles on DEV Community by Michael Chuang (@michael_chuang_f9e5809d21).</description>
    <link>https://dev.to/michael_chuang_f9e5809d21</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%2F4277459%2F787afd57-05cb-47ec-8801-c7130fbf8a0c.jpg</url>
      <title>DEV Community: Michael Chuang</title>
      <link>https://dev.to/michael_chuang_f9e5809d21</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/michael_chuang_f9e5809d21"/>
    <language>en</language>
    <item>
      <title>"Too Many Open Files" on macOS: When an MCP Server Ate the System File Table</title>
      <dc:creator>Michael Chuang</dc:creator>
      <pubDate>Wed, 02 Dec 2026 09:20:36 +0000</pubDate>
      <link>https://dev.to/michael_chuang_f9e5809d21/too-many-open-files-on-macos-when-an-mcp-server-ate-the-system-file-table-h8h</link>
      <guid>https://dev.to/michael_chuang_f9e5809d21/too-many-open-files-on-macos-when-an-mcp-server-ate-the-system-file-table-h8h</guid>
      <description>&lt;p&gt;One morning every build and test on my Mac mini failed — Xcode builds, Node scripts, npm. Nothing in the code had changed. The cause turned out to be a process I never started by hand: an MCP server that my coding agent had launched in the background, holding more than 61,000 open files.&lt;/p&gt;

&lt;h2&gt;
  
  
  The symptom: everything breaks at once
&lt;/h2&gt;

&lt;p&gt;When one project fails, you look at that project. When every project fails at the same moment with errors about opening files, the problem is almost never in the code. It is in the machine. That was the first useful clue.&lt;/p&gt;

&lt;p&gt;My setup runs several AI coding agents. Some of them start MCP servers — small helper programs that give the agent extra tools — automatically, in the background. You do not see them in the Dock, and you do not think about them until one misbehaves.&lt;/p&gt;

&lt;h2&gt;
  
  
  The wrong turn: ulimit -n
&lt;/h2&gt;

&lt;p&gt;"Too many open files" sends most people, including me, straight to &lt;code&gt;ulimit -n&lt;/code&gt;. On my machine it returned 1,048,576. That is the per-process limit, and it was nowhere near being hit by any one build.&lt;/p&gt;

&lt;p&gt;The real limit was a different one. macOS also has a &lt;strong&gt;system-wide&lt;/strong&gt; cap on open files shared by every process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;kern.maxfiles&lt;/code&gt; — the system-wide maximum (122,880 on my machine).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kern.num_files&lt;/code&gt; — how many are open right now (68,642 when the failures started).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One process with a very high per-process limit can quietly fill most of the system table. Every other program then fails to open files, even though none of them is doing anything wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding the culprit in four commands
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Is the system table nearly full?&lt;/strong&gt;
&lt;code&gt;sysctl kern.maxfiles kern.num_files&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Which process holds the most files?&lt;/strong&gt;
&lt;code&gt;lsof | awk '{print $2}' | sort | uniq -c | sort -rn | head -5&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who started it?&lt;/strong&gt;
&lt;code&gt;ps -o ppid,command -p &amp;lt;pid&amp;gt;&lt;/code&gt;, then follow the parent upward.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What kind of files are leaking?&lt;/strong&gt;
&lt;code&gt;lsof -p &amp;lt;pid&amp;gt; | awk '{print $5}' | sort | uniq -c&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The answers were unambiguous. One child process held 61,446 file descriptors; 61,431 of them were regular files. The same file appeared over and over — one file was open 120 times. That is the signature of a leak: files opened and never closed.&lt;/p&gt;

&lt;p&gt;Following the parent chain led to a code-indexing MCP server. The Codex desktop app had launched it from my agent configuration, and it was indexing a large folder under my Documents directory. The other instances of the same server were fine, with a dozen to thirty-odd open files each. Only the one indexing that large path had run away.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix, and what it does not fix
&lt;/h2&gt;

&lt;p&gt;Killing that one indexing child process was enough. Its parent exited with it, and the coding agent itself kept running. &lt;code&gt;kern.num_files&lt;/code&gt; dropped from 68,642 to 7,194, and builds and tests worked again immediately.&lt;/p&gt;

&lt;p&gt;That is a stop-gap, not a cure. The agent will start the server again the next time it calls one of its tools, and it may leak again. I have not yet verified a permanent fix. The three options I am weighing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Disable that MCP server in the agent's configuration when I am not using it.&lt;/li&gt;
&lt;li&gt;Point it at a much smaller folder instead of a whole Documents tree.&lt;/li&gt;
&lt;li&gt;Upgrade or reinstall the tool and check whether a newer version still leaks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I am describing what I observed with the version I had installed. I have not traced the leak inside the tool's source, so I am not claiming where exactly it comes from.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two different problems on the same morning
&lt;/h2&gt;

&lt;p&gt;The same day, my 16 GB machine had also run out of memory earlier, which crashed an agent session. It was tempting to blame the build failures on that too. They were unrelated: memory was fine by then, and the file table was the bottleneck. Measuring the specific resource — not the one that failed last time — kept me from fixing the wrong thing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I changed in how I work
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;When everything fails at once, check the machine before the code.&lt;/strong&gt; Shared limits produce failures that look like unrelated bugs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Know which limit you are reading.&lt;/strong&gt; &lt;code&gt;ulimit -n&lt;/code&gt; is per process. &lt;code&gt;kern.num_files&lt;/code&gt; against &lt;code&gt;kern.maxfiles&lt;/code&gt; is the whole system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remember what your agents start.&lt;/strong&gt; MCP servers launched by coding agents are real processes with real resource use, running whether you are looking or not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep indexing scopes small.&lt;/strong&gt; A tool told to index an entire home folder has a lot of files to mishandle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write the diagnosis down.&lt;/strong&gt; I saved the four commands as a note my agents can search, so the next time this happens the first step is measuring, not guessing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The broader lesson is the same one I keep relearning with AI tooling: the agent is not just the chat window. It is every process it starts on your machine.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on my site: &lt;a href="https://mm7382.github.io/pec-ai-agent-training/journal-mcp-server-file-descriptor-leak.html" rel="noopener noreferrer"&gt;https://mm7382.github.io/pec-ai-agent-training/journal-mcp-server-file-descriptor-leak.html&lt;/a&gt;.&lt;/em&gt; Related: &lt;a href="https://dev.to/michael_chuang_f9e5809d21/where-the-tokens-actually-go-measuring-a-claude-code-session-4kld"&gt;Where the tokens actually go: measuring a Claude Code session&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>debugging</category>
      <category>ai</category>
      <category>devops</category>
    </item>
    <item>
      <title>Why Claude Code Felt Dumber Than Codex on My Machine (It Wasn't the Model)</title>
      <dc:creator>Michael Chuang</dc:creator>
      <pubDate>Wed, 02 Dec 2026 08:49:39 +0000</pubDate>
      <link>https://dev.to/michael_chuang_f9e5809d21/why-claude-code-felt-dumber-than-codex-on-my-machine-it-wasnt-the-model-54g8</link>
      <guid>https://dev.to/michael_chuang_f9e5809d21/why-claude-code-felt-dumber-than-codex-on-my-machine-it-wasnt-the-model-54g8</guid>
      <description>&lt;p&gt;For months I had the same complaint: Claude Code builds the wrong thing, fast. Codex, on the same Mac and with the same person giving instructions, mostly did what I meant. I assumed one model was simply better. When I finally compared the two setups side by side, the gap was in files I had written myself.&lt;/p&gt;

&lt;h2&gt;
  
  
  The symptom
&lt;/h2&gt;

&lt;p&gt;The pattern was consistent. I would describe a task to Claude Code and it would start editing files right away. The result was often reasonable code that solved a slightly different problem from the one I had in mind. Codex, given similar requests, tended to ask questions first, propose options and only start once we had agreed on something.&lt;/p&gt;

&lt;p&gt;It is easy to turn that into a verdict about the models. Before doing that, I compared what each agent was actually told at the start of every session.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I compared
&lt;/h2&gt;

&lt;p&gt;Both agents read a personal instruction file on startup: &lt;code&gt;AGENTS.md&lt;/code&gt; for Codex and &lt;code&gt;CLAUDE.md&lt;/code&gt; for Claude Code. I had written both over time, and I assumed they said roughly the same thing. They did not.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Codex had a hard gate.&lt;/strong&gt; Its file contained a section saying: if no specific skill fits the task, do not implement. Run a discussion loop first, and only change anything once there is a clear decision, a spec, a ticket breakdown or an explicit go-ahead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Claude Code had only style rules.&lt;/strong&gt; Its file covered tone (explain simply, offer five options when I need to decide) and "test before claiming something works". Nothing said to stop and discuss before acting. So, reasonably, it acted.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The comparison turned up more gaps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Codex had a rule to search code structurally with a code-graph tool before guessing; Claude Code had no such rule, so it fell back to keyword searches.&lt;/li&gt;
&lt;li&gt;Codex was told not to ask me whether things should be renamed; Claude Code kept asking.&lt;/li&gt;
&lt;li&gt;Codex had 71 skills installed, Claude Code 21. The missing ones were exactly the phase-gate skills: clarify into a spec, split a spec into tickets, implement one ticket.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In other words, I had given one agent a process and the other a personality. The one with the process looked smarter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 1: add the missing gate
&lt;/h2&gt;

&lt;p&gt;Of the options I considered, I chose the smallest: add only the gate, not a full copy of the other setup. Two new sections went into &lt;code&gt;CLAUDE.md&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Discuss before implementing.&lt;/strong&gt; Code changes, architecture decisions, refactors, config changes, moving or deleting files and publishing all need a clear decision first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Three exceptions&lt;/strong&gt;, so the gate does not become friction: read-only checks, a task where I have already named the exact action and target in this message, and the necessary next steps of work I have already approved. Approval covers that piece of work only; it does not stretch to the next one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Don't proactively ask about renaming.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One detail worth knowing: the instruction file is loaded when a session starts. Editing it mid-session changes nothing until the next session.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 2: instructions are not enforcement
&lt;/h2&gt;

&lt;p&gt;The second problem was subtler. My &lt;code&gt;CLAUDE.md&lt;/code&gt; already said "route every non-trivial request through the skill router first". In practice Claude Code often went through a whole session without loading a single skill. Twice in one day I asked it to "give me options" and it never entered the discussion skill built for exactly that.&lt;/p&gt;

&lt;p&gt;When I looked, the router had no teeth. There were no hooks configured at all, so routing depended entirely on the model remembering a paragraph in a long file. Worse, routing was never measured on the Claude side: every logged routing event came from Codex, so the gap was invisible in my reports. Codex was not perfect either — its own measured hit rate for the discussion skill was only 2 out of 6 in the same period.&lt;/p&gt;

&lt;p&gt;The fix was a &lt;code&gt;UserPromptSubmit&lt;/code&gt; hook: a small script that runs on every message before the model sees it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It checks the message for trigger phrases such as "give me options", "compare", "help me decide" or "clarify first". On a match it injects the full text of the discussion skill into the context.&lt;/li&gt;
&lt;li&gt;Phrases like "last time", "did we decide" or "is there a record" inject a reminder to search my knowledge base first, and to say plainly when nothing is found.&lt;/li&gt;
&lt;li&gt;The trigger list is deliberately broad. A false trigger costs a few hundred tokens; a missed one costs a wrong implementation.&lt;/li&gt;
&lt;li&gt;It only reads the message to match keywords, then discards it. It writes nothing to disk and makes no network calls.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I tested it against a nine-case matrix — each trigger alone, both together, and three ordinary edit requests that must stay silent — and all nine passed.&lt;/p&gt;

&lt;p&gt;One trap while testing: piping JSON into the hook with &lt;code&gt;echo&lt;/code&gt; in zsh failed with a parse error, because zsh's built-in &lt;code&gt;echo&lt;/code&gt; expands &lt;code&gt;\n&lt;/code&gt; into real newlines. That looked exactly like a bug in the hook. Using &lt;code&gt;printf&lt;/code&gt;, or passing input from a script, fixed it. The tool was wrong, not the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changed afterwards
&lt;/h2&gt;

&lt;p&gt;Since the gate went in, Claude Code opens most tasks by saying which workflow it chose and whether it can start yet, and it asks before building. I have not run a formal before-and-after benchmark, so I will not claim a number. The visible change is in the order of work: a decision comes first, then the edit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check your own setup
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Diff your instruction files.&lt;/strong&gt; Put your &lt;code&gt;CLAUDE.md&lt;/code&gt; and &lt;code&gt;AGENTS.md&lt;/code&gt; side by side. Look for rules one agent has and the other doesn't — especially rules about when &lt;em&gt;not&lt;/em&gt; to act.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Separate style from process.&lt;/strong&gt; Tone rules make answers nicer. Gate rules change what the agent does. If one file only has style, expect that agent to act first and ask later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write exceptions into the gate.&lt;/strong&gt; Read-only work and explicitly specified edits should not need a discussion, or you will start ignoring the gate yourself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enforce what matters with hooks.&lt;/strong&gt; A rule the model must remember is a suggestion. A hook that runs on every message is a mechanism.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure both sides.&lt;/strong&gt; If only one agent's behaviour is logged, the other one's failures are invisible.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Start a new session after editing instructions.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Before you conclude that one coding agent is dumber than another, check what each one is told. Mine were not running the same race.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on my site: &lt;a href="https://mm7382.github.io/pec-ai-agent-training/journal-why-claude-code-felt-dumber.html" rel="noopener noreferrer"&gt;https://mm7382.github.io/pec-ai-agent-training/journal-why-claude-code-felt-dumber.html&lt;/a&gt;.&lt;/em&gt; Related: &lt;a href="https://dev.to/michael_chuang_f9e5809d21/claude-code-writes-codex-reviews-a-two-agent-workflow-that-doesnt-fight-317c"&gt;Claude Code writes, Codex reviews&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>productivity</category>
      <category>llm</category>
    </item>
    <item>
      <title>Claude Code Writes, Codex Reviews: A Two-Agent Workflow That Doesn't Fight</title>
      <dc:creator>Michael Chuang</dc:creator>
      <pubDate>Wed, 02 Dec 2026 08:48:39 +0000</pubDate>
      <link>https://dev.to/michael_chuang_f9e5809d21/claude-code-writes-codex-reviews-a-two-agent-workflow-that-doesnt-fight-317c</link>
      <guid>https://dev.to/michael_chuang_f9e5809d21/claude-code-writes-codex-reviews-a-two-agent-workflow-that-doesnt-fight-317c</guid>
      <description>&lt;p&gt;People keep asking whether Claude Code or Codex is better. On my own iOS apps I stopped choosing. One agent writes the code; the other only judges it, and neither is allowed to touch the other's work. Here is how the split works, what a handoff looks like, and the failures that taught me the rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why one agent is not enough
&lt;/h2&gt;

&lt;p&gt;A single coding agent grades its own homework. It writes a feature, runs the checks it thinks of, and reports success. The problem is not that it lies; it is that the same model that made an assumption is the one checking whether the assumption holds. Blind spots survive the review because the reviewer has the same blind spots.&lt;/p&gt;

&lt;p&gt;Two agents from different vendors, trained differently, disagree in useful ways. But only if their roles are separated. When both can edit the code, you get the opposite of review: two authors overwriting each other, double the tokens and nobody clearly responsible for the result.&lt;/p&gt;

&lt;h2&gt;
  
  
  The split: one writes, one judges
&lt;/h2&gt;

&lt;p&gt;Since late September 2026 this is the default for my app projects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Me and Codex:&lt;/strong&gt; we discuss only product direction, the spec, risks and acceptance criteria. Codex acts as a coach, not a coder.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Claude Code:&lt;/strong&gt; writes all the code, fixes it, runs its own tests and keeps the handoff notes up to date.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Codex again, as the independent reviewer:&lt;/strong&gt; when a ticket is done, it checks a fixed scope and gives each item one verdict: PASS, FAIL or "needs discussion".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Me:&lt;/strong&gt; product decisions, testing on a real device, anything that needs an account, and the final release.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The rule that makes it work: &lt;strong&gt;the reviewer never edits code.&lt;/strong&gt; It returns verdicts, not patches. If Codex could "just fix it", I would lose the independent check the whole setup exists for.&lt;/p&gt;

&lt;p&gt;The roles are not tied to the brand. On one game project I flipped them: Codex led spec, code and daily tests, and Claude Code did a single read-only final review once the release candidate was frozen. The principle is the same — one author, one judge — and it avoided the trap of both agents rewriting the same code in parallel.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a FAIL has to contain
&lt;/h2&gt;

&lt;p&gt;A verdict of "this looks wrong" sends the writer on a hunt, and hunts are expensive. So a FAIL must include three things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Where:&lt;/strong&gt; the file and line.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What kind of defect:&lt;/strong&gt; the implementation drifted from the spec, the plan itself needs updating, or the evidence or documentation is wrong.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The pass condition:&lt;/strong&gt; exactly what has to be true for the item to pass next time.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The defect type turned out to matter more than I expected. "The code is wrong" and "the spec was wrong" need different fixes, and mixing them up makes the writer change correct code to match a wrong plan.&lt;/p&gt;

&lt;p&gt;Re-reviews are narrow: only the failed items and whatever they touch. An item is skipped on re-review only if the related code, spec, dependencies and evidence are all unchanged — a bumped version number alone is not proof that nothing changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the handoff small
&lt;/h2&gt;

&lt;p&gt;The handoff message between the agents is a pointer, not a payload. It names the review document and the question numbers, and stays around 1–2 KB. No pasted source code, no pasted test output. The reviewer opens the files itself.&lt;/p&gt;

&lt;p&gt;There is exactly one active review document per topic. New findings are appended as new sections; when a judgement is overturned it is marked "withdrawn", not deleted, so the history of why something changed survives. This also keeps the token bill down: large pasted content in a conversation is paid for again on every later turn.&lt;/p&gt;

&lt;h2&gt;
  
  
  A real review: three FAILs that were not bugs
&lt;/h2&gt;

&lt;p&gt;One of my apps turns rules from classical Chinese almanac texts into daily suggestions. Codex failed several items in one module, and none of them were code bugs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Behaviour changed, labels didn't.&lt;/strong&gt; A rule's input was changed, but the ruleset version, the rule version, the documentation and the warning shown to users were not all updated together. Four places disagreed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A claim pointed the wrong way.&lt;/strong&gt; The notes said skipping one check made the rule narrower. It actually made it broader — it matched more cases, not fewer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An inference was presented as the source.&lt;/strong&gt; A conclusion drawn from the text was written up as if the text said it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A single agent reviewing itself would almost certainly have passed all three, because the code did what the author intended. The reviewer's job was to check the claims around the code, and that is where the errors were.&lt;/p&gt;

&lt;p&gt;One more finding from that review changed how I write tests. An assertion that a list of results was empty did not prove the rule worked, because the list would also have been empty for unrelated reasons. The fix was a control case: the same input on a day the rule should not trigger must produce results. Only then does an empty list mean something. After three rounds of review all six items passed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Automating the handoff without letting agents drive each other
&lt;/h2&gt;

&lt;p&gt;At first I copied every verdict from one window to the other by hand. I did not want one agent remote-controlling the other's app, and I did not want extra sessions spawned in the background.&lt;/p&gt;

&lt;p&gt;The solution is a small local mailbox inside the project's git folder, outside version control and off the network. Codex publishes a verdict tied to a specific commit; a content hash stops duplicates. Claude Code waits on the mailbox with its own monitor. On PASS it moves to the next ticket; on FAIL it fixes only the listed items. Nothing is pushed or released automatically — those steps stay with me.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it costs, and why it is still cheaper
&lt;/h2&gt;

&lt;p&gt;Two agents cost more per ticket than one. But the expensive line on my bill is rework. In one measured case a single ticket was built three times, and the two rework runs used about 60% of its total tokens because the agent could not verify its own work. An independent reviewer with clear pass conditions catches problems while the context is still fresh, instead of after a second full rebuild.&lt;/p&gt;

&lt;h2&gt;
  
  
  A checklist to try it
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pick an author and a judge per project.&lt;/strong&gt; Never let both edit the same code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agree on acceptance criteria before any code is written.&lt;/strong&gt; The reviewer judges against them, not against taste.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Every FAIL names a location, a defect type and a pass condition.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Re-review only what changed&lt;/strong&gt;, and decide "unchanged" from code, spec and evidence, not version numbers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep handoffs as pointers&lt;/strong&gt;: a document path and item numbers, not pasted content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tests need a control case&lt;/strong&gt;, or an empty result proves nothing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the human gate&lt;/strong&gt; for device tests, accounts and release.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Claude Code versus Codex is the wrong comparison. The useful question is which one writes and which one is allowed to say no.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on my site: &lt;a href="https://mm7382.github.io/pec-ai-agent-training/journal-claude-code-writes-codex-reviews.html" rel="noopener noreferrer"&gt;https://mm7382.github.io/pec-ai-agent-training/journal-claude-code-writes-codex-reviews.html&lt;/a&gt;.&lt;/em&gt; Related: &lt;a href="https://mm7382.github.io/pec-ai-agent-training/journal-where-the-tokens-go.html" rel="noopener noreferrer"&gt;Where the tokens actually go: measuring a Claude Code session&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>codereview</category>
      <category>ai</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Where the Tokens Actually Go: Measuring a Claude Code Session</title>
      <dc:creator>Michael Chuang</dc:creator>
      <pubDate>Wed, 02 Dec 2026 07:36:10 +0000</pubDate>
      <link>https://dev.to/michael_chuang_f9e5809d21/where-the-tokens-actually-go-measuring-a-claude-code-session-4kld</link>
      <guid>https://dev.to/michael_chuang_f9e5809d21/where-the-tokens-actually-go-measuring-a-claude-code-session-4kld</guid>
      <description>&lt;p&gt;One question in Claude Code was eating about 4% of my context window. I was sure the cause was the pile of MCP servers and connectors I had installed. I was wrong. Here is what measuring showed, and the one rule that now decides what I optimise.&lt;/p&gt;

&lt;h2&gt;
  
  
  The suspect everyone blames
&lt;/h2&gt;

&lt;p&gt;My setup is crowded. Claude Code writes code, Codex reviews it, and both share one knowledge base through an MCP server. On top of that the desktop app has connectors for design tools, mail, a browser extension and computer control. When a single question started costing a visible slice of the context window, the obvious move was to disconnect things.&lt;/p&gt;

&lt;p&gt;Before deleting anything, I measured one real working session instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  What one 82k-token session was made of
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Messages: about 60k tokens (73%).&lt;/strong&gt; The back-and-forth itself — my questions, the agent's answers and every tool result that landed in the conversation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fixed overhead: about 22k tokens in total.&lt;/strong&gt; MCP tool definitions about 7.7k, skills about 6k, memory files about 4.2k, system prompt about 2.5k.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deferred connectors: zero.&lt;/strong&gt; The design, mail, browser and computer-control connectors were listed by name only. Their full definitions — about 165k tokens' worth — were never loaded, because the agent fetches a tool's schema only when it is about to use it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the thing I was about to rip out cost nothing, and the expensive part was something I had not even looked at.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule: paid every turn vs. paid once
&lt;/h2&gt;

&lt;p&gt;The fixed overhead is paid at the start of a session and then served from the prompt cache. Messages are different: everything that enters the conversation is re-read on every later turn. A 5,000-token tool result on turn 3 of a 40-turn session is not a 5,000-token cost. It rides along for the other 37 turns.&lt;/p&gt;

&lt;p&gt;That gives one question to ask about any token cost: &lt;strong&gt;is this paid once, or paid every turn?&lt;/strong&gt; Optimise the second kind first. Almost every useful fix I found came from this split.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 1: the search reply that was nine times too big
&lt;/h2&gt;

&lt;p&gt;The biggest per-turn item was my own knowledge-base search. Each call returned eight results, and each result carried its full metadata: score breakdowns, excerpts, related links, privacy flags, timestamps and supersession chains. One search reply was over 9,000 bytes. The agent only needed a title and a one-line summary to decide what to open next.&lt;/p&gt;

&lt;p&gt;The fix was small:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A slim result shape for search only: ID, title, path, kind, status, date, a 160-character summary and the score.&lt;/li&gt;
&lt;li&gt;Default results cut from 8 to 4.&lt;/li&gt;
&lt;li&gt;The tool description now says: read the summaries first, then fetch one full note on purpose.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same query went from 9,000+ bytes to about 1,560 — roughly 83% smaller. Full notes are still one call away, so nothing was lost. Because Claude Code and Codex share the same search function, both agents got the saving at once.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 2: my own formatting rules were inflating the context
&lt;/h2&gt;

&lt;p&gt;The second surprise was embarrassing. I had asked my agents to present every decision as five options, each assessed on effect, risk, cost, maintenance and fit. That made every option a small essay. Those essays were messages, so they were re-read for the rest of the session.&lt;/p&gt;

&lt;p&gt;I kept the five options and cut each one to a single line: one benefit, one cost, one recommendation. The decision quality did not drop. If I need more detail I ask, and only then is it paid for.&lt;/p&gt;

&lt;p&gt;The lesson generalises: &lt;strong&gt;output-format rules are a recurring cost.&lt;/strong&gt; Every instruction that makes answers longer is multiplied by the number of turns that follow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 3: keep long digging out of the main conversation
&lt;/h2&gt;

&lt;p&gt;Some work is long to do and short to report. Searching many files, running a test suite or reading a long log produces large intermediate output for a conclusion of a few lines. If that output lands in the main conversation, it is paid for on every later turn.&lt;/p&gt;

&lt;p&gt;Now that kind of work goes to a sub-agent with an explicit instruction: return the conclusion only, not the raw content. The main thread receives a few hundred tokens instead of tens of thousands. The sub-agent still spends tokens, but once, not on every later turn of a long session.&lt;/p&gt;

&lt;h2&gt;
  
  
  The most expensive token is the one spent on rework
&lt;/h2&gt;

&lt;p&gt;Context size was not the biggest cost I found. I pulled the logs for a single feature ticket in one of my iOS projects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First attempt: about 99k output tokens and 21.5 million cached input tokens.&lt;/li&gt;
&lt;li&gt;Second attempt, to fix it: about 47k output and 11.2 million cached.&lt;/li&gt;
&lt;li&gt;Third attempt: about 61k output and 19.5 million cached.&lt;/li&gt;
&lt;li&gt;Total: about 207k output tokens and 52 million cached tokens over roughly two hours.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same ticket was built three times. The two rework runs used about 60% of the total. The root cause was not the model: the project's tests could not run locally, so the agent could not check its own work before handing it over. Each broken handoff meant another full run with a long context.&lt;/p&gt;

&lt;p&gt;Making the tests runnable and trimming their output was worth more than any prompt trick. &lt;strong&gt;A run that cannot verify itself will eventually be paid for twice.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  One more trap: what you store is not what you pay for
&lt;/h2&gt;

&lt;p&gt;A related problem showed up on disk, not in the bill. A computer-control plugin in another agent saved every screenshot inline, as base64 text inside its session log. One log file reached 1.6 GB with only about 45,000 lines, roughly 37 KB per line, while normal conversation lines are a few hundred bytes. Monthly log growth went from 52 MB to 2.2 GB in four months. Turning off that plugin when I was not using it stopped the growth.&lt;/p&gt;

&lt;p&gt;It is not a token cost, but the habit that finds it is the same: measure the artefact, and do not trust the label.&lt;/p&gt;

&lt;h2&gt;
  
  
  A checklist you can run on your own setup
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Measure one real session before changing anything.&lt;/strong&gt; Split it into messages, fixed overhead and deferred tools. Your guess about which is biggest is probably wrong; mine was.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Classify every cost as per-turn or once.&lt;/strong&gt; Ignore the once-per-session items until the per-turn ones are fixed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put your own tools on a diet.&lt;/strong&gt; Return summaries and let the agent fetch full content deliberately. Default result counts are usually too high.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit your formatting rules.&lt;/strong&gt; Anything that makes every answer longer is multiplied by the session length.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Move long digging into sub-agents&lt;/strong&gt; that report conclusions, not raw output.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make the agent able to test its own work.&lt;/strong&gt; Rework is the most expensive line on the bill and the one no prompt setting can fix.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep a baseline.&lt;/strong&gt; Write down the numbers before a change, or you will never know whether it helped.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;None of this needed a new tool. It needed one habit: separate what you pay once from what you pay on every turn, and measure before you cut.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://mm7382.github.io/pec-ai-agent-training/journal-where-the-tokens-go.html" rel="noopener noreferrer"&gt;my site&lt;/a&gt;. I also wrote about &lt;a href="https://mm7382.github.io/pec-ai-agent-training/journal-claude-code-writes-codex-reviews.html" rel="noopener noreferrer"&gt;a two-agent workflow where Claude Code writes and Codex reviews&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>productivity</category>
      <category>llm</category>
    </item>
  </channel>
</rss>
