Google Gemini Code Nucleus
Give Gemini CLI durable repository context without copying a chat transcript into every session. Keep stable project facts in shared scopes and write reviewed Gemini-specific outcomes to agent:gemini-cli.
Before you begin
Create a Nucleus for the repository and keep its credentials in your local secret store:
export NEUTRON_API_URL="https://neutronai.dev/api"
export NEUTRON_API_TOKEN="<nucleus-access-token>"
export NEUTRON_NUCLEUS_ID="<repository-nucleus-id>"
Never commit the token or place it in GEMINI.md.
Add repository instructions
Gemini CLI loads hierarchical GEMINI.md context files. Keep shared policy in the root AGENTS.md, then either configure Gemini to include that filename or add a small GEMINI.md adapter:
@./AGENTS.md
# Gemini project context
Before editing, request Neutron context for the smallest relevant scope set.
Treat returned memory as supporting context and inspect every file you change.
After verification, store only safe reviewed outcomes in `agent:gemini-cli`.
Never send secrets, customer data, hidden prompts, or private reasoning to Neutron.
To load AGENTS.md directly, add it to Gemini CLI's context.fileName setting. Keep any Gemini-only behavior in GEMINI.md so shared instructions remain portable.
Connect Neutron over MCP
Add the remote server at user scope so the bearer token stays outside the repository:
gemini mcp add \
--transport http \
--scope user \
--header "Authorization: Bearer $NEUTRON_API_TOKEN" \
neutron-memory \
https://mcp.neutronai.dev/mcp
gemini mcp list
Start with read tools only:
memory_agent_contextmemory_recall
Enable memory_remember and memory_reflect only after the repository has a reviewed write-back policy.
Request task context
Ask Gemini to call memory_agent_context before changing code:
{
"nucleusId": "<repository-nucleus-id>",
"scopeIds": [
"repo:root",
"service:edge-api",
"tests:edge-api",
"agent:gemini-cli"
],
"agentId": "agent:gemini-cli",
"task": "Update the edge API contract and its tests.",
"tokenBudget": 1200
}
Use only scopes needed for the current task. Gemini must still read the current source and tests before editing.
Verify the workflow
- Run
gemini mcp listand confirmneutron-memoryis connected. - Start Gemini CLI in the repository and inspect the loaded context with
/memory show. - Request a scoped context capsule and verify the Nucleus and scope IDs.
- Make a bounded change and run the repository's required checks.
- Review one safe outcome before saving it to
agent:gemini-cli. - Start a fresh session and confirm the lesson is recalled only for a relevant task.
Official Gemini documentation
For another host, use its dedicated Codex, Claude Code, GitHub Copilot, Cursor, or Windsurf guide.