knowledge-session-state-and-context

knowledge-session-state-and-context is a skill for Claude Code, Codex from echoVic/blade-code. It costs 133 tokens per session (1,756 once invoked), scanned A, original, MIT.

A codebase guide for storing agent sessions, rebuilding their visible state, recovering active work, branching or rewinding history, and shortening context sent to the model.

In plain words
What is it for?
Use it for session loading, resume, fork, rewind, JSONL event storage, project memory, token budgets, and context compression.
Why use it?
It helps developers keep durable session history separate from temporary interface state and recover sessions without losing the authoritative record.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for session loading, resume, fork, rewind, JSONL event storage, project memory, token budgets, and context compression.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/echovic/blade-code/session-state-and-context
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.

Any agent
npx skills add echoVic/blade-code --skill session-state-and-context
Clone the repo
git clone --depth 1 https://github.com/echoVic/blade-code

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for knowledge-session-state-and-context

README.md
[![agentmods](https://agentmods.dev/badge/skills/echovic/blade-code/session-state-and-context.svg)](https://agentmods.dev/skills/echovic/blade-code/session-state-and-context)
Your own site
<a href="https://agentmods.dev/skills/echovic/blade-code/session-state-and-context"><img src="https://agentmods.dev/badge/skills/echovic/blade-code/session-state-and-context.svg" alt="Measured on agentmods" height="20"></a>
Per session 133 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,756 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00133 $0.01756
Opus 5 $0.00067 $0.00878
Sonnet 5 $0.00027 $0.00351
Haiku 4.5 $0.00013 $0.00176

Measured 3d ago against content hash 6737b8a5a85c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

knowledge-session-state-and-context 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.

Origin

Copies of this mod

7 near-identical copies found in the catalogue:

.trae/knowledges/session-state-and-context/SKILL.md · 55 lines

How it starts

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

Module Structure

该域负责把一次会话的权威事实、活动运行时与各端读模型分开:持久事实进入 JSONL,运行时持有互斥与恢复状态,TUI/Web/ACP 从相同事实投影,模型上下文则可在不破坏完整历史的前提下压缩。

Directory Layout

  • packages/cli/src/context/:事件模型、持久存储、上下文组装、压缩与 Token 预算
  • packages/cli/src/agent/runtime/:Session 所有权、活动轮次 mailbox、恢复和私有 artifact
  • packages/cli/src/services/SessionService.ts:会话目录、加载、分叉、回退、归档与导出编排
  • packages/cli/src/services/SessionInteractionService.ts:持久交互请求、响应和崩溃恢复
  • packages/cli/src/memory/:跨会话项目记忆与压缩后巩固

Key Entry Points

  • SessionRuntime.initialize() in packages/cli/src/agent/runtime/SessionRuntime.ts:获取会话所有权并执行恢复
  • PersistentStore in packages/cli/src/context/storage/PersistentStore.ts:将领域动作转换为有序事件
  • SessionService in packages/cli/src/services/SessionService.ts:面向 CLI、Web 与 ACP 的持久会话服务
  • CompactionService.compact() in packages/cli/src/context/CompactionService.ts:生成并约束模型可见替换上下文

Gotchas

  • sessionId 不是全局身份;省略 projectPath 的查找可能因多个工作区同名而拒绝,跨端路由必须保持 sessionId + canonical projectPath 复合身份 (packages/cli/src/services/SessionService.ts, packages/cli/src/server/sessionRef.ts)
  • Runtime、TUI store、Web store 和 SQLite 都不是持久真相,修复恢复问题时必须从 materialized JSONL 重新推导,不能把某个内存快照写回当作权威 (packages/cli/src/context/storage/PersistentStore.ts, packages/cli/src/context/storage/sqlite/projection.ts)
  • rewind 与 compaction 都保留原始 transcript:前者通过 session_rewound 改变有效事件,后者通过 replacement checkpoint 改变模型可见上下文;直接截断 JSONL 会同时破坏审计、导出和断点续传 (packages/cli/src/services/sessionRewind.ts, packages/cli/src/services/SessionService.ts)
  • durable inbox、prompt artifact 等 sidecar 不是独立会话真相;它们必须通过 transcript 中的 acknowledgement、message metadata 或生命周期事件对账后才能删除或重放 (packages/cli/src/agent/runtime/DurableSteeringInbox.ts, packages/cli/src/agent/runtime/UserPromptArtifactStore.ts)
  • 会话恢复必须先取得 SessionLease 再修复 orphan 进程、工具调用和 turn;颠倒顺序会让两个进程同时“恢复”同一条父链 (packages/cli/src/agent/runtime/SessionRuntime.ts, packages/cli/src/agent/runtime/SessionLease.ts, git:46145c53)

Architecture

  • 写路径为 SessionRuntime/SessionService -> ContextManager/PersistentStore -> SessionEventLog -> JSONLStore,事件落盘并取得 seq 后才允许发布给各 surface (packages/cli/src/agent/runtime/SessionRuntime.ts, packages/cli/src/context/ContextManager.ts, packages/cli/src/context/events/SessionEventLog.ts)
  • 读路径有三种不同投影:完整可见历史供 UI/导出,replacement checkpoint 之后的上下文供模型,SQLite materialization 供目录与搜索;三者不能互相替代 (packages/cli/src/services/SessionService.ts, packages/cli/src/context/storage/sqlite/projection.ts)
  • 活动轮次采用“双账本”恢复:inbox 保存尚未确认的输入,JSONL 保存 turn/tool/interaction 事实;启动时通过 message ID 和终态 receipt 对账形成 exactly-once continuation (packages/cli/src/agent/runtime/DurableSteeringInbox.ts, packages/cli/src/context/storage/PersistentStore.ts)
  • 跨端一致性依赖同一事件语义而非同一 UI reducer:TUI 使用共享 conversation reducer,Web 消费 SSE 投影,ACP 消费顺序化 update,但都以已提交 JSONL 生命周期为恢复边界 (packages/cli/src/store/slices/sessionSlice.ts, packages/cli/web/src/store/session/handlers/eventHandlers.ts, packages/cli/src/acp/Session.ts)

Read the full file on GitHub · 55 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 · 55 lines · 133 tokens per session scan A 6737b8a5a85c

Subscribe to this mod's changes

knowledge-session-state-and-context is a skill published in the GitHub repository echoVic/blade-code (178 stars, last pushed yesterday), licensed MIT. It adds 133 tokens to every session and 1,756 once invoked, about $0.0007 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-09-03.

Related

Other skills, from other repositories

linearis

Manage Linear.app work from the command line with the linearis CLI (bins linearis / linear), which outputs JSON: issues/tickets, projects, cycles (sprints), milestones, initiatives (roadmap), documents, labels, teams, users, and issue discussions/comments. Use when the user mentions Linear, a ticket identifier like…

linearis-oss/linearis · 111 tokens

autogpt-agents

Autonomous AI agent platform for building and deploying continuous agents. Use when creating visual workflow agents, deploying persistent autonomous agents, or building complex multi-step AI automation systems.

synthetic-sciences/openscience · 39 tokens

algorithmic-art

Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright…

alleneee/skill-agent · 62 tokens

mcp-builder

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external agents through well-designed tools. Use when building MCP servers to integrate external APIs or agents, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

alleneee/skill-agent · 61 tokens

slack-gif-creator

Toolkit for creating animated GIFs optimized for Slack, with validators for size constraints and composable animation primitives. This skill applies when users request animated GIFs or emoji animations for Slack from descriptions like "make me a GIF for Slack of X doing Y".

alleneee/skill-agent · 57 tokens

canvas-design

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.

alleneee/skill-agent · 59 tokens