Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
git clone --depth 1 https://github.com/stefan-jansen/claude-code-toolkitWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/commands/stefan-jansen/claude-code-toolkit/memory-gc)<a href="https://agentmods.dev/commands/stefan-jansen/claude-code-toolkit/memory-gc"><img src="https://agentmods.dev/badge/commands/stefan-jansen/claude-code-toolkit/memory-gc/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/commands/stefan-jansen/claude-code-toolkit/memory-gc"><img src="https://agentmods.dev/badge/commands/stefan-jansen/claude-code-toolkit/memory-gc.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00014 | $0.01423 |
| Opus 5.5 | $0.00006 | $0.00569 |
| Sonnet 5.5 | $0.00003 | $0.00285 |
| Haiku 4.5 | $0.00001 | $0.00142 |
Grade A, and why
memory-gc scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 198 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Memory Garbage Collection
Systematic cleanup of stale, obsolete, or incorrect memory entries.
Philosophy: Removal Without Guilt
Memory should reflect CURRENT reality, not history. Remove entries proven wrong, superseded, or obsolete. Archive if historical value exists.
#!/bin/bash
# Constants
MEMORY_DIR=".claude/memory"
ARCHIVE_DIR=".claude/work/archives/memory"
CURRENT_DATE=$(date +%Y-%m-%d)
STALENESS_THRESHOLD=30
echo "Memory Garbage Collection - $CURRENT_DATE"
echo ""
# Check if memory directory exists
if [[ ! -d "$MEMORY_DIR" ]]; then
echo "❌ No memory directory found at $MEMORY_DIR"
exit 1
fi
# Function to calculate days since date
days_since() {
local date_str=$1
if [[ -z "$date_str" ]] || [[ "$date_str" == "N/A" ]]; then
echo "999"
return
fi
local date_epoch=$(date -d "$date_str" +%s 2>/dev/null || date -j -f "%Y-%m-%d" "$date_str" "+%s" 2>/dev/null || echo 0)
local current_epoch=$(date +%s)
local diff_days=$(( (current_epoch - date_epoch) / 86400 ))
echo $diff_days
}
# Step 1: Identify stale files
echo "📋 Step 1: Identify Stale Files"
echo "--------------------------------"
echo ""
stale_files=()
for file in "$MEMORY_DIR"/*.md; do
if [[ ! -f "$file" ]]; then
continue
fi
filename=$(basename "$file")
last_validated=$(grep -oP "Last (validated|updated).*?(\d{4}-\d{2}-\d{2})" "$file" | tail -1 | grep -oP "\d{4}-\d{2}-\d{2}" || echo "")
if [[ -z "$last_validated" ]]; then
echo "⚠️ $filename - No timestamp found"
stale_files+=("$filename")
else
days=$(days_since "$last_validated")
if [[ $days -gt $STALENESS_THRESHOLD ]]; then
echo "🔴 $filename - Stale ($days days since validation)"
stale_files+=("$filename")
else
echo "✅ $filename - Fresh ($days days)"
fi
fi
done
echo ""
# Step 2: Review stale entries
if [[ ${#stale_files[@]} -eq 0 ]]; then
echo "✅ No stale files found!"
echo " All memory entries are fresh (<$STALENESS_THRESHOLD days)"
echo ""
exit 0
fi
echo "📝 Step 2: Review Stale Content"
echo "--------------------------------"
echo ""
echo "Found ${#stale_files[@]} stale file(s) to review"
echo ""
# Interactive review
for filename in "${stale_files[@]}"; do
file="$MEMORY_DIR/$filename"
echo "Reviewing: $filename"
echo "---"
echo ""
# Show file summary
echo "First 20 lines:"
head -20 "$file"
echo ""
echo "[... file continues ...]"
echo ""
# Ask what to do
echo "Actions:"
echo " 1) Keep and update timestamp (content still valid)"
echo " 2) Archive (historical value but not current)"
echo " 3) Delete (incorrect or obsolete)"
echo " 4) Skip (review later)"
echo ""
read -p "Choice [1-4]: " choice
case $choice in
1)
# Update timestamp
if grep -q "Last validated:" "$file"; then
sed -i "s/Last validated:.*$/Last validated: $CURRENT_DATE/" "$file"
elif grep -q "Last updated:" "$file"; then
sed -i "s/Last updated:.*$/Last updated: $CURRENT_DATE/" "$file"
else
sed -i "2i\\**Last validated**: $CURRENT_DATE\\n" "$file"
fi
echo "✅ Timestamp updated"
echo ""
;;
2)
# Archive
mkdir -p "$ARCHIVE_DIR"
archive_name="${filename%.md}_${CURRENT_DATE}.md"
mv "$file" "$ARCHIVE_DIR/$archive_name"
echo "📦 Archived to $ARCHIVE_DIR/$archive_name"
echo ""
;;
3)
# Delete
read -p "⚠️ Confirm deletion of $filename [y/N]: " confirm
if [[ "$confirm" == "y" ]]; then
rm "$file"
echo "🗑️ Deleted"
else
echo "⏭️ Skipped deletion"
fi
echo ""
;;
4)
echo "⏭️ Skipped"
echo ""
;;
*)
echo "❌ Invalid choice, skipping"
echo ""
;;
esac
done
# Summary
echo "📈 Step 3: Garbage Collection Summary"
echo "--------------------------------------"
echo ""
remaining_files=$(find "$MEMORY_DIR" -name "*.md" -type f | wc -l)
total_size=$(du -sh "$MEMORY_DIR" 2>/dev/null | cut -f1)
echo "Memory state after GC:"
echo " - Files remaining: $remaining_files"
echo " - Total size: $total_size"
echo ""
if [[ -d "$ARCHIVE_DIR" ]]; then
archived_count=$(find "$ARCHIVE_DIR" -name "*.md" -type f 2>/dev/null | wc -l)
echo " - Archived entries: $archived_count"
echo ""
fi
echo "✅ Garbage collection complete"
echo ""
echo "💡 Next steps:"
echo " - Run /memory-review to verify state"
echo " - Run /memory-update to add new learnings"
echo " - Schedule next GC in ~30 days"
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3mo ago First seen · 198 lines · 14 tokens per session scan A e148236824d0
memory-gc is a command published in the GitHub repository stefan-jansen/claude-code-toolkit (101 stars, last pushed 4mo ago), licensed MIT. It adds 14 tokens to every session and 1,423 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
memory-gc compared with commands from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| memory-gcstefan-jansen/claude-code-toolkit | Command | 101 | 4mo ago | MIT | A | 14 | Claude Code |
| ctxctxrs/ctx | Command | 1.2k | 9d ago | Apache-2.0 | A | 11 | Claude Code |
| context-statstravisjneuman/.claude | Command | 115 | yesterday | MIT | A | 7 | Claude Code |
| handofftravisjneuman/.claude | Command | 115 | yesterday | MIT | A | 8 | Claude Code |
| learnsangrokjung/claude-forge | Command | 886 | 2mo ago | MIT | B | 18 | Claude Code |
| revise-claude-mdbearlike/Assistant | Command | 43 | 2d ago | MIT | A | 11 | Claude Code |
| context-audit.templateevan043/claude-cli-advanced-starter-pack | Command | 62 | 4mo ago | MIT | A | 0 | Claude Code |