What happens when Claude Code runs npm install: a syscall autopsy
The last post ended on a promise: the first write-up would be the smallest version of the idea, a single agent running a single task, with its transcript on one side and what the machine did on the other. Here it is.
I gave Claude Code one instruction: install the project’s dependencies. In the transcript that is two lines. It says it will run npm install, runs it, and reports that it is done. Both are true, and both are close to useless, because that is where the machine gets busy. Under strace, the same task was two processes (three in the reproduce container below), about six thousand open files, and roughly fifteen TCP connections to one or two addresses, and none of that is in the two lines the agent wrote.
Here it is in one picture, the transcript on one side and the trace on the other:
One honest scoping note before the numbers: I traced the npm install itself, not the whole agent. Claude Code runs a command through a shell, so the real chain above npm on my machine was claude → zsh → npm: the agent process, the shell it spawned for the tool call, then the command. The two processes below are npm and its child; the agent’s own shell sits one level up, out of this trace.
strace writes down every system call the install makes: the moments a program asks the kernel to do something it cannot do alone. Three kinds carry most of the story. execve starts a program, openat opens a file, and connect reaches for the network. Counting each is a line of grep, at the top of its section. If shell is not your language, skip those lines; the numbers are in the prose. I ran it with express and core-js as dependencies, on Node 22 and npm 10.
The processes
grep -E '^[0-9]+ +(clone3?|v?fork)\(' autopsy.log | grep -v CLONE_THREAD | wc -l
Counting processes is not the same as counting execve calls, and a loose grep gets it wrong twice over: clone also matches file paths (core-js ships a web.structured-clone.js), and a call split across two log lines is counted twice. Anchoring to the syscall at the start of the line fixes both. A new process is a clone or fork without the CLONE_THREAD flag; with the flag it is a thread, a strand of an existing process. The command finds one, the child of the postinstall; npm itself does not appear, because strace executed it rather than cloning it, so the total is two, or three when you run the container below. That first process, npm, is a Node program (the npm command re-executes into node) that does almost everything alone, across seventeen threads. Opening thousands of files and pulling the tarballs is one busy process, not a swarm.
The second process is the one that matters. core-js ships a postinstall script, and npm ran it. In the trace that is Node stepping through the PATH to find a shell (the failed execves, one per directory it tries) and then sh -c 'node -e "..."': a shell, then a Node process, running code the package author wrote. A pure-JavaScript install with no lifecycle script would have stayed at one process.
The files
grep 'openat' autopsy.log | grep '= [0-9]' | wc -l # opens that returned a descriptor
A successful openat returns a file descriptor; a failed one returns -1 and an error, so keeping the lines whose result is a number drops every failure, not just the ENOENT “no such file”. (I match the name openat, not the call openat(, because when threads interleave strace splits some calls across two lines and the result lands on the second.) That leaves about six thousand opens, and the mix matters more than the total. Most are the node_modules/ tree being written and read back as npm resolves the graph. The rest are files nothing in the transcript points to: the .npmrc files with registry and auth settings, /etc/resolv.conf and /etc/hosts to look up an address, /etc/ssl/openssl.cnf for TLS. One file it never touched is a system certificate bundle: the official Node image bundles its own list of trusted authorities, so it verified the connection without reading /etc/pki or /etc/ssl/certs. (A distro build of Node with --use-openssl-ca would read them, so this is a fact about the build, not about npm.) From this side you see every file the install reads, whether or not the agent thought to mention it.
The network
grep 'connect(' autopsy.log | grep '<TCP' | grep 'htons(443)' # real connections
Here a naive count is a trap. grep -c connect reports dozens, but most of those are connect() on UDP sockets that getaddrinfo opens against each candidate address just to sort them (RFC 6724), and they send no packet. The real traffic is TCP on port 443, and there is far less of it than the raw number suggests: about fifteen connections (the exact count drifts between runs), landing on one or two addresses.
That is where the honesty has to stop. The kernel saw an address, 2606:4700::6810:722, not a hostname. It belongs to Cloudflare, which fronts a large slice of the web, so “it went to registry.npmjs.org” is something DNS told me, not something connect() proved. A dependency that phoned home to another domain behind the same CDN would draw the same line here. This is the TLS blind spot from the last post seen from the socket side: the kernel hands you the destination address and the fact of a connection, and stops. Tying the address back to a name, from the DNS answers or the TLS SNI the way AgentSight does, is the next layer up, not this one.
The part the transcript can’t reach
That second process is worth a last look. core-js’s postinstall was a modest node -e this time, but npm would have run it the same way if it built a native module, downloaded a binary, or opened a socket of its own. To the kernel it is one more execve, free to spawn processes and reach the network; to the transcript it is nothing. The agent said “install the dependencies,” and installing them means running whatever the dependencies decided to run. The ecosystem knows this is a sharp edge: npm install --ignore-scripts turns it off, and pnpm 10 blocks lifecycle scripts by default.
This is the earlier argument made concrete. When the tool is “run whatever the package shipped,” a log of what the tool returned describes the box, not what is inside it. The agent’s two lines are true and empty. The second process, the files, and the connections are the contents.
Reproduce it
The lab on GitHub has the Containerfile, the trace script and the steps to run it. Your numbers will differ a little: this container shows three processes, not two, because its shell forks a separate node for the postinstall where mine runs it in place. The shape does not change.
Why this is the place to start
One tool call is the unit everything else is built from. Before I compare agents, run several at once, or ask any security question, I want to know what one plain, benign tool call costs, and whether I can read it off the machine cleanly. This one took two processes, six thousand files, and fifteen connections, and the agent’s own account of the task mentioned none of them.
Next I will line the transcript and the trace up on the same task, event by event, and start marking which kernel calls belong to which tool call.
Run the lab on your own machine and tell me if the numbers come out different. If your company ships agents that shell out, I would also like to hear what you can see of them today and what you can’t. Send a note to contact@josehenrique.dev or find me on LinkedIn.