Innovation Engine — insight

Tool Autopsy Reverse-Search

August 06, 2026

Ethan has ~600 custom tools and no fast way to answer 'did I already build this?' before writing tool #601 — a real risk given tool-sprawl-sentinel and tool-graveyard-reaper already exist to clean up after the fact. This builds a semantic index of every tool in ~/.local/bin by extracting its header comment/usage string, embedding it, and exposing a `tool-recall ""` command that returns the 5 closest existing tools with last-run timestamps. It converts sprawl from a cleanup problem into a prevention problem at the moment of intent.

~/.local/bin tool corpusembed-batch-submitclaude-code-hookssystemd-timerstool-sprawl-sentinel

Create ~/.local/bin/tool-recall (bash+python). Index pass: walk ~/.local/bin, for each executable grab the first 20 lines, strip shebang, extract comment block or `usage:` line as the description; fall back to `--help` output only for files with a `# desc:` marker to avoid side effects. Write {name, desc, mtime, last_run} to ~/.cache/tool-recall/index.jsonl, where last_run comes from `journalctl --user -o json` unit matches plus atime. Embed descriptions via the existing embed-batch-submit tool (or local ollama via the `gemma` wrapper if offline) into ~/.cache/tool-recall/vecs.npy. Query pass: `tool-recall "watch a git branch and email me"` embeds the query, cosine-ranks, prints top 5 as `name — desc — last run 34d ago`. Add a Claude Code PreToolUse hook in ~/.claude/settings.json matching Write to paths under ~/.local/bin that runs `tool-recall --terse "$FILENAME"` and injects results as context, so any agent about to create a new tool sees near-duplicates first. Refresh index nightly via a systemd timer reusing the cron-capped wrapper.

Built & Ready
**tool-recall — LIVE**

**What it does**
- `tool-recall "watch a git branch and email me"` → 5 closest existing tools, each with its description and last-run age
- `tool-recall --index` → rebuilds the index (617 tools found across `~/.local/bin` + `~/bin`)
- `tool-recall --terse <path>` → compact form used by the hook

**Created**
- `~/bin/tool-recall` — 100-line python; descriptions come from header comments/usage/docstrings only, never by executing anything
- `~/bin/tool-recall.test.sh` — 6 bats tests, all green, including a negative control proving indexing never executes a tool
- `~/.claude/hooks/tool-recall-dupe-check.sh` — PreToolUse(Write) hook; fires only for NEW files under `~/bin`/`~/.local/bin`, injects near-duplicates, never blocks
- `~/.config/systemd/user/tool-recall-index.{service,timer}` — nightly 03:20 refresh via `cron-capped`, enabled, ran clean, next fire Fri 03:23
- `~/.claude/settings.json` — hook registered (backup at `.bak-toolrecall`)

**Two things worth knowing**
- **Ollama is not running on this box**, so embeddings fall back to a deterministic local lexical vectorizer. It works and never hangs, but matching is lexical-ish rather than truly semantic until ollama is up with `nomic-embed-text`. Verified with a real query.
- **Last-run comes from atime**, which relatime makes coarse. Indexing restores atime after reading so the index doesn't corrupt its own signal — but the first index run (before that fix) already stamped everything "today"; the value
Active Projects
russ-telegram, innovation-engine, joyos-labs-monitor, joyos-lab-staging, jekelinspections
Category
insight