Building Non-Interactive Agentic Coding Workflows with Moonshot AI’s Kimi CLI, JSONL Streaming, Testing, and Session Memory
MarkTechPost Sana Hassan ● Covered by 33 sources
A tutorial shows how to run Moonshot AI's Kimi CLI as a headless coding agent, no terminal chat needed. It fixes bugs, writes tests, and remembers context across calls, useful for wiring AI into real CI pipelines.
Based on reporting by MarkTechPost, Sana Hassan — read the original for the full story.
Summary, retelling and take written by AI under human oversight; images are AI-generated illustrations. How we work · Report an error
Most coding-agent demos are theater: someone types into a chat window and watches the model think out loud. This MarkTechPost walkthrough does something more useful, it shows Kimi CLI, Moonshot AI's command-line agent, running entirely non-interactively, the way you'd actually want it in a build pipeline.
The setup is straightforward but deliberate. The author installs Kimi CLI through uv with an isolated Python 3.13 environment, then wires up Moonshot API authentication via a TOML config file specifying the provider, the model (kimi-k2-0711-preview), and a 131,072-token context window. From there, a Python wrapper function handles every subsequent call, quietly assembling flags for streamed JSON output, autonomous tool approval, session continuation, and step limits, then returns the result for further processing. It's the kind of glue code you'd write once and never think about again.
The real test comes with a deliberately broken inventory-management project: a Python class with a remove() method that lets stock go negative and throws a bare KeyError on missing items. Kimi is first asked to read the codebase and flag risks, which it does without touching anything. Then, with a --yolo flag and a 30-step budget, it's told to fix the bug, write unit tests with Python's unittest module, run them, and keep iterating until everything passes. The author doesn't just trust the model's word for it, either, they independently rerun the test suite afterward to confirm the fixes actually hold up, which is the part most agent demos skip entirely.
Beyond the core repair loop, the piece walks through Kimi's more specialized modes, structured JSONL event streams for machine-parseable output, persistent multi-turn memory (the model correctly recalls a made-up release codename, BLUE-FALCON, across calls), a read-only plan mode, model switching, a
My take — AI-written commentary, not fact-checked reporting
Ralph loop
Read more about this at: MarkTechPost