Wink Pings

AI Coding Is Slow Because It Is Waiting on Itself

Turnpack folds an AI coding agent’s search, read, edit, and test steps into three tool calls. In real tests, round trips dropped from 6 to 3, cost fell 36%, and test failures can be rolled back byte-for-byte. But database migrations are another matter; file rollback can’t save it.

The slowness of AI coding agents has a very concrete cause: they are waiting on themselves.

Search, wait for results, read files, wait for reads, edit, wait for writes, run tests, wait for output. Every step requires a full model turn: first wait for the first token to appear, then wait for the remaining tokens to come out one by one.

Some of that waiting could be eliminated. If the agent already knows which files to read, parallel reads can solve part of it. But some steps naturally depend on the previous step’s result: until the search returns, the agent doesn’t know which file to open; until the edit lands, the test can’t run. After a test failure it gets worse: the repo has already been changed halfway, and the agent has to spend extra turns undoing the changes.

Turnpack’s approach is to fold these interdependent steps into a single tool call. It is a local MCP server that gives the agent three tools.

Turnpack: edits that are tested before they stay.

pack: get context in one call

In one call, it performs regex search (with surrounding code), reads multiple files (whole file, line range, or just one function), lists globs, and runs git status. The response has a size cap, and .env and secret files are replaced with placeholders.

This solves the dependency between search and read. The agent doesn’t need to see search results first and then decide which file to read; a single pack gives it all at once.

how it works

ship: edit, test, roll back on failure

This is the core one. In a single call, it makes changes across multiple files, then runs the verification command you specify. If verification fails, every file is restored byte-for-byte to its pre-edit state, and the agent gets the failure output.

Every edit is checked before writing. If the fifth file has a problem, the first four files are never touched. All problems are returned at once, with the closest matching text in the file, the line number, and the first point of difference, so the next attempt doesn’t have to re-read the file.

The start of the response directly tells you the true state on disk: SHIPPED_AND_VERIFIED, ABORTED_BEFORE_WRITE, FAILED_AND_ROLLED_BACK, etc.

batch: one script instead of forty reads

Run a read-only script on the repo. “Which of these 40 files export X?” One call, ten lines of answer, instead of forty reads.

Measured data

One task: rename a function referenced by five files, then make the tests pass. Claude Code 2.1.280, Claude Sonnet 5, three runs per experimental group, median taken.

measured

Built-in tools group: 6 round trips, 13 tool calls, 23.4 seconds, 2,044 output tokens, $0.131.

Turnpack group: 3 round trips, 2 tool calls, 12.7 seconds, 873 output tokens, $0.084.

All three runs used the same three turns: one pack, one ship that made nine edits across five files and ran npm test, and one closing message. The model chose this tool on its own in all three runs, with no hint in the prompt.

Where the 36% cost saving comes from

Someone asked the author, Terp, whether it was fewer calls or shorter context. His answer was fewer calls. The context size is roughly the same, about 45k tokens, but every call has to re-read it. With 3 calls instead of 6, the amount re-read is halved, accounting for 60% of the savings. Another 25% comes from less model output, and 15% from less new context.

This breakdown is worth noting. The benefit comes mainly from reducing the number of turns, not from compressing context. If your agent is already bad at parallel reads, pack’s benefit is larger; if it already batch-reads, ship will feel more noticeable, because none of the built-in tools can do edit, test, and rollback-on-failure in one shot.

But there is one boundary

dust drew a line in the recommendation: if the test runs a database migration, that migration stays. The files are restored to their pre-edit state, but the database schema has already changed. His suggestion is to give the agent a disposable database for running checks, even if file edits can be rolled back.

Someone below added how to do it for a Java service: use Testcontainers to create a Postgres for each run, let Flyway or Liquibase migrations land in that temporary database, and throw it away after the run. File rollback cannot undo schema changes, so the database also has to be disposable.

This reminder is very practical. ship’s rollback documentation also states it clearly: side effects of the verification command itself, such as migrated databases and generated files, are not undone.

Security design

workspace jail: the working directory is determined by the server, and the model cannot switch it arbitrarily. Symlinks are resolved before checking, including those whose targets do not yet exist.

secret shield: files such as .env, private keys, .npmrc, and cloud credentials are redacted in pack and batch, and ship refuses to write them. It matches file names, not contents; the agent can bypass it by explicitly passing allow_secrets. It prevents accidents, not a safe.

Read-only batch: scripts run in a separate process under the Node permission model; they cannot write files, start child processes, or read anything outside the workspace.

Rollback: a byte-exact snapshot is taken before the first write, and restored if verification fails or times out. It also restores if SIGINT or SIGTERM arrives midway. In the case of kill -9 or a power loss, it recovers from an on-disk log the next time the server starts.

Zero dependencies: dependencies is empty. The entire server is TypeScript in src/. Apache 2.0 licensed.

How to use

Requires Node.js 22 or newer.

Ten-second trial: npx turnpack demo. It creates a disposable repo in a temporary directory, runs the three tools, then deletes it. It does not touch your own project.

demo

Install: npx turnpack init. It finds the AI apps you have installed, shows you what it will change before asking. By default it supports Claude Code, Claude Desktop, Codex, OMP, and Grok Build. Afterwards, run npx turnpack doctor to check whether each app’s configuration can actually start the server.

Supports Claude Code, Codex CLI, ChatGPT desktop, Cursor, Gemini CLI, OpenCode, and any MCP client that uses stdio.

When you don’t need it

A one-line fix, with the file already open in the agent’s hands. One edit is one edit; there’s nothing to fold.

Pasting the whole repo into the chat window. That’s what Repomix does.

The project has no fast check. ship’s value comes when tests, type checks, or builds take only a few seconds. Without verify, it’s just a multi-file edit with validation.

Project URL: https://github.com/OnlyTerp/turnpack

发布时间: 2026-11-16 11:29