wrap

A command for closing a Claude Code session, including checks for potentially risky file deletions and recording session context.

In plain words
What is it for?
Use it when ending a session manually or when the context monitor asks you to wrap up.
Why use it?
It helps preserve useful session information and warns before closing when many files appear to have been deleted.

Command

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/vaibhavaher100/wrap-session/wrap
Clone the repo
git clone --depth 1 https://github.com/VaibhavAher100/wrap-session
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 2,094 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.02094
Opus 5 $0.00000 $0.01047
Sonnet 5 $0.00000 $0.00419
Haiku 4.5 $0.00000 $0.00209

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

Security

Grade A, and why

wrap 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 yesterday.

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.

commands/wrap.md · 198 lines

How it starts

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

You are closing a Claude Code session. Execute all steps below in order.

Note: This skill tracks only the current model's context window. Context percentage is read from the Claude Code API via the statusline state file — model-aware, accurate for any context window size. The 5-hour and 7-day usage limits are separate — do not conflate them with session context.

When invoked manually by the user (/wrap): execute all steps immediately, no confirmation needed. When invoked automatically by the context monitor hook at 40%: the hook will have already asked the user whether they want to wrap. By the time this skill runs, the user has already said yes — proceed directly.


Step 0 — Pre-flight safety check

Use the Bash tool (bash, not PowerShell — these are bash-specific commands):

git -C . status --short 2>/dev/null | grep "^.D\|^ D" | wc -l

If the count is 20 or more uncommitted deletions, stop and output:

Warning: Detected N uncommitted file deletions. Wrapping now may lose context on files that were deleted this session. Type confirm wrap to proceed anyway, or commit/stash first.

Wait for user response before continuing. If count is under 20, proceed immediately.


Step 1 — Determine session ID

Use the Bash tool:

ls logs/sessions/$(date +%Y-%m-%d)-*.md 2>/dev/null | sort | tail -1
  • If output is empty: new ID is <today's date>-001
  • If output is e.g. ...2026-05-21-003.md: new ID is 2026-05-21-004
  • Do not count manually — use the shell output as the source of truth

Step 2 — Write the session log

Self-assess confidence using this rubric:

  • confidence: high — full session visible, no compaction events fired, all tool calls in context, clean completion with no unexplained gaps
  • confidence: medium — at least one of: some compaction occurred, session ran >2 hours, >50 tool calls, some tool outputs were truncated; key decisions are present but some actions may be missing
  • confidence: low — heavy compaction (early messages gone), unresolved blockers exist that you cannot explain, or more than ~30 minutes of work is unaccounted for in your context

Read the full file on GitHub · 198 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. yesterday First seen · 198 lines · 0 tokens per session scan A c3d0419111a3

Subscribe to this mod's changes

wrap is a command published in the GitHub repository VaibhavAher100/wrap-session (1 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,094 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.