When to Use
When publishing a prompt unit viastratt publish. This is the most complex CLI command — a 5-step saga with failure compensation.
The Saga
Why R2 First (FM-09)
| Ordering | R2 Fails | Git Fails |
|---|---|---|
| R2-first-then-Git (correct) | Revert fingerprint, exit 4 — clean state | Warn — R2 has correct content, Git can be fixed manually |
| Git-first-then-R2 (wrong) | Git has fingerprint pointing to nothing — orphaned state | N/A |
git add + git commit.
YAML Round-Trip Fidelity
The fingerprint write usesyaml.parseDocument() → doc.set("fingerprint", value) → doc.toString(). This preserves:
- Comments
- Scalar styles (quoted vs plain)
- Key ordering
- Whitespace formatting
yaml.parse() → modify → yaml.stringify() would rewrite the entire file, creating noisy diffs.
Compensation
R2 Key Derivation
strat://, prepend units/, append .yaml.