官方教程中文版上下文与配置
上下文与配置
Gemini CLI 上下文与配置入口:settings、GEMINI.md、memory、.geminiignore、自定义命令、生成参数、system prompt、themes 和 trusted folders。
这一组解决 Gemini CLI 能不能长期稳定使用。一次性 prompt 只能解决当前任务;GEMINI.md、settings、memory、自定义命令和 ignore 文件,才是把经验沉淀下来的地方。
核心原则:反复说的项目规则写进 GEMINI.md;行为开关写进 settings;不该读的文件写进 .geminiignore;重复任务写成 custom command。
学习路径
flowchart LR
Rules["GEMINI.md"] --> Settings["settings.json"]
Settings --> Memory["memory"]
Memory --> Ignore[".geminiignore"]
Ignore --> Commands["custom commands"]
Commands --> Advanced["generation / system prompt"]
Advanced --> Trust["themes / trusted folders"]
Trust --> Tools["tools / MCP"]
style Rules fill:#dbeafe,stroke:#3b82f6
style Ignore fill:#fee2e2,stroke:#ef4444
style Commands fill:#dcfce7,stroke:#22c55e
分层建议
一次性 prompt 当前任务临时要求
GEMINI.md 项目长期规则和工作方式
settings.json CLI 行为、模型、工具、MCP、权限配置
.geminiignore 不让 Gemini CLI 读取的文件
custom commands 重复执行的任务入口规则与行为分层
先区分 GEMINI.md、settings、memory 和 prompt 的职责。
上下文安全边界
继续看 memory、.geminiignore 和 trusted folders。
可复用操作
把重复任务沉淀为 custom commands,再考虑扩展和 MCP。
页面清单
| 页面 | 解决的问题 |
|---|---|
| Settings | CLI 行为、模型、工具、MCP、权限配置放哪里 |
| GEMINI.md | 项目长期规则和上下文如何沉淀 |
| Memory management | 长期记忆、auto memory、/memory reload 边界 |
| .geminiignore | 排除敏感文件、大文件和不该读的上下文 |
| Custom commands | 把重复任务变成 slash command |
| Generation settings | 什么时候调模型生成参数 |
| System prompt override | 高级 system prompt 替换的风险 |
| Themes | 终端 UI 和教程截图一致性 |
| Trusted folders | workspace 信任和 safe mode 边界 |
下一步
先读:Settings。