We've all been there. You open a project, and for a split second, you freeze. "Wait, is this npm run dev, yarn start, or docker-compose up?"
Context switching is a productivity killer. As developers, we spend too much time remembering how to run the project instead of actually running it.
The Solution: Smart Context Awareness π οΈ
I've been building a VS Code extension called DotCommand, and today I finally cracked the code on its biggest feature yet: Smart Context Awareness.
The goal was simple: Don't make me search for commands. Show me what I need based on the files I have.
Detects package.json? β Show NPM commands (install, run script).
Detects Dockerfile? β Show Docker commands (build, run).
Detects .git? β Show Git workflow.
The "Behind the Scenes" Struggle π
It sounds simple, but the implementation was tricky.
I initially built a ContextDetector class that scanned the workspace. It worked, but it was slow. So, I added a caching layer (30 seconds).
The Bug: I would create a package.json file, and... nothing happened. The UI wouldn't update until the cache expired. It felt laggy and "dumb."
The Fix: I had to rewire the FileSystemWatcher events to aggressively invalidate the cache and force a UI refresh the millisecond a critical file (like package.json) is created or deleted.
Now? It feels instant. β‘
See it in action π₯
Bonus: Dynamic Git Branches
I didn't stop at just file detection. I also hated typing branch names manually. So, I added a Dynamic Input system. Now, when you run a command like git checkout, it spawns a native VS Code dropdown populated with your actual local branches.
Try it out?
I'm building this in public and would love your feedback. Does this solve a real pain point for you?
https://marketplace.visualstudio.com/items?itemName=FreeRave.dotcommand
Happy Coding! π



Top comments (0)