# px

> A coding agent built around DeepSeek's prefix cache, where the repo's own tests decide when the work is done, not the model.

Canonical: https://mark-web.com/projects/px
Author: Mark Sulleza
Stack: TypeScript on Bun, DeepSeek API, SQLite ledger
Source: https://github.com/mSulleza/px
Write-up: https://mark-web.com/writing/px-deepseek-coding-agent

## Set it up

```sh
bun install
mkdir -p ~/.px && printf 'PX_DEEPSEEK_API_KEY=sk-...\n' > ~/.px/env && chmod 600 ~/.px/env
bun run doctor   # probe the live API against every assumption px encodes
bun link         # put `px` on PATH
```

Use a DeepSeek key that nothing else uses. px writes every call to a local ledger and checks it against the account balance; a shared key makes that check meaningless.

## Give it a task

```sh
px run "make the failing auth test pass"
```

1. px makes a git worktree on its own branch. Your checkout and uncommitted work are out of reach.
2. It finds the verify command: `.px/verify.toml` first, then `package.json` test scripts, pytest files, `Cargo.toml`, `go.mod` or a Makefile `test:` target. With none, it exits before the first API call.
3. It runs that command once on the untouched worktree and records what already fails.
4. The model works with thinking off, on a frozen prompt prefix, so nearly every turn is a cache hit. When it needs depth it asks a separate reasoning lane one question, and the answer comes back as a tool result.
5. When the model calls finish, px runs verify. If anything that passed at baseline now fails, the model gets the failing output instead of a finish, and keeps going.
6. The run ends `passed`, `partial`, `blocked`, `budget` or `error`. Only `passed` exits 0.

## Land it

```sh
px land px/<taskId>
```

Fast-forward only. px never resolves a conflict or rewrites history for you; if your branch moved, rebase it yourself or run px again.

## Watch the money

`px cost 7` shows spend by day, lane and cache tier from the ledger. `px spend` shows the account balance and today's spend against the daily ceiling. `--budget` caps a single task (default $0.15) and `--budget-day` caps the day (default $1.00).

DeepSeek charges double on weekday mornings UTC, and px shows the model the current multiplier every turn.

## The tests

[Screenshot: bun test reporting 169 passing tests across 7 files.] 169 tests across 7 files run in under three seconds.

The API research behind it: [What DeepSeek’s API won’t tell you](/writing/what-deepseeks-api-wont-tell-you).
