$npx -y skills add adityahimaone/hermes-agent-rtk-caveman --skill context-optimizationOptimize Hermes context usage — expand RTK coverage, prune sessions, manage memory, set up auto-prune cron. Use when token usage is high or RTK coverage is low.
| 1 | # Context Optimization Workflow |
| 2 | |
| 3 | Use this skill when Adit wants to reduce token usage, optimize context, or check RTK/agent efficiency. |
| 4 | |
| 5 | ## When to Use |
| 6 | - User asks about token savings, RTK coverage, or context management |
| 7 | - Periodic maintenance (monthly recommended) |
| 8 | - After noticing high session count or bloated database |
| 9 | |
| 10 | ## Steps |
| 11 | |
| 12 | ### 1. Check Current State |
| 13 | ```bash |
| 14 | rtk gain # RTK token savings |
| 15 | hermes insights # Full usage analytics (last 30 days) |
| 16 | hermes sessions stats # Session store size |
| 17 | ``` |
| 18 | |
| 19 | ### 2. Prune Old Sessions |
| 20 | ```bash |
| 21 | # Cron sessions older than 3 days (auto-generated, safe to delete) |
| 22 | hermes sessions prune --older-than 3 --source cron --yes |
| 23 | |
| 24 | # Telegram sessions older than 14 days (if needed) |
| 25 | hermes sessions prune --older-than 14 --source telegram --yes |
| 26 | ``` |
| 27 | |
| 28 | ### 3. Verify RTK Enforcement |
| 29 | Check that CLAUDE.md contains: |
| 30 | - Golden Rule: always prefix with `rtk` |
| 31 | - MANDATORY section for execute_code terminal() calls |
| 32 | - Exception list (interactive, no-output, full-output) |
| 33 | |
| 34 | If missing, patch CLAUDE.md with execute_code RTK rules. |
| 35 | |
| 36 | ### 4. Set Up Auto-Prune Cron (if not exists) |
| 37 | ```bash |
| 38 | # Create cron: daily at 3 AM WIB |
| 39 | hermes sessions prune --older-than 3 --source cron --yes |
| 40 | ``` |
| 41 | Schedule: `0 3 * * *` (daily 3 AM) |
| 42 | Deliver: `origin` |
| 43 | |
| 44 | ### 5. Optimize Memory |
| 45 | - Check memory usage (% of 2,200 char limit) |
| 46 | - Consolidate redundant entries |
| 47 | - Update RTK mandate entry if changed |
| 48 | |
| 49 | ### 6. Report Summary |
| 50 | Present combined analysis: |
| 51 | - Sessions: before → after pruning |
| 52 | - RTK coverage: commands filtered / total terminal calls |
| 53 | - Memory: usage % |
| 54 | - Auto-prune: active/paused |
| 55 | |
| 56 | ## Key Metrics to Track |
| 57 | | Metric | Target | How to Check | |
| 58 | |--------|--------|--------------| |
| 59 | | RTK coverage | 100% of eligible commands | `rtk gain` — compare count vs `hermes insights` tool calls | |
| 60 | | Session count | <100 (prune regularly) | `hermes sessions stats` | |
| 61 | | Memory usage | <90% | Memory tool response | |
| 62 | | Auto-prune | Active | `hermes cron list` | |
| 63 | |
| 64 | ## Common Issues |
| 65 | - **Low RTK coverage**: Patch CLAUDE.md with stricter execute_code rules |
| 66 | - **Memory at 100%**: Consolidate or remove entries using memory tool replace action |
| 67 | - **Session bloat**: Run prune for cron source first (safest to delete) |
| 68 | - **RTK name collision**: Check `which rtk` — should be Rust Token Kit, not Rust Type Kit |