ktg-plugin-marketplace/plugins/ultra-cc-architect/skills/cc-architect-catalog/hooks-observability-pattern.md
Kjell Tore Guttormsen ab504bdf8c refactor(marketplace): split cc-architect from ultraplan-local into its own plugin
Extract `/ultra-cc-architect-local` and `/ultra-skill-author-local` plus all 7
supporting agents, the `cc-architect-catalog` skill (13 files), the
`ngram-overlap.mjs` IP-hygiene script, and the skill-factory test fixtures
from `ultraplan-local` v2.4.0 into a new `ultra-cc-architect` plugin v0.1.0.

Why: ultraplan-local had drifted into containing two distinct domains — a
universal planning pipeline (brief → research → plan → execute) and a
Claude-Code-specific architecture phase. Keeping them together forced users
to inherit an unfinished CC-feature catalog (~11 seeds) when they only
wanted the planning pipeline, and locked the catalog and the pipeline into
the same release cadence. The architect was already optional and decoupled
at the code level — only one filesystem touchpoint remained
(auto-discovery of `architecture/overview.md`), which already handles
absence gracefully.

Plugin manifests:
- ultraplan-local: 2.4.0 → 3.0.0 (description + keywords updated)
- ultra-cc-architect: new at 0.1.0 (pre-release; catalog is thin, Fase 2/3
  of skill-factory unbuilt, decision-layer empty, fallback list still
  needed)

What stays in ultraplan-local: brief/research/plan/execute commands, all
19 planning agents, security hooks, plan auto-discovery of
`architecture/overview.md` (filesystem-level contract, not code-level).

What moved (28 files via git mv, R100 — full history preserved):
- 2 commands, 8 agents, 1 skill catalog (13 files), 2 scripts, 8 fixtures

Documentation updates: plugin CLAUDE.md and README.md for both plugins,
root README.md (added ultra-cc-architect section, updated ultraplan-local
section), root CLAUDE.md (added ultra-cc-architect to repo-struktur),
marketplace.json (registered ultra-cc-architect), ultraplan-local
CHANGELOG.md (v3.0.0 entry with migration guidance).

Test verification: ngram-overlap.test.mjs passes 23/23 from new location.

Memory updated: feedback_no_architect_until_v3.md now points at the new
plugin and reframes the threshold around catalog maturity rather than an
ultraplan-local milestone.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 17:18:47 +02:00

3.3 KiB

name description layer cc_feature source concept last_verified ngram_overlap_score review_status
hooks-observability-pattern Observe user-interaction patterns across session lifecycle hooks and emit cooldown-gated nudges pattern hooks ../../../../ai-psychosis/README.md progressive alerts via lifecycle hooks 2026-04-18 0.01 approved

Hooks — Progressive-Alert Observability Pattern

Use this when

  • Measure behaviour the model itself cannot see: cadence, duration, repetition, time-of-day.
  • Surface soft nudges rather than hard blocks — the operator keeps the final call.
  • Separate "what happened" (metrics) from "what was said" (prompt text) so no conversation content touches disk.

Shape

  • Wire four lifecycle events: a start handler for baseline counters, a prompt handler for language-category flags, a tool handler for cadence and burst detection, and an end handler for totals and state cleanup.
  • Keep per-session counters in a tiny JSON file under the plugin data dir; keep aggregate events in an append-only JSONL log for later reporting.
  • Gate every nudge behind two things: a threshold (hard or soft) and a cooldown window, so repeat alerts do not spam the transcript.
  • Deliver alerts as additionalContext injection, never as a tool block — the goal is awareness, not control.

Forces

  • Privacy vs. signal. Richer signal wants more content logged; the user wants none. Resolve by computing boolean flags in-memory and discarding the raw text before the handler returns.
  • Latency budget. Handlers fire on every prompt and every tool call. Stay well under 100 ms per invocation; append-only JSONL is sub-millisecond and safe.
  • Portability. Hooks that assume a shell, jq, or npm dependencies break on half the operator fleet. Stick to Node stdlib so the same script runs on macOS, Linux, and Windows.
  • Instruction layer alone is not enough. Behavioural rules in a skill file shape tone but cannot measure duration or frequency. Layer the hook observability on top of the skill — each compensates for the other.

Gotchas

  • A handler that crashes blocks the turn. Catch everything, log, and exit zero by default.
  • Cooldowns must be per-category, not global, or the most-triggered alert silences the rarer, more informative ones.
  • Late-night and rapid-fire thresholds are legitimate signals but also easy to over-tune; start with generous bands and tighten only with data.
  • additionalContext from an end-of-session handler is discarded — inject alerts on start, prompt, or tool events where the model will actually see them.

Anti-patterns

  • Storing prompt text or tool arguments "just for debugging" — once it is on disk, the privacy guarantee is gone.
  • Treating every elevated metric as an intervention. If the hook starts blocking, the operator works around it and loses the awareness benefit.
  • Hardcoding thresholds into the handler. Pull them from a single config so future tuning does not require a rewrite of four scripts.

Decision quick-check

Reach for this pattern when you need visibility into how the user is interacting, not what they are saying, and when the response should be a gentle nudge rather than a gate. Otherwise use a PreToolUse denylist (hard limit) or a skill-only instruction layer (style, not cadence).