research-cache

Manage and search the research cache for previously analyzed repositories

Best use case

research-cache is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Manage and search the research cache for previously analyzed repositories

Teams using research-cache should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/research-cache/SKILL.md --create-dirs "https://raw.githubusercontent.com/stevengonsalvez/agents-in-a-box/main/toolkit/packages/skills/research-cache/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/research-cache/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How research-cache Compares

Feature / Agentresearch-cacheStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Manage and search the research cache for previously analyzed repositories

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Research Cache

Manage the global repository analysis cache used by the `/research` command.

## Overview

The research cache stores analysis results from external repositories discovered during web research. This prevents re-analyzing the same repositories and speeds up research workflows.

**Cache Location**: `{{HOME_TOOL_DIR}}/research-cache/`

**Cache Structure**:
```
{{HOME_TOOL_DIR}}/research-cache/
  <owner>-<repo>-<commit-short>/
    analysis.md          # Focused analysis document
    metadata.json        # Cache metadata (timestamps, query hash)
```

## Cache Behavior

### Automatic Caching

When the `/research` command discovers external repositories:

1. **Detection**: URLs extracted from web research results (Step 3.5)
2. **Cache Check**: Before analysis, check if commit already analyzed
3. **Analysis**: If not cached, spawn `focused-repository-analyzer` agent
4. **Save**: Analysis saved to cache with metadata
5. **Reuse**: Future research queries use cached results

### Cache TTL

- **Default TTL**: 7 days
- **Max Age**: 30 days (before purge)
- **Query Matching**: Cache reused if query hash matches

## Commands

### View Cache Statistics

```bash
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh stats
```

**Output**:
```
Cache Statistics

Directory: {{HOME_TOOL_DIR}}/research-cache

Entries:
  Total:   15
  Valid:   12
  Expired: 3
  Invalid: 0

Storage:
  Total Size: 45678KB

Configuration:
  TTL:          604800s (7 days)
  Max Age:      2592000s (30 days)
```

### List Cache Entries

```bash
# List valid entries only
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh list

# Include expired entries
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh list --expired
```

**Output**:
```
Cache Directory: {{HOME_TOOL_DIR}}/research-cache

CACHE KEY                      STATUS          CREATED              QUERY HASH
----------                     ------          -------              ----------
facebook-react-a1b2c3d         VALID           2026-01-01T12:00:00  f3a8c91e
vercel-next.js-e4f5g6h         VALID           2026-01-02T14:30:00  7b2d4a9c
golang-go-i7j8k9l              EXPIRED         2025-12-20T09:15:00  3c1e5f2a
```

### Purge Expired Entries

```bash
# Purge only expired entries (older than max age)
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh purge

# Force purge all entries
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh purge --force
```

**Output**:
```
Purging: golang-go-i7j8k9l (age: 2678400s)
Purging invalid: broken-repo-abc123

Purge Summary:
  Purged: 2
  Kept:   13
```

### Get Cached Analysis

```bash
# Get path to cached analysis
CACHE_KEY="facebook-react-a1b2c3d"
ANALYSIS_PATH=$(bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh get "$CACHE_KEY")

if [ $? -eq 0 ]; then
    echo "Found cached analysis: $ANALYSIS_PATH"
    cat "$ANALYSIS_PATH"
else
    echo "No cached analysis found"
fi
```

### Check Cache Existence

```bash
# Check if cache entry exists
CACHE_KEY="facebook-react-a1b2c3d"
if bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh exists "$CACHE_KEY"; then
    echo "Cache hit: $CACHE_KEY"
else
    echo "Cache miss: $CACHE_KEY"
fi

# Check with query hash matching
QUERY_HASH="f3a8c91e"
if bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh exists "$CACHE_KEY" "$QUERY_HASH"; then
    echo "Cache hit with matching query"
else
    echo "Cache miss or query mismatch"
fi
```

### Generate Cache Key

```bash
# Generate cache key from repo URL and commit
REPO_URL="https://github.com/facebook/react"
COMMIT_HASH="a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0"

CACHE_KEY=$(bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh key "$REPO_URL" "$COMMIT_HASH")
echo "Cache key: $CACHE_KEY"
# Output: facebook-react-a1b2c3d
```

## Cache Metadata

Each cache entry includes `metadata.json`:

```json
{
  "cache_key": "facebook-react-a1b2c3d",
  "repo_url": "https://github.com/facebook/react",
  "commit_hash": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0",
  "query": "How to implement React hooks?",
  "query_hash": "f3a8c91e",
  "context": "Discovered during web research for: React hooks implementation",
  "created_at": 1735747200,
  "created_date": "2026-01-01T12:00:00Z",
  "ttl_seconds": 604800,
  "expires_at": 1736352000,
  "expires_date": "2026-01-08T12:00:00Z"
}
```

## Best Practices

### When to Purge Cache

1. **Regular Maintenance**: Run `purge` monthly to remove old entries
2. **Disk Space**: Purge when cache size exceeds reasonable limits
3. **Forced Purge**: Use `--force` when resetting research state

### Cache Invalidation

Cache entries are automatically invalidated when:

- **Age > TTL**: Entry older than 7 days
- **Query Mismatch**: Different query hash (query-specific caching)
- **Invalid Metadata**: Missing or corrupted metadata.json

### Manual Cache Management

```bash
# View what's cached
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh list

# Check stats before purging
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh stats

# Purge expired only
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh purge

# Force clean slate
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh purge --force
```

## Configuration

### Environment Variables

```bash
# Override cache directory
export CLAUDE_RESEARCH_CACHE="/custom/cache/path"

# Default: {{HOME_TOOL_DIR}}/research-cache
```

### Cache Settings

Edit `toolkit/claude-code-4.5/utils/repo-analysis-cache.sh`:

```bash
# Cache TTL in seconds (7 days)
CACHE_TTL=$((7 * 24 * 60 * 60))

# Max age before purge (30 days)
MAX_CACHE_AGE=$((30 * 24 * 60 * 60))
```

## Troubleshooting

### Cache Not Being Used

**Symptom**: Research always re-analyzes repositories

**Check**:
```bash
# Verify cache exists
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh stats

# Check if entry is valid
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh exists <cache-key>
```

**Fix**:
- Entry may be expired (age > TTL)
- Query hash mismatch (different research query)
- Invalid metadata.json

### Cache Growing Too Large

**Symptom**: Cache directory consuming excessive disk space

**Check**:
```bash
# View cache size
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh stats
```

**Fix**:
```bash
# Purge expired entries
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh purge

# Or force purge all
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh purge --force
```

### Corrupted Cache Entry

**Symptom**: Cache entry exists but cannot be read

**Fix**:
```bash
# Manually remove corrupted entry
rm -rf {{HOME_TOOL_DIR}}/research-cache/<cache-key>

# Reinitialize cache
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh init
```

## Integration with /research Command

The research cache is automatically used by the `/research` command:

1. **Step 3.5**: External repositories detected from web research
2. **Step 3.6**: Cache checked before cloning/analyzing
3. **Cache Hit**: Cached analysis included in research document
4. **Cache Miss**: Repository cloned, analyzed, and saved to cache

No manual intervention required for normal research workflows.

## Performance Impact

**Without Cache**:
- Clone time: 30-60s per repository
- Analysis time: 25-35 minutes per repository
- Total: ~30 minutes for single repo

**With Cache**:
- Cache lookup: <1s
- Analysis reuse: instant
- Total: <1s for cached repo

**Typical Savings**: 99%+ time reduction for repeated research queries

## Advanced Usage

### Batch Cache Operations

```bash
# Get all valid cache keys
for cache_dir in {{HOME_TOOL_DIR}}/research-cache/*; do
    if [ -f "$cache_dir/metadata.json" ]; then
        CACHE_KEY=$(basename "$cache_dir")
        AGE=$(jq -r '.created_at' "$cache_dir/metadata.json")
        echo "$CACHE_KEY: created $(date -r $AGE)"
    fi
done
```

### Export Cache Statistics

```bash
# Export to JSON
bash toolkit/claude-code-4.5/utils/repo-analysis-cache.sh stats > cache-stats.txt

# Parse for monitoring
grep "Total:" cache-stats.txt
```

### Custom Cache Queries

```bash
# Find all React-related analyses
grep -r "React" {{HOME_TOOL_DIR}}/research-cache/*/analysis.md

# Find analyses newer than N days
find {{HOME_TOOL_DIR}}/research-cache -name "metadata.json" -mtime -7 -exec jq -r '.repo_url' {} \;
```

## See Also

- `/research` - Main research command that uses cache
- `focused-repository-analyzer` - Agent that generates cached analyses
- `toolkit/claude-code-4.5/utils/repo-analysis-cache.sh` - Cache utility script

Related Skills

research

8
from stevengonsalvez/agents-in-a-box

Conduct comprehensive research across multiple sources - codebase, web, and documentation - by spawning parallel sub-agents and synthesizing findings. Searches past learnings first, then codebase, docs, and optionally web.

crypto-research

8
from stevengonsalvez/agents-in-a-box

Comprehensive cryptocurrency market research and analysis using specialized AI agents. Analyzes market data, price trends, news sentiment, technical indicators, macro correlations, and investment opportunities. Use when researching cryptocurrencies, analyzing crypto markets, evaluating digital assets, or investigating blockchain projects like Bitcoin, Ethereum, Solana, etc.

workflow

8
from stevengonsalvez/agents-in-a-box

Guide through structured delivery workflow with plan, implement, validate phases

webapp-testing

8
from stevengonsalvez/agents-in-a-box

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

validate

8
from stevengonsalvez/agents-in-a-box

Verify implementation against specifications

ui-ux-pro-max

8
from stevengonsalvez/agents-in-a-box

UI/UX design intelligence. 67 styles, 96 palettes, 57 font pairings, 25 charts, 13 stacks (React, Next.js, Vue, Svelte, Astro, Nuxt, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui, Jetpack Compose). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient.

tui-style-guide

8
from stevengonsalvez/agents-in-a-box

TUI style guide for consistent terminal interface design

token-usage

8
from stevengonsalvez/agents-in-a-box

Show Claude Code token usage across sessions — daily, weekly, per-project, and per-session breakdowns. Parses {{HOME_TOOL_DIR}}/projects/**/*.jsonl for consumption data. Use when the user asks about token usage, costs, how many tokens were used, session statistics, or wants a usage report.

tmux-status

8
from stevengonsalvez/agents-in-a-box

Show status of all tmux sessions including dev environments, spawned agents, and running processes

tmux-monitor

8
from stevengonsalvez/agents-in-a-box

Monitor and report status of all tmux sessions including dev environments, spawned agents, and running processes. Uses tmuxwatch for enhanced visibility.

tmux-message

8
from stevengonsalvez/agents-in-a-box

Reliable peer-to-peer message delivery to other Claude Code instances via tmux send-keys. Use as a fallback when claude-peers MCP send_message fails to surface in the receiver's inbox (delivered server-side but receiver never picks it up — observed behaviour). Also use when sending a directive to a known Claude Code TUI session by tmux session name or fuzzy hint, or when injecting a multi-line directive into a peer's prompt and submitting it. Trigger phrases — "claude-peers fallback", "tmux send-keys", "send to peer via tmux", "inject directive", "deliver to nanoclaw/hermes peer", "peer message". Tmux-only — won't reach peers running outside tmux.

test-driven-development

8
from stevengonsalvez/agents-in-a-box

Use when implementing any feature or bugfix, before writing implementation code. Enforces RED-GREEN-REFACTOR cycle with test-first approach.