Essay · 2026-07-02
Snowball: Self-Improving AI
AI automates a lot, but it quickly devolves into tedious context engineering. Snowball automates the context management engineering.
I use AI in just about every aspect of my work.
But as anyone who has used AI for a while knows, AI is only as valuable as the context you provide. Using AI effectively quickly devolves into tedious context engineering. You have to constantly feed the AI context about your codebase, your business, your goals, and your constraints for it to be effective. And that quickly gets pretty tedious.
Fortunately, much of the context engineering can be automated. I call this "snowballing", and I just invoke it from a custom /snowball command. It tells the AI to read its own session logs and automatically generate improvements in agentic skills or the agentic instructions in CLAUDE.md or AGENTS.md files. I now use it every evening. While I sleep, Snowball automatically closes the context gap, saves on token costs, and reduces hallucinations.
Close the Context Gap
The AI Agents default to making reasonable decisions but they aren't always right for every project. For a product, a recent customer was an enterprise corporate client in the medical sector with very high security standards. The AI is trained to make reasonable security-versus-complexity tradeoffs and kept coming up with solutions that were insufficiently secure for this client. I kept on manually reviewing agentic-generic code and asking it to upgrade design-level security issues, which ate up a lot of time and delayed coding because of all the agentic rewrites.
After running /snowball, the agent scanned my coding logs, flagged this as an issue, and proposed updates to my AGENTS.md file to include this new context for future sessions. This closed the context gap (the AI didn't know about the specific client requirements) and implemented higher security standards by default, without requiring manual review of each pull request, speeding up my workflow.
Saving Token Costs
I have leaned into using AI to query databases and analyze data to the point where I rarely write SQL, or use an analytics codebase. At one point, I upgraded how I handled authentication and credentials for the production database to make it more secure, neglecting to update the agent instructions in AGENTS.md. Unlike in traditional code, where the issue would have been caught immediately, the AI is smart enough to debug its access, so the context gap was not apparent. However, it would spend an extra ~6 tool calls and a few minutes relearning this in every session! I soon noticed my analytics queries slowing down.
This was caught in a nightly /snowball run, which correlated this tool-call pattern across sessions, the changes in git history that documented my authentication and credentials shift. From there, it updated the underlying agentic skill for database access to the new authentication method. This made analytics queries faster and cut unnecessary token waste.
Reducing AI Hallucinations
I use fully automated, agentic coding loops in which the AI is expected to run tests before committing code. The original instructions to AGENTS.md read "Generally run tests before committing code unless only non-code files are changed." The "unless" clause is an optimization: test results cannot change if code files are not changed. However, the agent often wrote code that didn't pass testing. Merging code with errors risks shipping bugs into production and slows coding because the next agentic session is forced to debug an unrelated error introduced by the previous agent.
In a /snowball run, the AI admitted it had not followed the instructions. It suggested I write the same rule more emphatically: using "always" instead of "generally" and writing the instructions in all caps. (I thought the instruction to use all caps was a hallucination until I found that researchers have shown that LLMs comply better with instructions in ALL CAPS TEXT. The paper is comically written in all caps.) These changes to AGENTS.md worked brilliantly, making my AI system more robust and reducing hallucinations and errors while speeding up my coding session.
Results
The benefits of /snowball have really snowballed (pun intended). While they started small, I've found that the cumulative impact of running /snowball every evening has really added up. Instead of making the same mistake over and over again, the AI is now learning from its mistakes and improving. I'm turning my time-consuming coding sessions into human-in-the-loop reinforcement learning training data to customize the AI for myself. This translates to closing the context gap, saving on token costs, and reducing hallucinations. How are you using AI to improve your AI? Reach out on LinkedIn and I'll share my /snowball command with you.