Building brain.nvim — Daily Coding Challenges to Fight AI Brain Rot
by Oskar Freye
How I built a Neovim plugin in Lua that serves daily coding challenges to keep your problem-solving skills sharp in an AI-assisted world.
I’ve been leaning on Copilot and AI assistants more and more over the past year. At some point I noticed something uncomfortable: I was struggling to implement a basic trie from memory. That’s when I decided to build brain.nvim — a Neovim plugin that gives you one coding challenge per day, right inside your editor, with no AI crutches allowed.
The idea
The concept is simple. Run :BrainStart, get a split view with a TypeScript stub on the left and a chat panel on the right. Implement the solution, tests auto-run on save via vitest, and you get scored. Clean solve? 3 points. Needed a hint? 2. Partial? 1. Skipped? Zero. Everything gets logged to a Markdown training file so you can track your progress over time.
The key rule: Copilot and autocompletion are automatically disabled in challenge buffers. It’s just you, the problem description, and your keyboard.
Building it in Lua
The initial release landed on February 24th with 8 built-in challenges — LRU Cache, Trie, Debounce, Deep Clone, Event Emitter, Promise.all, Binary Search, and Flatten Array. The trickiest part of the plugin wasn’t the challenges themselves but the Neovim buffer management. Getting the split-view UI right — code on the left, chat feedback on the right, both updating correctly — required a lot of wrestling with vim.api window and buffer calls.
Deterministic rotation was another fun problem. I wanted each day to map to exactly one challenge, cycling through all of them before repeating. A simple day-of-epoch modulo does the job, but it had to account for the growing challenge pool without reshuffling the order for existing days.
Auto-testing on save was straightforward with a BufWritePost autocmd that shells out to vitest with JSON reporting, then parses results back into the chat panel. The scoring system reads the test output and hint count to determine your emoji grade.
Growing the challenge set
Since the initial release I’ve been adding a new challenge almost every day — Reactive Observable, Topological Sort, Async Task Scheduler, Sliding Window Rate Limiter, Curry Function, Memoize with TTL, Pipe and Compose, Min Heap, and more. We’re at 20 challenges now and counting.
The optional AI hint system connects to any OpenAI-compatible API. I use it with a local LM Studio instance. The chat panel uses Socratic-style prompting — it won’t give you the answer, but it’ll nudge you in the right direction. Every hint costs a point though, so there’s real incentive to think first.
What’s next
I want to add streak tracking, difficulty tiers, and maybe a community challenge submission format. If you’re a Neovim user who wants to keep your problem-solving muscles from atrophying, give brain.nvim a spin. One challenge a day, no excuses.