Skip to content

docs: add prompt caching FAQ (RTK does not break cache) - #560

Merged
KuSh merged 3 commits into
developfrom
docs/prompt-caching-faq
Sep 8, 2026
Merged

KuSh merged 3 commits into
developfrom
docs/prompt-caching-faq

Conversation

@FlorianBruniaux

@FlorianBruniaux FlorianBruniaux commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes a recurring question (raised publicly by Mathieu GRENIER): does RTK break Claude's prompt cache and make input 10x more expensive?

  • Add a "Does RTK break Claude's prompt cache?" entry to docs/guide/resources/troubleshooting.md, the guide published at rtk-ai.app/guide/troubleshooting: the answer, why smaller tool results make caching cheaper (writes bill at 1.25x, reads at 0.1x), and rtk cc-economics as self-serve proof
  • Add an FAQ blockquote in README.md after "How It Works": one-liner answer with a link, for scanners
README.md                               |  2 ++
docs/guide/resources/troubleshooting.md | 17 +++++++++++++++++

Review changes

The first version added docs/PROMPT_CACHING.md; per review feedback it was reduced to README + troubleshooting only. Two follow-up commits were pushed during review:

  • faaa446b merge develop into the branch, clearing the merge conflict
  • c81c0977 move the answer from docs/TROUBLESHOOTING.md into the published guide

docs/TROUBLESHOOTING.md is a flat file removed in a94e9493 when the docs were consolidated, so content added there never reaches the docs site, and the copy reintroduced an unpinned cargo install --git that develop had already pinned to --branch master. The same commit corrects rtk gain to rtk cc-economics — rtk gain reports token savings only, the cache write/read breakdown lives in cc-economics — and drops a duplicated Type Kit collision section that the guide already covers more fully.

Test plan

  • docs/guide/resources/troubleshooting.md renders correctly (frontmatter intact, section lands before "Run the diagnostic script")
  • README.md blockquote renders, and its #does-rtk-break-claudes-prompt-cache anchor resolves against the target file
  • No remaining references to the removed docs/TROUBLESHOOTING.md path in the touched files
  • cargo fmt --all --check, cargo clippy --all-targets, cargo test --all (3359 passed, 0 failed)
  • Merges cleanly into current develop

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 13, 2026 09:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a dedicated FAQ-style explanation to address whether RTK interferes with Claude prompt caching, and cross-links it from the main docs and README so the answer is easy to find.

Changes:

  • Added a new canonical doc (docs/PROMPT_CACHING.md) explaining what RTK changes, how caching works turn-by-turn, and how to verify via rtk gain.
  • Added a new top troubleshooting entry linking to the full prompt-caching explanation.
  • Added a one-line README FAQ blurb near “How It Works”, plus corrected the architecture module total.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
docs/TROUBLESHOOTING.md Adds a new top “Problem/Short Answer/Details” entry and links to the full prompt caching doc.
docs/PROMPT_CACHING.md New standalone explanation of prompt caching behavior and RTK’s impact, with examples and a cost comparison.
README.md Adds a prominent FAQ blockquote linking to the new prompt caching doc.
ARCHITECTURE.md Updates the module count total line.
Comments suppressed due to low confidence (1)

ARCHITECTURE.md:301

  • The updated total (64 = 38 command + 26 infrastructure) conflicts with the breakdown immediately below (Command Modules: 34, Infrastructure Modules: 20). Please reconcile these counts so the section is internally consistent.
**Total: 64 modules** (38 command modules + 26 infrastructure modules)

### Module Count Breakdown

- **Command Modules**: 34 (directly exposed to users)
- **Infrastructure Modules**: 20 (utils, filter, tracking, tee, config, init, gain, toml_filter, verify_cmd, etc.)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/PROMPT_CACHING.md Resolved
@pszymkowiak

Copy link
Copy Markdown
Collaborator

This PR has merge conflicts with develop. Please rebase:

git fetch upstream develop
git rebase upstream/develop
git push --force-with-lease

Labeling awaiting-changes until conflicts are resolved.

@CLAassistant

CLAassistant commented Mar 20, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@aeppling

Copy link
Copy Markdown
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

@aeppling

aeppling commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Hey @FlorianBruniaux , i think a mention about this in the root README.md "FAQ" section is enough, TROUBLESHOOTING as well for deeper explanation.

Could we clean to only keep in FAQ + Troubleshooting ? I do not think a dedicated markdown file is necesarry for this

Users asked whether RTK breaks Claude's prompt cache. Short answer: no.
RTK filters output once, the result is cached normally. Smaller outputs
also improve cache economics (cheaper writes and reads).

- Add FAQ blockquote in README after 'How It Works' section
- Add TROUBLESHOOTING.md with Problem/Short Answer/Details pattern

Signed-off-by: Florian BRUNIAUX <[email protected]>
@FlorianBruniaux
FlorianBruniaux force-pushed the docs/prompt-caching-faq branch from bee819b to cd9f1a9 Compare April 13, 2026 14:17
KuSh and others added 2 commits September 8, 2026 01:54
The section landed in docs/TROUBLESHOOTING.md, a flat file removed in
a94e949 when the docs were consolidated. Content there does not reach
the published guide, and the copy reintroduced install guidance that
develop had already pinned to --branch master.

Move the answer into docs/guide/resources/troubleshooting.md and drop the
duplicated Type Kit collision section, which that guide already covers.

The cache write/read breakdown is reported by `rtk cc-economics`, not by
`rtk gain`, so point readers at the command that actually shows it.

Co-Authored-By: Claude Opus 5 <[email protected]>

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Round 1 of 3 — APPROVED (fixup pushed)

Claim: answer the recurring "does RTK break Claude's prompt cache?" question in the README and the troubleshooting docs.

Scope: accept. The answer is correct and worth publishing — the placement and one command name were wrong, and both are now fixed on the branch. No competing PR or maintainer branch touches these files.

Ran: built the merged head against current develop; rtk gain, rtk gain --help and rtk cc-economics against a real 190k-command database; the weight constants in cc_economics.rs; path, link and anchor checks across develop. Docs-only, so the savings floor does not apply.

Thanks for this — the question comes up often enough that having a canonical answer is genuinely useful, and the reasoning in it is right.

Blocks merge (2, frozen at round 1) — both closed by c81c0977

1. rtk gain does not report cache metrics. The doc's one actionable step named the wrong command:

$ rtk gain
Total commands / Input tokens / Output tokens / Tokens saved / Total exec time
  -> no cache line at all

$ rtk cc-economics
    Cache writes:               215.2M
    Cache reads:                8645.4M

Routing confirms it: Commands::CcEconomics -> src/analytics/cc_economics.rs (cc_cache_create_tokens / cc_cache_read_tokens), while gain --help exposes no cache flag and src/analytics/gain.rs never mentions cache. In the one doc written to settle a credibility question, a sceptic following the verification step would have found nothing. Checked every .md on develop — no other doc makes this claim, so it was a single site, not a class.

2. docs/TROUBLESHOOTING.md is a deleted path. It was removed (337 lines) in a94e9493 "consolidate to user-facing guide, remove duplicates and legacy flat docs"; the live page is docs/guide/resources/troubleshooting.md, which is what the pipeline ships to rtk-ai.app and what docs/guide/index.md links. Content added there never reaches the docs site — so the answer, which is the point of the PR, would not have been published.

It also re-published install guidance develop had deliberately corrected:

develop:  cargo install --git https://github.com/rtk-ai/rtk --branch master   ("pinned to the release branch")
this PR:  cargo install --git https://github.com/rtk-ai/rtk

What I pushed

Two commits, no force-push — your commit is untouched:

  • faaa446b merge develop into the branch (clears the conflict flagged in March)
  • c81c0977 move the answer into docs/guide/resources/troubleshooting.md, point the README at it, name rtk cc-economics, and drop the duplicated Type Kit collision section that the guide already covers in a fuller version
README.md                               |  2 ++
docs/guide/resources/troubleshooting.md | 17 +++++++++++++++++

cargo fmt --all --check, clippy --all-targets, cargo test --all (3359 passed, 0 failed), clean merge into develop, README anchor resolves, frontmatter intact.

One thing worth recording, because it nearly bit me too: my first attempt used a relative link to docs/guide/troubleshooting.md, which resolved on the branch but 404s after merge, since develop had moved the file into resources/. Rename detection carried the content edit across but left the link text on the old path — the same failure as finding 2, reintroduced by the fix for it. Merging develop in first is what removed it.

Rolled into the fixup rather than filed as threads

  • The README blockquote pointed at a second, local troubleshooting destination while README.md:20 and :457 already route to the guide.
  • "RTK does not alter the prefix" is falsifiable as written — rtk init injects @RTK.md into CLAUDE.md (src/hooks/init.rs:151), which is cached prefix. Reworded to the accurate and stronger claim: RTK's contribution is stable, written once and cached thereafter. Worth keeping precise, since this doc exists to convince a sceptic.
  • The duplicated collision section had further problems that vanish with it: the fix omitted cargo uninstall rtk, so it aborts with "binary already exists" in exactly the scenario it addresses; and it gave the symptom as command not found, which is the separate PATH failure — Rust Type Kit actually prints rtk: 'gain' is not a rtk command.

Checked and correct — no need to re-verify

  • "cache writes 1.25x, reads 0.1x" matches WEIGHT_CACHE_CREATE / WEIGHT_CACHE_READ in cc_economics.rs:20-21 and Anthropic's published ratios.
  • The core argument is sound: filtered output is written into history once and never recomputed, so nothing already cached is rewritten.
  • All CI green; BLOCKED was only REVIEW_REQUIRED.

Hypotheses built and dropped

  • rtk cc-economics breaks the docs contract's "only rtk gain/init/verify/proxy are user-typed". Dropped — docs/guide/ already uses rtk telemetry (12), rtk discover (10), rtk session (5), rtk trust (3), rtk config (2). The list is stale, not enforced.
  • The doc review CI job should have caught the dead path. Dropped — it is an AI reviewer over CONTRIBUTING.md rules and does not validate link targets.

Your questions

  • @aeppling — "Could we clean to only keep in FAQ + Troubleshooting? I do not think a dedicated markdown file is necessary": done, by the author at cd9f1a98. docs/PROMPT_CACHING.md is gone; README + troubleshooting only. The one gap was that "TROUBLESHOOTING" was read as the old flat path, which the fixup retargets. Your instruction is fully satisfied.
  • @pszymkowiak — "merge conflicts with develop": resolved by faaa446b. The awaiting-changes label can come off.
  • Copilot's thread on docs/PROMPT_CACHING.md ("12.5x doesn't match the numbers"): no longer relevant, that file does not exist at head. Resolving it.

Separately, the PR description still describes docs/PROMPT_CACHING.md and an ARCHITECTURE.md count fix that are not in the diff — worth a quick edit, not a blocker.

Six other files (INSTALL.md, README_es/fr/ja/ko/zh.md) still carry 12 links to the deleted docs/TROUBLESHOOTING.md. Pre-existing and outside this PR; it is being folded into the wider documentation review rather than filed separately.

Next

Nothing — approving. Merges as-is.

Rounds: 1/3. Threads: 1 resolved this round (fixup-closed and outdated included).

@KuSh
KuSh merged commit 665b272 into develop Sep 8, 2026
19 checks passed
@KuSh
KuSh deleted the docs/prompt-caching-faq branch September 8, 2026 00:06
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants