Context File Optimizer

Trim

by danielmiessler · MIT license · ★ 19,269 on GitHub · v1.0.4

Trim cover

Reduces an always-on LifeOS context file that has grown too big via a human-gated pass — deterministic GC of stale entries first, then semantic merges and relocations — never dropping a directive and committing every change reversibly.…

---
name: Trim
version: 1.0.4
description: "Reduces an always-on LifeOS context file that has grown too big via a human-gated pass — deterministic GC of stale entries first, then semantic merges and relocations — never dropping a directive and committing every change reversibly. USE WHEN /trim, trim the context, trim OPERATIONAL_RULES, this file is too big, reduce a doctrine file, prune an always-loaded file, fold the proposal inbox, shrink CLAUDE.md or DA_IDENTITY. NOT FOR general code refactoring, trimming video or audio media (use AudioEditor for audio files), or removing AI writing patterns from prose."
---

# Trim

Shrink an always-on context file that has gotten too big. `/trim <file>` walks the reduction, safest cuts first, never dropping a rule.

## Workflow Routing

| Trigger | Workflow |
|---------|----------|
| `/trim <file>`, "trim OPERATIONAL_RULES", "this file is too big", "reduce a doctrine file", "fold the proposal inbox" | `Workflows/Trim.md` |

## Quick Reference

Overview

Shrink an always-on context file that has gotten too big. /trim <file> walks the reduction, safest cuts first, never dropping a rule.

Example prompts

/trim OPERATIONAL_RULES/trim # → no arg: wc -c the always-on set, take the largest, then the same walkthrough
Manual install (npx, ZIP)
Claude Codenpx skills add danielmiessler/LifeOS --skill Trim -g -a claude-code
Claude Code (degit)npx degit danielmiessler/LifeOS/LifeOS/install/skills/Trim#main ~/.claude/skills/trim
Claude.ai / desktopZip the folder and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md3.6 KB
Read SKILL.md here
danielmiessler/main1 file shown
SKILL.md
Show the full text52 lines

Trim

Shrink an always-on context file that has gotten too big. /trim <file> walks the reduction, safest cuts first, never dropping a rule.

Workflow Routing

Trigger Workflow
/trim <file>, "trim OPERATIONAL_RULES", "this file is too big", "reduce a doctrine file", "fold the proposal inbox" Workflows/Trim.md

Quick Reference

  • Target resolution: a bare name (OPERATIONAL_RULES) resolves against the always-on set — the system prompt, CLAUDE.md, its @-imports, and the hook-injected memory files. No arg → wc -c that set and take the largest.
  • Order is safest-first: (1) show state, (2) deterministic GC (zero-risk), (3) semantic trims (human-gated), (4) safety gate, (5) re-measure. Full steps: Workflows/Trim.md.
  • One tool it orchestrates — never reimplement: LIFEOS/TOOLS/ProposalGC.ts (removes superseded/duplicate/absorbed entries). Sizes come from wc -c.
  • Three semantic moves: MERGE overlapping rules, TIGHTEN verbose ones, RELOCATE rarely-used detail to an on-demand reference (leave a stub + pointer).
  • The invariant: a trim never drops a distinct directive. If a merge would, keep the original.

Gotchas

  • USER files commit to the USER_DATA repo, not ~/.claude. LIFEOS/USER/** (OPERATIONAL_RULES, PROJECTS, the identity files) is a symlink into a separate private repo. Commit with git -C ~/.config/LIFEOS/USER …. A ~/.claude commit captures nothing under LIFEOS/USER/ — a false safety net.
  • The file can change mid-edit. The autonomic memory loop appends proposals to these files while you work. If a Write/Edit reports "modified since read", RE-READ before writing — a concurrent correction may have landed (this is how a real deploy-command fix was nearly reverted). Never write from a stale read.
  • Semantic merges must never drop a directive. Before applying any merge/tighten, confirm every proper noun, path, tool name, and imperative from the originals survives in the result. If one is missing, the merge is wrong — keep the original. Deterministic GC (superseded/dup/absorbed) is always safe; semantic edits are the risky class.
  • bun/bunx only, never npm/npx.
  • Deterministic first, always. Run ProposalGC before proposing any semantic edit — the free, zero-risk removals often clear enough that no judgment-call edit is needed.

Examples

/trim OPERATIONAL_RULES
# → shows 40,456 B → ProposalGC dry-run (0 removable) → ranks semantic trims (fold the
#   40-entry proposal tail, relocate skill-scoped directives to a reference)
#   → applies approved ones behind the safety gate → commits to USER_DATA → 28,043 B (−31%)

/trim
# → no arg: wc -c the always-on set, take the largest, then the same walkthrough

Execution Log

After completing the workflow, append a single JSONL entry:

echo '{"ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","skill":"Trim","workflow":"Trim","input":"8_WORD_SUMMARY","status":"ok|error","duration_s":SECONDS}' >> ~/.claude/LIFEOS/MEMORY/SKILLS/execution.jsonl
1---
2name: Trim
3version: 1.0.4
4description: "Reduces an always-on LifeOS context file that has grown too big via a human-gated pass — deterministic GC of stale entries first, then semantic merges and relocations — never dropping a directive and committing every change reversibly. USE WHEN /trim, trim the context, trim OPERATIONAL_RULES, this file is too big, reduce a doctrine file, prune an always-loaded file, fold the proposal inbox, shrink CLAUDE.md or DA_IDENTITY. NOT FOR general code refactoring, trimming video or audio media (use AudioEditor for audio files), or removing AI writing patterns from prose."
5---
6 
7# Trim
8 
9Shrink an always-on context file that has gotten too big. `/trim <file>` walks the reduction, safest cuts first, never dropping a rule.
10 
11## Workflow Routing
12 
13| Trigger | Workflow |
14|---------|----------|
15| `/trim <file>`, "trim OPERATIONAL_RULES", "this file is too big", "reduce a doctrine file", "fold the proposal inbox" | `Workflows/Trim.md` |
16 
17## Quick Reference
18 
19- **Target resolution:** a bare name (`OPERATIONAL_RULES`) resolves against the always-on set — the system prompt, `CLAUDE.md`, its `@`-imports, and the hook-injected memory files. No arg → `wc -c` that set and take the largest.
20- **Order is safest-first:** (1) show state, (2) deterministic GC (zero-risk), (3) semantic trims (human-gated), (4) safety gate, (5) re-measure. Full steps: `Workflows/Trim.md`.
21- **One tool it orchestrates — never reimplement:** `LIFEOS/TOOLS/ProposalGC.ts` (removes superseded/duplicate/absorbed entries). Sizes come from `wc -c`.
22- **Three semantic moves:** MERGE overlapping rules, TIGHTEN verbose ones, RELOCATE rarely-used detail to an on-demand reference (leave a stub + pointer).
23- **The invariant:** a trim never drops a distinct directive. If a merge would, keep the original.
24 
25## Gotchas
26 
27- **USER files commit to the USER_DATA repo, not `~/.claude`.** `LIFEOS/USER/**` (OPERATIONAL_RULES, PROJECTS, the identity files) is a symlink into a separate private repo. Commit with `git -C ~/.config/LIFEOS/USER …`. A `~/.claude` commit captures nothing under `LIFEOS/USER/` — a false safety net.
28- **The file can change mid-edit.** The autonomic memory loop appends proposals to these files while you work. If a Write/Edit reports "modified since read", RE-READ before writing — a concurrent correction may have landed (this is how a real deploy-command fix was nearly reverted). Never write from a stale read.
29- **Semantic merges must never drop a directive.** Before applying any merge/tighten, confirm every proper noun, path, tool name, and imperative from the originals survives in the result. If one is missing, the merge is wrong — keep the original. Deterministic GC (superseded/dup/absorbed) is always safe; semantic edits are the risky class.
30- **`bun`/`bunx` only, never `npm`/`npx`.**
31- **Deterministic first, always.** Run ProposalGC before proposing any semantic edit — the free, zero-risk removals often clear enough that no judgment-call edit is needed.
32 
33## Examples
34 
35```
36/trim OPERATIONAL_RULES
37# → shows 40,456 B → ProposalGC dry-run (0 removable) → ranks semantic trims (fold the
38# 40-entry proposal tail, relocate skill-scoped directives to a reference)
39# → applies approved ones behind the safety gate → commits to USER_DATA → 28,043 B (−31%)
40 
41/trim
42# → no arg: wc -c the always-on set, take the largest, then the same walkthrough
43```
44 
45## Execution Log
46 
47After completing the workflow, append a single JSONL entry:
48 
49```bash
50echo '{"ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","skill":"Trim","workflow":"Trim","input":"8_WORD_SUMMARY","status":"ok|error","duration_s":SECONDS}' >> ~/.claude/LIFEOS/MEMORY/SKILLS/execution.jsonl
51```
52 
View all files on GitHub →

Details

Version
1.0.4
License
MIT
Stars on the repo
★ 19,269
Checked
Source
danielmiessler/LifeOS ↗
Creator
danielmiessler · 63 listings
View creator

Similar skills

See all →

More from danielmiessler

SkillScope Oscillation Analyzerdanielmiessler/LifeOS · by danielmiessler3-pass scope oscillation that holds a question constant while shifting zoom — narrow/tactical, wide/strategic, then synthesis — to surface design tensions, scope recommendations, and coherence assessments invisible at any single zoom level. USE WHEN aperture oscillation, oscillate scope, zoom in and out, tactical vs strategic, scope framing, design tension, system coherence check, local vs global design, wrong scope, scope negotiation. NOT FOR lens rotation across angles (use IterativeDepth).★ 19.3k GitHub starsSkillAphorism Library Managerdanielmiessler/LifeOS · by danielmiesslerCurated aphorism collection with CRUD — content-based matching, themed search, thinker research, DB maintenance. Quotes organized by author/theme/context/usage to prevent repetition. Four workflows: FindAphorism, AddAphorism, ResearchThinker, SearchAphorisms. Themes: Stoicism, Wisdom, Truth-seeking, Excellence, Resilience, Curiosity. USE WHEN aphorism, quote, find a quote, research thinker, add aphorism, quote for newsletter, what did X say about, quote bank. NOT FOR creative writing or social posts.★ 19.3k GitHub starsSkillSocial Platform Scraperdanielmiessler/LifeOS · by danielmiesslerScrapes social platforms, business data, and e-commerce via Apify actors — Instagram, LinkedIn, TikTok, YouTube, Facebook, Google Maps, Amazon, and web crawls — filtering in code. USE WHEN scrape Instagram, scrape LinkedIn, scrape TikTok, scrape YouTube, scrape Facebook, Google Maps leads, Amazon reviews, business intelligence, multi-platform social listening, competitive analysis, lead generation, social monitoring, Apify actors, web crawl, extract contacts. NOT FOR X/Twitter account operations like posting, threads, or bookmarks (those need a dedicated X API client), 4-tier progressive scraping with proxy escalation (use BrightData), or real-Chrome bot bypass and computer use (use Interceptor).★ 19.3k GitHub starsSkillVisual Content Generatordanielmiessler/LifeOS · by danielmiesslerStatic visual content across 20+ formats — diagrams, mermaid, infographics, D3 dashboards, comics, icons, wallpaper — via Nano Banana Pro (default), Nano Banana, and Flux. USE WHEN art, illustration, diagram, flowchart, infographic, header image, blog social thumbnail, visualize, generate image, mermaid, architecture diagram, comic, icon, blog art, framework diagram, D3 chart, remove background, wallpaper. NOT FOR locked house-style YouTube/channel/video thumbnails, video or animation (use Remotion), or web UI design and integrated frontend layout (use Webdesign).★ 19.3k GitHub starsSkillArXiv Paper Finderdanielmiessler/LifeOS · by danielmiesslerSearch and retrieve arXiv academic papers by topic, category, or paper ID — with AlphaXiv-enriched AI-generated overviews. Uses arXiv Atom API across cs.AI/cs.LG/cs.CL/cs.CR/cs.MA/cs.SE/cs.IR. Three workflows: Latest, Search, Paper. USE WHEN arxiv, papers, latest papers, research papers, recent ML papers, paper lookup, summarize paper, latest LLM papers, AI safety papers, cs.AI latest. NOT FOR general research (Research), URL parsing, or annual reports.★ 19.3k GitHub starsSkillFiller Removal Audio Editordanielmiessler/LifeOS · by danielmiesslerAI audio editing pipeline: Whisper word-level transcription → Claude segment classification (KEEP/CUT_FILLER/CUT_FALSE_START/CUT_STUTTER/CUT_DEAD_AIR) → ffmpeg with 40ms qsin crossfades and room-tone fill → optional Cleanvoice cloud polish; plus GateScan/GateRepair for noise-gate ticking artifacts. Modes: --preview, --aggressive, --polish. Workflow: Clean. USE WHEN clean audio, edit audio, remove filler words, clean podcast, remove ums, cut dead air, polish audio, trim recording, cut stutters, ticking audio, clicking audio, audio clicks, gate artifacts, popping audio. NOT FOR video composition (use Remotion).★ 19.3k GitHub stars