Skill: sundevilatb/context-slimmer (version 1.0.0)

--- name: context-slimmer description: Audit and slim down always-loaded context files (AGENTS.md, TOOLS.md, USER.md, MEMORY.md, HEARTBEAT.md, SOUL.md, IDENTITY.md). Use when asked to reduce token usage, audit context files, optimize context window, or slim down workspace files. Measures current token cost and identifies what to move, remove, or compress. --- # Context Slimmer Audit workspace files that load into every message and reduce their token footprint. ## Quick Start ```bash # Measure current context cost bash scripts/measure.sh # Full audit (outputs recommendations) bash scripts/measure.sh --audit ``` ## Audit Process For each always-loaded file, evaluate: 1. **Move to skill** — Content only needed for specific tasks (betting config, group chat rules, detailed protocols). Move to a skill or reference file that loads on demand. 2. **Remove** — Outdated info, dead features, completed one-time setup, duplicated content across files. 3. **Compress** — Verbose explanations that could be 1 sentence. If the agent already knows it, cut it. ## Rules of Thumb - If a cron job handles it, remove it from HEARTBEAT.md - If it's in SOUL.md, don't repeat it in MEMORY.md or AGENTS.md - If it's in USER.md, don't repeat it in MEMORY.md - If the agent does it daily, it doesn't need instructions — just a trigger word - Prefer 1 sentence over 5 bullets saying the same thing - Target: each file should justify every line's token cost ## Expected File Sizes (lean targets) | File | Target | |------|--------| | AGENTS.md | < 500 tokens | | TOOLS.md | < 500 tokens | | USER.md | < 700 tokens | | MEMORY.md | < 400 tokens | | HEARTBEAT.md | < 400 tokens | | SOUL.md | < 250 tokens | | IDENTITY.md | < 50 tokens | | **Total** | **< 2,800 tokens** | ## Output Format Report: current size, projected size, savings per file. Include specific recommendations grouped by move/remove/compress.

path: scripts/measure.sh
content: #!/bin/bash
# Context Slimmer - Measure always-loaded context files
# Usage: bash measure.sh [--audit] [--workspace /path/to/workspace]

WORKSPACE="${2:-$(pwd)}"
AUDIT=false
[[ "$1" == "--audit" ]] && AUDIT=true

FILES="AGENTS.md TOOLS.md USER.md MEMORY.md HEARTBEAT.md SOUL.md IDENTITY.md"
TOTAL_BYTES=0
TOTAL_TOKENS=0

echo "📏 Context File Sizes"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
printf "%-20s %8s %8s %6s\n" "File" "Bytes" "~Tokens" "Lines"
echo "───────────────────────────────────────"

for f in $FILES; do
  filepath="$WORKSPACE/$f"
  if [ -f "$filepath" ]; then
    bytes=$(wc -c < "$filepath" | tr -d ' ')
    lines=$(wc -l < "$filepath" | tr -d ' ')
    tokens=$((bytes / 4))
    TOTAL_BYTES=$((TOTAL_BYTES + bytes))
    TOTAL_TOKENS=$((TOTAL_TOKENS + tokens))
    
    # Flag if over target
    flag=""
    case "$f" in
      AGENTS.md)     [[ $tokens -gt 500 ]] && flag=" ⚠️" ;;
      TOOLS.md)      [[ $tokens -gt 500 ]] && flag=" ⚠️" ;;
      USER.md)       [[ $tokens -gt 700 ]] && flag=" ⚠️" ;;
      MEMORY.md)     [[ $tokens -gt 400 ]] && flag=" ⚠️" ;;
      HEARTBEAT.md)  [[ $tokens -gt 400 ]] && flag=" ⚠️" ;;
      SOUL.md)       [[ $tokens -gt 250 ]] && flag=" ⚠️" ;;
      IDENTITY.md)   [[ $tokens -gt 50 ]]  && flag=" ⚠️" ;;
    esac
    
    printf "%-20s %8d %8d %6d%s\n" "$f" "$bytes" "$tokens" "$lines" "$flag"
  else
    printf "%-20s %8s %8s %6s\n" "$f" "MISSING" "-" "-"
  fi
done

echo "───────────────────────────────────────"
printf "%-20s %8d %8d\n" "TOTAL" "$TOTAL_BYTES" "$TOTAL_TOKENS"
echo ""
echo "Target: < 2,800 tokens"
if [ $TOTAL_TOKENS -le 2800 ]; then
  echo "✅ Within target"
else
  echo "⚠️  Over target by $((TOTAL_TOKENS - 2800)) tokens"
fi

if $AUDIT; then
  echo ""
  echo "📋 Audit Checklist"
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  for f in $FILES; do
    filepath="$WORKSPACE/$f"
    if [ -f "$filepath" ]; then
      echo ""
      echo "--- $f ---"
      
      # Check for duplicate content across files
      echo "Potential duplicates:"
      for other in $FILES; do
        [[ "$f" == "$other" ]] && continue
        otherpath="$WORKSPACE/$other"
        [ -f "$otherpath" ] || continue
        # Find shared non-trivial lines (>20 chars)
        common=$(comm -12 <(grep -oE '.{20,}' "$filepath" 2>/dev/null | sort -u) <(grep -oE '.{20,}' "$otherpath" 2>/dev/null | sort -u) | head -3)
        [[ -n "$common" ]] && echo "  ↔ $other: $(echo "$common" | wc -l | tr -d ' ') shared phrases"
      done
      
      # Check for verbose patterns
      bullets=$(grep -c "^- " "$filepath" 2>/dev/null)
      bullets=${bullets:-0}
      [[ $bullets -gt 15 ]] && echo "  📝 $bullets bullet points — consider compressing"
      
      headers=$(grep -c "^##" "$filepath" 2>/dev/null)
      headers=${headers:-0}
      [[ $headers -gt 8 ]] && echo "  📝 $headers sections — consider consolidating"
    fi
  done
fi


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: suspicious | SkillSpector: clean (LOW)