Claude Code setup: CLAUDE.md, rust-analyzer through LSP, and CodeGraph #1197
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1197
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1197"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@KluseG on GitHub · 2026-11-25 23:29 UTC · original
KluseG:docs/claude-code-setup→main· +78 −0 · 3 files · 2 commits · openThis fork is developed with Claude Code (see the README's credits). Today every session starts with no
project context. It finds its way around about 134k lines of Rust with text search and whole-file reads.
That is costly here:
victory-shader/src/emit/lower.rsis about 12k lines,victory-gpu/src/host.rsabout 9k, and
victory-gpualone is about 60k. This PR adds three things that make those sessionscheaper and safer. Only the first two change files in the repo.
1.
CLAUDE.md: project rules loaded into every sessionClaude Code reads
CLAUDE.mdat the start of every session. The new file is short (67 lines) andholds what a session currently has to rediscover, or can get wrong:
cargo xtask policychecks untracked,not-ignored files too, and that
cargo testruns it (repository_passes_policy). So any straycache or index file breaks the tests. It also says never to paste game-derived output into commits,
tests or docs. This is the rule an AI session is most likely to break by accident, for example by
quoting shader disassembly in a test.
--all-features),--locked, and thediagprofile, so a session checks its work the same way CI does.VICTORY_*switch (there areabout 250 of them, read where they are used); no claimed speed-up without a measured run; and credit
for ported patches.
2. rust-analyzer through Claude Code's LSP support
Claude Code has an
LSPtool that uses a language server installed through a code-intelligence plugin.With rust-analyzer behind it, a session can:
codebase because the same names recur across
victory-gpuandvictory-shader(there are threehost.rsfiles and tworesource.rsfiles);Results, whichunused_must_use = "deny"turns into hard errors), before a slow fullcargo clippyrun on a 2024-edition workspace.
.claude/settings.jsonenables the official plugin for the project:Each contributor still has to do two things once (enabling the plugin in the repo does not install it):
Caveats:
cfg(windows), and the toolchain targetsx86_64-pc-windows-msvc. Run on macOS or Linux, rust-analyzer analyses for the host target, so ittreats that code as inactive. On the Windows dev machine it works as is. Fixing this elsewhere would
need a small project plugin that passes
cargo.targetto rust-analyzer; that is not part of this PR.rust-toolchain.toml. Adding"rust-analyzer"tocomponentsin this file would install thebinary automatically for everyone, CI included. I left that out so this PR doesn't change CI; it is
an easy follow-up if you want it.
(cloud sessions).
3. CodeGraph: a local code graph over MCP (opt-in, nothing committed)
CodeGraph (MIT) indexes the code with tree-sitter into a
local SQLite database (
.codegraph/). It serves the index to Claude Code as an MCP server. Rust is afully supported language. One
codegraph_explorecall returns the relevant symbols' source, the callpaths between them and a summary of what depends on them. That suits questions this fork asks all the
time, such as "what reads
VICTORY_CARD_HASH_LEN, and what does that code call?", or "what doeschanging
changed_runsaffect?".Its README claims 88% fewer tool calls and 62% fewer tokens across its benchmark repos. For Tokio it
claims 3 tool calls instead of 29. These are the project's own numbers and we haven't measured them
here. The project also says the index leaves more retrieval context in the window over a long session.
There is nothing to commit. Anyone who wants it runs:
Code doesn't leave the machine. The CLI sends anonymous usage counts by default; turn that off with
codegraph telemetry off. This PR adds/.codegraph/to.gitignore. Otherwise the database wouldshow up as untracked binary data, and
cargo xtask policy, and with itcargo test, would fail.What changes
CLAUDE.md.claude/settings.jsonrust-analyzer-lsp@claude-plugins-official.gitignore/.claude/settings.local.json,/CLAUDE.local.md,/.codegraph/No Rust code changes.
cargo xtask policy --stagedpasses on the three files.Found while testing (not fixed here)
On
main,cargo xtask policyfails. The reason is that two diagnostic logs are over the policy's512 KiB limit:
diagnostics/timing-run-2026-11-25.txt(3,311,492 bytes, added in44bff61) anddiagnostics/timing-run-295s-2026-11-25.txt(6,551,447 bytes, added in32b31f7). Sorepository_passes_policy, and with it the CI test step, should fail onmainas it stands. I leftit alone because the fix is a policy choice: trim the logs, or add an exception with a reason in
xtask/src/policy.rs.🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.