clear

A session handoff command that summarizes current work, writes a handoff note, and updates project memory before a new session begins.

In plain words
What is it for?
Use it to close a coding session and prepare the next session to continue with the necessary context.
Why use it?
It helps preserve the task status, recent actions, open questions, changed files, and next steps when work crosses session boundaries.

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/fatihkan/badi/clear
Clone the repo
git clone --depth 1 https://github.com/fatihkan/badi

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 521 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.00000 $0.00521
Opus 5 $0.00000 $0.00260
Sonnet 5 $0.00000 $0.00104
Haiku 4.5 $0.00000 $0.00052

Measured 2d ago against content hash 0767d0ffcc84, 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 2d 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 · 89 lines

How it starts

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

Context-clearing command. Provides a seamless transition across session boundaries. Target: under 30 seconds.

Required Tools

  • Read (context files)
  • Write (handoff note and memory update)

Procedure (6 Steps)

Step 1: Reset the Gates

  • Clear the active file-watch list
  • Reset temporary analysis results
  • Close any open parallel work
  • Clear in-session variables

Step 2: Summarize the Session (7 Components)

Build a summary covering these 7 components:

  1. Active Task: What task is being worked on right now?
  2. Status: What stage? (start/middle/done/blocked)
  3. Last Action: What was the most recent work?
  4. Next Step: What needs to happen immediately?
  5. Open Questions: Any questions awaiting answers?
  6. Changed Files: Files modified this session
  7. Key Context: Critical information the next session must know

Step 3: Write the Handoff Note

Create handoffs/handoff-[DDMMYY-HHMM].md:

# Handoff Note - [date time]

## Active Task
[task description]

## Current Status
[status detail]

## Recent Actions
- [action list]

## Next Steps
1. [step]
2. [step]

## Open Questions
- [questions]

## Changed Files
- [file list]

## Critical Context
[information that must not be lost]

Step 4: Update Memory

In memory.md:

  • Update the latest task status
  • Add the handoff note reference
  • Update the timestamp

Step 5: Move Learnings

Transfer this session's learnings into knowledge-base.md:

  • Technical knowledge
  • Project decisions
  • Process notes

Step 6: Auto-Continue

Prepare for the next session's start command:

  • Point to the handoff note path
  • Highlight the priority actions
  • Offer a starting suggestion

Output Format

=== BADI CONTEXT CLEAR ===
Duration: [seconds]s
Handoff Note: handoffs/handoff-[date].md
Memory: UPDATED
Learnings: [count] items transferred

For the Next Session:
> [one-line starting suggestion]
===============================

Performance Target

  • The whole operation must finish in under 30 seconds
  • The memory file must not exceed 500 lines
  • The handoff note must be concise and clear (no needless detail)

Read the full file on GitHub · 89 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. 2d ago First seen · 89 lines · 0 tokens per session scan A 0767d0ffcc84

Subscribe to this mod's changes

clear is a command published in the GitHub repository fatihkan/badi (7 stars, last pushed 16d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 521 tokens. 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-31.