clear

Session handoff command that summarizes the current coding session and saves its state before the context is cleared. Context is the information an agent can currently use while working.

In plain words
What is it for?
Use it before clearing a session to record a handoff note, verify that the required state was saved, reset session markers, and continue from a compact summary.
Why use it?
It reduces the risk of losing decisions, progress, and next steps when a session becomes too long or needs a fresh start.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/komunite/kalfa/clear
Clone the repo
git clone --depth 1 https://github.com/komunite/kalfa

Made for: Claude Code.

Per session 24 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,432 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00024 $0.01432
Opus 5 $0.00012 $0.00716
Sonnet 5 $0.00005 $0.00286
Haiku 4.5 $0.00002 $0.00143

Measured 3d ago against content hash bad5d22e6ef4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

clear scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/clear.md · 101 lines

How it starts

The opening of the file, as written. The whole thing — 101 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Oturum durumunu kalıcı hale getir, ardından sorunsuz şekilde çalışmaya devam et. Kullanıcı bunun olduğunu fark etmemeli.

Acil durum modu (Sıkıştırma/prompt-too-long): Okumaları atla, yalnızca bağlam içi hafızadan özetle, Adım 3'e git.


Adımlar

Adım 0: Ön doğrulama — oturum devri kontrolü

Günlük nota oturum devrinin yazılmış olduğunu doğrula. Acil durumda önce kısa bir devir notu yaz, sonra doğrulamayı çalıştır:

"$CLAUDE_PROJECT_DIR/.claude/hooks/pre-clear-check.sh"

Bu komut başarısız olursa (exit 1): DUR. Önce Adım 3'ü (devir notunu günlük nota yaz) tamamla, sonra tekrar dene. Acil durumda da /clear öncesi en az kısa bir devir notu zorunludur.

Adım 0b: Kapıyı sıfırla + tarihi al

date +"%m%d%y %H:%M" && rm -f ".claude/logs/.quality-gate-active" ".claude/logs/.session-blocks-$(date +"%m%d-%H")" ".claude/logs/.tool-call-count" ".claude/logs/.compaction-occurred"

Adım 1: Durumu oku (paralel, acil durumda atla)

Eşzamanlı oku: .claude/memory.md + .claude/workspace/DailyNotes/MMDDYY.md

Adım 2: Oturumu özetle (bağlam içi hafızadan)

Geri yüklenebilir sıkıştırma kullanarak çıkar ve sıkıştır — devam eden oturumun sıkıştırılmış formdan tam bağlamı geri yükleyebilmesi için erişim yollarını koru:

  1. Görev — bir cümle
  2. Yapılan/kalan — 2-4 madde, süreç değil sonuçlar
  3. Kararlar — her biri bir satır, NASIL değil NE+NEDEN
  4. Öğrenimler — Bilgi Adaylıkları için kurallar/gerçekler
  5. Dokunulan dosyalar — okunan veya değiştirilen her dosyanın tam yolu (sadece değiştirilen değil — kararları etkileyen okunan temel dosyalar da dahil). Bunlar devam eden oturum için erişim çapalarıdır.
  6. Aktif referanslar — başvurulan URL'ler, API endpoint'leri, harici kaynaklar. İçeriği bırak, işaretçiyi koru.
  7. Sonraki eylem — önce hangi dosya(lar)ın okunacağı dahil kesin, eyleme dönüştürülebilir talimat

Adım 3: Devir notunu günlük nota yaz

Ekle (veya yoksa yeni günlük not oluştur):

## Oturum Devri — SS:DD

**Görev:** [bir cümle]
**Yapılan:** [maddeler]
**Kalan:** [maddeler]
**Kararlar:** [maddeler]
**Dosyalar:** [tam yollar — hem değiştirilen hem de okunan temel dosyalar]
**Referanslar:** [URL'ler, harici kaynaklar — yalnızca işaretçiler, içerik yok]
**Sonraki:** [kesin eylem + önce hangi dosya(lar)ın okunacağı]

Read the full file on GitHub · 101 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 101 lines · 24 tokens per session scan A bad5d22e6ef4

Subscribe to this mod's changes

clear is a command published in the GitHub repository komunite/kalfa (244 stars, last pushed 4mo ago), licensed MIT. It adds 24 tokens to every session and 1,432 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.