How I Built a Terminal AI Coding Assistant with a Free Token Quota
A sharp drop in LLM token prices gave me enough room to build and iterate on a terminal-native AI coding assistant using a free quota. This article explains how I routed tasks across models, kept users in control with plan approval, and compressed context to sustain long coding sessions. It also covers where the tool fell short and why a larger quota still needs careful management.
1. A Price Cut Changed What I Could Afford to Build
A cloud provider recently cut token prices for its LLM service by 98%, giving developers roughly 50 times as many tokens within the same budget. For an independent developer, that changes not just what a project costs, but which projects are practical in the first place.
Before the cut, using a flagship proprietary model for routine coding felt like driving a sports car to the grocery store. A common compromise was to ask the strongest model to sketch the architecture, then handle smaller changes by hand. With tens of times more tokens available, I could afford to use a model for the back-and-forth of building a tool of my own.
That raised a question: when tokens are no longer the main constraint, what do you build?
2. Why I Built a Terminal-Native AI Coding Assistant
I chose to build a coding assistant with a terminal user interface (TUI) for three reasons:
- The need was real. IDE integrations are mature, but terminal-native tools still have a place on remote servers and in containers without a graphical interface.
- The scope was manageable. The project was large enough to require iteration but small enough to develop within a free token quota.
- The project was its own test case. Using AI to build an AI tool exposed the model’s limitations as I worked and helped me understand where the tool needed stronger safeguards.
A mature Python TUI library made it possible to keep setup simple: install the package with pip and launch the assistant with a single command.
pip install my-ai-tuiai-tui # Launch the terminal coding assistant
3. Route Tasks by Complexity, Not by Default
No single model offered the best trade-off between cost and quality for every task. What worked better was routing tasks by how much judgment they required:
- Architecture: Use the strongest flagship model for overall design and architectural bug fixes. These tasks are infrequent, but their consequences reach across the project.
- Feature work: Use a more cost-effective model for small features and self-contained modules. These tasks are more numerous and follow more predictable patterns, so they account for most of the free quota usage.
- Small fixes: Use a lightweight model or a rule-based script for copy edits, straightforward bug fixes, and filling gaps in tests.
For a medium-sized open-source tool, my experience suggested that using a flagship model for everything could cost tens of dollars per month, comparable to a subscription. Routing tasks across models brought that cost down to less than a third of the flagship-only estimate.
4. Core Design: Plan Approval, Progress Panels, and Context Compression
4.1 Require Approval Before Writing Code
A coding assistant should leave the user in control. I used a three-step workflow: plan → approve → execute. The model proposes an implementation plan and breaks it into tasks, but it only starts writing code after the user approves. This gives the user a chance to catch a bad assumption before it turns into widespread edits.
4.2 Make Progress Visible in the Terminal
The interface separates different kinds of project state into four panels:
- Plan: The overall implementation plan and its progress
- Todo: A detailed checklist of individual steps
- Tasks: The status of background tasks running in parallel
- Agents: Subagent assignments and outputs
Users can switch panels at any time to see what the assistant is doing and what it has produced. That visibility makes it easier to debug the workflow and build trust in the tool.
4.3 Compress Context for Long Coding Sessions
Long sessions fill a model’s context window quickly. Instead of replaying the entire conversation, the assistant condenses earlier messages into a structured summary. It retains decisions, file paths, and interface agreements while dropping redundant discussion.
A compression prompt can use five or nine sections. Here is a five-section example:
[Goal] State the current iteration's objective in one sentence.[Completed] List implemented modules and modified files.[Key Decisions] Record architecture choices, naming conventions, and dependency versions.[Next Steps] List the remaining tasks in order.[Constraints] Preserve explicit user requirements and anything that is off-limits.
This approach kept the compressed context under 1,000 tokens, making it possible to continue development across long sessions without carrying the full conversation forward.
5. What I Learned Building the Tool
- Small changes were easier to get right than cross-module changes. AI-generated code performed well on narrow tasks, but interactions between modules still needed human review. Run the tests after each round of generated changes.
- A TUI should play to its strengths. Mature IDE plugins have an advantage in features like code completion and go-to-definition. A terminal assistant is more useful when it focuses on workflows where a terminal is already the right interface.
- A larger quota still needs a budget. Even with 50 times more tokens, repeatedly sending the full conversation can exhaust the allowance. Context compression is a cost-control measure as much as a way to stay within the context window.
6. What Cheaper Tokens Make Possible
Lower inference costs make AI-assisted development practical for more than a handful of carefully chosen tasks. For independent developers, the bigger opportunity isn’t the subscription fee they might save. It’s the projects they can now afford to iterate on, like a coding assistant built around their own terminal workflow.
The tool is still a work in progress, and issue reports are welcome. If you have a generous token quota, think about the project you’ve been putting off because it would take too much trial and error. Is it practical to start now?
