TLDR: my coding agents wrote 1.36 million lines of code in eight months, 75% of it Python. 25% of it is ephemeral programs.
An ephemeral program is a program that is written once, executed once, and thrown away.
- Coding agents write ephemeral programs at scale. In my trajectories: 29,990 ephemeral programs, 25.7% of all the code my agents wrote.
- Humans almost never write ephemeral programs. Writing a program is slow and error-prone, so a human who writes one saves it. For agents, writing a program is nearly free, so they throw it away happily.
- Ephemeral programs are unstudied. I found no empirical study of them.
[ data ]
I spend real time and effort in keeping the trajectory of every coding agent session. This does not come for free since all agents delete your old sessions by default.
The first trajectory dates from 18 February 2026, I lost everything before. So “Lifetime” means “since I started archiving”.
[ what is counted ]
A line counts if an agent authored it through a tool call and it is code:
- First, programs written to disk (
Writetool calls), we count every line of the file - Second, edits (
Edit,str_replace) count every line of their replacement text - Third,
apply_patch(GPT family) counts its+lines - Fourth, inline programs through shell heredoc such as
(
cat > f <<EOF) or fed to an interpreter (python3 - <<EOF,python -c)
Excluded:
- Markdown, LaTeX, plain text, JSON, YAML, TOML and commit messages. This is not code.
echo >andprintf >redirects,sed -i, code generated by programs.- failed tool calls, and files with no recognizable extension or shebang.
I report the gross number: rewriting a function ten times counts ten times, which is how agents actually work, they actually generated this code ten times.
[ result ]
In 8 months, we wrote 1,362,883 lines of code (1,213,861 non-blank) in 61,787 tool calls.
Claude Code: 77%. My own harness: 19%. Copilot CLI: 3.5%. OpenCode and Codex: the rest. So long for harness diversity.
[ by language ]
Python 1,022,669 75.0% ████████████████████████████████████████
Go 137,619 10.1% █████
Solidity 79,596 5.8% ███
HTML+JS 31,103 2.3% █
Shell 29,343 2.2% █
C 27,603 2.0% █
TypeScript 8,614 0.6% █
Lean 6,656 0.5% █
Java 4,596 0.3% █
Kotlin 4,518 0.3% █
Other (15 languages) 10,566 0.8% █
Python is three lines out of four. Go is a distant second. This reflects first my own preferences and instructions, and also the agent natural choices (Agent often use Python even if I don’t ask for it). Solidity comes from my smart-contract security work.
[ by location ]
Where does the code land?
project folder (cwd) 799,977 58.7% ████████████████████████████████████████
inline programs 350,614 25.7% ██████████████████
other paths outside the cwd 123,175 9.0% ██████
scratchpad (/tmp, …) 89,117 6.5% ████
What is the scratchpad? A temporary directory under /tmp
that Claude Code creates for each session
(/tmp/claude-<uid>/<project>/<session>/scratchpad).
The agent is told to put its throwaway files there (test inputs, one-off
scripts, intermediate results) to keep the project folder clean. I count
any write under /tmp as scratchpad.
The scratchpad + inline is what agents throw away.
The second row is the surprise. One line in four is never written to disk. Those are pure ephemeral programs, see next section.
[ ephemeral programs ]
An ephemeral program is a program that is written once, executed once, and thrown away. This happens when the agent pipes the program to an interpreter and reads the output:
python3 - <<'EOF'
from jmap_eas.app import create_app
from starlette.testclient import TestClient
app = create_app()
with TestClient(app) as c:
r = c.get('/healthz')
print(r.status_code, r.json())
EOF
That is a real one, six lines. It answers one question (“does the
health endpoint respond?”). Then it is gone. It is never in the project
folder, never in git, never in /tmp. The only trace is the
trajectory.
Why do they exist? A shell command answers a question you can phrase in one line. An ephemeral program answers a question that needs a loop, a parser, an import of the project’s own code. It is the agent’s powerful REPL.
An ephemeral program is the cheapest form of software: no name, no tests, no maintenance. Writing code has become so cheap that throwing it away after one use is the normal case.
[ numbers about ephemeral programs ]
- 29,990 ephemeral programs, 350,614 lines, 25.7% of all code written by my agents
- they outnumber persistent files written with the Write tool (5,328) by 5.6 to 1
- 95% are Python (28,453 programs), 5% Shell (1,401), the rest JavaScript and others
- a third of all Python lines (34%) written by my agents are ephemeral
Size distribution (lines per program, share of programs, share of ephemeral lines), median length: 7 lines, the longest has 547:
lines programs % progs % lines
1 6,872 22.9% 2.0% ███████████████████████
2-5 5,569 18.6% 6.3% ███████████████████
6-10 7,134 23.8% 15.7% ████████████████████████
11-20 5,591 18.6% 23.3% ███████████████████
21-50 4,013 13.4% 34.7% █████████████
51-100 691 2.3% 13.2% ██
101+ 109 0.4% 4.8%
The bars show the share of programs. Most ephemeral programs are
tiny: 42% have 5 lines or fewer, and 23% are one-liners (a
python3 -c equivalent). The 109 programs of 100+ lines are
no longer a REPL query, they are real scripts that the agent still chose
not to save.
Is it a quirk of one tool? No. Claude Code 24.8% ephemeral, Copilot CLI 20.8% ephemeral, Codex 23.9% ephemeral.
wc -l or cloc on the project folder misses
a quarter of what the agent wrote. If you measure agent productivity by
commits or by lines in the repository, you undercount.
[ humans would write ephemeral? ]
A human writes a program of a few lines, runs it, and deletes it? Almost never, because of:
- Time. Typing 12 lines into a terminal takes minutes. The agent takes seconds.
- Difficulty. A multi-line program has typos, wrong API calls, a bug on the second line. A human fixes it by editing, so the program has to live somewhere: a file, an editor buffer, a notebook cell. The agent gets it right, or rewrites it whole.
- Reuse. A human who “paid” for a program keeps it. Next week there is a second question, and the program is the starting point. Cost makes humans save.
What humans do instead is the one-liner: a shell pipeline, a
python -c with one expression, a REPL session. These are
ephemeral in spirit, but they are small. 58% of the ephemeral programs
of my agents have more than 5 lines, and 16% more than 20.
[ we need empirical studies ]
I found no empirical study of ephemeral programs. The adjacent literature is about exploratory programming, studied for tools and workflows, not as code that is never kept: a literature study of 212 publications.
Many cool research questions are open:
- How much of the code written by agents is ephemeral, across agents, languages, and tasks? Mine is one developer, eight months.
- What is the goal of an ephemeral program? What is the intent of the agent when it writes one: inspect the state of the system, test a hypothesis, transform data, call an API, fix a file? What’s the underlying taxonomy?
- Are they pure? Does the program only read and compute, or does it have side effects: files written or deleted, network calls, processes started, changes to a database? What share of ephemeral programs is pure, and what share mutates the world?
- Are ephemeral programs correct? Nobody ever reviews them.
- Are they secure, do they cause damage: deleted files, leaked secrets, calls to production?
- Should harnesses show them? A quarter of the code is invisible to the human in the loop, what’s the best UX?
- How should we measure agent productivity, when a quarter of the output is not in the repository?
[ validation ]
I checked the line counter against an independent jq
count of Claude Code’s Write calls: 5,127 calls, zero mismatches.
[ compute on your own trajectories! ]
The counter is part of reproducible-trajectories. It reads the trajectories of Claude Code, Copilot CLI, Codex and OpenCode on your machine. Nothing leaves it.
pipx run reproducible-trajectories count-loc
or with uv:
uvx reproducible-trajectories count-loc
Add --json for machine-readable output.
[ cite ]
@misc{monperrus2026ephemeral,
author = {Martin Monperrus},
title = {Ephemeral programs: a quarter of the code my coding agents write is never saved},
year = {2026},
month = oct,
howpublished = {\url{https://www.monperrus.net/martin/my-agents-wrote-1m-loc}}
}