AgentSkillsCN

GeminiModule

为构建专为Gemini CLI优化、且具备跨工具移植性的模块提供专业指导。

SKILL.md
--- frontmatter
name: GeminiModule
description: Specialized guidance for building modules optimized for the Gemini CLI and cross-tool portability.

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 --cwd for context steering.
  • Support --transcript-path for session analysis.
  • Provide --help for auto-discovery by AI agents.

Semantic Transcript Analysis

When building reflection or auditing modules, go beyond count-based heuristics.

  1. Extract Topics: Use regex to capture titles or topics following markers (e.g., ★ Insight: (.*)).
  2. Normalize and Match: slugify transcript topics and compare them against memory filenames.
  3. Avoid Date Prefixes: Use simple Title.md formats 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.sh is invoked to inject project-specific steering into the session context.