Building Carto — An AI Codebase Bundler for VS Code
I was tired of manually selecting files to provide context to AI assistants. Every time I wanted help with a code review or refactoring, I had to copy file after file. So I built Carto, a VS Code extension that does it in one click.
Carto scans your project, detects its tech stack, builds a directory tree, and outputs a beautifully structured Markdown file with all your code. It supports four AI providers out of the box — Google Gemini, OpenAI, Groq, and Ollama for local models.
The most technically challenging part was abstracting multiple AI providers behind a unified interface. Each provider has different streaming behaviors, token limits, and response formats. Gemini streams differently than OpenAI. Groq is incredibly fast but has different rate limits. Ollama runs locally and might not even be running.
I settled on a provider abstraction layer that normalizes streaming into async generators. Each provider adapter handles its own connection and parsing, but feeds into the same rendering pipeline. This made it easy to add new providers later.
The output preview was another challenge. VS Code WebViews are essentially iframes with limited capabilities. I needed a markdown renderer that could handle large outputs with syntax highlighting, collapsible sections, and a table of contents. I built it with a custom React application that communicates with the extension host through message passing.
Security scanning was a requirement from the start. The extension automatically detects .env files, private keys, SSH credentials, and API keys, and excludes them from the bundle. It uses pattern matching against known sensitive file formats.
The most rewarding feedback came from a developer who said Carto saved them an hour a day preparing context for AI code reviews. That is the kind of impact that makes building developer tools worth it.