Building a Gemini CLI Extension for Eleventy (11ty)
Developing with Eleventy is a joy, but as projects grow, keeping track of all custom filters, shortcodes, and layouts can be a challenge—especially when working with AI tools. To solve this, I built the 11ty-helper-extension for Gemini CLI. This tool automates the process of teaching the AI about your project's unique architecture in real-time.
Why a Custom Extension?
The biggest hurdle in AI-assisted development is context. When you ask an AI to "Refactor this Nunjucks template," it might hallucinate filters or layout paths that don't exist in your project. I wanted a way to ensure Gemini always had a "ground truth" view of my 11ty environment.
🚀 Key Functionality
The extension transforms Gemini into an expert on your specific site by providing:
- Live Architecture Auditing: It automatically scans your
.eleventy.js(oreleventy.config.js) and directories to identify exactly what tools are available. - Filter & Shortcode Extraction: Using regex, it finds custom logic like
addFilteroraddShortcode, so Gemini knows your project-specific syntax. - Template Intelligence: It maps layouts in
_includesand global data in_datato prevent hallucinated file paths.
🤔 How It Works
The magic lies in an on-startup hook defined in the gemini-extension.json manifest.
- Trigger: When you launch
geminiin your project, the hook is triggered. - Background Process: The hook executes
start-watcher.js, which launches a main audit script as a detached background process. - Real-time Updates: This script performs an initial audit and then watches for file changes, rewriting a
.gemini-context.logfile whenever you modify your configuration. - Seamless Integration: By setting a simple shell alias (
alias gemini='gemini --context .gemini-context.log'), the AI always has the latest knowledge of your project structure.
🛠 Getting Started
If you're using Gemini CLI and Eleventy, you can install the extension directly from GitHub:
gemini extensions install https://github.com/bdashley/11ty-helper-extension
Configure Your Shell
To automate the context loading, add this to your ~/.bashrc or ~/.zshrc:
# Always load the 11ty context file if it exists
alias gemini='gemini --context .gemini-context.log'
🤖 Conclusion
By bridging the gap between our local configuration and the AI's knowledge base, we can spend less time correcting hallucinations and more time building great web experiences. This extension is open source, and I'm excited to see how others in the 11ty community might use or improve it.
Check out the full source code on GitHub.