TopRank Skills

Home / Claw Skills / Intégration d'API / context-gatekeeper
Official OpenClaw rules 36%

context-gatekeeper

Keeps the conversation token-friendly by summarizing recent exchanges, surfacing pending actions, and delivering a compact briefing for each turn before calling the model. Trigger this skill whenever you need to prune a bloated thread or keep the next prompt lean.

Stars

0

Installs

0

Status

ACTIVE

Visibility

PUBLIC

安装方式

直接复制以下提示词,发送给你的 AI 助手即可完成安装。

请先检查是否已安装 SkillHub 商店,若未安装,请根据 https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/skillhub.md 安装 SkillHub 商店,然后安装 context-gatekeeper 技能。 若已安装,则直接安装 context-gatekeeper 技能。

Overview

Skill Key
davienzomq/context-gatekeeper
Author
Davi Marques
Source Repo
openclaw/skills
Version
-
Source Path
skills/davienzomq/context-gatekeeper
Latest Commit SHA
60e215a91cdf696ddce31dd10a4845aee41e071e

Extracted Content

SKILL.md excerpt

# Context Gatekeeper

## Objetivo
Reduzir o volume de tokens enviados ao modelo preservando apenas o essencial: o resumo das decisões, os próximos passos e os trechos mais recentes da conversa. Este skill roda em paralelo à sua rotina habitual, produzindo o artefato `context/current-summary.md` que serve como contexto de substituição (em vez de reenviar toda a conversa).

## Fluxo mínimo
1. **Registre as trocas**: a cada prompt/resposta, grave uma linha formatada `ROLE: texto` em um arquivo de histórico (`context/history.txt` ou qualquer caminho acessível). Exemplo:
   ```
   USER: Quero definir metas para o Q2
   ASSISTANT: Fiz um plano com marcos e métricas
   ```
2. **Execute o guardião**:
   ```bash
   python skills/context-gatekeeper/scripts/context_gatekeeper.py \
     --history context/history.txt \
     --summary context/current-summary.md
   ```
   O script limita o resumo (até 6 sentenças por padrão), extrai atividades abertas (TODO, próxima ação, tarefa, follow-up) e inclui as últimas 4 jogadas para contexto imediato.
3. **Use o resumo**: antes de chamar a API (ou responder ao usuário), injete o conteúdo de `context/current-summary.md` e cite os itens pendentes. Apenas depois disso, se for necessário, adicione as últimas trocas concretas (máximo de 2-3 mensagens) para clareza imediata.
4. **Repita**: atualize `context/history.txt` com a nova resposta e execute o script novamente antes do próximo turno.

## Argumentos do script
- `--history`: caminho do arquivo com o log das trocas (cada linha deve ser `ROLE: texto`). Usa STDIN se omitido.
- `--summary`: destino do resumo (substitui o arquivo se já existir).
- `--max-summary-sents`: limite de sentenças resumidas (padrão 6).
- `--max-recent-turns`: quantas trocas finais aparecerão na seção "Últimos turnos" (padrão 4).

## Dica de operação diária
- Monte um cron/loop leve que chame o script antes de cada resposta automática.
- Guarde um paralelo `context/pending-tasks.md` e copie a seção "Pendências" do resu...

README excerpt

# Context Gatekeeper — Full documentation

## Purpose
**Context Gatekeeper** keeps OpenClaw sessions token-efficient by compressing the active conversation. It summarizes the tail of the thread, spots open tasks, and keeps a short log of the latest turns so you only send what matters to the model.

## Repository layout
```
skills/context-gatekeeper/
├── SKILL.md                  # Meta description (triggers and usage)
├── README.md                 # This reference for ClawHub and contributors
├── scripts/
│   ├── context_gatekeeper.py  # Builds the compact summary, highlights, and recent-turn log
│   ├── auto_monitor.py        # Watches history.txt and regenerates the summary automatically
│   └── ensure_context_monitor.sh  # Starts (or restarts) the monitor safely
├── context/
│   ├── history.txt           # Rolling log (ROLE: message)
│   ├── current-summary.md    # Briefing used before every reply
│   └── sample-history.txt    # Test data for quick verification
└── README.md                 # This document
```

## Scripts overview

### `context_gatekeeper.py`
1. Reads the history file (ROLE: message per line) and slices the text into sentences.
2. Picks up pending tasks by keyword (todo, task, follow-up, next step, etc.) and keeps up to the last four turns.
3. Outputs `current-summary.md` containing: timestamp, "Compact summary", "Pendencies and next steps" and "Last turns" sections.
4. You can tweak output length via `--max-summary-sents`, `--max-pendings`, and `--max-recent-turns`.

### `auto_monitor.py`
1. Runs in a loop and watches `context/history.txt` for modification time changes.
2. When new content appears, it executes `context_gatekeeper.py` and logs the event to `/tmp/context-gatekeeper-monitor.log`.
3. Ensures the summary is fresh before each answer, supporting 24/7 operation.

### `ensure_context_monitor.sh`
- Checks for an existing `auto_monitor.py` process (`pgrep -f auto_monitor.py`). If none exists, it launches the monitor with `nohup` and saves...

Related Claw Skills