ClaudeMap

Context Bridge Guide

A Chinese handbook for context engineering in self-built AI apps: prompt caching, chat compression, memory recall, API / Claude Code switching, and one conversation carried across web, mobile and messaging channels

Tutorials & Guidesguidecontext engineeringprompt cachingmemorymulti-channel

context-bridge-guide (Chinese title: 让 AI 接得上话) is a Chinese handbook distilled from a continuously used personal AI application, covering the context layer that keeps one conversation coherent across devices and engines: how history is organized (topic summaries, recent verbatim messages, memos, and why character estimates and real token counts must not be mixed), how memory actually enters the request (write sources, rule/event layers, relevance recall, prefetch and query alignment, plus the stored-but-not-injected troubleshooting path), how to choose between the two Claude Code paths (native session resume needs a catch-up watermark; per-turn independent CC needs a full briefing and explicit tool conclusions), and how channels share one conversation (trusted identity mapping, source event dedup, full turn ordering). Seven chapters, runnable offline demos (Python 3.10+, standard library only, no model account; the payload example needs an explicit --send flag to touch the network), and tests. The README pairs it with Cheiineeey/api-where-it-breaks for API integration troubleshooting and states its reference docs were consulted on 2026-11-14.

What it does

  • Seven chapters: architecture, prompt cache, context compression, memory, API / Claude Code switching, multi-channel sharing, observability and fallback
  • A responsibility table separating what prompt cache, chat compression, memory systems and channel/engine adapters each do — and do not do
  • The two Claude Code integration paths compared honestly: native resume vs per-turn independent sessions, neither automatically inheriting the other's state
  • Offline demos you can run before trusting anything: demo.py simulates a web session mentioning a plan, a phone following up, then an engine switch; anthropic_payload.py prints a payload with cache breakpoints; cc_command.py previews claude -p arguments without launching it
  • Boundary statements up front: no fixed-savings-ratio or never-forgets promises; teaching stand-ins are labeled as such

When to use it

Use when building your own AI application that must keep one conversation coherent across devices (web, mobile, messaging bridges) and across engines (raw Messages API and Claude Code), or when you need to explain to a team what prompt caching does and does not do before wiring up memory and channel adapters.

Getting started

Five-minute offline tour — needs Python 3.10+, standard library only, no model account, no network requests:

python3 examples/demo.py
python3 examples/anthropic_payload.py
python3 examples/cc_command.py
python3 -B -m unittest discover -s tests -v

demo.py simulates a web session mentioning a plan, a phone following up, then an engine switch; anthropic_payload.py needs an explicit --send flag to touch the network.

Things to know

The README's own limits: the offline examples' ledger, summary cache and locks live in memory and lose state on restart; wiring a real application needs database persistence, trusted channel identity mapping, full turn serialization and idempotent tool-result records. The replier and summarizer in the demos are labeled teaching stand-ins; word-hit retrieval does not pretend to be vector retrieval; the examples cannot verify real-model memory effects, cache hits or gateway compatibility. Real endpoint cache behavior, billing and CLI parameters follow the versions you actually use. MIT license. 15 stars as of writing (2026-11-15).

Repository

yanke521/context-bridge-guide

Charted

Related on the map