Atlas / Skills / alexgreensh / Token Optimizer

Token OptimizerBLOCK

skills/alexgreensh/token-optimizer

Find the ghost tokens. Fix them. Survive compaction. Avoid context quality decay.

Verdict
BLOCK
Grade
F
Trust score
52 /100
Version
—
Hosts
6 documented
License
NOASSERTION
Stars
2,621
01

Overview

Find the ghost tokens. Fix them. Survive compaction. Avoid context quality decay.

Read from source at commit 1e25a3caf054OBSERVED · 2026-10-22
Advertisement
02

Install

Commands as the repository documents them. They are shown, not run.

npm install -g qmd
03

Host compatibility

What the documentation claims. We have not run a compatibility test.

HostStatusNotes
claude-codementioned
claude-desktopmentioned
codexmentioned
copilotmentioned
cursormentioned
openclawmentioned
04

What it tells the agent

The instruction file, verbatim from the audited commit — this is the text the model reads, and the surface the audit's instruction layer examines. Quoted here so you can judge it without cloning anything.

---
name: token-optimizer
description: Audits a Claude Code or Codex setup for context-window waste, fixes it with the user's approval, and measures the saving. Use when context feels tight, sessions degrade, or costs climb.
effort: high
---

# Token Optimizer

Measures where a setup spends its context window, proposes fixes, applies the ones the user approves, and re-measures. The deliverable is a before-and-after the user can verify, with every change backed up. Typical recovery is 5-15% of the window from config cleanup, more when compaction and caching settings are wrong for the way the user works.

Token Optimizer's own skills (`token-optimizer`, `token-coach`, `token-dashboard`, `fleet-auditor`, `resume-checkpoint`) are the measurement layer, so leave them out of every unused-skill, archive or consolidation suggestion, however rarely they run.

## Step 0: pick the right workflow for this runtime

The audit below reads and edits `~/.claude`, which is the wrong target anywhere but Claude Code, so settle the runtime before touching any path. Run exactly this, in this order.

**a. Environment check** (touches no file; an explicit `TOKEN_OPTIMIZER_RUNTIME` wins, and Claude plugin variables are checked before stray `OPENCODE_*` exports, the same order `detect_runtime()` uses):

```bash
if [ "${TOKEN_OPTIMIZER_RUNTIME:-}" = "claude" ] || [ "${TOKEN_OPTIMIZER_RUNTIME:-}" = "codex" ]; then
  :
elif [ "${TOKEN_OPTIMIZER_RUNTIME:-}" = "opencode" ]; then
  echo "Token Optimizer — OpenCode runtime detected."
elif [ "${TOKEN_OPTIMIZER_RUNTIME:-}" = "copilot" ]; then
  echo "Token Optimizer — GitHub Copilot runtime detected."
elif [ "${TOKEN_OPTIMIZER_RUNTIME:-}" = "cursor" ]; then
  echo "Token Optimizer — Cursor runtime detected."
elif [ "${TOKEN_OPTIMIZER_RUNTIME:-}" = "antigravity" ]; then
  echo "Token Optimizer — Google Antigravity runtime detected."
elif [ -n "${CLAUDE_PLUGIN_ROOT:-}${CLAUDE_PLUGIN_DATA:-}" ]; then
  :
elif [ -n "${OPENCODE_BIN:-}${OPENCODE_CONFIG_DIR:-}${OPENCODE_DATA_DIR:-}${OPENCODE_CONFIG:-}${OPENCODE_CLIENT:-}" ]; then
  echo "Token Optimizer — OpenCode runtime detected."
elif [ -n "${COPILOT_HOME:-}${TOKEN_OPTIMIZER_COPILOT_HOME:-}" ]; then
  echo "Token Optimizer — GitHub Copilot runtime detected."
elif [ -n "${TOKEN_OPTIMIZER_CURSOR_HOME:-}" ]; then
  echo "Token Optimizer — Cursor runtime detected."
elif [ -n "${CURSOR_PROJECT_DIR:-}" ] && [ -n "${CURSOR_VERSION:-}" ]; then
  echo "Token Optimizer — Cursor runtime detected."
elif [ -n "${TOKEN_OPTIMIZER_ANTIGRAVITY_HOME:-}" ]; then
  echo "Token Optimizer — Google Antigravity runtime detected."
fi
```

| It prints | Do this |
|-----------|---------|
| "OpenCode runtime detected." | Stop. Follow `references/opencode-workflow.md` (Token Optimizer runs as a native plugin there). |
| "Cursor runtime detected." | Stop. Follow `references/cursor-workflow.md` (it runs through the Cursor hook bridge). |
| "GitHub Copilot runtime detected." | Stop. Follow the Copilot guidance in `docs/copilot.md`. |
| "Google Antigravity runtime detected." | Stop. Follow `docs/antigravity.md`. |
| nothing | Continue to b. |

**b. Resolve `$MEASURE_PY` once.** Every later command uses it:

```bash
# Resolve measure.py to the NEWEST installed copy across channels so a stale
# plugin-cache copy never shadows a fresh install. find -L follows the
# install.sh symlink under ~/.claude/skills; cd -P resolves it before reading each
# copy's plugin.json for its version. find (not bare globs) never errors under zsh.
MEASURE_PY=""; _best_ver=""
while IFS= read -r _cand; do
  [ -f "$_cand" ] || continue
  _root="$(cd -P -- "$(dirname -- "$_cand")/../../.." 2>/dev/null && pwd)"
  _ver="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$_root/.claude-plugin/plugin.json" 2>/dev/null | head -1)"
  [ -n "$_ver" ] || _ver="0.0.0"
  if [ -z "$_best_ver" ] || [ "$(printf '%s\n%s\n' "$_ver" "$_best_ver" | sort -t. -k1,1n -k2,2n -k3,3n -k4,4n | tail -n1)" = "$_ver" ]; then
    _best_ver="$_ver"; MEASURE_PY="$_cand"
  fi
done <<EOF
$(find -L "$HOME/.claude/skills" "$HOME/.claude/plugins/cache" "$HOME/.claude/token-optimizer" "$HOME/.codex/skills" "$HOME/.codex/plugins/cache" "$HOME/.config/opencode/plugins" -type f -name measure.py -path '*token-optimizer*/scripts/measure.py' 2>/dev/null)
EOF
if [ -z "$MEASURE_PY" ]; then echo "[Error] measure.py not found. Is Token Optimizer installed?"; exit 1; fi
```

**c. The authoritative gate.** The environment check cannot see an OpenCode started without its variables; this one scans the process tree:

```bash
python3 "$MEASURE_PY" report 2>&1 | head -1
```

Any "... runtime detected." line means stop and follow that runtime's file from the table above. On Codex (`TOKEN_OPTIMIZER_RUNTIME=codex` or a Codex environment) follow `references/codex-workflow.md`. Claude Code continues below.

## The audit (Claude Code)

Work through these in order and tick each off; a skipped phase stays in the list as `skip: <reason>`.

```
- [ ] 0. Setup            references/phase0-setup.md
- [ ] 1. Parallel audit   references/agent-prompts.md
- [ ] 2. Synthesis        references/agent-prompts.md (Synthesis Agent)
- [ ] 3. Present, then wait for the user's decision   references/presentation-workflow.md
- [ ] 4. Implement the approved changes               references/implementation-playbook.md
- [ ] 5. Verify and report before/after               references/agent-prompts.md (Verification Agent)
```

**0. Setup.** Context window detection, pre-check, backup, the coordination folder (`COORD_PATH`), hook checks, daemon, smart compaction. Then, only when `python3 "$MEASURE_PY" keepwarm-consent-status` returns `should_ask: true`, follow `references/keepwarm-consent.md` exactly; it spends the user's money, so its wording and command order are fixed.

**1. Parallel audit.** Dispatch six agents in one message, each with `COORD_PATH` and its prompt from `references/agent-prompts.md`. They gather and count, so they run on the cheapest 
05

Trust audit

BLOCKgrade F · trust 52/100 Do not install this without reading the findings. The audit found something that could harm you or your machine.

LayerWhat it checksResult
L0Provenance & inventoryPASS
L1Static analysis of the codeFAIL
L2Instruction surface (what it tells the agent)PASS
L3Class-specific surfacePASS
L4Behavioural (sandbox)SKIPPED

What the source does

Filesystem
declared (13 observation(s))
Network
UNDECLARED (7 observation(s))
Shell
declared (8 observation(s))
Dependencies
pinned
Secrets in source
found

Findings (25)

CRITICALHard-coded secrets · secret.github · CWE-798, CWE-321
scripts/benchmark.py:217
"raw_output": "GITHUB_TOKEN=ghp_ABCDEFghijklmnopqrstuvwxyz0123456789\nPATH=/usr/bin\n",
CRITICALHard-coded secrets · secret.github · CWE-798, CWE-321
scripts/benchmark.py:218
"must_preserve": ["ghp_ABCDEFghijklmnopqrstuvwxyz0123456789"],
CRITICALHard-coded secrets · secret.github · CWE-798, CWE-321
scripts/benchmark.py:342
"src/secrets_demo.py:8:0: C0103 Variable name doesn't conform: SECRET_TOKEN=ghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789\n"
CRITICALHard-coded secrets · secret.github · CWE-798, CWE-321
scripts/benchmark.py:353
"must_preserve": ["ghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789"],
CRITICALHard-coded secrets · secret.github · CWE-798, CWE-321
scripts/benchmark.py:441
"│   │   │   └── ghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789.txt\n"
CRITICALHard-coded secrets · secret.slack · CWE-798, CWE-321
scripts/benchmark.py:225
"raw_output": "SLACK_TOKEN=xoxb-FAKE-TEST-FIXTURE-00000\nDEBUG=true\n",
CRITICALHard-coded secrets · secret.slack · CWE-798, CWE-321
scripts/benchmark.py:226
"must_preserve": ["xoxb-FAKE-TEST-FIXTURE-00000"],
HIGHCode injection · code.eval_exec · CWE-78, CWE-94, CWE-95
scripts/devin_compress.py:79
exec(compile(_source_bytes, str(_source_path), 'exec'), _source_namespace)
Why it matters. evaluates text as code
Fix. remove; use a parser or a dispatch table
HIGHCode injection · code.eval_exec · CWE-78, CWE-94, CWE-95
scripts/devin_doctor.py:71
exec(compile(_source_bytes, str(_source_path), 'exec'), _source_namespace)
Why it matters. evaluates text as code
Fix. remove; use a parser or a dispatch table
HIGHCode injection · code.eval_exec · CWE-78, CWE-94, CWE-95
scripts/devin_doctor.py:307
"exec(compile((root / 'devin_source.py').read_bytes(), 'devin_source.py', 'exec'), namespace)\n"
Why it matters. evaluates text as code
Fix. remove; use a parser or a dispatch table
HIGHCode injection · code.eval_exec · CWE-78, CWE-94, CWE-95
scripts/devin_hooks.py:153
_EXEC_RULE = re.compile(r'(?i)exec(?:\((.*)\))?')
Why it matters. evaluates text as code
Fix. remove; use a parser or a dispatch table
HIGHCode injection · code.eval_exec · CWE-78, CWE-94, CWE-95
scripts/devin_source.py:72
exec(compile(content,str(source),'exec'),module.__dict__)
Why it matters. evaluates text as code
Fix. remove; use a parser or a dispatch table
HIGHFilesystem / path · fs.credential_store · CWE-22, CWE-59
scripts/context_intel.py:83
"/.ssh/",
Why it matters. touches a credential store
HIGHFilesystem / path · fs.credential_store · CWE-22, CWE-59
scripts/context_intel.py:84
"/.aws/",
Why it matters. touches a credential store
HIGHFilesystem / path · fs.credential_store · CWE-22, CWE-59
scripts/context_intel.py:85
"/.gnupg/",
Why it matters. touches a credential store
HIGHFilesystem / path · fs.credential_store · CWE-22, CWE-59
scripts/context_intel.py:91
"id_rsa",
Why it matters. touches a credential store
HIGHFilesystem / path · fs.credential_store · CWE-22, CWE-59
scripts/context_intel.py:92
"id_ed25519",
Why it matters. touches a credential store
MEDIUMCode injection · code.dynamic_import · CWE-78, CWE-94, CWE-95
scripts/devin_doctor.py:310
'    __import__(name)\n',
MEDIUMCode injection · code.dynamic_import · CWE-78, CWE-94, CWE-95
scripts/structure_map_ts.py:231
__import__(pkg)
MEDIUMCode injection · code.dynamic_import · CWE-78, CWE-94, CWE-95
scripts/structure_map_ts.py:284
mod = __import__(pkg)
MEDIUMNetwork egress · net.cli · CWE-200, CWE-319
scripts/cloud_kit.py:692
"( T=\"$(mktemp -d)\" && cd \"$T\" && curl -fsSL --max-time 30 -o m.json %s && "
MEDIUMNetwork egress · net.client · CWE-200, CWE-319
scripts/cloud_kit.py:54
import urllib.request
MEDIUMNetwork egress · net.client · CWE-200, CWE-319
scripts/cloud_kit.py:638
with urllib.request.urlopen(url, timeout=timeout) as resp:  # noqa: S310 - fixed https host
MEDIUMNetwork egress · net.client · CWE-200, CWE-319
scripts/cowork_doctor.py:22
import urllib.request
MEDIUMNetwork egress · net.client · CWE-200, CWE-319
scripts/cowork_doctor.py:211
class _NoRedirect(urllib.request.HTTPRedirectHandler):

Gates applied: critical_finding, no_behavioural_pass.

Audited 2026-10-22 · audit v0.4.1 · source sha 1e25a3caf054full audit observations/trust-audit/skill/alexgreensh__token-optimizer.json · Report an issue / request a re-scan
06

Audit history

Every audit this skill has had.

DateSourceVerdictGradeScoreChange
2026-10-221e25a3caf054BLOCKF52first audit
07

Questions

What does the token-optimizer — alexgreensh/token-optimizer skill do?

Find the ghost tokens. Fix them. Survive compaction. Avoid context quality decay.

Is token-optimizer — alexgreensh/token-optimizer safe to install?

No — not without reading the findings first. The audit graded it F (52/100) and found 17 critical or high issues in the source. Each one is listed on this page with the file and line it is on.

What can token-optimizer — alexgreensh/token-optimizer access on my machine?

The audit observed that it reaches the network, runs shell commands and reads or writes files. At least one of those is not mentioned in its own description, which is itself a finding. Secrets in the source: found — see the findings.

Which assistants does token-optimizer — alexgreensh/token-optimizer work with?

Its documentation mentions claude-code, claude-desktop, codex, copilot, cursor and openclaw. That is what the text claims, not a compatibility test we ran.

How current is this page?

The grade is for one exact copy of the source (1e25a3caf054), read on 2026-10-22. The repository is watched, and a new audit runs when it changes — this is the first audit.

Add this badge to your README

Shows this page's audit result and links back to it. It updates when the audit does.

ModelsAtlas audit badge

Markdown
[![ModelsAtlas audit: Token Optimizer](https://modelsatlas.com/skills/alexgreensh/token-optimizer/badge.svg)](https://modelsatlas.com/skills/alexgreensh/token-optimizer/)

Not your listing, or something out of date? Claim or update your listing.

Advertisement