Arkhe-claude-plugins sops-add-key
install
source · Clone the upstream repo
git clone https://github.com/joaquimscosta/arkhe-claude-plugins
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/joaquimscosta/arkhe-claude-plugins "$T" && mkdir -p ~/.claude/skills && cp -r "$T/plugins/devtools/skills/sops-add-key" ~/.claude/skills/joaquimscosta-arkhe-claude-plugins-sops-add-key && rm -rf "$T"
manifest:
plugins/devtools/skills/sops-add-key/SKILL.mdsource content
SOPS Add Key
Add a new machine's age public key to the project and re-encrypt all files so the new machine can decrypt them.
Workflow
-
Detect current state:
python3 ${CLAUDE_SKILL_DIR}/../sops-setup/scripts/detect_sops.py <project-root> -
Verify prerequisites:
must be true — if not, tell user to runproject.sops_yaml.exists
first/devtools:sops-setup
should be non-empty — warn if there are noproject.encrypted_files
files to re-encrypt.enc.yaml- If
is non-empty, warn about stale temporary files (leftover from a failed decrypt/re-encrypt) and suggest the user delete themproject.tmp_files
-
Audit key propagation (if encrypted files exist): For each encrypted file, read its YAML and check the
recipients list againstsops.age
. If any authorized key is missing from any file's recipients:project.sops_yaml.authorized_keysWARNING: Key age1xxx...yyy is in .sops.yaml but NOT a recipient in: - apps/web/.env.local.enc.yaml - apps/api/.env.local.enc.yaml These files need re-encryption before the corresponding machine can decrypt them.Offer to run
for each affected file before proceeding with the new key addition.sops updatekeys -y <file> -
Show current authorized keys from
:project.sops_yaml.authorized_keysCurrently authorized keys (N): 1. age1abc...def (truncated) 2. age1ghi...jkl (truncated) -
Use
— ask user to paste the new machine's age public key. Validate it starts withAskUserQuestion
.age1 -
Read
and add the new key to the.sops.yaml
field inage:
. Use thecreation_rules
tool to append the key to the comma-separated list or multi-line block.Edit -
Re-encrypt all files using
:sops updatekeyssops updatekeys -y <file>.enc.yamlFor each encrypted file. The
flag auto-confirms. This re-wraps only the data encryption key for the new recipient list — values and MAC are unchanged, producing a minimal diff.-yIf
is not available (older sops version), fall back to decrypt + re-encrypt:sops updatekeyssops --decrypt <file>.enc.yaml > <file>.tmp.yaml sops --encrypt <file>.tmp.yaml > <file>.enc.yaml rm <file>.tmp.yamlVerify: After re-encrypting, read each file's
recipients block and confirm all keys fromsops.age
(including the newly added key) appear as recipients. If any key is missing, warn the user that re-encryption may have failed..sops.yaml -
Summary:
| Action | Detail | |--------|--------| | Key added | age1xyz... (new machine) | | .sops.yaml | Updated (now N+1 authorized keys) | | Re-encrypted | .env.local.enc.yaml | | Re-encrypted | .env.production.enc.yaml |Remind user to commit both
and the updated.sops.yaml
files..enc.yaml
Key Rotation vs Key Addition
- Adding a key (
): Re-wraps the DEK for the new recipient list. Safe, minimal diff. Use for onboarding machines.sops updatekeys - Rotating keys (
): Generates a new DEK and re-encrypts every value. Use when a key is compromised or for periodic security hygiene.sops rotate -i - If the user mentions a compromised key, recommend
after removing the compromised key fromsops rotate -i
..sops.yaml
Key Rules
- Validate the public key format (must start with
) before modifyingage1.sops.yaml - Always show the current keys before adding a new one
- Re-encrypt ALL
files — missing any would lock out the new machine for those files.enc.yaml - Use
(not full decrypt/re-encrypt) for routine key additionssops updatekeys - After re-encryption, the new machine can clone and decrypt immediately