Type claude in a terminal and a full-screen app appears almost at once. I wanted to know how fast “almost” is, so I timed the Claude Code boot sequence from the outside, with nothing but a stopwatch script. The numbers tell a clear story about how a big CLI stays quick. Then I built a small CLI of my own and applied the same three ideas, one at a time, to see what each one is worth.
The short version: answering --version before loading anything cut that command from 216 ms to 26 ms. Running a slow system call in parallel with a heavy import, then deferring work the first screen does not need, brought my prompt from 600 ms to 221 ms. One of the three ideas also has a trap that crashed my CLI, and I’ll show the one-line fix.
Timing the Claude Code boot sequence
I used Claude Code 2.1.247 on an Apple Silicon Mac. The first surprise came before any timing: the claude command is not a Node.js script any more. It is a single native executable of about 222 MB:
$ file $(readlink -f $(which claude)) .../@anthropic-ai/claude-code/bin/claude.exe: Mach-O 64-bit executable arm64
Next, I timed three commands with a small Python script that runs each one 15 times after three warm-up runs and reports the median:
def run(cmd, n=15, warm=3):
for _ in range(warm):
subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
ts = []
for _ in range(n):
t = time.perf_counter()
subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
ts.append((time.perf_counter() - t) * 1000)
return statistics.median(ts), min(ts), max(ts)
| Command | Median | What it has to do |
|---|---|---|
node -e 0 | 26 ms | Start Node.js and do nothing (for scale) |
claude --version | 9 ms | Print one line |
claude --help | 131 ms | Build the full command-line interface |
claude (to first screen) | ~325 ms | Start the interactive app and draw it |
Printing the version takes 9 ms, which is faster than starting an empty Node.js process. In contrast, --help takes 131 ms, because describing every option means loading the code that defines them. So the binary clearly answers --version on a separate fast path before it loads the rest of the program.
Time to the first screen
The interactive app is harder to time, because it draws to a terminal rather than printing a line and exiting. Therefore, I started it inside a pseudo-terminal in an empty folder and measured the time until a known piece of text appeared. In a folder it hasn’t seen before, the first screen is the safety check that asks whether you trust the folder. I never answered it; the script reads the screen and kills the process.
pid, fd = pty.fork()
if pid == 0:
os.chdir(cwd); os.execvp(cmd[0], cmd)
t0 = time.perf_counter()
while time.perf_counter() - t0 < timeout:
r, _, _ = select.select([fd], [], [], 0.05)
if r:
buf += os.read(fd, 65536)
if needle in strip_ansi(buf): # "Yes, I trust this folder"
hit = time.perf_counter() - t0
break
os.kill(pid, signal.SIGKILL)
first bytes ms: [720, 316, 319, 303, 314, 316, 303] first screen ms: [740, 327, 331, 315, 326, 327, 315]
After the first, cold run (740 ms), the first screen appeared in 315 to 331 ms every time. That is quick for an app of this size, though it is only the visible part. What runs after the screen is drawn, I cannot see from the outside.
Users don’t measure how long your program takes to load. They measure how long they wait before they can type.
The Claude Code boot sequence ideas, measured in my own CLI
To find out what each idea is worth, I wrote a small Node.js 22 CLI with the three classic startup costs:
- A heavy import. I used TypeScript 5.9, whose compiler is a single 8.7 MB JavaScript file that takes about 188 ms to import.
- A slow system call before the first screen, such as reading a credential from the keychain. Here, a 150 ms child process stands in for it.
- Work the first screen doesn’t need, such as fetching release notes, here a 200 ms wait.
The obvious version does everything in order:
import ts from "typescript";
if (process.argv[2] === "--version") {
console.log(VERSION);
process.exit(0);
}
const token = await readCredential(); // 150 ms
const notes = await fetchReleaseNotes(); // 200 ms
console.log(`ready> (ts ${ts.version}, ${token ? "signed in" : "signed out"}, ${notes.length} note)`);
The improved version applies three changes, each behind an environment variable, so the benchmark can switch them off one at a time:
// 1. Fast path: answer cheap commands before loading anything heavy.
if (process.argv[2] === "--version") {
console.log(VERSION);
process.exit(0);
}
// 2. Parallel: start the slow system call first, then load code while it runs.
const tokenPromise = readCredential();
const ts = (await import("typescript")).default;
const token = await tokenPromise;
// 3. Defer: show the prompt first; fetch what the first screen doesn't need afterwards.
console.log(`ready> (ts ${ts.version}, ${token ? "signed in" : "signed out"})`);
fetchReleaseNotes().then(showNotes).catch(() => {});
The benchmark spawns the CLI and measures the time until its first line of output, using the median of 15 runs:
| Variant | Time to output |
|---|---|
--version, heavy import first | 216 ms |
--version, fast path | 26 ms |
| Prompt, everything in order | 600 ms |
| Prompt, + parallel credential and import | 443 ms |
| Prompt, + parallel + deferred notes | 221 ms |
Each number matches simple arithmetic. In order, the prompt waits for Node.js, the import, the credential and the notes: about 26 + 188 + 150 + 200 ms. Running the credential lookup during the import hides its 150 ms almost entirely. Deferring the notes removes another 200 ms from the wait. As a result, the prompt now appears after roughly the import time alone, which is the next thing to attack if it matters to you.
The fast path is the cheapest win of all. It is a single if placed before the heavy import, and it made --version over eight times faster. The same idea works for any command that doesn’t need the full program, like --help for a single subcommand, or a shell completion script.
The trap: a promise you start early can crash the CLI
Starting work early has a catch. While the early call runs, nothing is listening for its result yet. If it fails in that window, Node.js sees a rejected promise with no handler and, by default, ends the process, even if a try/catch around the later await was waiting for it.
I tested this with a credential lookup that fails after a few milliseconds, while the CLI awaits 300 ms of other asynchronous work:
const tokenPromise = run("false"); // fails almost at once
await slowAsyncWork(); // 300 ms; the event loop keeps running
try {
await tokenPromise;
} catch {
console.log("ready> signed out"); // never reached
}
$ node pitfall2.mjs; echo "exit code $?" Error: Command failed: false exit code 1
Interestingly, the same code did not crash when the work in between was the TypeScript import. Loading that module blocks the event loop while it compiles, so the failure isn’t noticed until after the import finishes and the try is in place. That makes the bug worse, not better. The code works today and then crashes the day someone swaps the import for something truly asynchronous.
The fix is to attach a handler at the moment you start the work:
const tokenPromise = readCredential().catch((err) => ({ error: err }));
await slowAsyncWork();
const token = await tokenPromise; // a value, never a crash
console.log("ready>", token.error ? "signed out" : "signed in");
The same applies to deferred work. A background fetch that fails after the prompt is drawn will also take down the process unless it has its own .catch.
Tests that keep startup fast
Startup speed decays quietly. Someone adds a static import at the top of a file, and the fast path is gone. So I wrote six tests with Node’s built-in test runner. They compare variants against each other rather than against fixed numbers, which keeps them stable on slower machines:
test("the fast path makes --version at least 3x quicker", async () => {
const slow = await median("fast.mjs", ["--version"], { FAST_PATH: "0" }, 7);
const fast = await median("fast.mjs", ["--version"], {}, 7);
assert.ok(fast * 3 < slow, `fast ${fast} ms, slow ${slow} ms`);
});
test("an early call that fails while we await something else crashes the CLI", () => {
const r = node(["pitfall2.mjs"]);
assert.equal(r.status, 1);
assert.match(r.stderr, /Command failed: false/);
});
$ node --test startup.test.mjs # tests 6 # pass 6 # fail 0
The other tests check that both versions print the same version string, that the prompt appears at least 250 ms sooner with all techniques on, that the deferred notes still arrive, and that the guarded version exits cleanly.
What I took from the Claude Code boot sequence
Measured from the outside, the Claude Code boot sequence follows the same rules my small CLI needed. The cheap command is answered on a fast path, the expensive interface loads only when needed, and, once warm, the first screen arrives in about a third of a second. You don’t need access to anyone’s source code to learn from that. A stopwatch, a pseudo-terminal and a few variants of your own program are enough.
For your own CLI, my checklist is short. Answer cheap commands before heavy imports. Start slow I/O first and load code while it runs. Draw the first screen before fetching anything it doesn’t show. And attach a .catch to every promise the moment you create it.
If you use Claude Code daily, you might also like why Claude Code searches with grep instead of vector search, and how I write CLAUDE.md files for Opus 5.5.
