A Claude Code spinner may report four tool calls when the transcript shows only two. The counter's update logic is the first place to look: if it increments whenever the screen refreshes, two calls can appear to be four. Ado Kukic's new walkthrough of Claude Code mods explains how separate JavaScript handlers can record an event and read a shared variable to display the result. Anthropic's mod test kit provides a way to check that arithmetic without asking a model to perform any work. [1] [2] [4]
A counter makes a useful first test because its expected result is easy to establish. After two tool calls, two requests for the total should both return two. In this example, the count covers calls observed since the mod loaded, so the output should identify that scope. It does not measure changed files or successful operations. A failed lookup followed by a retry should count as two calls even though the user was trying to retrieve only one file.
Give the count one owner
The local version is the first setup check. The command claude –version reports the installation running in the terminal, and Anthropic's creation guide requires version 2.1.287 or later for its terminal walkthrough. A small plugin needs a manifest at .claude-plugin/plugin.json, a hooks/hooks.json file that points to the handler module, and a module such as hooks/register.js. Claude Code loads JavaScript or TypeScript directly, so this counter does not require a separate compilation step before the developer can try it. [2] [3]
A variable in the handler module can hold the count. The tool.call handler increments it, requests a redraw and passes the original event onward with next(e). A separate display handler reads the variable when Claude Code draws the spinner and adds the total to the existing spinner properties. Several redraws during a single lookup should therefore show the same number. Only a new tool event should change the stored value, keeping display activity from inflating the count. [2] [3]
A slash command can expose that same value as text for the test to inspect. Anthropic's example registers tally in the session.start handler, then uses a command.run handler that listens specifically for that name. The handler returns the text directly when the developer types /tally. A model call would add nothing to reading an integer already held in memory. Restricting the handler to tally also prevents it from interfering with unrelated slash commands. [1] [3]
Run the two-call experiment
A test file such as tally.test.ts belongs inside the plugin directory. It imports test and assertion functions from claude-code/testing and declares at least one test. The supplied event stub can answer a tool call with a fixed result while the test sends two tool events through the mod, one at a time. Anthropic's example uses a directory listing and a file read. Because the stub supplies the replies, the result does not depend on the files present on the developer's machine. [4]
The test then invokes tally through the test kit and compares its returned text with the expected count of two. The command claude plugin test runs it from the plugin directory without a live session, a sign-in or a network connection. A failed test exits with status one. A message saying that hooks modules are turned off instead identifies a configuration problem. The developer needs to resolve that problem before using the run to draw conclusions about the counter's arithmetic. [4]
The same test should read the command a second time. A correct implementation returns the same total twice. This additional assertion catches a plausible mistake: the mod might count every event it handles, including a request to display its own total. The test can also make a baseline read before sending any simulated tool calls. A nonzero baseline in a newly loaded counter points the developer toward initialization. A zero followed by a correct first answer and an incorrect second answer points instead to what happens while the value is being read. Each assertion helps locate a different kind of counting error.
The test kit and the mod both use a parameter called $, but they have different jobs. In a test, its methods fire events into the mod. Inside a handler, it is the API the mod uses to ask Claude Code to do something, such as refresh the display. Stubs stand in for the part of Claude Code that would otherwise respond. Keeping those roles straight helps explain why returning a fabricated tool result from a test is appropriate while doing so in the actual counter would change what the user’s tool call accomplished. [4]
Check the display in a real session
A passing text assertion cannot establish whether the spinner suffix fits in the terminal. The –plugin-dir option loads the local plugin's directory for one interactive session. At the prompt, /plugin shows whether the active mod list includes it. A small, observable read of a known file then gives the developer a chance to watch the spinner and compare /tally with the transcript. The transcript matters because even a simple request may legitimately generate more than one tool call. [2] [3]
A correct text answer with no spinner suffix points first to the rendering side. Anthropic documents different display support across the terminal, desktop application and editor extension. A noninteractive run can execute hooks without displaying the interface. If neither the command nor the spinner works, the developer should check whether the session loaded the plugin and whether both configuration files point to the intended module. The same symptoms can come from a file in the wrong place or a session that never loaded the changed version. [2] [3]
The counter's limited scope helps make these comparisons manageable. Reloading its module may initialize the in-memory variable again, so a support engineer comparing it with a long transcript needs to record when the count began. Only entries after a reload belong in that comparison. If /tally reports two while the spinner shows four, the tool handler has supplied the expected value. The remaining discrepancy lies in the display, which the developer can repair and test against the same two events.
Sources
[1] Ado Kukic on shared state in a Claude Code mod
[3] Anthropic’s guide to creating a mod
[4] Anthropic’s mod testing guide
[5] Official embed of the walkthrough
Have a correction or a useful perspective?
Get in touch with the publication.


