How to trace a shell command to the Claude Code helper that ran it
Match a Claude Code helper to its shell command and tool result. A local test shows how two identical commands produced two writes and one session summary.
Which agent wrote the file? In Claude Code, start with the parent session's delegation record. Follow its helper ID to the helper's transcript, match the shell call to its result by ID, then check the file itself. We tried this in an empty folder. Excellent's session summary counted three tool calls. The file contained two lines. Both counts were right.
Three tool calls, two writes
On November 20, 2026, we ran Claude Code 2.1.322 on a Mac with an empty project and fresh session storage. A script on the same Mac supplied fixed model responses so we could repeat the exact sequence. The script chose the calls and their labels. The installed Claude Code client started the helper, ran the shell commands and wrote its usual transcripts. We used only the records from this test.
The parent used the Agent tool once. Its helper used Bash twice. Each call asked the shell to append the word checked and a newline to status.txt. Here are the event times from the helper's own transcript, in UTC on November 21, still November 20 on the test Mac.
| Bash call ID | Request recorded | Result recorded | Tool result |
|---|---|---|---|
toolu_trace_a | 06:03:43.323 | 06:03:43.458 | No error flagged |
toolu_trace_b | 06:03:43.466 | 06:03:43.527 | No error flagged |
We gave the same two transcripts to the scan engine included with Excellent for Mac 1.0.0. The report behind Agents & Sessions → Recent sessions had one Claude Code session with three calls. The parent delegation counts as a tool call. To find which helper wrote each line, we opened the underlying records.
Follow the delegation
- Find the parent call. In the parent transcript, look for an
assistantrecord with atool_useblock namedAgent. Ours had the call IDtoolu_delegate. The lateruserrecord containing the matchingtool_resultcarried the helper's ID intoolUseResult.agentId. The worduserhere labels a record containing the tool's reply. - Open that helper's file. Under the parent session's folder, we found
subagents/agent-ac70e088827cd6fae.jsonl. Its filename and its Bash records carried the same helper ID the parent reported. Claude Code also lets you open a listed helper's transcript from/tasks. For the default folder and other agents' locations, see where session logs live and Anthropic's subagent documentation. - Match the call to its return. Read the
idon eachBashrequest and find the same value in a result'stool_use_id. We also captured the native command-line event stream with--verbose --output-format stream-json --forward-subagent-text. It putparent_tool_use_id: toolu_delegateon both helper calls and their replies. The timestamps show when Claude Code recorded those events. The IDs establish which reply belongs to which request. Anthropic's tool result format
If you have jq, the following prints just the timestamp, record kind and ID from a helper transcript. Set helper to the path of the one file you want to read. Run it in your own terminal so the transcript stays on your machine. The command omits prompts, shell arguments and returned content.
jq -r '
select(.type == "assistant" or .type == "user")
| . as $row
| .message.content | arrays | .[]
| select((.type == "tool_use" and .name == "Bash") or .type == "tool_result")
| [$row.timestamp, .type, (.id // .tool_use_id)] | @tsv
' "$helper"The filter includes results from other tools. Keep the results whose IDs match your Bash calls. If you see an identical call record twice across copied history, check its session, recorded helper ID and call ID before counting it. When we added a copy of the first call and reply to our analysis, three visible Bash requests still represented two distinct calls. Counting distinct command text gave one, since both requests used the exact same shell command. When we withheld the second reply in a separate test, that request's outcome was unknown.
Check what changed
The requested command was printf 'checked\n' >> status.txt. The relative path matters. We checked the fresh directory where the helper ran it, then read the file in a separate process after the client exited. On a Mac, these commands give the line count, byte count and checksum. Run them in the working directory you identified in the session.
wc -l -c < status.txt
shasum -a 256 status.txtOur file contained two checked lines, 16 bytes in all. Its SHA-256 was 006b0707a717b886237fa96a751b07700746192de3353a28c21857e2e9933b0a. We knew the file was absent at the start. On a shared project, anyone with write access could also change it. A later file read gives you its contents at inspection time. A successful tool result alone cannot settle what happened at a remote destination.
That distinction mattered when our founder traced 58 helper commands that put his email in more than 150 web requests. One shell command could make several requests. For a first pass through your own local history, run the Free Scan. If an action looks unfamiliar, our agent security guide explains which evidence to preserve and which control to check next.



