Skip to content

stateofthehart/claude-code-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code Config

Portable context management toolkit for Claude Code. Installs hooks, pruning tools, and skills for smarter session management.

What's Included

Hooks (fire automatically during sessions)

Hook Event Purpose
pre_tool_limiter.sh PreToolUse Caps Read to 500 lines on large files, adds Grep head_limit
post_tool_summarizer.sh PostToolUse Injects summary systemMessages for outputs >4KB
pre_compact_preserver.sh PreCompact Extracts session context (files, decisions, errors, git state)
session_start_reinjector.sh SessionStart Re-injects preserved context after /compact

Session Pruner (session_pruner.py)

DCP-like between-session compression with 5-stage pipeline:

  1. Strip bookkeeping — removes progress, snapshot, queue messages (~50% savings)
  2. Deduplication — identical tool calls collapsed to latest
  3. Observation masking — old tool outputs replaced with structured metadata
  4. TF-IDF relevance scoring — low-relevance outputs pruned regardless of age
  5. Batched API summarization — optional Haiku-powered semantic compression

Slash Commands

Command Effect
/prune Show help
/prune --dry-run Preview pruning on current session
/prune --apply Prune current session (backs up first)
/prune --list List all sessions with sizes

Skill (context-management)

Auto-activating skill that teaches Claude to proactively:

  • Suggest pruning when sessions get long
  • Use the Memory MCP for persistent facts
  • Recommend /compact at natural breakpoints

MCP Configuration

Disables redundant built-in servers: sequential-thinking, chrome-devtools, filesystem, git

Sets persistent memory storage at ~/.claude/memory.jsonl

Installation

Quick Install

git clone <this-repo> ~/claude-code-config
cd ~/claude-code-config
bash setup.sh

What setup.sh Does

  1. Backs up existing settings.json
  2. Writes hook scripts to ~/.claude/hooks/context-pruning/
  3. Configures settings.json with hooks + disabled MCPs
  4. Installs session_pruner.py and creates scikit-learn venv for TF-IDF
  5. Installs /prune and /prune-list slash commands
  6. Installs the context-management skill
  7. Configures MEMORY_FILE_PATH in shell profile
  8. Runs 8-point verification

Manual Install

Copy files to their destinations:

# Hooks
mkdir -p ~/.claude/hooks/context-pruning
cp hooks/* ~/.claude/hooks/context-pruning/
chmod +x ~/.claude/hooks/context-pruning/*.sh

# Commands
mkdir -p ~/.claude/commands
cp commands/* ~/.claude/commands/

# Skill
mkdir -p ~/.claude/plugins/marketplaces/claude-plugins-official/plugins/context-pruning/skills/context-management
cp skills/context-management/SKILL.md ~/.claude/plugins/marketplaces/claude-plugins-official/plugins/context-pruning/skills/context-management/

# TF-IDF venv
python3 -m venv ~/.claude/hooks/context-pruning/.venv
~/.claude/hooks/context-pruning/.venv/bin/pip install scikit-learn

Then merge the hooks config into your ~/.claude/settings.json.

Prerequisites

  • Claude Code v2.1.85+
  • jq
  • python3

Tested Results

On real sessions:

  • 78.8MB session → 24.4MB (69% reduction)
  • 209MB total → ~89MB (57% average reduction)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages