Keen Code - A context-efficient CLI coding agent built by agents

Keen Code is an open-source, context-aware and efficient CLI coding agent written in Go. Three aspects stand it out from other similar products: - It was built from scratch by coding agents, with the full prompt/design trail preserved and shared in the repo. - It uses turn memory to keep multi-turn sessions lean which saves context significantly. - It maps MCP servers to lazy-loaded Skills instead of stuffing large schemas into context upfront. This again saves context in mult-MCP setting.

Add a comment

Replies

Best
Hi Product Hunt! I’m happy to share Keen Code, an open-source CLI coding agent written in Go. I’ve been building it solo since February as a side project, and I used it as an opportunity to experiment with context efficiency and agent-driven development. Three things make Keen Code different from other similar products: 1. Built by agents Keen Code was built from scratch using state-of-the-art coding agents. My role was to act as the human orchestrator: writing prompts and requirements, then reviewing the designs and code produced by agents. To keep this transparent, the repo includes an ai-interactions folder with prompts and output docs. More: 2. Turn memory To avoid filling the context window during multi-turn loops, Keen discards raw tool inputs and outputs after each turn. It keeps a distilled “turn memory” instead: a simple deterministic Go struct passed into the next turn. More here: 3. Skills-driven MCP servers Instead of loading large MCP server schemas into context upfront, Keen abstracts MCP tools into local markdown Skills. It only retrieves the exact JSON schema when the LLM requests a specific tool at runtime. Details: I’ve been using Keen to develop Keen itself, as well as in my other projects. I’m looking forward to questions, feedback, suggestions, and reviews. I’m committed to improving the project over the long term. Thanks in advance!

Building a CLI agent that manages its own context window is a genuinely hard problem. We've dealt with similar tradeoffs in long-running background jobs where keeping relevant context without blowing token budgets required careful chunking. What's your eviction strategy when the agent's working set grows mid-task: do you prioritize recency or semantic relevance?

 Hey! Good question. Right now Keen prefers keeping user-agent interaction over tool calls. And in my experience, tool call results have been the single most costly part of the context window.

So if an agent loop grows too much that it cannot fit in the context any more, the simple strategy is to evict oldest tool results for the turn and so on. Since Keen doesn't retain tool results beyond a single turn, the context is already lean when a new turn starts. As a result, this strategy to evict oldest tool results is enough to reduce in-turn context window size.

Sounds interesting, but aren’t you worried about competition? There are already many AI coding tools, and new ones appear every day.

 Hey! This is an open source product and there is no business model associated with it. Yes there is competition which I don't mind at all. If people use it and find it useful, that's good enough for me and worth the effort. :)

Really cool, and respect for building it solo. The turn memory idea for keeping context lean is smart. How much context does it actually save in a long session?

 In my experience, it has been significant. I have done some very basic benchmarking between Keen vs OpenCode. In those benchmarks, I have clearly seen Keen's context window drops 1/10th from one agent turn loop to the next.

Context window size for OpenCode grows linearly. The more a multi-turn conversation progresses, it keeps going up. With Keen, it grows within a turn, but comes back down significantly after a turn. The next turn starts with a far smaller context compared to previous turn's end.

The tradeoff that Keen has here is pretty obvious: if agent needs to refer to some tool call results done a turn or more ago, that result is no more available. The counter-argument here is that models can always re-run those tools, assuming those tools are idempotent. There has to be some shenanigans done for MCP tools, which I intend to address in next releases.

Here is a Claud-written analysis: . It's a bit dramatic but good for understanding the idea.

Context efficiency is the right constraint to optimize for in a coding agent. Most agents bloat the context window with irrelevant file chunks and then thrash on eviction decisions. We've hit this exact failure mode building multi-file reasoning features and it's where agent reliability falls apart. How does Keen Code handle context prioritization across a multi-step tool use chain when multiple files are relevant?

 I am not entirely sure I understood your question :D

Right now, there is nothing done specifically for prioritisation between multiple files in Keen.

The "lazy-loaded Skills instead of stuffing MCP schemas into context upfront" choice is the detail that stood out to me - that's usually where multi-MCP setups quietly fall apart, the context budget gets eaten before you do any real work.

As someone still figuring out how to keep agent sessions lean, I'm curious: with turn memory compacting older turns, how do you decide what's safe to drop vs keep? Do you summarize older turns or hard-truncate them? Wondering where the line is before the agent starts "forgetting" a constraint from earlier in the session.

Also love that the whole prompt/design trail is in the repo - genuinely useful to learn from. Respect for building it solo. Congrats on the launch.

 Turn memory is pretty simple and dumb. Right now it's a Go struct with two fields: files_changed and failed_bash_commands. This is to give later turns a simple sticky note: this is what changed in the previous turns and this is what failed. That's it.

The reasoning behind this is that if agent needs to refer to some tool result before, it should simply run that tool again. In fact, SoTA agents do that frequently: they read some file, does some change. Later, if you ask them to do something else, they read the same file again to ensure the latest state.

So Keen's thought process is: just don't retain tool call results from read_file or grep or other tools after an agent turn loop finishes.

the skills-driven MCP approach is the part that caught my attention. every multi-tool agent setup I've seen just dumps the entire schema into context upfront and then wonders why performance drops off a cliff three turns in. lazy-loading only what the model actually needs at runtime feels obvious in hindsight but almost nobody does it. also respect for shipping the full prompt trail in the repo... that's genuinely useful for anyone trying to learn how agent-driven development actually works in practice. congrats on the launch and doing this solo is no joke

 Thanks for your feedback!

The context-efficiency angle is what stands out to me here — lazy-loading MCP skills instead of front-loading schemas is a genuinely smart architectural choice that most CLI agents skip. Fellow solo builder launching nearby (Sensemaker, a thinking-to-writing tool), and the "built by agents, orchestrated by human" workflow you described is almost exactly how I shipped my own MVP. Curious: how did you handle the moments where the agent went off-spec mid-session? Did you find the prompt/design trail in the repo was enough to course-correct, or did you need other guardrails?

 Hey, yes going off-spec mid-session has not been a problem. I think it's up to you to carefully design how big of a bite you would want the agent to take. As long as it's reasonably planned, it works pretty well.

One thing we've noticed with agent workflows is that reducing context size and improving context quality are often treated as the same problem when they're actually different.

Have you found Keep Code's biggest win coming from compression, retrieval, or helping agents maintain a more consistent mental model of the codebase across longer sessions?

 Good question. Not exactly mental model, but I have been thinking to experiment with a pre-calculated repository mapping for agents. I don't know if it will surely improve efficiency or performance, but need to actually implement and get a feel for it.

For Keen, yes the focus is indeed context efficiency through compression or lazy loading where possible. I think this is what the biggest win would be.

 That's interesting because repository mapping feels like it sits somewhere between compression and retrieval.

Instead of reducing context after the fact, you're giving the agent a higher-level representation of the codebase before it starts reasoning.

We've seen cases where agents don't fail because the relevant files are missing, but because they never build the right picture of how the pieces fit together. A repository map seems like it could help with that.

I'd be curious whether you end up generating that map statically from the codebase structure, or whether it evolves based on what agents actually touch and modify over time.