session-distill

Instructions for compressing a long coding session into notes that another session can use to continue the work.

In plain words
What is it for?
Creating session handoffs, recording unfinished work and current assumptions, and saving verified decisions for future tasks.
Why use it?
It separates temporary work details from lasting decisions, so a new session can resume without repeating the investigation.

Cursor rule for Cursor

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 rules/srmackey/context-forge/session-distill
Clone the repo
git clone --depth 1 https://github.com/srmackey/context-forge

Made for: Cursor.

Per session 59 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 891 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.00059 $0.00891
Opus 5 $0.00030 $0.00445
Sonnet 5 $0.00012 $0.00178
Haiku 4.5 $0.00006 $0.00089

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

Security

Grade A, and why

session-distill 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.

.cursor/rules/session-distill.mdc · 83 lines

How it starts

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

Session distiller

When a work session runs long or context gets bloated mid-task, compress it into ContextForge so the next session resumes without re-deriving anything. This rule tells you how to capture; it does not hold the knowledge.

1. Identify the task

Resolve the task slug (e.g. proj-1234). If unsure, ask or infer from the session. If no task: entity exists yet, create one (create_task) before capturing.

2. Two outputs, two filters — do not cross-contaminate

The hard rule. Each piece of the session goes to exactly one of:

  • Session seed"what do I need to resume tomorrow without losing momentum?" Transient. Includes things the durable corpus must NOT have (dead-ends, half-formed plans, current hypothesis).
  • Durable distillation"would a cold agent on a future, unrelated task want this?" Permanent. Decisions + rationale, gotchas, cross-links.

If a fact fails the durable test (e.g. a path you tried and ruled out), it belongs in the seed only — never the corpus.

3. Be faithful and verify

  • Record only what actually happened this session. Never invent state. Flag uncertainty.
  • Before writing "done"/"fixed"/"passing", verify against ground truth — git log, the test run, the Jira ticket — and cite file:line, commit SHA, or PR. Code and Jira outrank prose; the next session must be able to confirm, not just trust.
  • The human's decisions and overrides are binding. Record them so the next session does not relitigate settled calls.

4. Write the session seed (overwrite each time)

upsert_context(ref="task:<slug>/session-state", content=...) — overwrite, it's the current head, not history. Keep it short. Structure:

**Status:** branch `<branch>`, last commit `<sha>`; <one line on overall state>

## Where I am
- Done this session: ...
- Half-done / in progress: ...

## Next step (do this first)
1. <the single most concrete next action>

## Open loops
- Decisions not yet made; things waiting on someone/something.

## Dead-ends (do NOT re-explore)
- <path tried> — ruled out because <why>.

## Working hypothesis
- The mental model you'd lose on restart.

## Verify state yourself
- `git log --oneline -5`
- `<test / build / run command>`

Read the full file on GitHub · 83 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 · 83 lines · 59 tokens per session scan A 9522de36dc42

Subscribe to this mod's changes

session-distill is a cursor rule published in the GitHub repository srmackey/context-forge (1 stars, last pushed 23d ago), licensed MIT. It adds 59 tokens to every session and 891 once invoked, about $0.0003 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-31.