Gemini Module
Optimization and portability guide for Forge modules. Ensures modules run seamlessly in Gemini CLI while maintaining full compatibility with Claude Code and OpenCode.
Portability Patterns
1. AI-Agnostic Module Resolution
Never rely on tool-specific environment variables alone. Use FORGE_MODULE_ROOT as the primary standard, with fallbacks.
In Bash Hooks:
bash
MODULE_ROOT="${FORGE_MODULE_ROOT:-${CLAUDE_PLUGIN_ROOT:-$(builtin cd "$(dirname "$0")/.." && pwd)}}"
export FORGE_MODULE_ROOT="$MODULE_ROOT"
In SKILL.md (DCI calls):
bash
dispatch skill-load <module>
In SKILL.md (body bash snippets):
Do NOT use ${} variable expansion — Claude Code's permission system blocks it. Use hardcoded relative paths:
bash
MODULE="Modules/<module-name>" [ -d "$MODULE" ] || MODULE="."
2. Robust Binary Interface
Use the clap crate (Rust) to support standard CLI arguments. This allows Gemini to invoke tools directly with flags rather than relying solely on stdin JSON pipes.
- •Support
--cwdfor context steering. - •Support
--transcript-pathfor session analysis. - •Provide
--helpfor auto-discovery by AI agents.
Semantic Transcript Analysis
When building reflection or auditing modules, go beyond count-based heuristics.
- •Extract Topics: Use regex to capture titles or topics following markers (e.g.,
★ Insight: (.*)). - •Normalize and Match: slugify transcript topics and compare them against memory filenames.
- •Avoid Date Prefixes: Use simple
Title.mdformats to make matching more reliable across different AI behaviors.
Gemini Specifics
- •Output Formatting: Use моноширинный-friendly Markdown.
- •Unicode Support: Gemini correctly renders unicode markers (★, ─, 📌). Use them for visual hierarchy in digests.
- •Skill Loading: Ensure
skill-load.shis invoked to inject project-specific steering into the session context.