Sops age git encryption

From CarlosCaPe/octorato · View interactive version

Sops age git encryption is an AI agent skill from the GitHub repository CarlosCaPe/octorato. SOPS + age (per-user keys) as the default encryption stack for HIPAA / GDPR / SOC-2 / regulated-data git repos. Two-layer envelope (SOPS AES-256-GCM for values + age X25519/ChaCha20-Poly1305 for key wrap), per-user revocation in one command, no GPG fragility. Includes encrypt-vs-clear matrix, key cu

How to use this skill

Skill file

SOPS + age Git Encryption

What

A default encryption stack for git repos that hold regulated content (PHI, PII, PCI, controlled-classified data, internal architecture chats with patient identifiers, raw API payloads from a SaaS like Microsoft Graph). Encrypted blobs are committed to the repo as ciphertext; per-user age keys decrypt locally. Per-user revocation requires only a recipient-list edit, not a full repo rewrite.

Why

Most regulated engagements eventually face the question: "we want to commit transcripts / raw API exports / embeddings — how?"

The wrong defaults cost real money:

SOPS + age beats those alternatives on:

How the Two Layers Compose (Precise)

This is the single point most descriptions get wrong. Get it right and crypto reviewers nod.

Two independent layers. SOPS-AES-GCM (value layer) + age-X25519/ChaCha20-Poly1305 (key-wrap layer). Don't conflate them in the doc.

Project Status (correct as of 2026)

Encrypt-vs-Clear Matrix

| Path pattern | Encrypted? | Reason |

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

| users/*/transcripts/* | ✅ | Raw meeting text, regulated-suspect |

| users/*/raw/** | ✅ | Raw API payloads (mail bodies, chat content) |

| users/*/embeddings/<date>.json | ✅ | Vectors derived from regulated content |

| users/*/_inventory.json | ✅ | Org metadata (people, sites) — quasi-identifiers |

| users/*/_health.log | ✅ | May include error context with regulated content |

| users/*/digests/*.md | ❌ | Already PHI-scrubbed by pipeline |

| users/INDEX.md | ❌ | Hash → email mapping (not regulated) |

| <arm>/knowledge.json | ❌ | Project roadmap; no regulated content |

| lib/, *.js, configs | ❌ | Source code — must be code-reviewable |

Rule: encrypt regulated paths; keep source code clear. Encrypting code defeats PR review.

Implementation (10 steps, ~30 min on a clean repo)

# 1. Install (user-scope, no admin)
winget install Mozilla.SOPS FiloSottile.age      # Windows
# brew install sops age                            # macOS
# apt install sops age                             # Debian/Ubuntu

# 2. Generate age keypair tied to a specific laptop (BitLocker / FileVault protected)
age-keygen -o ~/.config/sops/age/keys.txt
# Public key prints to stdout — copy it for step 3
# Add ~/.config/sops/age/keys.txt to .gitignore (NEVER commit)

# 3. Create <arm>/.sops.yaml declaring path regexes + recipients
cat > <arm>/.sops.yaml <<'EOF'
creation_rules:
  - path_regex: clients/[^/]+/users/.*/(transcripts|raw|embeddings)/.*
    age: >-
      age1xxx... # operator@example.com
EOF

# 4. Encrypt existing regulated files in place
sops -e -i clients/<arm>/users/<slug>/transcripts/*.txt

# 5. Update .gitignore to remove now-encryptable paths from the ignore list
# (they're now safe to commit as ciphertext)

# 6. Add a pre-commit hook that blocks plaintext commits to regulated paths
# Verifies the first ~200 bytes of each regulated-path file include a `sops:` marker

# 7. Add a GitHub Actions audit job (.github/workflows/regulated-audit.yml)
# Server-side gate — fails if any file under regulated paths is unencrypted

# 8. Commit + push (encrypted blobs go to remote)
git add .
git commit -m "feat: enable SOPS+age encryption for regulated paths"
git push

# 9. Verify by clone-without-key
git clone <repo> /tmp/clone-test
cd /tmp/clone-test
cat clients/*/users/*/transcripts/*  # should be ciphertext, not plaintext

# 10. Document in <arm>/SECURITY.md
# Encryption policy, key rotation schedule (quarterly is HIPAA-friendly),
# onboarding/offboarding ceremony, break-glass restore

Key Custody Decision Tree

| Scope | Recommended custody |

|---|---|

| Solo consultant on a single client laptop | Single age key on that laptop (BitLocker/FileVault protected) |

| 2–3 consultants on one engagement | Each consultant has own age key; recipient list in .sops.yaml includes all |

| Team grows past 3, OR auditor asks for decrypt logs | Upgrade to SOPS + KMS (Azure Key Vault / AWS KMS / GCP KMS); KMS produces decrypt audit logs |

| Highest sensitivity (real patient identifiers, not just adjacent data) | KMS with hardware token (YubiKey) for break-glass |

Cross-Arm Boundary (Octopus rule)

Each client repo gets its OWN .sops.yaml with client-scoped recipients. Same consultant uses different age keys per arm:

~/.config/sops/age/<arm-1>.key
~/.config/sops/age/<arm-2>.key

Shared keys across arms would break arm isolation. Don't.

When to Upgrade to KMS

| Trigger | Why KMS now |

|---|---|

| Team grows past 3 consultants | Per-user revocation still works with age, but log management gets unwieldy |

| Auditor asks: "prove who decrypted this and when" | age provides confidentiality + revocation but NOT decrypt audit trails. Only KMS gives that (HIPAA §164.312(b)). |

| BAA scope expands to actual patient identifiers | Higher sensitivity → higher control requirements |

| Client provisions a Key Vault for the consultant team | Use it; integrates cleanly with SOPS via --kms / --azure-kv flags |

Pitfalls

Anti-patterns

| Anti-pattern | Why it fails |

|---|---|

| git-crypt + GPG | Per-user revocation requires full repo rewrite; GPG fragility |

| transcrypt | Less mature, niche |

| Encrypting source code | Defeats PR review |

| Single shared symmetric key across team | No per-user revocation possible |

| Storing age private key alongside .sops.yaml in the repo | Defeats encryption entirely |

| Skipping the pre-commit + CI audit | Eventually someone forgets sops -e and pushes plaintext |

| Skipping SECURITY.md | Auditor needs the paper trail; without it, the technical solution is fine but the audit fails |

Composability

Lessons Learned

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.