Sops setup

From joaquimscosta/arkhe-claude-plugins · View interactive version

Sops setup is an AI agent skill from the GitHub repository joaquimscosta/arkhe-claude-plugins. Set up SOPS + age encryption for sharing .env files securely across machines. Detects existing state, installs tools, generates age keys, creates .sops.yaml, and encrypts .env files as YAML (avoids SOPS dotenv bug #1435). Use when user mentions "sops setup", "encrypt env", "share secrets", "secure e

How to use this skill

Skill file

SOPS + age Setup Wizard

Interactive setup for SOPS + age encryption. Detects current state and guides through configuration.

Important: This skill uses YAML format for encrypted files (not dotenv) because SOPS has a known bug (#1435) where the dotenv store corrupts backslash and \n sequences on decrypt. A helper script handles dotenv↔YAML conversion transparently.

Pre-flight

Run the detection script to understand current state:

python3 ${CLAUDE_SKILL_DIR}/scripts/detect_sops.py <project-root>

Two-Phase Workflow

Phase 1: Detect

  1. Run the detector on the project root:

```bash

python3 ${CLAUDE_SKILL_DIR}/scripts/detect_sops.py <project-root>

```

  1. Summarize findings — show a status table:

| Component | Status | Detail |

|-----------|--------|--------|

| sops binary | installed/missing | version, path |

| age binary | installed/missing | version, path |

| age key | exists/missing | public key (truncated) |

| .sops.yaml | exists/missing | # of authorized keys |

| .env files | N found | list of filenames |

| encrypted files | N found | list of *.enc.yaml files |

| .gitignore | ok/needs update | env ignored, enc.yaml not ignored |

Phase 2: Configure

Walk through each missing component. Skip steps where detection shows everything is already configured.

  1. Install tools (if tools.sops.installed or tools.age.installed is false):
  1. Generate age key (if age_key.exists is false):
  1. Generate backup key (recommended):

```bash

age-keygen 2>&1 | tee /dev/stderr | grep "public key:" | awk '{print $NF}'

```

Display BOTH the public key AND the full output (which includes the private key).

Tell user: Copy the entire output (including the private key line starting with AGE-SECRET-KEY-) to a password manager or secure offline storage. This is your recovery key.

  1. Create .sops.yaml (if project.sops_yaml.exists is false):

```yaml

creation_rules:

age: >-

<machine-public-key>,

<backup-public-key>

```

  1. Set up .gitattributes for diff-friendly encrypted files:

```

*.enc.yaml diff=sopsdiffer

```

```bash

git config diff.sopsdiffer.textconv "sops decrypt"

```

  1. Update .gitignore (if needed):
  1. Encrypt files (if project.env_files is non-empty):

```bash

python3 ${CLAUDE_SKILL_DIR}/scripts/dotenv_yaml.py to-yaml <file> > <file>.enc.yaml.tmp

sops --encrypt <file>.enc.yaml.tmp > <file>.enc.yaml

rm <file>.enc.yaml.tmp

```

Example: .env.local → .env.local.enc.yaml

  1. Confirmation summary — show table of all actions taken:

```

| Step | Action | Result |

|------|--------|--------|

| Tools | sops 3.9.4, age 1.2.0 | installed |

| Key | Machine key generated | age1abc...def |

| Key | Backup key generated | age1xyz...uvw (save offline!) |

| Permissions | chmod 600 keys.txt | done |

| Config | .sops.yaml created | 2 keys authorized |

| Git | .gitattributes updated | sopsdiffer configured |

| Git | .gitignore updated | .env* ignored |

| Encrypt | .env.local → .env.local.enc.yaml | done |

## Next Steps

```

Key Rules

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.