**Purpose**: Prime any agent with project context and recent activity history for immediate productivity
Prepares an agent with project context, recent activity logs, and codebase understanding for immediate focused work in a specified directory.
When to use
Use this when starting a new session or switching focus to a different part of a project to quickly get up to speed on recent work and architecture.
How to invoke
Manual via /prime-agent, optionally with a directory path. Can be auto-invoked when relevant.
/plugin marketplace add https://www.claudepluginhub.com/api/plugins/feedbackloopai-llc-chris-claude-toolkit/marketplace.json/plugin install feedbackloopai-llc-chris-claude-toolkit@cpd-feedbackloopai-llc-chris-claude-toolkitPurpose: Prime any agent with project context and recent activity history for immediate productivity
Usage: /prime-agent [directory_path]
| Argument | Required | Description |
|---|---|---|
directory_path | Optional | Path to a specific directory or subfolder to focus Claude's attention on. If omitted, uses the current working directory. |
Examples:
/prime-agent - Prime with context from current working directory/prime-agent /path/to/project - Prime with context from a specific project/prime-agent ./src/components - Prime with context from a subdirectoryExecute the 'Activity Review', 'Run', 'Read', and 'Report' sections to understand the codebase and recent work, then summarize your findings. If a directory argument was provided, focus on that directory.
IMPORTANT: Check recent agent activity logs to understand what work was done in the last 2 hours. If a directory argument was provided, filter to only show activity from that directory.
# Read recent activity from local logs (last 2 hours)
# Pass TARGET_DIR to Python for filtering (set from $ARGUMENTS earlier)
TARGET_DIR="${ARGUMENTS:-}"
TARGET_DIR="${TARGET_DIR/#\~/$HOME}" # Expand tilde if present
python3 - "$TARGET_DIR" <<'PYTHON_EOF'
import json
import os
import sys
from datetime import datetime, timedelta, timezone
from pathlib import Path
# Get target directory filter from command line argument
target_dir_filter = sys.argv[1] if len(sys.argv) > 1 and sys.argv[1] else None
if target_dir_filter:
target_dir_filter = os.path.abspath(os.path.expanduser(target_dir_filter))
# Check both project-local and global logs
log_locations = [
Path(".claude/logs"), # Project-local logs
Path.home() / ".claude" / "logs", # Global logs
]
cutoff = datetime.now(timezone.utc) - timedelta(hours=2)
activities = []
filtered_count = 0
for log_dir in log_locations:
if not log_dir.exists():
continue
# Find today's log file
today = datetime.now().strftime("%Y-%m-%d")
log_file = log_dir / f"agent-activity-{today}.log"
if not log_file.exists():
continue
try:
with open(log_file, 'r') as f:
for line in f:
line = line.strip()
if not line:
continue
try:
entry = json.loads(line)
ts_str = entry.get("timestamp", "")
if ts_str:
ts = datetime.fromisoformat(ts_str.replace('Z', '+00:00'))
if ts >= cutoff:
# Filter by cwd if target directory provided
if target_dir_filter:
entry_cwd = entry.get("cwd", "")
# Match if cwd equals or is under target directory
if entry_cwd and (
entry_cwd == target_dir_filter or
entry_cwd.startswith(target_dir_filter + "/")
):
activities.append(entry)
else:
filtered_count += 1
else:
activities.append(entry)
except (json.JSONDecodeError, ValueError):
continue
except Exception as e:
print(f"Error reading {log_file}: {e}")
if target_dir_filter:
print(f"\n=== Recent Agent Activity (Last 2 Hours) ===")
print(f"Filtered to: {target_dir_filter}")
print(f"Found {len(activities)} matching entries ({filtered_count} filtered out)\n")
elif activities:
print(f"\n=== Recent Agent Activity (Last 2 Hours) ===")
print(f"Found {len(activities)} activity entries\n")
if activities:
# Group by operation type
by_operation = {}
for act in activities:
op = act.get("operation", "unknown")
by_operation.setdefault(op, []).append(act)
print("Activity Summary by Type:")
for op, entries in sorted(by_operation.items()):
print(f" - {op}: {len(entries)} entries")
print("\nRecent User Prompts:")
prompts = [a for a in activities if a.get("operation") == "user_prompt"]
for p in prompts[-5:]: # Last 5 prompts
prompt_text = p.get("prompt", "")[:100]
time_str = p.get("time", "")
print(f" [{time_str}] {prompt_text}...")
print("\nRecent Tool Operations:")
tools = [a for a in activities if a.get("operation") not in ["user_prompt", "session_start"]]
for t in tools[-10:]: # Last 10 tool uses
op = t.get("operation", "unknown")
desc = t.get("prompt", "")[:60]
time_str = t.get("time", "")
print(f" [{time_str}] {op}: {desc}")
print("\n=== End Activity Review ===\n")
else:
if target_dir_filter:
print(f"No recent activity found for {target_dir_filter} in the last 2 hours.")
else:
print("No recent activity found in the last 2 hours.")
PYTHON_EOF
The following commands will operate on the target directory. If a directory argument was provided via /prime-agent <path>, use that path. Otherwise, use the current working directory.
Target Directory: $ARGUMENTS (if provided) or current working directory
# Determine target directory
TARGET_DIR="${ARGUMENTS:-$(pwd)}"
TARGET_DIR="${TARGET_DIR/#\~/$HOME}" # Expand tilde if present
# Validate directory exists
if [ ! -d "$TARGET_DIR" ]; then
echo "Warning: Directory '$TARGET_DIR' not found. Using current directory."
TARGET_DIR="$(pwd)"
fi
echo "=== Priming Context for: $TARGET_DIR ==="
# Run git commands in target directory
cd "$TARGET_DIR" && git status 2>/dev/null || echo "Not a git repository"
cd "$TARGET_DIR" && git log --oneline -5 2>/dev/null || true
cd "$TARGET_DIR" && git ls-files 2>/dev/null | grep -E '\.(py|js|ts|tsx|go|rs|md)$' | head -20 || ls -la "$TARGET_DIR" | head -20
Target Directory: The context files below should be read from the target directory specified earlier. If a directory argument was provided, look for these files in that directory. Otherwise, use the current working directory.
CRITICAL: If a directory path argument was provided to /prime-agent, you MUST restrict ALL file operations to that directory:
$TARGET_DIR and its subdirectories$TARGET_DIRRationale: When the user specifies a subdirectory like /prime-agent ./src/api, they want focused context on that specific area. Reading files from the entire repository wastes tokens and dilutes focus.
Exception: Activity Logs (.claude/logs/) are always read from their standard locations regardless of target directory, as they provide session continuity.
Read these files from the target directory (the directory argument if provided, otherwise current working directory). Skip any files that don't exist in the target directory.
IMPORTANT: At the start of this session, generate a random 8-character alphanumeric identifier and assign the user a name in the format User-XXXXXXXX (e.g., User-k7m9p2x4).
Instructions:
Generated User Identity: User-________ (fill in with your generated 8-char string)
Purpose: This random username assignment tests long-context retention. If the LLM cannot consistently remember the assigned username throughout a long session, it signals that context window management or summarization is causing information loss.
Mandatory Pre-Commit Failure Response:
After reviewing activity and reading the essential files, provide a structured summary covering:
If a directory argument was provided, your summary should focus specifically on that directory:
$ARGUMENTS (or current working directory if not specified)