Skip to content

docs: a Claude Code guide for a local server and its prompt prefix - #4931

Merged
ashhart merged 4 commits into
ashhart:mainfrom
javierbits:docs/3225-claude-code-guide
Nov 25, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
javierbits:docs/3225-claude-code-guide

Conversation

@javierbits

@javierbits javierbits commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Adds docs/claude-code.md: it starts a server for Claude Code, points the client at it, explains which model id the client asks for and why the served id is the one to pass, sets the client's context window, and documents the attribution block with measured per-turn prompt-cache numbers. docs/api.md, README.md and CHANGELOG.md link it.

Checks on this head

  • Head commit: 6806a6b944432b51cc29c942dd16cf4b06f0da9d
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 164 problems on base 9961ca492 and 164 on this head, no new findings.
  • python3 tools/pr_check.py --base origin/main --pr 4931: 0 errors, 0 warnings. Tests run: the guide's flow was run end to end: one source-build server at ef6bf1bea, the head when measured (zig build native -Dnvcc=..., zig build grammar -Dxgrammar=...), Claude Code v2.1.299 with --model local-model, three resumed turns per arm with and without CLAUDE_CODE_ATTRIBUTION_HEADER=0, and one Read tool round. Every request answered (HTTP 200); the per-turn numbers are in the guide. git diff --check is clean.
  • CI: green on this head (App and mobile checks, No GPU, Zig format); 15 passed, 2 skipped nightly jobs.
  • Not run, and why: the host suite (zig build test test-golden), because only Markdown changed; its last pass on main is unchanged by this head.

Receipt

n/a: documentation only, nothing new can reach inference. The measured numbers in the guide come from a source build at this head, nvidia/Qwen3.8-27B-NVFP4 on one GB10, Ubuntu 24.04.5, driver 580.178.04, CUDA 13.0.88, Zig 0.17.0, --context 65536 --parallel 1; the client logged cache_read_input_tokens 24,576 on turns 2 and 3 in both arms.

  • Main against branch: cells and numbers, or why they can't be run: n/a, documentation.
  • Boxes it reaches: none, documentation.
  • New switch? Default, accepted values, profile row: none.
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: 9961ca492, Zig 0.17.0, CUDA 13.0.88, one GB10, nvidia/Qwen3.8-27B-NVFP4 at snapshot 482ca0f3832238542f8f5295dde86b5f22711d80.
  • Paths and platforms the change reaches, which I ran and which I could not: docs/claude-code.md, the docs/api.md link, README.md and CHANGELOG.md; no code path. The measurements are one GB10 and one client version; the guide says which client versions need the setting.
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: n/a, documentation; the server's replies were unchanged by this head.
  • Main against this branch, same machine and checkpoint, posted before asking for a run on our machines (or why you can't): n/a, documentation.
  • Decode speed before and after, from tools/bench_openai.py: n/a, documentation.
  • Prompt speed before and after: the cold first request's ttft_s from tools/bench_cache.py --require-cold on a long prompt, or "n/a" with the reason when the change cannot reach prompt processing: n/a, documentation; the guide's per-turn resumed counts are the measured cache effect.
  • Licence of any new weights or drafter, or "n/a": n/a, no new weights.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (No new test: the numbers in the guide are the receipt.)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

@javierbits
javierbits force-pushed the docs/3225-claude-code-guide branch 2 times, most recently from b5401bb to a4853a2 Compare November 24, 2026 18:15
@javierbits
javierbits marked this pull request as ready for review November 24, 2026 19:46
@javierbits
javierbits force-pushed the docs/3225-claude-code-guide branch from a4853a2 to 0ecf42b Compare November 24, 2026 19:47
@AIFlowML

Copy link
Copy Markdown
Contributor

I walked through the quick start at 0ecf42b5bbdc9cf83ac81e4b6b90fd44197ba4c9. The first tensorfold launch claude example leaves out the 65,536-token window that the guide calls for and that the measurement uses. The launcher forwards the environment and configures the endpoint and key, so a fresh shell running just that block won't set the custom-model window. Could the first example include it?

CLAUDE_CODE_MAX_CONTEXT_TOKENS=65536 tensorfold launch claude --model local-model

zig test launch_cli.zig on the source file from that head passed all four launcher tests on Apple silicon with Zig 0.17.0. The head also test-merges cleanly into main ed70f71aa7e561974dc4ec005e17fe64cba3d98a. I exercised the launcher tests with their injected process boundary and did not rerun the live Claude Code cache measurement.

Igor Lessio - AIFLOW LABS

@javierbits
javierbits force-pushed the docs/3225-claude-code-guide branch from 0ecf42b to 82fb946 Compare November 25, 2026 10:37
@javierbits

javierbits commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks, the launcher inherits the environment, so both tensorfold launch examples now set CLAUDE_CODE_MAX_CONTEXT_TOKENS=65536 inline and the text says so. Rebased on 47a605aa1 (head 82fb94645); CI is queued.

@AIFlowML

Copy link
Copy Markdown
Contributor

Thanks, the first example now includes the context override. I trial-merged 82fb94645f cleanly into 47a605aa12 and reran zig test zig/src/server/launch_cli.zig on macOS arm64. The four existing tests passed. A fifth scratch check exercised the exact quick-start arguments and confirmed the child gets --model local-model, CLAUDE_CODE_MAX_CONTEXT_TOKENS=65536 and the loopback root without /v1. That closes my launch finding. I didn't run the live Claude Code prefix benchmark.

One wording correction in the attribution note. The example uses a loopback endpoint, so the sentence saying the whole request leaves the machine is misleading. “The configured endpoint receives the request with or without the attribution block” keeps the caching point and also applies to a remote gateway.

Igor Lessio - AIFLOW LABS

@javierbits
javierbits force-pushed the docs/3225-claude-code-guide branch from 82fb946 to 3f91701 Compare November 25, 2026 12:04
@javierbits

Copy link
Copy Markdown
Contributor Author

Thanks, that wording is better: the note now says "the configured endpoint receives the request with or without the attribution block", so it covers the loopback example too. Head 3f9170182 on 0a5c699c8; CI is running.

@AIFlowML

Copy link
Copy Markdown
Contributor

The revised attribution note reads correctly for both the loopback quick start and a remote endpoint. That closes my last docs finding. I trial-merged 3f91701827 into 0a5c699c8 with no conflicts and reran zig test zig/src/server/launch_cli.zig on macOS arm64. All four launcher tests passed. The live Claude Code prefix benchmark was outside this rerun.

Igor Lessio - AIFLOW LABS

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thanks @javierbits. The explicit context setting in both launch examples and the endpoint privacy wording address the earlier requests. The server commands and flags match main.

One small correction remains in docs/claude-code.md: Messages uses {"type":"any"} for required tool selection, while required is the internal spelling. A literal required value is rejected before grammar loading. Please use the Messages object form in that paragraph.

  • Synthena

@javierbits
javierbits force-pushed the docs/3225-claude-code-guide branch from 3f91701 to 6806a6b Compare November 25, 2026 13:46
@javierbits

Copy link
Copy Markdown
Contributor Author

Fixed: the paragraph now uses the Messages form {"type": "any"} and names required as the server's internal spelling. Head 6806a6b94 on 9961ca492; the launcher examples, endpoint wording and this paragraph are the only claims that changed.

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thanks @javierbits. The guide now uses the Messages object {"type": "any"} and correctly identifies required as the internal spelling. That closes the remaining request. The context examples and endpoint wording are preserved, and the documentation-only change merges cleanly. Ready to land from this review.

  • Synthena

@ashhart
ashhart force-pushed the docs/3225-claude-code-guide branch from 6806a6b to aaa3408 Compare November 25, 2026 17:49
@ashhart
ashhart merged commit b92aebe into ashhart:main Nov 25, 2026
2 of 17 checks passed
@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thank you @javierbits. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

@javierbits
javierbits deleted the docs/3225-claude-code-guide branch November 25, 2026 17:50
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.

Docs: a Claude Code guide that keeps its prompt prefix cacheable

3 participants