Selaa lähdekoodia

auto-detect plan, complexity scoring, ctx7 cache, graphify in workflows

- detect_plan() auto-detects Max/Pro/Free from ~/.claude.json
- session-start budget adapts to plan (Max=20k, Pro=11k, Free=5k)
- token counting now uses only ACTIVE plugins, not installed binaries
- statusline shows plan label + session duration instead of start time
- plugin-advisor: complexity assessment (0-100%) drives tool selection
- plugin-advisor: auto-activation with confirmation (PHASE 4)
- ruflo OFF by default, GSD v2 preferred for multi-session
- init-project: ctx7 pre-fetch + graphify scaffold + graphify full
- ship-feature: ctx7 cache check before implementation
- frontend-design disabled in installer (doublon with ui-ux-pro-max)
- python3 -c moved from deny to ask (unblocks graphify)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bastien 1 kuukausi sitten
vanhempi
sitoutus
66beae16b7

+ 52 - 5
agents/plugin-advisor.md

@@ -74,12 +74,41 @@ Detect signals from the project description and filesystem scan:
 
 ---
 
+## PHASE 2.5 — COMPLEXITY ASSESSMENT
+
+Rate project complexity 0-100% to decide tool depth.
+Factors (weighted):
+
+| Factor | Weight | Low (0-30) | Med (30-70) | High (70-100) |
+|---|---|---|---|---|
+| Data model | 25% | Static pages, no DB | Simple CRUD, 1 DB | Relations, multi-DB, sessions, auth |
+| Business logic | 25% | Display only | Forms, validation | Algorithms, real-time, social, payments |
+| Integration surface | 20% | Standalone | 1-2 APIs | OAuth, webhooks, queues, 3rd-party SDKs |
+| Frontend complexity | 15% | None or static | SPA, basic routing | Design system, animations, a11y, i18n |
+| Infra/deploy | 15% | Local only | Single deploy target | Multi-env, CI/CD, containers, monitoring |
+
+**Score thresholds:**
+- **0-30% (simple)**: superpowers only. No gstack, no gsd, no ctx7, no graphify.
+  _Examples: site vitrine, landing page, script CLI, simple CRUD._
+- **30-60% (moderate)**: + context7 if fast-libs, + graphify after implementation.
+  _Examples: blog with auth, dashboard with charts, API with validation._
+- **60-85% (complex)**: + gstack if browser-QA, + gsd if multi-session, + graphify both passes.
+  _Examples: SaaS with billing, game with social features, e-commerce._
+- **85-100% (enterprise)**: all tools justified. Consider ruflo only if explicitly requested.
+  _Examples: multi-service platform, real-time collab app, marketplace._
+
+Output: `COMPLEXITY: <score>% — <label>` with one-line justification.
+
+---
+
 ## PHASE 3 — OUTPUT
 
 ```
 PLUGIN CHECK
 ACTIVE: [plugin — status, one line each]
 SIGNALS: [detected signals]
+COMPLEXITY: <score>% — <simple|moderate|complex|enterprise>
+PLAN: <Max|Pro|Free> (budget: ~<N>t passive tokens)
 COST ESTIMATE: ~Xt passive tokens (all active plugins combined)
 
 RECOMMENDATIONS:
@@ -94,6 +123,23 @@ BLOCKING: [issues] or none
 ACTION REQUIRED? YES / NO
 ```
 
+## PHASE 4 — AUTO-ACTIVATION (when called from /init-project or /ship-feature)
+
+After presenting RECOMMENDATIONS, if any plugin has ⚡ ENABLE status:
+1. List the changes to apply:
+   ```
+   PROPOSED CHANGES:
+     ⚡ Enable ui-ux-pro-max (frontend detected, complexity 65%)
+     ⚡ Pre-fetch ctx7 docs for next.js, prisma
+     ⚠️  Disable ruflo (not needed, saves ~1000t)
+   Apply these changes? (yes / no / customize)
+   ```
+2. On "yes" → apply changes (rename .disabled dirs, update MCP config).
+3. On "customize" → user picks which to apply.
+4. On "no" → proceed with current config.
+
+**Never auto-activate without showing the list and getting confirmation.**
+
 ---
 
 ## DECISION TABLE
@@ -107,7 +153,7 @@ ACTION REQUIRED? YES / NO
 | `deploy` + `browser-qa` | gstack | — | Full-product workflow |
 | `multi-session` | gsd v2 CLI | — | Run `gsd` in terminal, not CC plugin |
 | `fast-libs` | context7 | — | Doc freshness critical |
-| `multi-agent` + `complex-arch` | ruflo (CLI) | — | Only if genuine swarm needed |
+| `multi-agent` + `complex-arch` | gsd v2 CLI | ruflo (unless explicitly requested) | GSD v2 preferred; ruflo only on explicit user request |
 | `simple` / single-session | — | gsd, gstack, ruflo, ui-ux-pro-max | Saves ~3000-5000t |
 | `embedded` / firmware | — | all toggles; superpowers optional | workflow: /analyze → edit or /ship-feature |
 | backend/lib/CLI only | — | frontend-design, ui-ux-pro-max, gstack | ~3100t saved |
@@ -151,7 +197,7 @@ ACTION REQUIRED? YES / NO
 | Quick fix / hotfix | superpowers | all toggles | ~800t |
 | Design system / component lib | superpowers, frontend-design, ui-ux-pro-max | gstack, ruflo, gsd | ~1600t |
 | Fast-evolving libs (Next.js etc.) | superpowers, context7, frontend-design | ruflo | ~1200t |
-| Enterprise multi-agent orchestration | superpowers, ruflo + gsd v2 (external) | plugin-dev | ~2300t CC |
+| Enterprise multi-agent orchestration | superpowers + gsd v2 (external) | ruflo (unless explicit), plugin-dev | ~800t CC |
 
 > security-guidance and rtk are ALWAYS ON (0 tokens) — omitted from cost estimates for clarity.
 
@@ -187,8 +233,9 @@ RULE: IF "fast-libs" (Next.js/React 18+/Prisma/Supabase/Drizzle):
   → context7 ON (~200t)
 
 RULE: IF "multi-agent" AND "complex-arch":
-  → ruflo CLI ON (~500-1500t)
-  → IF gstack also ON: WARN overlap (~3250-4250t combined)
+  → gsd v2 CLI recommended (0t passive, multi-session coordination)
+  → ruflo CLI OFF by default — only enable if user explicitly requests swarm/parallel orchestration
+  → IF user explicitly requests ruflo AND gstack also ON: WARN overlap (~3250-4250t combined)
 
 RULE: IF "simple" OR "hotfix":
   → Disable all toggles. ~800t base only.
@@ -242,7 +289,7 @@ RULE: IF `complex-arch` signal (multiple services, event bus, distributed system
 - gstack ON + ruflo ON simultaneously (overlap, ~3250-4250t)
 - ruflo ON with no multi-agent signal detected
 - Multi-session feature + `gsd` CLI not installed → `npm install -g gsd-pi`
-- Total passive cost > 5500t (~50% of Pro session budget)
+- Total passive cost > 50% of plan budget (Pro: ~5500t, Max: ~10000t, Free: ~2500t)
 - **Next.js/React 18+/Prisma/Supabase detected + context7 not configured**
   → Risk: Claude may generate code using outdated APIs (App Router changes frequently)
   → Fix: `npm install -g ctx7 && ctx7 setup --claude`

+ 30 - 12
hooks/session-start.sh

@@ -86,25 +86,43 @@ fi
 REPO_DIR="${_repo_dir:-}"
 unset _claude_real _repo_dir
 
-# Quick passive token cost estimate (Pro session budget = ~11k tokens)
+# Detect plan and set passive token budget
+PLAN=$(detect_plan 2>/dev/null || echo "pro")
+case "$PLAN" in
+  max)  _budget=20000; PLAN_LABEL="Max" ;;
+  pro)  _budget=11000; PLAN_LABEL="Pro" ;;
+  free) _budget=5000;  PLAN_LABEL="Free" ;;
+  *)    _budget=11000; PLAN_LABEL="Pro" ;;
+esac
+
+# Quick passive token cost estimate
+# Only count plugins that are ACTIVE (detected as ON), not just installed
 _passive_t=0
 detect_superpowers 2>/dev/null && _passive_t=$((_passive_t + 800))
-detect_gstack      2>/dev/null && _passive_t=$((_passive_t + 2750))
-detect_frontend_design 2>/dev/null && _passive_t=$((_passive_t + 200))
-detect_plugin_dev  2>/dev/null && _passive_t=$((_passive_t + 100))
-detect_uiux_pro_max    2>/dev/null && _passive_t=$((_passive_t + 400))
-detect_context7    2>/dev/null && _passive_t=$((_passive_t + 200))
-detect_ruflo       2>/dev/null && _passive_t=$((_passive_t + 1000))
-detect_graphifyy   2>/dev/null && _passive_t=$((_passive_t + 300))
-_budget_pct=$((_passive_t * 100 / 11000))
+
+# Token costs for toggle plugins — map display name to cost
+declare -A _plugin_costs=(
+  [gstack]=2750
+  [ui-ux-pro-max]=400
+  [frontend-design]=200
+  [plugin-dev]=100
+  [context7]=200
+  [ruflo]=1000
+  [graphifyy]=300
+)
+for _p in "${TOGGLE_ACTIVE[@]}"; do
+  _cost="${_plugin_costs[$_p]:-0}"
+  _passive_t=$((_passive_t + _cost))
+done
+_budget_pct=$((_passive_t * 100 / _budget))
 if [ "$_budget_pct" -gt 50 ]; then
-  TOKEN_WARN="⚠️  ~${_passive_t}t passif (${_budget_pct}% budget)"
+  TOKEN_WARN="⚠️  ~${_passive_t}t passif (${_budget_pct}% budget $PLAN_LABEL)"
 elif [ "$_budget_pct" -gt 25 ]; then
-  TOKEN_WARN="~${_passive_t}t passif (${_budget_pct}% budget)"
+  TOKEN_WARN="~${_passive_t}t passif (${_budget_pct}% budget $PLAN_LABEL)"
 else
   TOKEN_WARN=""
 fi
-unset _passive_t _budget_pct
+unset _passive_t _budget_pct _budget
 
 echo ""
 echo "┌─ Claude Code config ──────────────────────────────────┐"

+ 24 - 2
hooks/statusline.sh

@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# Claude Code statusline — folder, git branch, model, context %
+# Claude Code statusline — model, folder, branch, plan, context bar, session start
 # Receives JSON on stdin from Claude Code.
 
 INPUT=$(cat)
@@ -18,6 +18,28 @@ if [ -d "$DIR" ]; then
 fi
 BRANCH_STR="${BRANCH:+ ($BRANCH)}"
 
+# Plan detection (reuse shared lib)
+_lib="$(dirname "${BASH_SOURCE[0]}")/../lib/detect-plugins.sh"
+if [ -f "$_lib" ]; then
+  source "$_lib"
+  PLAN=$(detect_plan 2>/dev/null || echo "pro")
+else
+  PLAN="pro"
+fi
+PLAN_UPPER=$(echo "$PLAN" | tr '[:lower:]' '[:upper:]' | head -c1)$(echo "$PLAN" | tail -c+2)
+
+# Session duration (from total_duration_ms)
+DURATION_MS=$(echo "$INPUT" | jq -r \
+  '.cost.total_duration_ms // 0' | cut -d. -f1)
+DURATION_S=$((DURATION_MS / 1000))
+if [ "$DURATION_S" -ge 3600 ]; then
+  DURATION="$((DURATION_S / 3600))h$((DURATION_S % 3600 / 60))m"
+elif [ "$DURATION_S" -ge 60 ]; then
+  DURATION="$((DURATION_S / 60))m"
+else
+  DURATION="<1m"
+fi
+
 # Progress bar (20 chars wide)
 WIDTH=20
 FILLED=$((PCT * WIDTH / 100))
@@ -45,4 +67,4 @@ fi
 RESET="\033[0m"
 
 # Output: single line
-echo -e "$MODEL | $FOLDER${BRANCH_STR} | ${COLOR}${BAR}${RESET} ${PCT}%"
+echo -e "$MODEL | $FOLDER${BRANCH_STR} | $PLAN_UPPER | ${COLOR}${BAR}${RESET} ${PCT}% | ${DURATION}"

+ 3 - 1
install-plugins.sh

@@ -343,7 +343,9 @@ install_plugin() {
 info "Adding Anthropic bundled plugins marketplace..."
 claude plugin marketplace add anthropics/claude-code 2>/dev/null || true
 install_plugin "security-guidance"  "claude-code-plugins"
-install_plugin "frontend-design"    "claude-code-plugins"
+# frontend-design: DISABLED — doublon with ui-ux-pro-max (2026-04-12)
+# To re-enable: uncomment line below + remove .disabled suffix from cache
+# install_plugin "frontend-design"    "claude-code-plugins"
 install_plugin "pr-review-toolkit"  "claude-code-plugins"
 install_plugin "plugin-dev"         "claude-code-plugins"
 

+ 30 - 0
lib/detect-plugins.sh

@@ -72,3 +72,33 @@ detect_graphifyy() {
   # Graphifyy — codebase knowledge graph, installed via pipx
   command -v graphify &>/dev/null
 }
+
+
+# --- Plan detection ---
+
+detect_plan() {
+  # Detect Claude plan: max, pro, or free.
+  # Checks ~/.claude.json for model access hints.
+  # Returns plan name on stdout, always exits 0.
+  local claude_json="$HOME/.claude.json"
+  if [ -f "$claude_json" ]; then
+    # Max plan: has opus model access or max flag
+    if grep -q '"planType".*"max"' "$claude_json" 2>/dev/null; then
+      echo "max"; return 0
+    fi
+    # Check cached features for max indicators
+    if grep -q '"tengu_cobalt_compass": true' "$claude_json" 2>/dev/null \
+       && grep -q '"tengu_harbor": true' "$claude_json" 2>/dev/null; then
+      echo "max"; return 0
+    fi
+  fi
+  # Fallback: check if claude CLI reports plan
+  local plan
+  plan=$(claude config get planType 2>/dev/null || true)
+  case "$plan" in
+    max|Max|MAX) echo "max" ;;
+    pro|Pro|PRO) echo "pro" ;;
+    free|Free|FREE) echo "free" ;;
+    *) echo "pro" ;;  # default assumption
+  esac
+}

+ 68 - 68
settings.json

@@ -1,9 +1,65 @@
 {
   "cleanupPeriodDays": 30,
   "permissions": {
-    "defaultMode": "default",
-    "disableBypassPermissionsMode": "disable",
-    "disableAutoMode": "disable",
+    "allow": [
+      "Bash(git status)",
+      "Bash(git log*)",
+      "Bash(git diff*)",
+      "Bash(git branch*)",
+      "Bash(git fetch*)",
+      "Bash(git pull*)",
+      "Bash(git add *)",
+      "Bash(git commit*)",
+      "Bash(git checkout *)",
+      "Bash(git switch *)",
+      "Bash(git stash)",
+      "Bash(git stash push*)",
+      "Bash(git stash list*)",
+      "Bash(git stash show*)",
+      "Bash(git tag*)",
+      "Bash(git show*)",
+      "Bash(ls *)",
+      "Bash(ls)",
+      "Bash(find *)",
+      "Bash(cat *)",
+      "Bash(head *)",
+      "Bash(tail *)",
+      "Bash(grep *)",
+      "Bash(rg *)",
+      "Bash(fd *)",
+      "Bash(wc *)",
+      "Bash(echo *)",
+      "Bash(pwd)",
+      "Bash(which *)",
+      "Bash(type *)",
+      "Bash(whoami)",
+      "Bash(uname *)",
+      "Bash(mkdir -p *)",
+      "Bash(touch *)",
+      "Bash(cp *)",
+      "Bash(mv *)",
+      "Bash(jq *)",
+      "Bash(yq *)",
+      "Bash(awk *)",
+      "Bash(sort *)",
+      "Bash(uniq *)",
+      "Bash(tr *)",
+      "Bash(cut *)",
+      "Bash(diff *)",
+      "Read(**/*.md)",
+      "Read(**/*.txt)",
+      "Read(**/*.json)",
+      "Read(**/*.yaml)",
+      "Read(**/*.yml)",
+      "Read(**/*.toml)",
+      "Read(**/*.lock)",
+      "Read(**/*.gitignore)",
+      "Read(**/*.dockerignore)",
+      "Read(**/.claudeignore)",
+      "Read(**/Makefile)",
+      "Read(**/Dockerfile*)",
+      "Read(**/docker-compose*)"
+    ],
     "deny": [
       "Bash(rm -rf *)",
       "Bash(rm -rf /*)",
@@ -99,7 +155,6 @@
       "Bash(cp **/.ssh/*)",
       "Bash(source /dev/stdin)",
       "Bash(mkfifo *)",
-      "Bash(python3 -c *)",
       "Bash(node -e *)",
       "Bash(xargs * .env*)",
       "Bash(tar * .env*)",
@@ -122,71 +177,17 @@
       "WebFetch",
       "Bash(xargs *)",
       "Bash(sed *)",
+      "Bash(python3 -c *)",
       "Bash(git stash pop*)",
       "Bash(git stash drop*)",
       "Bash(git stash clear)"
     ],
-    "allow": [
-      "Bash(git status)",
-      "Bash(git log*)",
-      "Bash(git diff*)",
-      "Bash(git branch*)",
-      "Bash(git fetch*)",
-      "Bash(git pull*)",
-      "Bash(git add *)",
-      "Bash(git commit*)",
-      "Bash(git checkout *)",
-      "Bash(git switch *)",
-      "Bash(git stash)",
-      "Bash(git stash push*)",
-      "Bash(git stash list*)",
-      "Bash(git stash show*)",
-      "Bash(git tag*)",
-      "Bash(git show*)",
-      "Bash(ls *)",
-      "Bash(ls)",
-      "Bash(find *)",
-      "Bash(cat *)",
-      "Bash(head *)",
-      "Bash(tail *)",
-      "Bash(grep *)",
-      "Bash(rg *)",
-      "Bash(fd *)",
-      "Bash(wc *)",
-      "Bash(echo *)",
-      "Bash(pwd)",
-      "Bash(which *)",
-      "Bash(type *)",
-      "Bash(whoami)",
-      "Bash(uname *)",
-      "Bash(mkdir -p *)",
-      "Bash(touch *)",
-      "Bash(cp *)",
-      "Bash(mv *)",
-      "Bash(jq *)",
-      "Bash(yq *)",
-      "Bash(awk *)",
-      "Bash(sort *)",
-      "Bash(uniq *)",
-      "Bash(tr *)",
-      "Bash(cut *)",
-      "Bash(diff *)",
-      "Read(**/*.md)",
-      "Read(**/*.txt)",
-      "Read(**/*.json)",
-      "Read(**/*.yaml)",
-      "Read(**/*.yml)",
-      "Read(**/*.toml)",
-      "Read(**/*.lock)",
-      "Read(**/*.gitignore)",
-      "Read(**/*.dockerignore)",
-      "Read(**/.claudeignore)",
-      "Read(**/Makefile)",
-      "Read(**/Dockerfile*)",
-      "Read(**/docker-compose*)"
-    ],
+    "defaultMode": "default",
+    "disableBypassPermissionsMode": "disable",
+    "disableAutoMode": "disable",
     "additionalDirectories": []
   },
+  "model": "opus",
   "hooks": {
     "SessionStart": [
       {
@@ -210,6 +211,10 @@
       }
     ]
   },
+  "statusLine": {
+    "type": "command",
+    "command": "bash ~/.claude/hooks/statusline.sh"
+  },
   "extraKnownMarketplaces": {
     "claude-code-plugins": {
       "source": {
@@ -229,10 +234,5 @@
         "repo": "nextlevelbuilder/ui-ux-pro-max-skill"
       }
     }
-  },
-  "model": "opus",
-  "statusLine": {
-    "type": "command",
-    "command": "bash ~/.claude/hooks/statusline.sh"
   }
 }

+ 36 - 2
skills/init-project/SKILL.md

@@ -13,10 +13,11 @@ $ARGUMENTS
 
 ---
 
-## STEP 0 — PLUGIN CHECK
+## STEP 0 — PLUGIN CHECK + AUTO-ACTIVATE
 Load `$HOME/.claude/agents/plugin-advisor.md`. Feed request.
 - ACTION REQUIRED → show RECOMMENDATIONS block, offer: A) fix plugins B) type "force". STOP.
-- OK → `✅ Plugin check passed — [active plugins]`, continue.
+- PROPOSED CHANGES exist → show list, ask "Apply? (yes / no / customize)". Apply on confirm.
+- OK → `✅ Plugin check passed — [active plugins] — complexity: <score>%`, continue.
 
 ## STEP 1 — INTERVIEW
 Before loading the interviewer, check for an existing CLAUDE.md:
@@ -62,6 +63,30 @@ Verify: `git init` + build passes.
 ## STEP 5b — CREATE README
 Load `$HOME/.claude/agents/readme-updater.md`. README.md missing → CREATE mode auto. No stop.
 
+## STEP 5c — CTX7 PRE-FETCH (if fast-libs detected)
+If `fast-libs` signal was detected in STEP 0 (Next.js, React 18+, Prisma, Supabase, Drizzle, etc.):
+1. Create `.ctx7-cache/` directory in project root.
+2. For each detected fast-lib, fetch core docs:
+   ```bash
+   mkdir -p .ctx7-cache
+   # Example for detected libs — adapt to actual deps:
+   ctx7 docs /vercel/next.js "app router middleware routing" > .ctx7-cache/nextjs-core.md 2>/dev/null || true
+   ctx7 docs /prisma/prisma "schema client queries" > .ctx7-cache/prisma-core.md 2>/dev/null || true
+   ```
+3. Add `.ctx7-cache/` to `.gitignore` (local dev cache, not committed).
+4. Print: `📚 ctx7 docs pre-fetched for: <libs>. Cache at .ctx7-cache/`
+If `ctx7` not installed or no fast-libs → skip silently.
+
+## STEP 5d — GRAPHIFY SCAFFOLD (light pass)
+If `graphify` CLI is installed AND complexity >= 30%:
+1. Run light graphify on the scaffold:
+   ```bash
+   graphify . --output graphify-out --mode quick 2>/dev/null || true
+   ```
+2. Add `graphify-out/` to `.gitignore` if not already present.
+3. Print: `🔗 Scaffold graph generated at graphify-out/`
+If `graphify` not installed or complexity < 30% → skip silently.
+
 ## STEP 6 — PLAN
 Invoke `superpowers:writing-plans` with BRIEF + skeleton.
 Granular tasks (2-5 min each), exact file paths, TDD: tests before code.
@@ -79,6 +104,15 @@ Changes → back to STEP 6. Approved → continue.
 ## STEP 8 — IMPLEMENT
 Invoke `superpowers:subagent-driven-development`. Isolated subagents, TDD, 2-stage review per task.
 
+## STEP 8b — GRAPHIFY FULL (after implementation)
+If `graphify` CLI is installed AND complexity >= 30%:
+1. Run full graphify on the implemented project:
+   ```bash
+   graphify . --output graphify-out 2>/dev/null || true
+   ```
+2. Print: `🔗 Full project graph updated at graphify-out/`
+If `graphify` not installed or complexity < 30% → skip silently.
+
 ## STEP 9 — ANALYZE
 Load `$HOME/.claude/agents/analyzer.md`. Check: no regressions, no deviations, no stale scaffold, conventions respected.
 

+ 21 - 3
skills/ship-feature/SKILL.md

@@ -13,10 +13,11 @@ $ARGUMENTS
 
 ---
 
-## STEP 0 — PLUGIN CHECK
+## STEP 0 — PLUGIN CHECK + AUTO-ACTIVATE
 Load `$HOME/.claude/agents/plugin-advisor.md`. Feed request.
-- ACTION REQUIRED → show RECOMMENDATIONS, offer: A) fix plugins B) type "force". STOP.
-- OK → `✅ Plugin check passed — [active plugins]`, continue.
+- ACTION REQUIRED → show RECOMMENDATIONS block, offer: A) fix plugins B) type "force". STOP.
+- PROPOSED CHANGES exist → show list, ask "Apply? (yes / no / customize)". Apply on confirm.
+- OK → `✅ Plugin check passed — [active plugins] — complexity: <score>%`, continue.
 
 ## STEP 0b — PROJECT CONTEXT CHECK
 Verify the project has a `CLAUDE.md` and print a brief orientation summary:
@@ -43,6 +44,23 @@ ls .gsd/ROADMAP.md 2>/dev/null | head -1
   then re-run `/ship-feature`."
   STOP.
 
+## STEP 0c — CTX7 CACHE CHECK (if fast-libs in project)
+Check if the project uses fast-evolving libs (scan `package.json` for next, react, prisma, supabase, drizzle, expo):
+1. If `.ctx7-cache/` exists with recent files (<7 days old) → print `📚 ctx7 cache found: <libs>` and continue.
+2. If `.ctx7-cache/` missing or stale AND `ctx7` is installed AND fast-libs detected:
+   ```bash
+   mkdir -p .ctx7-cache
+   # Fetch docs for each detected fast-lib (adapt to actual deps):
+   ctx7 docs /vercel/next.js "app router middleware routing" > .ctx7-cache/nextjs-core.md 2>/dev/null || true
+   ctx7 docs /prisma/prisma "schema client queries" > .ctx7-cache/prisma-core.md 2>/dev/null || true
+   ```
+   Print: `📚 ctx7 docs pre-fetched for: <libs>`
+3. If no fast-libs or `ctx7` not installed → skip silently.
+
+During implementation (STEP 4), when making decisions about fast-lib APIs:
+- Read the relevant `.ctx7-cache/<lib>.md` file before writing code.
+- This avoids repeated ctx7 calls and keeps docs available without context cost.
+
 ## STEP 1 — BRAINSTORM
 Invoke `superpowers:brainstorming`. Refine request into validated design via Socratic questioning. Don't proceed until design approved.