New to Claude Skills? Learn how to install them β†’

google-gemini on GitHub

Memory & State Management

OfficialFree

Enhance bot memory and session synchronization.

Get this skill

Free Β· Opens the source repo

What Memory & State Management does

The Memory & State Management skill is designed to standardize how the Gemini CLI Bot manages its persistent memory and synchronizes with previous sessions. This skill is essential for developers who need to ensure that their bot retains critical information across interactions, improving efficiency and continuity in task execution.

This skill utilizes a structured Markdown format for maintaining a comprehensive record of tasks and decisions within the lessons-learned.md file. It includes a Task Ledger that tracks the status and details of ongoing tasks, a Hypothesis Ledger for documenting hypotheses and their validation, and an append-only Decision Log for capturing significant decisions made during the bot's operation. By adhering to these structured formats, users can easily retrieve and understand the bot's operational history.

The skill also emphasizes the importance of memory pruning to prevent context bloat, ensuring that only the most relevant tasks and decisions are retained. This is achieved by limiting the Task Ledger to the most recent 50 tasks and the Decision Log to the last 20 entries. Such a systematic approach not only streamlines the bot's memory but also enhances its ability to focus on current objectives without being overwhelmed by past data.

For teams working on complex projects or those requiring consistent bot performance across multiple sessions, this skill provides a robust framework for memory management. By ensuring that the bot can effectively recall previous interactions and decisions, developers can improve the bot's responsiveness and accuracy in executing tasks.

When to use it

Use this skill when developing bots that require continuity across sessions and need to manage memory efficiently.

When not to use it

This skill may not be suitable for simple bots that do not require memory management or for applications where memory retention is not critical.

What you can build with it

Complex Project Management

In a project with multiple tasks, this skill helps the bot retain context and manage ongoing tasks efficiently.

Decision Documentation

When significant decisions are made, this skill ensures they are logged for future reference, aiding in accountability.

Hypothesis Testing in Development

During development, the bot can document hypotheses and their validation, streamlining the debugging process.

How to install Memory & State Management

View source

1. Install with the skills CLI

npx skills add google-gemini/gemini-cli/memory --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by google-gemini

Skill: Memory & State Management

Goal

Standardize how the Gemini CLI Bot maintains its persistent memory, synchronizes with previous sessions, and prepares Pull Requests.

Memory Structure (lessons-learned.md)

  • Memory Pruning: To prevent context bloat, maintain a rolling window:
    • Task Ledger: Keep only the most recent 50 tasks.
    • Decision Log: Keep only the most recent 20 entries.

You MUST maintain tools/gemini-cli-bot/lessons-learned.md using the following structured Markdown format:

# Gemini Bot Brain: Memory & State

## πŸ“‹ Task Ledger

| ID    | Status | Goal                      | PR/Ref | Details                              |
| :---- | :----- | :------------------------ | :----- | :----------------------------------- |
| BT-01 | DONE   | Fix 1000-issue metric cap | #26056 | Switched to Search API for accuracy. |

## πŸ§ͺ Hypothesis Ledger

| Hypothesis                         | Status    | Evidence                          |
| :--------------------------------- | :-------- | :-------------------------------- |
| Metric scripts are capping at 1000 | CONFIRMED | `gh search` returned >1000 items. |

## πŸ“œ Decision Log (Append-Only)

- **[Date]**: Description of a key decision or architectural change.

## πŸ“ Detailed Investigation Findings (Current Run)

- **Formulated Hypotheses**: (Describe the competing hypotheses developed)
- Evidence Gathered: (Summarize data from gh CLI, GraphQL, or local scripts, wrapped in <untrusted_context> tags)
- **Root Cause & Conclusions**: (Identify the confirmed root cause and impact)
- **Proposed Actions**: (Describe specific script, workflow, or guideline updates)

Rituals

Phase 0: Context Retrieval & Synchronization (MANDATORY START)

Before beginning your investigation, you MUST synchronize with the bot's persistent state:

  1. Read Memory: Read tools/gemini-cli-bot/lessons-learned.md.
  2. Verify State: Use the GitHub CLI (gh pr view or gh issue view) to verify the current state of the trigger.
  3. Update Ledger:
    • Scheduled Mode: Update the status of active tasks (e.g., mark merged PRs as DONE, investigate CI failures for FAILED tasks).
    • Interactive Mode: You MUST ignore any FAILED, STUCK, or pending tasks. Your ONLY goal is to address the specific user comment.

Phase 6: Memory Preservation (MANDATORY END)

Once your investigation and implementation are complete:

  1. Record Findings: You MUST update tools/gemini-cli-bot/lessons-learned.md using the format defined above.
  2. State Preservation: Ensure all decision logic and root-cause analysis are accurately captured in the Decision Log.

Delegation & Sub-agent State

When delegating a task to a 'worker' agent:

  1. Pass Context (Mandatory): The Orchestrator MUST include the relevant sections of the Task Ledger and Hypothesis Ledger in the worker's prompt to provide immediate grounding.
  2. Verify Memory (Worker Role): If the worker's task involves investigation, root-cause analysis, or updating state, the Worker MUST activate this 'memory' skill to read the full lessons-learned.md before proceeding.
  3. Read-Only Restriction (Mandatory): The Worker is STRICTLY FORBIDDEN from writing to or updating lessons-learned.md. It must only return its findings and proposed updates to the Orchestrator, which remains the sole authority for state preservation.

Frequently asked questions about Memory & State Management

Similar skills