Agent skill

Cursor BYOK Prefix Stability

by leookun in leookun/cursor-byok

Guides changes to the cursor-byok server so provider conversation history stays append-only and each turn's history remains an exact prefix of the next, protecting prefix caches.

MITAuto-check passedAI & LLM Engineering

Install Cursor BYOK Prefix Stability

skills CLI
$ npx skills add leookun/cursor-byok --skill cursor-prefix-stability -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install leookun/cursor-byok cursor-prefix-stability --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/leookun/cursor-byok.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/cursor-prefix-stability .claude/skills/cursor-prefix-stability && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cursor-prefix-stability
GitHub stars
3.2k
Token cost
~1.3k tokens
SKILL.md length
537 words
Files
1
Skills in repo
7
Repo updated
First seen
Licence
MIT

At a glance

Guides changes to the cursor-byok server so provider conversation history stays append-only and each turn's history remains an exact prefix of the next, protecting prefix caches.

  • Changing runtime prompts or request context in cursor-byok
  • SKILL.md covers Architecture, Required invariants, Change workflow and Verification
  • Calls cargo
  • Reviewing a change to canonical messages or provider history serialization

What it does

A rulebook for implementing and reviewing how cursor-byok projects a Cursor conversation into provider history. The central rule is to keep the longest valid provider prefix across turns and to treat provider-visible history as an append-only log unless an explicit compaction replaces it. Stability is solved once in the provider-independent conversation layers, before dispatch to OpenAI Responses, OpenAI Chat, Anthropic or another provider, and not separately in each adapter.

The listed invariants say that without compaction, turn N's history must be an exact structural prefix of turn N+1, the instructions and tool prefix stay byte-stable, and per-turn runtime content such as the query and open files stays apart from stable request context. Rules, skills, subagents, environment and MCP metadata are projected as a request-context message that is appended only when its compiled content changes, compared by content so that a change from A to B and back to A appends again while retries stay idempotent. Checkpoint hydration after a restart and automatic compaction as an explicit prefix reset are covered too.

When your agent uses it

  • Changing runtime prompts or request context in cursor-byok
  • Reviewing a change to canonical messages or provider history serialization
  • Working on checkpoint hydration or compaction
  • Debugging a lost prefix cache

Example prompts

  • “Review this change to request context compilation for prefix stability.”
  • “Add a new environment context block without breaking the append-only history.”
  • “Why does the provider history change between turns after a restart?”

Requirements

  • A checkout of cursor-byok with its server directory

What it can do on your machine

Read from SKILL.md and the folder at commit 7ee68c2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • cargo

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Cursor BYOK Prefix Stability loads about 1.3k tokens when it runs. Until then it costs about 79 tokens; SKILL.md has 537 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~79
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from leookun/cursor-byok at commit 7ee68c2, republished under its MIT licence (© leookun). 537 words, ~1,291 tokens.

Download SKILL.mdSave it as .claude/skills/cursor-prefix-stability/SKILL.md (or your agent's skills folder).
name
cursor-prefix-stability
description
Implement and review Cursor BYOK conversation projection with append-only provider history and prefix-cache stability. Use when changing runtime prompts, request context, canonical messages, checkpoint hydration, compaction, message identity, or provider history serialization under server.

Cursor prefix stability

Preserve the longest valid provider prefix across turns. Treat provider-visible history as an append-only log unless an explicit compaction operation replaces it.

Architecture

Keep the invariant in the provider-independent conversation layers:

text
server/
├── prompt/cursor/*/runtime.md       Per-turn runtime content
├── src/cursor/request/              Request context and runtime compilation
├── src/cursor/projection/           Canonical ↔ Cursor checkpoint projection
├── src/cursor/checkpoint/           Stable roots, turns, and hydration
├── src/run/                         Provider-independent model history
└── src/provider/                    Provider-specific serialization only

Do not solve prefix instability independently in each provider adapter. Produce one stable canonical history before dispatching to OpenAI Responses, OpenAI Chat, Anthropic, or another provider.

Required invariants

  • When no compaction occurs, the complete provider-visible history from turn N must be an exact structural prefix of turn N+1. Never edit, remove, merge, reorder, renormalize, or regenerate an earlier message.
  • Keep PromptSpec.instructions and the stable tool prefix byte-stable when their inputs have not changed. Deterministic ordering is required; do not use unordered iteration in provider-visible output.
  • Separate conversation/request context from the per-turn runtime message. The runtime message contains current-turn material such as the user query, selected context, open files, action context, mode reminders, and timestamp.
  • Project rules, skills, subagents, environment/Git context, and MCP metadata as a stable request-context:* message:
    • append it on the first applicable turn;
    • do not append it again when its compiled content is identical to the latest projected request context;
    • when its content changes, append a new request-context message immediately before the current runtime message;
    • never represent a context change by rewriting the system prompt, replacing an earlier context message, or mutating a checkpoint root.
  • Give every appended context update a unique event identity. Compare the latest context by content, not only by identifier, so A → B → A appends the final A again while retries of the same event remain idempotent.
  • Preserve request-context:* wire identity through checkpoint encoding and hydration. Deduplication must still work after process restart or conversation resume.
  • Automatic compaction is an explicit prefix reset. Compact obsolete history, retain exactly the latest request-context message, then place the summary and current initial messages in deterministic order. Manual compaction may reproject current context on the next user turn.
  • Background completions and injected runtime events must not manufacture duplicate request context unless they actually start a user turn whose context changed.
Show full SKILL.md (201 more words)Show less

Change workflow

Before editing, trace the whole path that applies:

text
AgentRunRequest
→ request context hydration/compilation
→ CanonicalMessage identity and persistence
→ checkpoint encode/decode
→ projected ModelRequest history
→ provider serialization

Determine which data is conversation-level and which is turn-level. If a proposed change moves or rewrites an earlier provider-visible value, redesign it as a new append-only event unless the operation is explicitly compaction.

Use TDD for changes in this path. Start with a failing behavioral test, then implement the smallest provider-independent change.

Verification

Cover the affected behavior with structural assertions, not token-count estimates alone:

  • Two turns with identical request context: the first request history is an exact prefix of the second, the system instructions are identical, and only one request-context:* message exists.
  • Changed context: one new context message appears at the tail before the new runtime query; all earlier messages remain unchanged.
  • Context reversion A → B → A: three distinct context events are retained in order.
  • Retry of one runtime event: no duplicate or conflicting context message is persisted.
  • Checkpoint round-trip: request-context identity and content survive encode/hydrate.
  • Automatic compaction: only the latest context is retained outside the summary.
  • Runtime templates render without embedding conversation-level rules or MCP metadata in every user query.

Run focused tests first, then the relevant server suites:

bash
cargo test --lib
cargo test --test runtime_modes
cargo test --test prefix_stability
cargo test --test checkpoint_recovery
cargo test --test compaction
cargo clippy --lib -- -D warnings
cargo fmt --all -- --check

Do not repair unrelated dirty-worktree failures while validating. Report them separately.

© leookun, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/cursor-prefix-stability of leookun/cursor-byok.

Open the folder on GitHubat commit 7ee68c2

Compare with similar skills

Cursor BYOK Prefix Stability next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cursor BYOK Prefix Stability compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cursor BYOK Prefix Stability this skillleookun/cursor-byok3.2k—~1.3kAutomated safety check: PassMIT
Agents Best PracticesDenisSergeevitch/agents-best-practices2.4k—~7.4kAutomated safety check: PassMIT
Using Ccproxy Inspectorstarbaser/ccproxy350—~2.7kAutomated safety check: PassCustom licence
Openai Knowledgeopenai/openai-agents-python30k1 repos~408Automated safety check: PassMIT
Cognee Integrations Setuptopoteretes/cognee32k—~1kAutomated safety check: NotesApache-2.0
Codex Agent Provider for NanoClawnanocoai/nanoclaw31k—~2.3kAutomated safety check: NotesMIT

Similar skills

  • Agents Best Practices

    DenisSergeevitch/agents-best-practices

    A skill your agent uses when designing, generating an MVP blueprint for, auditing, troubleshooting, refactoring, or explaining an agentic harness for any domain.

    2.4k GitHub stars~7.4k tokensUpdated 3 days ago
    AI & LLM EngineeringAuto-check passed
  • Using Ccproxy Inspector

    starbaser/ccproxy

    Operates the ccproxy inspector MITM system for intercepting, inspecting, and transforming LLM API traffic.

    350 GitHub stars~2.7k tokensUpdated 1 mo ago
    AI & LLM EngineeringAuto-check passed
  • Openai Knowledge

    openai/openai-agents-python

    Official

    Retrieve authoritative OpenAI API and platform documentation when an integration or claim needs current external evidence.

    30k GitHub starsUsed in 1 repo~408 tokens
    AI & LLM EngineeringAuto-check passed
  • Cognee Integrations Setup

    topoteretes/cognee

    Switches cognee's LLM, embedding, relational, vector and graph backends through environment variables, with the extras to install and the traps to avoid.

    32k GitHub stars~1k tokensUpdated today
    AI & LLM EngineeringAuto-check: notes
  • Installs Codex as an agent provider for NanoClaw groups, with streaming, MCP tools, server-side history and vault-only credentials, next to or instead of Claude.

    31k GitHub stars~2.3k tokensUpdated 2 days ago
    AI & LLM EngineeringAuto-check: notes
  • Openai Docs Skill

    aiskillstore/marketplace

    Query the OpenAI developer documentation via the OpenAI Docs MCP server using CLI (curl/jq).

    430 GitHub starsUsed in 2 repos~517 tokens
    AI & LLM EngineeringAuto-check passed

More from leookun/cursor-byok

  • Cursor BYOK Database Schema

    leookun/cursor-byok

    Guides SQLite schema changes in the Cursor BYOK server, keeping SQLx migrations, the Rust store, API contracts and fixtures aligned.

    3.2k GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Cursor BYOK Frontend Guide

    leookun/cursor-byok

    Sets the rules for building the Cursor BYOK desktop app's React and Tauri frontend, especially its HTTP boundary and component state architecture.

    3.2k GitHub stars~1.9k tokensUpdated today
    Auto-check passed
  • Model Selection Component

    leookun/cursor-byok

    Standardizes how a desktop app's UI lets a person choose one or more already-configured AI models, through a single grouped dropdown component.

    3.2k GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Cursor BYOK Desktop Release

    leookun/cursor-byok

    Guides releases of the Cursor BYOK desktop app on GitHub, with strict rules on who may publish and how version tags, updater manifests and signing are handled.

    3.2k GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Desktop i18n for Cursor BYOK

    leookun/cursor-byok

    Rules for localizing the Cursor BYOK desktop app: the global t() function, complete locale catalogs, system-language selection and the scan-and-check commands.

    3.2k GitHub stars~508 tokensUpdated today
    Auto-check passed
  • Floating UI Overlays

    leookun/cursor-byok

    Rules for building dropdowns, popovers, tooltips and menus in the desktop app with @floating-ui/dom, covering portals, positioning, dismissal and ARIA state.

    3.2k GitHub stars~496 tokensUpdated today
    Auto-check passed

Questions about Cursor BYOK Prefix Stability

What does Cursor BYOK Prefix Stability do?

Guides changes to the cursor-byok server so provider conversation history stays append-only and each turn's history remains an exact prefix of the next, protecting prefix caches. A rulebook for implementing and reviewing how cursor-byok projects a Cursor conversation into provider history. The central rule is to keep the longest valid provider prefix across turns and to treat provider-visible history as an append-only log unless an explicit compaction replaces it.

When should I use Cursor BYOK Prefix Stability?

Cursor BYOK Prefix Stability fits situations like: changing runtime prompts or request context in cursor-byok; reviewing a change to canonical messages or provider history serialization; working on checkpoint hydration or compaction; debugging a lost prefix cache.

How do I install Cursor BYOK Prefix Stability in Claude Code?

Run `npx skills add leookun/cursor-byok --skill cursor-prefix-stability -a claude-code`. Or copy the skill folder (.agents/skills/cursor-prefix-stability in leookun/cursor-byok) into .claude/skills/cursor-prefix-stability in your project. Claude Code loads it when a task matches its description.

How do I install Cursor BYOK Prefix Stability in Codex?

Run `npx skills add leookun/cursor-byok --skill cursor-prefix-stability -a codex`. Or copy the skill folder (.agents/skills/cursor-prefix-stability in leookun/cursor-byok) into .agents/skills/cursor-prefix-stability in your project. Codex loads it when a task matches its description.

Can I use Cursor BYOK Prefix Stability in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add leookun/cursor-byok --skill cursor-prefix-stability -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cursor-prefix-stability, .gemini/skills/cursor-prefix-stability, .github/skills/cursor-prefix-stability and .opencode/skills/cursor-prefix-stability in your project.

What does Cursor BYOK Prefix Stability need to run?

Going by SKILL.md and its folder, Cursor BYOK Prefix Stability needs the command-line tools its instructions call (cargo). Our summary lists: A checkout of cursor-byok with its server directory.

Does Cursor BYOK Prefix Stability access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Cursor BYOK Prefix Stability safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Cursor BYOK Prefix Stability use?

Cursor BYOK Prefix Stability is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cursor BYOK Prefix Stability use?

About 1.3k tokens (SKILL.md is roughly 5.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Cursor BYOK Prefix Stability?

Skills that share tags, products or a category with Cursor BYOK Prefix Stability: Agents Best Practices (DenisSergeevitch/agents-best-practices, 2.4k stars), Using Ccproxy Inspector (starbaser/ccproxy, 350 stars), Openai Knowledge (openai/openai-agents-python, 30k stars) and Cognee Integrations Setup (topoteretes/cognee, 32k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cursor BYOK Prefix Stability?

leookun (a GitHub user) maintains it in leookun/cursor-byok, which has 3,156 GitHub stars. The repository holds 7 skills in this directory. The repository was last updated on October 8, 2026.

Source: leookun/cursor-byok on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.