Writing Like Programming
Programmatic Writing, Claude Code + K2

"Programmatic Writing"
I've recently made a major breakthrough: using Claude Code to write like I program.
Before this, I'd been using Gemini 2.5 Pro. Its context window is exceptionally long, its reasoning capabilities are excellent — it handled nearly all my writing needs.
The problem was that conversing directly with a large model creates serious version-control headaches.
Each generation could vary significantly. I'd find myself trapped between several full-draft versions, cherry-picking the best passages from each to stitch together a final piece.
The direct result: 30 seconds to generate a draft, an hour to patchwork and revise.
The traditional conversational AI approach hit a ceiling. I started thinking: what is writing, fundamentally?
So here's my next major theoretical insight: writing, especially longer pieces, is essentially an engineering management problem.
Writing and programming are remarkably alike. Writing is programming in natural language; coding is programming in formal language. Traditional writing relies entirely on intuition, but intuition alone can't give AI precise instructions.
Writing, like programming, requires architectural thinking, version control, and modularity.
I call this programmatic writing.
The core idea: use Claude Code as the project manager. I just provide context and clarify my intent, then the AI breaks down the task and executes the steps.
Take the piece I published the other day, The Great Abstraction Era — written entirely with Claude Code + K2.
I simply dumped my spoken ideas (ten minutes of rambling into the Tongyi app), reference materials, and my past articles into a folder for Claude Code to access, then clearly stated my writing intent: which points to emphasize, which past pieces to emulate stylistically, target length, and so on.

What followed was the shock of a programming agent in action.
Claude Code proactively created a work plan, then executed methodically like a real project manager: studying materials, mimicking style, outputting an outline, and writing section by section.
The resulting article, The Great Abstraction Era, hewed closer to my original vision with higher overall completion. Using Gemini directly produces more fluid language, but only captures about 70% of my voice — still a hassle to revise.
This kind of programming agent that can autonomously decompose tasks and execute step-by-step completely transforms writing into a context engineering problem.
The user's most important job is selecting what context to feed it and articulating their intent. The execution? The agent handles everything.
But here's the problem: Claude Code really hates China 😟
Anthropic explicitly lists China as a hostile country and even prohibits serving enterprises where Chinese companies hold over 50% ownership. Damn Italians, why they gotta be like this 😡
So I must use Claude Code critically. As everyone knows, I'm a patriotic blogger.
Therefore, I switched Claude Code's backend model to Kimi K2 🤓
For the past week-plus, most of my articles have been written with the "Claude Code + K2" combo.
My other major practical finding: in the Claude Code writing workflow, K2 performs quite well.
K2's limitation is its 262K context length. On ultra-long, complex reasoning tasks, it tends to stumble logically. Its hallucination rate on summaries is low, but in the full-draft-writing stage — a.k.a. creative writing, especially pieces over 1,000 characters — hallucinations remain noticeable.
But Claude Code's engineering capabilities compensate for the model's inherent weaknesses.
The key is that Claude Code, as project manager, automatically breaks complex writing tasks into bite-sized chunks. Each segment runs only three to four hundred characters.
Under this task-planning model, the model's capabilities are maximally focused. It doesn't need to process all context and logic at once — just write a few hundred characters of clean text.
And the most immediate benefit: K2 is cheap.
I started out using Claude Code where just generating an outline cost $5. Now with K2, a full article runs me four or five RMB at most — several times cheaper.**
Speed-wise, K2's high-speed "turbo" version outputs decently, dozens of tokens per second. After several days of intensive use, I spend roughly 10 RMB daily. The standard version halves that again.
My heaviest day, I wrote continuously for four or five hours and spent just 28 RMB. CC+K2's hourly rate works out to five RMB — a quarter of Shenzhen factory-floor wages 🤙

This is how AI goes — application scenarios can't be planned.
Since switching to the CC + K2 combo, I've felt something like the rush of first writing with Claude 3.5 Sonnet a year ago.
I've been feeding Claude Code everything from my incoherent spoken ramblings to bizarre PDFs from my computer, just for kicks — I love watching AI scholars spin elaborate arguments from my offhand remarks.
The beauty of programmatic writing is that it solves the engineering management problem in long-form writing. No more step-by-step prompting, branching conversations, or agonizing between different versions.
The "programmatic writing" method is simple: the core is giving the agent abundant contextual materials. Then, clarify your intent like a product manager writing requirements, and delegate execution to Claude Code.
Specifically:
Step one: create a project folder.
It should contain three types of files: first, background materials on the topic — media coverage, research papers; second, your core arguments on the subject, which I typically dictate for ten-plus minutes and transcribe (you could also include leadership directives, client briefs...); third, several past pieces of yours whose style you're satisfied with, as reference samples for the AI to study.

Then you're ready to direct Claude Code and K2.
Step two: articulate your intent thoroughly.
I highly recommend downloading Mac app Wisper Flow — summon it anytime for voice input to explain your needs fully and clearly.

Clarify what the article is about, its intended length. Ask the AI to thoroughly study the folder materials, then based on your transcribed dictation or current input, referencing the background materials and your past work, draft an outline.
Be as thorough as possible here, then have it create a work plan — a.k.a. a CLAUDE.md file — and execute according to that plan.
Step three: once the outline is confirmed, write the full text section by section. Have Claude Code write the complete piece segment by segment, following the outline and your established stylistic patterns.

Very simple — the same logic as my earlier AI Writing Guide. The difference is that calling LLMs directly for writing creates version management problems — at both the outlining and draft-writing stages, conversations can branch into multiple versions.
Using Claude Code + K2, you first clarify requirements, establish a work plan a.k.a. project architecture, then let the AI automatically execute step-by-step and modularly, finally synthesizing the modules into a cohesive article.
It's basically applying software development fundamentals to writing. Ensuring the AI accurately understands intent and stably executes tasks.
The rest? Just try it yourself. Download a Claude Code terminal — free. Call K2 for writing — ten-odd RMB a day.
One small trick: in Claude Code's input box, double-press shift+tab to activate "planning mode." Then after entering complex instructions, CC will proactively create a work plan, making tasks less likely to interrupt.
Of course, programmatic writing has one adjustment period: it's easy to get distracted.
When Claude Code is executing outline or draft tasks, depending on context length, it may take anywhere from dozens of seconds to several minutes, even ten minutes.
During that time, I easily wander off to do something else and forget it's still working.
(Article illustrations generated by ChatGPT, writing assisted by Claude Code.)