docs: add CLAUDE.md/AGENTS.md agent guide (#759)#1008
Conversation
Seed the agent-driven workflow from #759 with an operational guide for coding agents (Claude Code, Codex). Covers the mechanical contract: preset-based build, C++/GPU/Python test invocation, the clang-format v14 / pre-commit rule, the CI gates to clear before a PR, commit/PR conventions, the #759 guardrails (scoped diffs, physics changes need human review), and the domain gotchas that agents get wrong (dtype enum ordering, Type.type_promote across real/complex, GPU in-place kernel gaps, the variant-dispatch direction). AGENTS.md is a symlink to CLAUDE.md so both toolchains read one source of truth. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive guide for coding agents in CLAUDE.md and creates a symlink to it in AGENTS.md. The review feedback suggests replacing the Git symlink with a standard markdown pointer file to avoid compatibility issues on Windows. Additionally, it recommends simplifying the build instructions in CLAUDE.md by leveraging CMake's --preset option during the build phase instead of hardcoding build directories and job flags.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1008 +/- ##
==========================================
+ Coverage 30.82% 32.96% +2.14%
==========================================
Files 229 230 +1
Lines 33348 33106 -242
Branches 14069 13813 -256
==========================================
+ Hits 10281 10915 +634
+ Misses 15795 14824 -971
- Partials 7272 7367 +95
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
ReviewNice work — this is an unusually well-fact-checked guide. I verified the claims directly against the repo (presets, 1. The
|
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
|
||
| Python — CI installs editable and runs pytest (pyproject pins `--preset=openblas-cpu`): | ||
|
|
||
| ```bash |
There was a problem hiding this comment.
It is possible to use preset here
| Green locally before opening a PR. CI enforces: | ||
|
|
||
| - **clang-format-check** (v14) — formatting clean. | ||
| - **ci-cmake_tests** — `ctest` (`test_main`) *and* `pytest pytests/` both pass; Codecov. |
There was a problem hiding this comment.
It is able to set up cuda build environment in cloud agent environment. We can consider to ask build cuda to align with the previous section "use cuda preset if touch cuda code"
There was a problem hiding this comment.
It is able to set up cuda build environment in cloud agent environment. We can consider to ask build cuda to align with the previous section "use cuda preset if touch cuda code"
Does this mean running agents off Github? Or we can subscribe to the Github GPU workers.
There was a problem hiding this comment.
Does this mean running agents off Github?
Yes. In both codex and Claude Code cloud session. cuda compiler and libraries can be installed on a machine without GPU. The limitation is cuda code can be built on those machines but can not be run. We can also build cuda variant with GitHub action without GPU workers.
| ## Commits & PRs | ||
|
|
||
| - Branch off `master`; never push straight to `master`. | ||
| - Small, single-purpose commits; conventional subjects: `fix(linalg): …`, |
There was a problem hiding this comment.
How about just tell the bots follow conventional commits? It is a commit standard
There was a problem hiding this comment.
Maybe this should be defined in Contribution.md
|
|
||
| ```bash | ||
| cmake --preset debug-openblas-cpu | ||
| cmake --build --preset debug-openblas-cpu --target test_main |
There was a problem hiding this comment.
While building and running debug cuda preset, some env need to be set to suppress ASAN errro
There was a problem hiding this comment.
Could you provide some examples?
There was a problem hiding this comment.
ASAN_OPTIONS='protect_shadow_gap=0:replace_intrin=0:detect_leaks=0'
Refer to:
google/sanitizers#629 (comment)
https://stackoverflow.com/a/68027496
|
its worth having a separate GEMINI.md because that is used by the Gemini bot for reviews. For example it keeps suggesting changes for C++17 compatibility, which is really annoying and pointless. GEMINI.md can be more focussed on what needs reviewing, rather than developer-orientated CLAUDE.md and AGENTS.md. See for example https://github.com/Uni20-dev/uni20/blob/main/GEMINI.md. Its basically a moving target of "stop bringing up these issues in automated reviews". Gemini free reviews go away in another week, but you could get a gemini free trial for another month, and maybe worth paying for it longer-term. I have used gemini-cli briefly (now replaced by Antigravity), but only the free tier so I am not sure how good the higher tier models are, but I've been generally impressed with the gemini reviews. |
Code ReviewUseful, accurate agent guide — I spot-verified the content against the repo: every named preset exists in Findings1. 🟠 2. 🟡 Consider folding in the review-attribution policy. There's an (uncommitted) maintainer 3. 🟡 Add the naming conventions @IvanaGyro asked to codify (in the #1001 thread): leading 4. 🟢 Forward-looking gotcha: "a length-1 scalar RHS must stay CPU-resident (#988)" describes post-#980/#992 semantics — neither merged yet. Fine as guidance; consider "(once #980/#992 land)". Content: LGTM. The symlink defect (finding 1) is the one must-fix. Posted by Claude Code on behalf of @pcchen |
I may have bad wording so the bot cannot understand me. I suggest follow Google style for naming for all new code except that file has consistent naming other than the style guide. Most of C++ files have messy naming now. It is not benefit to try to follow the messy naming if the file has already messy. Google style picked in this project (not by me). Additionally, leading |
|
I suggest also adding to the AI guidance, is to pass simple C++ types by value. The AI tends to follow the surrounding code so it passes simple values by The other thing is |
|
I don't like the Google style of |
|
I think the easiest way to enforce Google C++ style is using Skills, such as Google C++ Style Guide Skill,Google Python Style Guide Skill. |
Address the style-enforcement review feedback on #1008: - Add two Claude Code skills that enforce the project's Google style baseline for new code: google-cpp-style and google-python-style. They encode the Cytnx-specific overrides raised in review — no leading underscore in new code (#836), trailing-underscore = in-place mutator returning *this, snake_case for new identifiers, and scalars passed by value rather than const& (per @ianmccul). - Add GEMINI.md as a focused list of review-specific reminders for the Gemini Code Assist bot, so it stops raising C++17-compat suggestions (the project is C++20 / CUDA 20) and other recurring false positives. - Un-ignore .claude/skills/ so the shared skills are committed while per-user .claude config stays ignored. - Reference the skills and GEMINI.md from CLAUDE.md (AGENTS.md symlink). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- AGENTS.md: replace the dangling symlink (git mode 120000 whose target was the pointer text, so it ENOENT'd on POSIX checkouts) with a regular 100644 pointer file to CLAUDE.md. Resolves the broken-symlink finding; update the "AGENTS.md is a symlink" wording in CLAUDE.md to "pointer". - Document the AddressSanitizer env for debug presets: ASAN_OPTIONS='protect_shadow_gap=0:replace_intrin=0:detect_leaks=0' (debug-* presets set USE_DEBUG=ON -> -fsanitize=address). - Note that a *-cuda preset can be built without a GPU to compile-check CUDA code (toolkit installs on GPU-less machines / cloud agents; only running GPU tests needs hardware). - Reference the Conventional Commits standard by name in the commit section. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Seeds the agent-driven workflow proposed in #759 with an operational guide for coding agents (Claude Code, Codex). This is the "Phase 1" safeguard from that issue: a single place that tells an agent how to produce PRs that pass CI, plus the guardrails and domain rules agents otherwise get wrong.
AGENTS.mdis a symlink toCLAUDE.md(git mode120000) so both toolchains read one source of truth — editCLAUDE.mdonly. Resolves cleanly on Linux/macOS/WSL, where Cytnx is developed.Scope of decisions (per discussion)
CLAUDE.md,AGENTS.mdsymlinked to it.Contents
CMakePresets.json), toggle summary.debug-*preset →test_main→ctest --preset cpu-only), GPU (gpu_test_main,cpu-and-cuda), Python (the exact editable-install +pytest pytests/CI runs).pre-commit, re-add after the hook reformats (a newer clang-format fails CI).find_package, version-consistency).Co-Authored-Bytrailer, problem→fix→testing body.Type.type_promoteacross the real/complex boundary, GPU in-place kernel gaps (GPU: scalar in-place ops throw on non-contiguous tensors for *= and /=, and do a per-call H2D copy #988),cuKronbroken under CUDA 13 (GPU build broken: cuKron fails to compile (CUDA 13) after the #982 type_promote change #999), thecytnx_error_msg/cytnx::errormacros, and thestd::variantdispatch direction (Refactor internal functions using std::variant and visitor pattern #650, Make invalid types passed to cv_typeid_v<T> a compile-time error #938).CONTRIBUTING.md/RELEASING.md/Readme.md.Notes for reviewers
test_main/gpu_test_maintargets, ctest presets).AGENTS.mdas a symlink vs. a one-line pointer file (symlink risk on native-Windows checkouts); (2) whether theCo-Authored-Byagent-attribution line should be project policy.Closes #759 is not asserted — this is only Phase 1 of that issue; leaving #759 open for the later phases.
🤖 Generated with Claude Code