Agent skill

Save Tokens

by aspenkit in aspenkit/aspens

Token-saving session automation — statusline, prompt guard, precompact handoffs, session rotation, and handoff commands for Claude Code

MITAuto-check passedAgent Workflows

Install Save Tokens

skills CLI
$ npx skills add aspenkit/aspens --skill save-tokens -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install aspenkit/aspens save-tokens --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/aspenkit/aspens.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/save-tokens .claude/skills/save-tokens && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
save-tokens
GitHub stars
102
Token cost
~1.6k tokens
SKILL.md length
621 words
Files
1
Skills in repo
12
Repo updated
First seen
Licence
MIT

At a glance

Token-saving session automation — statusline, prompt guard, precompact handoffs, session rotation, and handoff commands for Claude Code

  • Tasks that involve LLM guardrails
  • SKILL.md covers Domain purpose, Business rules / invariants, Non-obvious behaviors and Critical files (purpose, not…, plus 2 more sections
  • Calls git

What it does

Save Tokens is an agent skill from aspenkit/aspens. Token-saving session automation — statusline, prompt guard, precompact handoffs, session rotation, and handoff commands for Claude Code

Its SKILL.md is about 1.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Agent Workflows, covering LLM guardrails. The repository describes itself as: Your CLAUDE.md stopped working at 200 lines. Generate scoped skill files from your import graph, auto-sync on every commit. Claude Code, Codex and OpenCode. The licence is MIT.

When your agent uses it

  • Tasks that involve LLM guardrails

Example prompts

  • “/save-tokens”

What it can do on your machine

Read from SKILL.md and the folder at commit 8dde826. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Save Tokens loads about 1.6k tokens when it runs. Until then it costs about 37 tokens; SKILL.md has 621 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~37
When it runs · the whole SKILL.md, loaded when a task matches
~1.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from aspenkit/aspens at commit 8dde826, republished under its MIT licence (© aspenkit). 621 words, ~1,614 tokens.

Download SKILL.mdSave it as .claude/skills/save-tokens/SKILL.md (or your agent's skills folder).
name
save-tokens
description
Token-saving session automation — statusline, prompt guard, precompact handoffs, session rotation, and handoff commands for Claude Code
triggers.files
src/commands/save-tokens.js, src/lib/save-tokens.js, src/templates/hooks/save-tokens*.sh, src/templates/hooks/save-tokens.mjs…
triggers.keywords
save-tokens, handoff, statusline, prompt-guard, precompact, session rotation, token warning

You are working on save-tokens — the feature that installs Claude Code hooks and commands to warn about token usage, auto-save handoffs before compaction, and support session rotation.

Domain purpose

aspens save-tokens installs three Claude Code hooks (statusline, prompt-guard, precompact) plus /save-handoff, /resume-handoff-latest, and /resume-handoff slash commands. The hooks observe Claude's own token telemetry and inject system messages telling Claude to rotate sessions before context blow-up. Handoff files persist enough state in .aspens/sessions/ to resume seamlessly in a fresh session.

Business rules / invariants

  • Claude-only feature. Hooks and statusline only work with Claude Code; Codex has no save-tokens integration. Config lives in .aspens.json under saveTokens.
  • Config thresholds default 175k warn / 200k compact. Number.MAX_SAFE_INTEGER is the disabled sentinel for either threshold; target.js#isValidSaveTokensConfig() validates shape, types, and threshold ordering — invalid config causes readConfig() to return null.
  • writeConfig preserves feature config — saveTokens is preserved across writeConfig calls unless explicitly set to null.
  • Sessions dir gitignored — .aspens/sessions/.gitignore excludes everything except .gitignore and README.md.
  • Settings backup — first install creates .claude/settings.json.bak if settings exist and no backup exists yet.
  • StatusLine pre-existence guard — canInstallSaveTokensStatusLine() refuses to overwrite an unrelated custom statusLine.command; when refused, applyStatusLineAvailability() forces both thresholds to MAX_SAFE_INTEGER and disables sessionRotation.

Non-obvious behaviors

  • Three hook entry points dispatched by subcommand. Shell wrappers (*.sh) read stdin, resolve project dir, and call save-tokens.mjs with statusline, prompt-guard, or precompact. ASPENS_PROJECT_DIR env var overrides CLAUDE_PROJECT_DIR; both fall back to cwd.
  • Statusline doubles as telemetry recorder. recordClaudeContextTelemetry() writes .aspens/sessions/claude-context.json summing input_tokens + cache_creation_input_tokens + cache_read_input_tokens + output_tokens from context_window.current_usage. Telemetry older than 5 minutes is ignored by the prompt guard.
  • Prompt-guard speaks to Claude, not the user. Above compactAtTokens: saves a handoff (reason rotation-threshold if sessionRotation, else compact-threshold) and stdout-prints an "IMPORTANT — you must tell the user" block instructing fresh session + /resume-handoff-latest. Above warnAtTokens: suggests /save-handoff. When telemetry is missing, prints a one-time link to the aspens issues page.
  • Precompact hook only fires when saveHandoff is enabled and claude.enabled !== false; reason is precompact.
  • extractSessionFacts() parses the JSONL transcript to extract originalTask (first user message, 500 char cap), recentPrompts (last 3, 200 char cap each), filesModified (Edit/Write tool_use file_path), gitCommits (regex on Bash git commit -m "..."), and branch (from gitBranch on user records). Transcript path is validated to be inside projectDir; falls back to input.prompt when transcript is missing or outside the project.
  • Transcript parsing is best-effort — all errors caught, invalid JSON lines silently skipped; returns empty facts on failure.
  • pruneOldHandoffs() keeps newest 10 *-handoff.md files by lexicographic (timestamp) sort; older are unlinked. latestHandoff() uses the same sort.
  • --recommended install is non-interactive — used standalone or invoked by doc init --recommended (which also installs agents and the doc-sync git hook).
  • --remove cleans legacy artifacts too — removes both .sh and historic .mjs variants of each hook, plus the legacy save-tokens-resume.md command; strips statusLine if it points at save-tokens and filters any hook entry whose command contains save-tokens-; nulls saveTokens in .aspens.json.
Show full SKILL.md (149 more words)Show less

Critical files (purpose, not inventory)

  • src/commands/save-tokens.js — install/remove orchestration; interactive multiselect (warnings, handoffs), --recommended, --remove. Exports installSaveTokensRecommended() consumed by doc-init.js.
  • src/lib/save-tokens.js — config + settings + template content builders (DEFAULT_SAVE_TOKENS_CONFIG, buildSaveTokensConfig, buildSaveTokensSettings, buildSaveTokensGitignore, buildSaveTokensReadme, buildSaveTokensRecommendations).
  • src/templates/hooks/save-tokens.mjs — runtime library: runStatusline, runPromptGuard, runPrecompact, saveHandoff, extractSessionFacts, telemetry record/read, handoff pruning, main() subcommand dispatch.
  • src/templates/hooks/save-tokens-{statusline,prompt-guard,precompact}.sh — shell wrappers; resolve PROJECT_DIR via cd "$SCRIPT_DIR/../.." && pwd and exec the .mjs with the matching subcommand.
  • src/templates/commands/{save-handoff,resume-handoff-latest,resume-handoff}.md — slash command bodies installed under .claude/commands/.

Critical Rules

  • Settings merge uses mergeSettings() from skill-writer.js — save-tokens hooks are treated as aspens-managed; do not hand-edit .claude/settings.json to add/remove save-tokens entries.
  • Hooks write to stdout to inject into Claude's context — comments in runPromptGuard() flag this; keep those messages addressed to Claude ("Tell the user...") not to a human reader.
  • Token sum includes cache tokens — do not switch to just input_tokens + output_tokens; that under-counts Claude's effective context use.

References

  • Impact integration: src/lib/impact.js — evaluateSaveTokensHealth() validates installed state

Last Updated: 2026-05-11

© aspenkit, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/save-tokens of aspenkit/aspens.

Open the folder on GitHubat commit 8dde826

Compare with similar skills

Save Tokens next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Save Tokens compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Save Tokens this skillaspenkit/aspens102—~1.6kAutomated safety check: PassMIT
Engineering ConventionsZaxbyHub/opencode-swarm488—~4.7kAutomated safety check: PassMIT
Claude Project Setupmohitagw15856/pm-claude-skills1.4k—~1.2kAutomated safety check: PassMIT
Run An Agent Teammohitagw15856/pm-claude-skills1.4k—~1.3kAutomated safety check: PassMIT
Improving MCP ToolsPostHog/posthog-foss721—~1.5kAutomated safety check: PassMIT
Git Guardrails Claude Codefossasia/eventyay-interpretation1.6k12 repos~578Automated safety check: PassApache-2.0

Similar skills

  • Engineering Conventions

    ZaxbyHub/opencode-swarm

    Guidelines and non-negotiable engineering invariants for modifying opencode-swarm.

    488 GitHub stars~4.7k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Claude Project Setup

    mohitagw15856/pm-claude-skills

    Set up a repo or project so an AI coding agent works well in it — the CLAUDE.md, the context, the guardrails, and the conventions the agent needs to be useful instead of lost.

    1.4k GitHub stars~1.2k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Run An Agent Team

    mohitagw15856/pm-claude-skills

    Design a small team of AI agents to tackle a complex task in parallel — who does what, how they hand off, and how to keep them coordinated — instead of one overloaded agent doing everything serially.

    1.4k GitHub stars~1.3k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Improving MCP Tools

    PostHog/posthog-foss

    Official

    Run an improve-my-MCP campaign: an autoresearch-style loop that measures the MCP agent experience with the eval harness, picks the highest-impact tool problem from production data, makes one bounded…

    721 GitHub stars~1.5k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Git Guardrails Claude Code

    fossasia/eventyay-interpretation

    Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute.

    1.6k GitHub starsUsed in 12 repos~578 tokens
    AI & LLM EngineeringAuto-check passed
  • Git Guardrails Claude Code

    vinvcn/mattpocock-skills-zh-CN

    设置 Claude Code hooks,在危险 git commands(push、reset --hard、clean、branch -D 等)执行前阻止它们。适用于用户想防止破坏性 git 操作、添加 git safety hooks,或在 Claude Code 中阻止 git push/reset 时。

    4.6k GitHub stars~474 tokensUpdated 9 days ago
    AI & LLM EngineeringAuto-check passed

More from aspenkit/aspens

All 12 skills in this repo
  • Injects a project's own skills and AGENTS.md content into generic bundled agent template files, adding a tech-stack line and real conventions without touching an agent's core logic.

    102 GitHub stars~898 tokensUpdated 24 days ago
    Auto-check passed
  • Orientation to the aspens codebase for agents working on the CLI itself: its Node.js stack, commands, module layout and debug settings.

    102 GitHub stars~1.6k tokensUpdated 24 days ago
    Auto-check passed
  • Aspens CLI Shell

    aspenkit/aspens

    Project context for the aspens CLI entry point: Commander wiring, the welcome screen, missing-hook warnings, CliError exit handling and the public programmatic exports.

    102 GitHub stars~1.1k tokensUpdated 24 days ago
    Auto-check passed
  • Explains how the aspens generator routes output to Claude Code or Codex CLI targets and transforms generated skills and instruction files between their formats.

    102 GitHub stars~1.9k tokensUpdated 24 days ago
    Auto-check passed
  • Doc Impact

    aspenkit/aspens

    Context health analysis — freshness, domain coverage, hub surfacing, drift detection, LLM-powered interpretation, and auto-repair for generated agent context

    102 GitHub stars~1.3k tokensUpdated 24 days ago
    Auto-check passed
  • Doc Sync

    aspenkit/aspens

    Incremental skill updater that maps git diffs to affected skills and optionally auto-syncs via a post-commit hook

    102 GitHub stars~1.8k tokensUpdated 24 days ago
    Auto-check passed

Questions about Save Tokens

What does Save Tokens do?

Token-saving session automation — statusline, prompt guard, precompact handoffs, session rotation, and handoff commands for Claude Code. Save Tokens is an agent skill from aspenkit/aspens.

When should I use Save Tokens?

Save Tokens fits situations like: tasks that involve LLM guardrails.

How do I install Save Tokens in Claude Code?

Run `npx skills add aspenkit/aspens --skill save-tokens -a claude-code`. Or copy the skill folder (.agents/skills/save-tokens in aspenkit/aspens) into .claude/skills/save-tokens in your project. Claude Code loads it when a task matches its description.

How do I install Save Tokens in Codex?

Run `npx skills add aspenkit/aspens --skill save-tokens -a codex`. Or copy the skill folder (.agents/skills/save-tokens in aspenkit/aspens) into .agents/skills/save-tokens in your project. Codex loads it when a task matches its description.

Can I use Save Tokens in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add aspenkit/aspens --skill save-tokens -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/save-tokens, .gemini/skills/save-tokens, .github/skills/save-tokens and .opencode/skills/save-tokens in your project.

What does Save Tokens need to run?

Going by SKILL.md and its folder, Save Tokens needs the command-line tools its instructions call (git).

Does Save Tokens access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Save Tokens safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Save Tokens use?

Save Tokens is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Save Tokens use?

About 1.6k tokens (SKILL.md is roughly 6.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Save Tokens?

Skills that share tags, products or a category with Save Tokens: Engineering Conventions (ZaxbyHub/opencode-swarm, 488 stars), Claude Project Setup (mohitagw15856/pm-claude-skills, 1.4k stars), Run An Agent Team (mohitagw15856/pm-claude-skills, 1.4k stars) and Improving MCP Tools (PostHog/posthog-foss, 721 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Save Tokens?

aspenkit (a GitHub organization) maintains it in aspenkit/aspens, which has 102 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on September 12, 2026.

Source: aspenkit/aspens on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.