Ai prompt

AI Prompt — Prompt Registry

  • *rea:*Intelligence
  • *ath:*services/ai/prompt
  • *ind:*Versioned prompt-template registry (CRUD + render + A/B + ratings)
  • *tatus:*v0.0.1 — sector bootstrapping (20260509)

Role in the stack

prompt is the shared home for every prompt in every Koder product. Today every product inlines its prompts in code — iterating means a code change → release → deploy. There is zero A/B testing, zero version history, zero auditing of "what prompt did we ship last week", and zero reuse across products.

It is the Koder analog of LangSmith, PromptLayer, the Anthropic Prompt Library and Humanloop — built thin on kdb-doc storage with aggressive in-memory caching for the hot read path.

Stable slugs + version pinning + A/B variants + ratings linked to runtime traces = data-driven prompt iteration.

Boundary vs neighbors

  • services/ai/playground is the editing UI (prompt sector ships SDK + REST + thin CLI only).
  • services/ai/eval reads prompts to score variants and writes ratings back.
  • services/ai/trace correlates runtime spans to prompt slug+version (links experiments to outcomes).
  • services/ai/gateway may render server-side before LLM call (optional fast path).

Features (v1 target)

  • Slugged, namespaced, version-pinned prompt registry
  • ICU MessageFormat templating (consistent with KoderL10n) + Mustache strict-mode fallback
  • A/B experiments with deterministic variant routing
  • Ratings (manual + auto from eval) aggregated per variant
  • Trace correlation: every render returns slug+version+experiment_id
  • System tenant for shipwithproduct prompts; tenant-private prompts isolated by default

Primary couplings

Consumer Relationship
services/ai/kode All system prompts
services/ai/agents Plan + tool-call prompts per role
services/ai/extract Extraction templates per entity type
services/ai/classify Zero-shot classification templates
services/ai/translate Translation system prompts per language pair
services/ai/playground Editing UI surface
services/ai/eval Reads + writes ratings
services/ai/trace Runtime span linking
services/ai/gateway Optional server-side render
infra/data/kdb-doc Backing store

RFC and bootstrap

  • RFC: prompt-RFC-001-foundations.kmd — *ccepted*20260509
  • Bootstrap ticket: services/ai/backlog/done/124-prompt-bootstrap.md
  • Implementation tickets: services/ai/prompt/backlog/pending/{001..005}

Selfhostedfirst analysis (5 gates)

Gate Status Notes
G1 Feature parity pending Skeleton phase; matches LangSmith / PromptLayer essentials
G2 Performance pending Target cached fetch p50 < 1ms; 5k req/s sustained per instance
G3 Stability pending Pre-MVP
G4 Capability pending Editing UI deferred to playground sector
G5 Critical-path readiness pending PreMVP; consolidating crossproduct prompts is the first concrete unblock

Source: ../home/koder/dev/koder/meta/docs/stack/modules/ai-prompt.md