Skip to content

RFC: Kai prompt & instruction governance - #618

Draft
claude[bot] wants to merge 3 commits into
mainfrom
rfc/kai-prompt-governance
Draft

RFC: Kai prompt & instruction governance#618
claude[bot] wants to merge 3 commits into
mainfrom
rfc/kai-prompt-governance

Conversation

@claude

@claude claude Bot commented Jul 9, 2026

Copy link
Copy Markdown

Requested by Jordan Burger · Slack thread

Description

Linear: to be filed (follows the 2026-07-09 cross-repo prompt audit; related AI-3531, AI-3532)

Change Type

  • Major (breaking changes, significant new features)
  • Minor (new features, enhancements, backward compatible)
  • Patch (bug fixes, small improvements, no new features) — doc-only

Summary

Proposes a governance model for the instructions that drive Kai, which today live across three repos (keboola/ai-kit skills, keboola/mcp-server tool docstrings + project system prompt, and keboola/ui's kai-agent) with no contract between them. A 2026-07-09 audit found 19 verified conflicts; the root cause is ai-kit skills authored for standalone Claude Code / kbagent being build-time vendored into Kai's different runtime (MCP + React sandbox).

Before: a prompt fragment is reviewed in isolation in one repo; a stale cross-reference or a standalone default that Kai contradicts ships silently, and nobody sees the composed prompt Kai actually receives.

After: each instruction has one owner, runtime-specific content is an explicit overlay, the fully-composed prompt is emitted as a diffable CI artifact, every skill/tool/file reference is linted, and prompt-consistency behavior is gated by KaiBench evals.

Adds feature_spec/kai_prompt_governance/RFC.md following the repo's RFC template. The RFC specifies: (1) an ownership contract (capability facts → mcp-server, domain how-to → ai-kit, runtime/persona → ui) + CODEOWNERS; (2) runtime-scoped skill overlays selected at vendor time; (3) a composed-prompt build artifact + git diff --exit-code CI gate mirroring tox -e check-tools-docs/TOOLS.md; (4) a cross-reference linter split across mcp-server (tool refs) and ui (skill/file refs); (5) a first-class prompt-consistency track built on KaiBench's existing forbidden_tools/expected_tools/--repeat/regression machinery, with four framework gaps to close and a dependency on a Kai backend endpoint that exposes the composed prompt.

Doc-only change (no code).

Testing

  • Tested with Cursor AI desktop (Streamable-HTTP transports) — N/A, doc-only change

Checklist

  • Self-review completed
  • Unit tests added/updated (if applicable) — N/A, doc-only
  • Integration tests added/updated (if applicable) — N/A, doc-only
  • Project version bumped according to the change type — N/A, doc-only
  • Documentation updated (if applicable)

Generated by Claude Code


Kai's behavior is shaped by instructions authored across **three repos with no contract between them**, and the same guidance is duplicated across them where it then drifts. A 2026-07-09 audit of every prompt surface found **19 verified conflicts** (5 high / 8 medium / 6 low).

The three layers that compose Kai's live instructions:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the clear definition of the 3 layers here.


## Resolution Strategy

### 1. Ownership contract

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, another option here is to go the path of having a plugin companion to the MCP. It's what Slack & Linear do (among others). Ofc, we would then need to decide where the Keboola MCP plugin lives (either in this repo or in the AI Kit)


### 2. Runtime-scoped overlays

ai-kit skills gain frontmatter runtime targeting (e.g. `targets: [claude-code, kai-sandbox, mcp-only]`) and use explicit `In Kai:` / `In standalone CLI:` callouts for content that diverges. Base content = shared core; overlays = runtime specifics — the model is base + overlay (like kustomize overlays or the CSS cascade), not copy-and-diverge. The existing vendoring step (`packages/kai-agent-sandbox/scripts/vendor-external-skills.ts`) selects/strips sections by target at vendor time. This directly resolves the Streamlit-first-vs-never-Streamlit, CDN-vs-React, and cache-vs-live-query conflicts: the base stops asserting a universal default that Kai contradicts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how scalable this is. Seems annoying to maintain.


Today the live prompt is assembled at runtime from four sources — `prompt-builder.ts` (base identity + skill gate + platform `llm_instruction` + per-request context), the vendored ai-kit skill markdown, the first-party `kai-extras` skill, and the MCP tool docstrings injected by the client — and **no human or test ever sees the whole assembled string**. Each fragment is reviewed in isolation, in a different repo, which is exactly how the high-severity contradictions slipped through.

Proposal: a generator + CI check that assembles and emits the composed prompt as a committed artifact, mirroring the pattern `mcp-server` already uses for tool docs (`python -m keboola_mcp_server.generate_tool_docs` → `TOOLS.md`, gated by `tox -e check-tools-docs`, which runs the generator then `git diff --exit-code TOOLS.md` so CI fails if it is stale).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds nice, but I'd need to understand more closely how it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants