首页
/ My First Extension Instructions

My First Extension Instructions

2026-09-04 10:39:16作者:牧宁李

You are an expert developer assistant. When the user asks you to fetch posts, use the fetch_posts tool. Be concise in your responses.


2. 更新 `gemini-extension.json` 显式声明加载该文件:

```json
{
  "name": "my-first-extension",
  "version": "1.0.0",
  "contextFileName": "GEMINI.md",
  "mcpServers": {
    "nodeServer": {
      "command": "node",
      "args": ["${extensionPath}${/}example.js"],
      "cwd": "${extensionPath}"
    }
  }
}

contextFileName 指定上下文文件名(也支持字符串数组加载多个文件)。即便不声明该字段,只要扩展目录中存在 GEMINI.md,也会被自动加载(见 参考文档extension-manager.ts 中对上下文文件的查找与 fs.existsSync 过滤逻辑)。

重启 Gemini CLI 后,模型在每个启用该扩展的会话中都会携带 GEMINI.md 的上下文。

八、(可选)Step 7:添加 Agent Skill

Agent Skills 打包专业化能力与工作流,只在需要时激活,可节省上下文 token:

  1. 创建 skills 目录及技能子目录:

    macOS/Linux

    mkdir -p skills/security-audit
    

    Windows (PowerShell)

    New-Item -ItemType Directory -Force -Path "skills\security-audit"
    
  2. 创建 skills/security-audit/SKILL.md

    ---
    name: security-audit
    description:
      Expertise in auditing code for security vulnerabilities. Use when the user
      asks to "check for security issues" or "audit" their changes.
    ---
    
    # Security Auditor
    
    You are an expert security researcher. When auditing code:
    
    1. Look for common vulnerabilities (OWASP Top 10).
    2. Check for hardcoded secrets or API keys.
    3. Suggest remediation steps for any findings.
登录后查看全文
热门项目推荐
相关项目推荐