Repository navigation
chore(agents): add the vitaminc skill for agents working on the repo - #1777
Conversation
The vitaminc skill maps each task that touches a secret to the vitaminc type for it, with working recipes. It was not installed here, so agents writing Rust in this repository hand-rolled what vitaminc already has. It is a copy from cipherstash/vitaminc at 5dbbafaa1, beside the misuse-resistance copy, in .claude/skills/ so it does not ship to customers. AGENTS.md says when to read it, and adds two rules the skill does not state yet: derive OpaqueDebug for a type that holds a secret, and reuse an engine or vitaminc type before wrapping it.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
cipherstash-agent
left a comment
There was a problem hiding this comment.
Review attestation
Reviewed 5329ca3 · posted from Claude Code (scheduled routine) · claude-opus-5-5 · effort medium
Sources: code-review · claude-opus-5-5; mattpocock-skills:code-review Standards and Spec sub-agents · model not reported
Skills: code-review, company-skills:rust-security, mattpocock-skills:code-review, company-skills:review-cross-check
Findings (5): 1 major, 4 minor — 4 inline, 1 below.
general(PR description) minor The body says #1774 "hand-writesimpl Debugfive times". #1774 has one commit, and it has three:Cipherincrates/core/src/cipher.rs, andPlaintextandCiphertextincrates/core/src/value.rs. Change it to "three".
Every finding was checked against 5329ca3 before posting. The copies hold up: RECIPES.md matches vitaminc 5dbbafaa1 byte for byte, SKILL.md differs only by its note, and ValueFrame derives OpaqueDebug.
Open question, not a defect: the new rule "Do not write impl Debug by hand" makes existing code non-conforming. That includes JsonPlaintext (packages/stack-encrypt/src/json/plaintext.rs:228), OpaqueBlob (packages/stack-encrypt/src/blob.rs:458) and the opaque_debug::implement! sites in packages/stack-kms. List them as known exceptions, or leave them for a follow-up?
Generated by Claude Code
| Read `.claude/skills/vitaminc/SKILL.md` before you write or review Rust that | ||
| holds a key, a token, a plaintext or another secret. That covers the stack-* | ||
| crates, the Go guests and every language binding crate. The skill maps each |
There was a problem hiding this comment.
major This puts protect-ffi in scope, but protect-ffi pins vitaminc = "=0.1.0-pre4.2" (languages/typescript/packages/protect-ffi/crates/protect-ffi/Cargo.toml:52), and RECIPES.md targets 0.10: SafeRand::next_below and vitaminc_aead::{ContextPiece, IntoContext} do not exist at pre4.2, so a recipe copied "as written" into protect-ffi fails to compile. Say that the recipes do not apply to protect-ffi until its pin moves, and that the Go guests get vitaminc through stack-encrypt's re-exports and must not add their own vitaminc dependency (languages/golang/encrypt/guest/Cargo.toml:66-70).
Source: code-review · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 7e533fb. I checked this against the head and against next. protect-ffi still pins vitaminc = "=0.1.0-pre4.2", and vitaminc-random 0.1.0-pre4.2 has no next_below. The Go encrypt guest has no vitaminc dependency of its own: its Cargo.toml says it takes vitaminc through stack-encrypt's re-exports.
The AGENTS.md section now says not to copy a recipe into protect-ffi until that pin moves to 0.10. The section also says not to add a vitaminc dependency to the encrypt guest. The auth guest is left out of that rule, because it depends on vitaminc-protected 0.10 directly.
I named only next_below as a missing item. I could not check IntoContext at pre4.2: protect-ffi does not turn on the aead feature, so that crate is not in the local registry.
| @@ -0,0 +1,287 @@ | |||
| # vitaminc recipes | |||
|
|
|||
| One recipe per task. Each is complete, compiles, and is the production path: copy it as written. Imports use the individual crates; with the facade crate, `vitaminc_protected::X` is `vitaminc::protected::X`, and so on. | |||
There was a problem hiding this comment.
minor In this workspace, several recipes do not compile as written. The root Cargo.toml has no direct vitaminc-random or vitaminc-password, and the facade has no password feature. stack-encrypt and stack-guest-abi build futures without executor. #[derive(Generatable)] (line 93) needs vitaminc-random as a direct dependency, because the derive's generated code names that crate. Add a stack-specific mapping to the copy note in SKILL.md, the one part allowed to differ: vitaminc_random::X → vitaminc::random::X, password needs a reviewed feature addition, and the Generatable derive and block_on are not usable without new dependencies.
Source: code-review · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 7e533fb, with one correction and in a different place.
The correction: the vitaminc 0.10 facade does have a password feature. The root workspace does not turn it on.
The rest checks out. The root Cargo.toml has no direct vitaminc-random or vitaminc-password. stack-encrypt builds futures with std only, and stack-guest-abi with std and async-await. The Generatable derive's generated code names vitaminc_random::SafeRand and vitaminc_random::RandomError.
The place: I put the mapping in the AGENTS.md "vitaminc" section, not in the copy note in SKILL.md. AGENTS.md is loaded in every session, so an agent sees the mapping before it opens the skill. The copy also keeps its one short note. A refresh stays a plain copy.
| let a: Equatable<Protected<[u8; 32]>> = Equatable::new([7; 32]); | ||
| let b: Equatable<Protected<[u8; 32]>> = Equatable::new([7; 32]); | ||
| assert!(tag_matches(&a, &b)); |
There was a problem hiding this comment.
minor These statements sit outside any function, so pasting the block into a .rs file gives expected item, found keyword 'let', which contradicts "compiles … copy it as written" at line 3. The "Keyed hash" block at 281-286 has the same problem. Upstream only compiles them as rustdoc doctests (packages/skill-doctests). Wrap the statements in a fn or #[test] upstream in cipherstash/vitaminc, then copy the file again.
Source: code-review · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Confirmed: the "Compare secrets" block and the "Keyed hash" block end with bare statements, so they compile only as doctests. RECIPES.md is a byte-for-byte copy of vitaminc at 5dbbafaa1, so I did not change it here.
In 7e533fb the AGENTS.md section tells an agent to put those lines in a function or a #[test]. The real fix belongs upstream in cipherstash/vitaminc: wrap the statements there, then copy the file again. I have listed that for the owner.
| For Rust techniques at each rung (newtypes, typestate, sealed traits, const generics, withheld traits, compile-fail tests, the assumptions behind "if it compiles, it is secure"), read [RUST.md](RUST.md). | ||
|
|
||
| In Rust, the vitaminc crates provide ready-made types for rules 3, 4 and 5: secret wrappers, randomness, encryption, key wrapping and keyed hashing. Reach for them before writing your own. The `vitaminc` skill shows how to use them. That skill is in the vitaminc repository, at `.claude/skills/vitaminc/`. It is not installed here. | ||
| In Rust, the vitaminc crates provide ready-made types for rules 3, 4 and 5: secret wrappers, randomness, encryption, key wrapping and keyed hashing. Reach for them before writing your own. The `vitaminc` skill shows how to use them. It is installed here, at `.claude/skills/vitaminc/`. |
There was a problem hiding this comment.
minor Upstream's last line at 5dbbafaa1 ("the vitaminc skill provides ready-made types … Reach for them before writing your own.") is now true here word for word, because this PR installs the skill. Take upstream's line, and change the note at line 10 to "differs in this note only", so a refresh no longer has to restore a rewritten section. While editing line 10, move its pin from 06861c1b9 to 5dbbafaa1; the content is the same, and both copies would then name one commit.
Source: mattpocock-skills:code-review (Standards) · model not reported
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 7e533fb. The last line is now upstream's line word for word. The note names 5dbbafaa1 (24 November 2026) and says SKILL.md "differs in this note only". I checked that RUST.md and EVIDENCE.md are the same at 5dbbafaa1 as in this copy, so moving the pin changes no content. The copy now differs from upstream in the note alone.
The vitaminc recipes are written for vitaminc 0.10 and its individual crates. In this repository they do not compile as written: - protect-ffi pins vitaminc 0.1.0-pre4.2, and that version lacks some items the recipes use. - The Go encrypt guest takes vitaminc only through stack-encrypt. - The root workspace has the facade crate but not vitaminc-random or vitaminc-password. - Two recipes end with statements outside a function. AGENTS.md now lists each change a recipe needs, and leaves the copied files as they are. The OpaqueDebug example now names JsonChildPlaintext. ValueFrame is deleted on next, so the old example would point at nothing after merge. The misuse-resistance copy now takes upstream's last line word for word. That line is true here once the vitaminc skill is installed. The note at the top names commit 5dbbafaa1, the same commit as the vitaminc copy, and says the copy differs in the note only.
|
Outcome of the findings in the review body of
A related fix not raised in the review: the AGENTS.md example for |
…d-written Debug AGENTS.md says a type with a secret in it derives vitaminc's OpaqueDebug. Five types did not: - OpaqueBlob<T> and JsonPlaintext in stack-encrypt wrote Debug by hand. - DataKey, DataKeyWithTag, and the test-support DeterministicSource in stack-kms used the opaque-debug crate. Each now derives OpaqueDebug. The derive masks every field with "***". No field is marked non_sensitive, so no Debug bound is added to T, and the text shows no value, key byte, or seed. The text now starts with the type's full path, as the other derived types' text does. Each type has a test that pins its Debug text. stack-kms no longer depends on opaque-debug. The six Cargo.lock files that list stack-kms drop it. AGENTS.md now says when a hand-written Debug is still right: to show a count or a length. The derive cannot show either.
|
Follow-up to the open question in the review body on
What I checked for each type:
The Checks run on f223efe:
|
Mutation testing (cargo-mutants,
|
Summary
Vitamin C is CipherStash's library of cryptographic building blocks. It has an agent skill: a short guide that tells a coding agent which Vitamin C type to use for each task that touches a secret, with working code for each.
That skill was not installed in this repository. Agents writing Rust here did not read it, and wrote by hand what Vitamin C already has. The latest case was an early draft of the TypeScript SDK work in #1774. It wrote
impl Debugby hand to hide a value, where the engine derivesOpaqueDebug. The merged version of #1774 derivesOpaqueDebug.This pull request installs the skill and tells agents when to read it.
Changes
.claude/skills/vitaminc/SKILL.mdandRECIPES.md: a copy of the skill fromcipherstash/vitaminc, at commit5dbbafaa1onmain.RECIPES.mdis unchanged.SKILL.mdgains one note at the top that says it is a copy and how to update it, as themisuse-resistancecopy does..claude/skills/misuse-resistance/SKILL.md: its last section said thevitamincskill "is not installed here". It now takes upstream's last line word for word, which is true once the skill is installed. Its note names commit5dbbafaa1, the same as the vitaminc copy, and says the copy differs in the note only.AGENTS.md: a "vitaminc" section under "Working on the Rust crates". It says to read the skill before writing or reviewing Rust that holds a secret. It lists the changes a recipe needs before it compiles in this repository: protect-ffi pins an older vitaminc, the Go encrypt guest takes vitaminc only throughstack-encrypt, and the root workspace has the facade crate but notvitaminc-randomorvitaminc-password. It also states two rules the skill does not have yet:OpaqueDebug, and does not hand-writeDebug;stack-encrypt and stack-kms:
OpaqueBlob<T>,JsonPlaintext,DataKey,DataKeyWithTag, and the test-supportDeterministicSourcenow deriveOpaqueDebugin place ofDebugwritten by hand. TheDebugtext still masks every field. Its exact text changed, and both changelogs say so. stack-kms no longer depends onopaque-debug. This branch mergesnextfirst, so the change applies tonext's code.The skill is in
.claude/skills/, notskills/, so it does not ship to customers in thestashpackage.Verification
.claude/skills/:git grep 'claude/skills' -- scripts .githubfinds only a comment about what a customer's install copies. CI on this pull request is the check.cipherstash/vitaminctheskill-doctestspackage does.CHANGELOG.md, and no npm package changed.cargo nextest run -p stack-kms -p stack-encrypt --all-featurespassed, with clippy, fmt, and the doctests.Review notes
OpaqueDebug. I put that rule inAGENTS.mdand left the copy unchanged, so the two copies stay the same. The rule should also go into the skill incipherstash/vitaminc.misuse-resistancecopy, so its last section may conflict with this one.