type: decision
status: active
timestamp: 2026-06-29
tags: [architecture, agent-tooling, okf, discoverability, hook]

OKF auto-lookup via UserPromptSubmit hook (CC) + manual script (other agents)

Fix for OKF-not-triggering symptom: a 50-LOC Python script scores knowledge/index.md lines by prompt-token overlap, returns top-3 paths. CC fires it automatically; other agents run it manually because their harnesses lack pre-prompt hooks.

OKF auto-lookup via UserPromptSubmit hook

Problem

knowledge/ has 700+ concept files. Agent answers questions from training-data memory instead of grepping knowledge/ first. The right answer exists in a concept file but is invisible because no mechanism forces a lookup.

Stated symptom from user 2026-06-29: “OKF is not getting triggered.”

Options considered

OptionCostCoverageVerdict
Convert 18 OKF runbooks to SKILL.md8-10 hr18/700 files (2.5%)Rejected — leaves 97.5% un-triggerable
Convert all 700 files to SKILL.md wrappers40 hr100% but noisyRejected — Anthropic spec warns against
Embed full index.md (1285 lines, ~30K tokens) as auto-import0 hr100% by titleRejected — pays cost every turn
Local embedding model semantic search4 hr + model download100% with smarter matchingDeferred — overkill for v1
Tiny LLM (Haiku) classification per turn1 hr + $0.0002/turn100% with smartest matchDeferred — pay-per-call
UserPromptSubmit hook + keyword script~2 hr100% by token overlapSelected

Decision

scripts/okf-prompt-lookup.py — stdlib Python, ~120 LOC. Reads prompt from argv or JSON-stdin, tokenises (strips stopwords + 3-char minimum), scores every line of knowledge/index.md by token overlap, returns top-N concept-file paths.

Wired into Claude Code via ~/.claude/settings.json UserPromptSubmit hook. Fires on every prompt. Output is prepended to context as a system-reminder block listing top-3 paths + their index descriptions + scores.

Fleet-parity gap

Audited 5 other agents 2026-06-29:

For the 5 unsupported agents, the okf-lookup-before-acting rule mandates the agent run the script itself at task start. Manual instead of automatic, but the rule lives in AGENTS.md and is loaded by every agent.

Implementation

Files added:

Files modified:

Verification

Smoke-tested 4 prompts 2026-06-29:

PromptTop hitScoreVerdict
”rotate a leaked GitHub token urgently”runbooks/security/credentials/rotate-cf-and-npm-tokens.md2✓ correct
”scaffold a new astro tool site”runbooks/scaffolding/sites/scaffold-tool-site.md4✓ correct
”add a new api subdomain to cloudflare DNS”3 CF-DNS-related files at score 33⚠ missed cf-dns-add-api-subdomain because of “cloudflare” vs “cf-” token mismatch
”ok”(empty, exit 1)✓ correctly skipped

Live confirmation: user’s first prompt after install surfaced parallel-fan-out-by-default + parallel-by-default + parallel-fan-out at score 3 each, exactly matching the user’s prompt about fan-out.

Known limitations (v1)

What this replaced

A prior plan (rounds 1-4 of the grill) proposed 28-skill cross-agent installation, 3 submodule forks of external skill repos, chirag127/agent-skills plugin marketplace, wshobson cross-harness adapter pattern. Round 5 reframe: the actual symptom was discoverability, not skill format. The auto-lookup hook fixes 90% of the symptom at 20% of the cost. The 28-skill plan is deferred indefinitely.


Edit on GitHub · Back to index