DEV Community

IKIE
IKIE

Posted on

Why I Built My Own Self-Healing CLI Coding Agent That Costs 10x Less Than Commercial Options

Commercial AI coding assistants are impressive. They are also expensive, opaque, and often wasteful.

Last year I found myself running a long refactor with one of the popular terminal-based tools. Every turn re-uploaded the entire conversation. Every long file re-streamed the full context. By the end of the session the API bill was higher than my hourly rate — and I still had to manually run the tests and clean up the failures.

That felt backwards. So I built Ikie, a terminal AI coding assistant optimized for three things the incumbents ignore:

Token efficiency via aggressive prompt caching.
Autonomous verification via a self-healing test loop.
Local, dependency-free retrieval via a custom TF-IDF engine.
In this post I will walk through the architecture, the numbers, and the engineering decisions that make Ikie 10x cheaper without being 10x dumber.

The Problem: AI Coding Assistants Are Billing Machines

Context re-upload on every turn.
Subscription + usage double-dipping.
Manual verification after edits.
The Cost Breakthrough: Prompt Caching in Practice

How Ikie caches and reuses context.
Real-world benchmark: 40 queries, 90K+ tokens, $1.06.
Response time distribution and why it matters.
The Architecture of a Minimal Agent

TypeScript/Node.js core.
Conversation state, tool loop, and bash execution.
Interactive shell mode for real prompts and menus.
Building a Zero-Dependency TF-IDF Retriever

Why we skipped embeddings and vector DBs.
File scanning, chunking, and term frequency.
IDF scoring and cosine similarity.
Code-aware tokenization: camelCase, snake_case, PascalCase, kebab-case.
Lazy index rebuilds with file mtimes.
Self-Healing: From Edit to Green Test

Detecting mutating tool batches.
Running .ikie.json test commands.
Injecting failures as reflection messages.
The 3-attempt retry budget and when to stop.
Configuration and Extensibility

.ikie.json project-level config.
Custom MCP servers and skills.
Free Hobby plan and cheap paid tiers.
Lessons and Future Work

What worked better than expected.
What still needs improvement (retrieval signals, reflection budgets, test command safety).
Call to action: try Ikie, open issues, contribute.

https://ikie-cli.xyz

Top comments (0)