plan-cache-lookup
Checks the local plan-template cache to see if a plan exists for the current task.
Install
mkdir -p .claude/skills/plan-cache-lookup && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/11172" && unzip -o skill.zip -d .claude/skills/plan-cache-lookup && rm skill.zipInstalls to .claude/skills/plan-cache-lookup
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Plan-phase Stage 0 gate that checks the local plan-template cache for a matching (task_class, repo_hash, gear, critical) key. Slice B ships MISS-only: emits PLAN_CACHE_MISS with a structured reason (no-template, disabled, shadow-mode) and lets the orchestrator fall through to recon + architect. The HIT path (Haiku adapter + structural validator) lands in Slice C. CLAUDE_PLAN_CACHE_MODE defaults to off in Slice B for partial-merge safety; Slice F flips the default to shadow.Key capabilities
- →Compute a cache key from the pipeline's task signature
- →Look for matching plan templates in the local cache
- →Emit `PLAN_CACHE_MISS` with a structured reason
- →Resolve the plan cache directory
- →Resolve the cache mode (off, shadow, on)
How it works
The skill computes a cache key from the pipeline's task signature and checks for a matching plan template in the local cache, emitting a `PLAN_CACHE_MISS` if not found or disabled.
Inputs & outputs
When to use plan-cache-lookup
- →Lookup cached plan templates
- →Optimize plan dispatch process
- →Verify pipeline state signatures
About this skill
Plan Cache Lookup (Slice B MISS path + Slice C HIT path)
What This Skill Does
Stage 0 of Plan Phase Dispatch. Computes a cache key from the current pipeline's task signature and looks for a matching plan template under learning/{project-hash}/plans/. In Slice B, every invocation emits PLAN_CACHE_MISS with a structured reason; the HIT-serving path and its Haiku adapter land in Slice C. The orchestrator MUST fall through to Stage 1 (recon) on MISS — this matches the existing flow exactly and is the partial-merge-safe shape (LOW-eng-3).
When to Invoke
- Plan phase, BEFORE Stage 1 recon dispatch (the orchestrator wiring lands in Slice D; until then this skill is callable but not yet wired).
- Once per pipeline run. The Plan phase runs once per
/harness:pipelineinvocation, so single-writer concurrency suffices (no flock). - Do NOT use when:
CLAUDE_PLAN_CACHE_MODE=off(default in Slice B) — the mode resolver short-circuits toMISS reason=disabled.
Inputs
- Pipeline state: the active pipeline file located via
_psp_find_active_pipelines(the canonical pipeline-state reader athooks/_lib/pipeline-state-paths.sh). NEVER use bare[ -f pipeline-state/$task/$phase.md ]; the union helper resolves DUAL_PATH layouts (new$state_dir/{task}/{phase}.md, legacy$state_dir/{task}-{phase}.md, and workstream variants). - Environment:
CLAUDE_PLAN_CACHE_MODE∈{off, shadow, on}; unset →offin Slice B (flipped toshadowin Slice F).CLAUDE_PROJECT_HASH— env-first override for the cache namespace (mirrorshooks/observation-capture.sh:30-38); unset →_project_hash --fallback "$(basename "$(pwd)")".
- Task signature:
(task_class, repo_hash, gear, critical)— the cache key (sha256 of canonical JSON).repo_hashis computed by_repo_hash(hooks/_lib/repo-hash.sh), leaf-content-blind by design (HIGH-eng-1 in plan.md Citation #11).
Procedure
The skill body sources hooks/_lib/plan-cache-lookup.sh and calls one public entry point.
Step 1 — Resolve mode
Call _plan_cache_mode. The resolver:
- Reads
CLAUDE_PLAN_CACHE_MODE. - Validates against the closed set
{off, shadow, on}; any other value (including unset) →off. - This is the hard-default-
offguarantee of LOW-eng-3: any subset of slices B-E that merges without Slice F STAYS inoff, so no HIT-serving path can ship by accident.
If mode is off, emit PLAN_CACHE_MISS reason=disabled and return — no key computation, no filesystem lookup, no audit cost.
Step 2 — Resolve cache directory
Call _plan_cache_dir. Resolution order (env-first, mirroring hooks/observation-capture.sh:30-38):
$CLAUDE_PROJECT_HASHif set and non-empty →$HOME/learning/$CLAUDE_PROJECT_HASH/plans.- Otherwise →
_project_hash --fallback "$(basename "$(pwd)")"→$HOME/learning/<hash>/plans.
Step 3 — Compute cache key + look up template
Call _plan_cache_lookup task_class gear critical. The function:
- Calls
_repo_hash(fromhooks/_lib/repo-hash.sh) —sha256(git ls-tree --name-only -r HEAD <stable-dirs>) ⊕ sha256(CLAUDE.md). - Calls
_plan_cache_key task_class repo_hash gear critical— sha256 of canonical-JSON{critical, repo_hash, task_class, gear}(jq's-cn --argbuilder fixes key order). - Checks
[[ -f "$cache_dir/$key.md" ]]. - Branches (this
_plan_cache_lookupentry point covers the off / shadow-mode branches only; the on-mode HIT path is in place in Slice C and is driven by the orchestrator via the four steps in § HIT Path Dispatch below — NOT through this lookup function):- File absent → emit
PLAN_CACHE_MISS reason=no-template. - File present + mode ∈ {off, shadow} → emit
PLAN_CACHE_MISS reason=shadow-mode(mode=off was already short-circuited at Step 1; this branch is reached only in shadow). See § HIT Path Dispatch for the on-mode flow.
- File absent → emit
Step 4 — Read pipeline state when callers need task_id
When the orchestrator wires this skill in Slice D, the caller MUST locate the active pipeline file via _psp_find_active_pipelines (NOT a bare [ -f ] test). The skill body's reference to _psp_find_active_pipelines documents this contract — Slice D's wiring will route task_id, task_class, gear, and critical into the entry call by reading the active intake/plan state located through this helper.
HIT Path Dispatch
On a key match (mode=on, template present), the skill performs four
single-shot steps. On validator rejection the path falls through in-cycle to
Stage 1+2 per Iron Law 6; the adapter is not re-invoked in this pipeline.
- Mutate template frontmatter via
_plan_cache_write_pending TEMPLATE(tmp+mv atomic). Setslast_adapted_at=now()andlast_adapt_outcome=pendingBEFORE adapter spawn (state-before-expensive-op, Memory M5). Crash mid-adapter leaves thependingmarker on disk so the next entry treats the template as stale. - Write the resume-safety stub via
_plan_cache_write_resume_stub TASK_ID(AC C8). Creates$state_dir/{task-id}/architect-context.mdwith body<!-- cache_hit: true, recon-skipped -->so/harness:pipeline-resumereaders don't stall on the missing recon output. - Spawn the adapter agent (one Agent directive — single-shot, no loop):
Agent({
subagent_type: "plan-cache-adapter",
model: "haiku",
maxTurns: 8,
prompt: "Read ~/.claude/agents/plan-cache-adapter.md.
Cached template: {template-path}.
Current ACs: {ACs from $state_dir/{task-id}/intake.md}.
Write adapted plan to $state_dir/{task-id}/plan.md with `cache_hit: true`
in the frontmatter and preserve the four required H2 sections:
## Slices, ## Alternatives Considered, ## Codebase Ground-Truth Citations,
## Pre-Mortem."
})
- Call
_plan_cache_finalize TEMPLATE PLAN KEY. Pass → flips outcome=success, emitsPLAN_CACHE_HIT. Reject → DELETES the produced plan.md, flips outcome=failed, appends bothverdict=PLAN_CACHE_MISS reason=adapter-rejectedandevent=PLAN_CACHE_FALLTHROUGHtometrics/{session}/plan-cache.jsonl, emitsPLAN_CACHE_MISS reason=adapter-rejected. The orchestrator MUST then run Stage 1+2 in the same pipeline (Iron Law 6: no deferral, no follow-up).
Outputs
A single line on stdout, prefixed with the audit-hook marker
[PlanCacheLookup] so the universal-PostToolUse sibling at
hooks/plan-cache-audit.sh (Slice E) can identify and parse it:
[PlanCacheLookup] {"verdict":"PLAN_CACHE_MISS","reason":"<reason>","cache_key":"<key-or-empty>"}
or, on HIT:
[PlanCacheLookup] {"verdict":"PLAN_CACHE_HIT","cache_key":"<key>"}
<reason> ∈ {no-template, disabled, shadow-mode} in Slice B; Slice C adds adapter-rejected, adapter-pending-stale, template-corrupt. Slice F adds hash-drift, key-mismatch.
Status Line Copy (Slice F)
Each verdict pairs the [PlanCacheLookup] JSON audit marker with one
user-facing console line (or stays silent). Strings below are VERBATIM
per $state_dir/plan-cache-agentic/plan.md § Status Line Copy and are
emitted by _plan_cache_status_line (hooks/_lib/plan-cache-lookup.sh).
| State | Console string |
|---|---|
MISS reason=shadow-mode | [plan-cache] shadow-mode active (cache observable, not serving) — recon+architect running as normal |
MISS reason=no-template | [plan-cache] no cached plan for this task signature — recon+architect running as normal |
MISS reason=disabled | (silent — no console line; JSON marker only) |
| HIT served | [plan-cache] cache HIT — Haiku adapted in {N}s, estimated savings ~${cost}; verify slices against current repo before Build |
MISS reason=adapter-rejected | [plan-cache] adapter output rejected by validator — falling through to recon+architect in this pipeline (Iron Law 6) |
{N} and {cost} are interpolated from CLAUDE_PLAN_CACHE_ADAPT_SECS
and CLAUDE_PLAN_CACHE_SAVINGS_USD (set by the orchestrator wiring around
the adapter spawn).
Verdicts
PLAN_CACHE_MISS(info, plan, emitter=plan-cache-lookup) — fall through to Stage 1 recon + Stage 2 architect in the same pipeline (Iron Law 6 onadapter-rejected).PLAN_CACHE_HIT(info, plan, emitter=plan-cache-lookup) — adapted plan written to$state_dir/{task-id}/plan.mdwithcache_hit: truemarker; skip Stage 1+2.
Failure Modes
- Missing git repo →
_repo_hashreturns sha256 of empty input;_plan_cache_keystill computes a stable key. Subsequent[ -f ]will fail →no-template. Safe. - Missing jq →
_plan_cache_keyreturns non-zero;_plan_cache_lookupreturns non-zero. Orchestrator MUST treat non-zero exit as MISS (fall through). Slice D wiring spec covers this. learning/<hash>/plansdirectory absent →[ -f ]fails →no-template. Nomkdir -phere; the write side lands in Slice C+F.
Out of Scope for Slice B
- HIT path / Haiku adapter / structural validator → Slice C.
- Stage 0 orchestrator wiring + Step 2c-bis in
skills/pipeline/SKILL.md→ Slice D. hooks/plan-cache-audit.sh+settings.jsonPostToolUse entry → Slice E.- Status line copy + mode default flip
off→shadow→ Slice F. /harness:plan-cache-rollout-gateskill → Slice G.
References
- Plan:
$state_dir/plan-cache-agentic/plan.md§ Slice slice-b-skill-miss-only and § Slice slice-c-adapter-and-validator. - Helper:
hooks/_lib/plan-cache-lookup.sh(Slice B + Slice C functions). - Repo-hash helper:
hooks/_lib/repo-hash.sh(Slice A). - Adapter agent:
agents/plan-cache-adapter.md(Slice C). - Pipeline-state reader:
hooks/_lib/pipeline-state-paths.sh::_psp_find_active_pipelines. - Project-hash fallback idiom:
hooks/observation-capture.sh:30-38. - Verdict rows:
protocols/verdict-catalog.md(PLAN_CACHE_MISS,PLAN_CACHE_HIT).
When not to use it
- →When `CLAUDE_PLAN_CACHE_MODE=off`
- →When the orchestrator is not in the plan phase
Limitations
- →Slice B ships MISS-only
- →The HIT path lands in Slice C
- →Mode defaults to off in Slice B for partial-merge safety
How it compares
This skill acts as a Stage 0 gate to check for cached plan templates, allowing the orchestrator to skip recon and architect stages if a valid plan is found, which optimizes the planning process.
Compared to similar skills
plan-cache-lookup side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| plan-cache-lookup (this skill) | 0 | 28d | No flags | Advanced |
| schedules | 1 | 2mo | Review | Beginner |
| configuration-steps-reorder | 0 | 2mo | Review | Advanced |
| orchestrator | 0 | 3mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
schedules
windmill-labs
MUST use when configuring schedules.
configuration-steps-reorder
ArduPilot
Add, delete, or re-order configuration steps in configuration_steps_*.json. Use when inserting new param files, deleting steps, renaming .param files with param_reorder.py, updating vehicle templates, or migrating parameters between files in backend_filesystem_migration.py.
orchestrator
taniwhaai
Use this skill when running as an ephemeral orchestrator subagent for a Taniwha project. The skill instructs the agent to read project state from disk, decide the single next action the dispatcher should take, write that decision back to disk, and exit. Trigger this whenever the dispatcher has invok
fleet-onboarding
OgenticAI
One-shot onboarding for the existing OgenticAI fleet — discover every active repo + Linear project, map repos to their owning projects, ensure factory labels exist, then bulk-install the factory into each repo through PRs (no direct pushes to main). Two human approval gates total, regardless of how
applescript
martinholovsky
Expert in AppleScript and JavaScript for Automation (JXA) for macOS system scripting. Specializes in secure script execution, application automation, and system integration. HIGH-RISK skill due to shell command execution and system-wide control capabilities.
bazel-build-optimization
wshobson
Optimize Bazel builds for large-scale monorepos. Use when configuring Bazel, implementing remote execution, or optimizing build performance for enterprise codebases.