Skip to content

mohsenil85/claude-output-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

claude-output-cache

A Claude Code plugin that caches full Bash command outputs and lets you retrieve them via MCP tools.

The problem

Claude Code truncates long command outputs to fit its context window — often appending | tail or only showing the last few hundred lines. When you later need the beginning of that output (where errors often are), the only option is to re-run the command.

This plugin fixes that by caching every Bash command's complete output and exposing MCP tools to selectively re-read it: paginated, grepped, or in full.

How it works

[Claude Code] --PostToolUse hook--> [cache writer] --> /tmp/claude-output-cache/*.json
[Claude Code] --MCP tools-------> [cache reader]  --> /tmp/claude-output-cache/*.json
  1. A PostToolUse hook fires after every Bash command, capturing the full output to a JSON file
  2. An MCP server exposes tools to list, read, grep, and inspect cached outputs
  3. Claude can use these tools to revisit any output without re-running commands

Quick start

# Install
git clone https://github.com/youruser/claude-output-cache ~/Projects/claude-output-cache
cd ~/Projects/claude-output-cache
uv tool install -e .

# Setup (adds hook + registers MCP server)
claude-output-cache setup

# Restart Claude Code

MCP tools

Tool Description
list_cached_outputs Browse recent cached command outputs (metadata only)
read_cached_output Read full or partial output with line-based pagination
grep_cached_output Search cached outputs with regex, with context lines
cache_status Cache stats: entry count, total size, age range

Configuration

Environment variables (all optional):

Variable Default Description
CLAUDE_OUTPUT_CACHE_DIR /tmp/claude-output-cache Cache directory path
CLAUDE_OUTPUT_CACHE_MAX_AGE_HOURS 4 Auto-evict entries older than this
CLAUDE_OUTPUT_CACHE_MAX_SIZE_MB 100 Max total cache size before eviction
CLAUDE_OUTPUT_CACHE_MAX_OUTPUT_BYTES 5242880 (5MB) Max single output size (truncates)

CLI commands

claude-output-cache setup    # Install hook + MCP server
claude-output-cache status   # Show cache stats
claude-output-cache clean    # Force eviction
claude-output-cache remove   # Uninstall hook + MCP server

Uninstall

claude-output-cache remove
uv tool uninstall claude-output-cache

License

MIT

About

Claude Code MCP server that caches full Bash command outputs for later retrieval, search, and pagination

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages