
Kimi Code: the long tasks, on a server, from anywhere
Kimi Code is Moonshot's coding agent, on its own subscription, with a context of one million tokens. We give it what is long rather than hard: reading a whole repository, a migration across many files, a task the operations agent would spend its quota on. Having two hosted agents also means one is still there when the other's quota runs out.
What you get. A second brain for the big jobs: a whole repository in its context, a session that keeps running when you close the laptop, and that you pick up from your phone.
1. Install it on the server, not on the laptop
npm install -g @moonshot-ai/kimi-code
kimi # first run: sign in to the managed provider
Run it inside a terminal multiplexer on the machine that holds the repositories, so the session survives a closed laptop:
tmux new -s kimi 'kimi' # on the server, once
ssh -t server tmux attach -t kimi # from the laptop, any time
A one-line alias on the laptop turns that into a single word. From a phone, the same command works in any SSH app over your private network.
2. Three ways in: terminal, web, remote control
- Terminal: the session in tmux above, attached from anywhere.
- Web interface:
kimi web --host <private address> --port <port> --no-openas a user service, reachable from the private network only. - Remote control:
kimi rc --no-openlets you follow and drive a session from another device.
The subscription offers several models; ours lists a coding model, a faster variant, and a long-context model with 256k tokens. Pick the fast one for small edits, the long one for reading a whole codebase.
3. Your subscription behind the gateway
Kimi Code itself wired this one for us: a small bridge, about 180 lines of Python with no dependency, that lets every tool of the lab use the Kimi subscription through the model gateway, like any other model.
- It listens on the machine itself only, and speaks the OpenAI format (model list, chat, streaming) that the gateway expects.
- It reuses the official client's login: it reads the same credential file instead of copying the token.
- It refreshes the token a few minutes before it expires, writes it back atomically to that same file, and reloads the file whenever the official client changed it. Both share one login, so neither invalidates the other.
- It never prints a token, not even in its own log.
Read your plan's terms before doing the same: providers differ on how their coding subscriptions may be used. Kimi's coding plan is meant for coding agents; if your provider offers an official API key for its plan, prefer it.
4. In a sandbox when it runs alone
When a queue hands a task to Kimi without you watching (see hybrid by escalation), run it in a sandbox such as bwrap: the repository read-write, the rest of the system read-only, no access to your keys. It cannot break what it cannot see.
Traps
The tool list has a size limit on the provider's side. With one tool server exposing 170 tools, every request came back 400 schema exceeds maximum allowed size, which looked like "model unreachable". Expose fewer tools, or split the server.
kimi --continue resumes the last session of the current folder. Started from another folder, it opens a new, empty session and you think the history is lost. Always resume from the folder where the work started.
Found this useful? Tell us what to measure next.