Skip to content

chore(agents): add the vitaminc skill for agents working on the repo - #1777

Merged
coderdan merged 4 commits into
nextfrom
chore/vitaminc-agent-skill
Nov 29, 2026
Merged

coderdan merged 4 commits into
nextfrom
chore/vitaminc-agent-skill

Conversation

@coderdan

@coderdan coderdan commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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 Debug by hand to hide a value, where the engine derives OpaqueDebug. The merged version of #1774 derives OpaqueDebug.

This pull request installs the skill and tells agents when to read it.

Changes

  • .claude/skills/vitaminc/SKILL.md and RECIPES.md: a copy of the skill from cipherstash/vitaminc, at commit 5dbbafaa1 on main. RECIPES.md is unchanged. SKILL.md gains one note at the top that says it is a copy and how to update it, as the misuse-resistance copy does.

  • .claude/skills/misuse-resistance/SKILL.md: its last section said the vitaminc skill "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 commit 5dbbafaa1, 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 through stack-encrypt, and the root workspace has the facade crate but not vitaminc-random or vitaminc-password. It also states two rules the skill does not have yet:

    • a type that holds a secret derives OpaqueDebug, and does not hand-write Debug;
    • use a type the engine or Vitamin C already has before wrapping it in a new one.
  • stack-encrypt and stack-kms: OpaqueBlob<T>, JsonPlaintext, DataKey, DataKeyWithTag, and the test-support DeterministicSource now derive OpaqueDebug in place of Debug written by hand. The Debug text still masks every field. Its exact text changed, and both changelogs say so. stack-kms no longer depends on opaque-debug. This branch merges next first, so the change applies to next's code.

The skill is in .claude/skills/, not skills/, so it does not ship to customers in the stash package.

Verification

  • I ran no test locally. No script or test in this repository reads .claude/skills/: git grep 'claude/skills' -- scripts .github finds only a comment about what a customer's install copies. CI on this pull request is the check.
  • I compared the two copied files with the source by eye. Nothing compiles the Rust in the recipes here; in cipherstash/vitaminc the skill-doctests package does.
  • No changeset: the changed crates record the change in their own CHANGELOG.md, and no npm package changed.
  • cargo nextest run -p stack-kms -p stack-encrypt --all-features passed, with clippy, fmt, and the doctests.

Review notes

  • The upstream skill does not mention OpaqueDebug. I put that rule in AGENTS.md and left the copy unchanged, so the two copies stay the same. The rule should also go into the skill in cipherstash/vitaminc.
  • No other open pull request adds this skill. chore: release candidate for EQL v4 and Stack Encrypt Rust and Go support #1229 touches the misuse-resistance copy, so its last section may conflict with this one.

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.
@coderdan
coderdan requested a review from a team as a code owner November 24, 2026 00:55
@changeset-bot

changeset-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f223efe

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI; Enforced overrides: Organization
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2cb69b31-6245-4f35-a57b-8b2b0f0333f2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

@cipherstash-agent cipherstash-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-writes impl Debug five times". #1774 has one commit, and it has three: Cipher in crates/core/src/cipher.rs, and Plaintext and Ciphertext in crates/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

Comment thread AGENTS.md Outdated
Comment on lines +875 to +877
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +64 to +66
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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@coderdan

Copy link
Copy Markdown
Contributor Author

Outcome of the findings in the review body of 5329ca3 that have no inline thread. The fixes are in 7e533fb.

  • PR description, "five times": fixed in the description. The merged feat(recipher-js): walking skeleton of the TypeScript SDK #1774 no longer writes impl Debug by hand: its types derive OpaqueDebug. The description now says an early draft of feat(recipher-js): walking skeleton of the TypeScript SDK #1774 wrote impl Debug by hand, and that the merged version derives OpaqueDebug. It gives no count, because I could not check the count in that early draft.
  • Open question: existing code that writes impl Debug by hand. This needs the owner's decision, so nothing changed. The choice is to list those sites in AGENTS.md as known exceptions, or to leave them for a follow-up that moves them to OpaqueDebug. The sites named were JsonPlaintext, OpaqueBlob, and the opaque_debug::implement! sites in stack-kms.

A related fix not raised in the review: the AGENTS.md example for OpaqueDebug named ValueFrame in dynamic/value_frame.rs. next deletes that file, so after merge the example would name nothing. The example now names JsonChildPlaintext in packages/stack-encrypt/src/json/plaintext.rs. That type derives OpaqueDebug on both this branch and next.

…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.
@coderdan

Copy link
Copy Markdown
Contributor Author

Follow-up to the open question in the review body on 5329ca3, answered in comment 7241680014: the existing code that writes impl Debug by hand. The owner decided to move it to the derive, and it is done.

  • 1d13d55 merges next into this branch, because the code to change is next's.
  • f223efe makes five types derive OpaqueDebug: OpaqueBlob<T> and JsonPlaintext in stack-encrypt, and DataKey, DataKeyWithTag, and the test-support DeterministicSource in stack-kms. The last three used opaque_debug::implement!. stack-kms no longer depends on opaque-debug, and the six Cargo.lock files that list stack-kms drop it.

What I checked for each type:

  • The text still shows no secret. Every field is masked with "***". No field is marked #[non_sensitive]. The text names the type by its full path, as Ciphertext's already does. For OpaqueBlob<T> that path includes T's type name. The program chooses that type at compile time, so the name is not read from the data.
  • The bounds still hold. The derive adds a Debug bound only for a field it shows, so OpaqueBlob<T> still needs only T: Zeroize.
  • The tests pin the new text. The five tests that pinned the old text now pin the new text, and check that the value is not in it. Two tests are new: one for DataKeyWithTag and one for DeterministicSource. Both changelogs record the change of text.

The AGENTS.md rule now says when Debug written by hand is still right: to show a count or a length. The derive cannot show either. That covers the other hand-written Debug impls in the crates, such as JsonTerms and FakeDataKeySource, so the rule needs no list of exceptions.

Checks run on f223efe:

  • cargo fmt --all --check: clean.
  • cargo clippy -p stack-kms -p stack-encrypt --all-targets -- -D warnings: clean with --all-features, and clean with --no-default-features.
  • cargo nextest run -p stack-kms -p stack-encrypt --all-features: 1777 passed, 1 skipped.
  • cargo test --doc -p stack-kms -p stack-encrypt --all-features: passed.
  • cargo metadata --locked in the six workspaces whose lock changed: passed.
  • cargo mutants --list --in-diff over the CI gate's crates and over stack-kms: no mutants on the changed lines.
  • The CRAP gate was not run. The change adds no function, and it removes two.

@github-actions

Copy link
Copy Markdown
Contributor

Mutation testing (cargo-mutants, --in-diff, stack-auth, stack-encrypt, stack-encrypt-jsonpath, vitaminc-aead, recipher-frame, vitaminc-aead-derive)

No mutants were generated for the changed lines.

@coderdan
coderdan merged commit dc1cdea into next Nov 29, 2026
65 checks passed
@coderdan
coderdan deleted the chore/vitaminc-agent-skill branch November 29, 2026 03:56
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.

2 participants