Gemini Extension Authoring by chen-ye/cye-agent-skills
npx skills add https://github.com/chen-ye/cye-agent-skills --skill 'Gemini Extension Authoring'提供关于为 Gemini CLI 创建、打包和发布扩展的专业指导。
将 Gemini CLI 扩展组织为包含命令、钩子、MCP 服务器和其他资源的自包含目录。
请遵循以下扩展目录结构:
my-extension/
├── gemini-extension.json (必需:清单文件)
├── README.md (必需:文档)
├── LICENSE (必需:许可证)
├── hooks/
│ ├── hooks.json (可选:钩子定义)
│ └── my_hook.py (可选:钩子脚本)
├── commands/ (可选:自定义命令)
├── mcp-servers/ (可选:MCP 服务器代码)
├── skills/ (可选:智能体技能)
└── agents/ (可选:子智能体定义)
gemini-extension.json)使用 gemini-extension.json 清单文件来定义元数据、配置设置、依赖项以及钩子或 MCP 服务器的入口点。
关键字段:
name:唯一标识符(使用短横线命名法)。version:语义化版本号(例如 "1.0.0")。广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
mcpServers:捆绑的 MCP 服务器定义。settings:向用户公开的配置选项。dependencies:所需的系统工具(例如 {"python": ">=3.7"})。请查阅 references/extension-schema.md 以获取完整的模式规范。
hooks.json)在 JSON 文件中定义钩子,以拦截和修改 CLI 行为。在清单文件中引用此文件。
结构:
AfterAgent、BeforeTool)。matcher 过滤事件(例如 * 表示全部,或指定具体的工具名称)。command。最佳实践: 在命令字符串中使用 ${extensionPath} 来可靠地引用扩展目录内的文件。
"command": "${extensionPath}/hooks/my_script.py"
请查阅 references/hooks-schema.md 以获取详细的事件类型和配置选项。
捆绑 MCP 服务器以向模型公开工具和资源。
配置:
在 gemini-extension.json 文件的 mcpServers 对象下定义服务器。
"mcpServers": {
"my-server": {
"command": "node",
"args": ["${extensionPath}/mcp-server/index.js"],
"env": {
"API_KEY": "${env:MY_API_KEY}"
}
}
}
trust 之外的所有标准 MCP 配置选项。gemini-extension.json 规范的服务器会覆盖 settings.json 中的服务器。通过将技能放置在 skills/ 目录中来提供专门的工作流。
skills/
└── security-audit/
└── SKILL.md
模型会自动发现此目录内的技能。
建议: 要学习如何编写有效的技能,请激活 Skill Development 技能。
activate_skill("Skill Development")
通过将 Markdown 定义文件放置在 agents/ 目录中来捆绑子智能体。
agents/
├── security-auditor.md
└── database-expert.md
请查阅 references/agents-schema.md 以获取配置详情。
通过将 TOML 配置文件放置在 commands/ 目录中来添加斜杠命令。
commands/
├── deploy.toml -> /deploy
└── gcs/
└── sync.toml -> /gcs:sync
请查阅 references/commands-schema.md 以获取 TOML 规范。
冲突解决: 处理用户命令和扩展命令之间的名称冲突:
/deploy/extension-name.deploy...
references/extension-schema.md - 详细的 gemini-extension.json 模式。references/hooks-schema.md - 详细的 hooks.json 模式和事件类型。references/agents-schema.md - 子智能体 (agents/) 的配置。references/commands-schema.md - 自定义命令 (commands/) 的配置。examples/gemini-extension.json - 完整的清单文件示例。examples/hooks.json - 完整的钩子配置示例。每周安装次数
0
代码仓库
GitHub 星标数
1
首次出现时间
1970年1月1日
安全审计
Provide expert guidance on creating, packaging, and publishing extensions for the Gemini CLI.
Organize Gemini CLI extensions as self-contained directories including commands, hooks, MCP servers, and other resources.
Maintain the following extension directory structure:
my-extension/
├── gemini-extension.json (Required: Manifest)
├── README.md (Required: Documentation)
├── LICENSE (Required: License)
├── hooks/
│ ├── hooks.json (Optional: Hook definitions)
│ └── my_hook.py (Optional: Hook script)
├── commands/ (Optional: Custom commands)
├── mcp-servers/ (Optional: MCP server code)
├── skills/ (Optional: Agent skills)
└── agents/ (Optional: Sub-agent definitions)
gemini-extension.json)Use the gemini-extension.json manifest to define metadata, configuration settings, dependencies, and entry points for hooks or MCP servers.
Key Fields:
name: Unique identifier (kebab-case).version: Semantic version (e.g., "1.0.0").mcpServers: Definitions for bundled MCP servers.settings: Configuration options exposed to the user.dependencies: Required system tools (e.g., {"python": ">=3.7"}).Consult references/extension-schema.md for the full schema specification.
hooks.json)Define hooks in a JSON file to intercept and modify CLI behavior. Reference this file in the manifest.
Structure:
AfterAgent, BeforeTool).matcher to filter events (e.g., * for all, or specific tool names).command to execute.Best Practice: Use ${extensionPath} in command strings to reference files within the extension directory reliably.
"command": "${extensionPath}/hooks/my_script.py"
Consult references/hooks-schema.md for detailed event types and configuration options.
Bundle MCP servers to expose tools and resources to the model.
Configuration:
Define servers in gemini-extension.json under the mcpServers object.
"mcpServers": {
"my-server": {
"command": "node",
"args": ["${extensionPath}/mcp-server/index.js"],
"env": {
"API_KEY": "${env:MY_API_KEY}"
}
}
}
trust.gemini-extension.json override those in settings.json if names collide.Provide specialized workflows by placing skills in a skills/ directory.
skills/
└── security-audit/
└── SKILL.md
The model automatically discovers skills within this directory.
Recommendation: To learn how to write effective skills, activate the Skill Development skill.
activate_skill("Skill Development")
Bundle sub-agents by placing markdown definitions in an agents/ directory.
agents/
├── security-auditor.md
└── database-expert.md
Consult references/agents-schema.md for configuration details.
Add slash commands by placing TOML configuration files in a commands/ directory.
commands/
├── deploy.toml -> /deploy
└── gcs/
└── sync.toml -> /gcs:sync
Consult references/commands-schema.md for the TOML specification.
Conflict Resolution: Handle name collisions between user commands and extension commands:
/deploy/extension-name.deploy...
references/extension-schema.md - Detailed gemini-extension.json schema.references/hooks-schema.md - Detailed hooks.json schema and event types.references/agents-schema.md - Configuration for sub-agents (agents/).references/commands-schema.md - Configuration for custom commands (commands/).examples/gemini-extension.json - Complete manifest example.examples/hooks.json - Complete hooks configuration example.Weekly Installs
0
Repository
GitHub Stars
1
First Seen
Jan 1, 1970
Security Audits
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
136,300 周安装