agentleFS
VeriTeknikVeriTeknik/pluggedin-app/.claude/skills/sops-secrets/SKILL.md

sops-secrets

Skill103 starsChanged 4 months agoMITView on GitHub

Use when adding, changing, reading or rotating a secret in infra/sops/secrets.env.sops, adding an age recipient, or when sops reports "Error unmarshalling input json", "Config file not found", or "no matching creation rules found" in this repo.

  • Reads credentials

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. yktsnet/dotfiles-public★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repositoryOne other file it gives its agents.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    All production secrets live encrypted in infra/sops/secrets.env.sops, age-encrypted and committed to a public repo.

    line 8
  2. Very specific:

    Write values literally — no escaping of any kind.

    line 47
  3. Very specific:

    If the new secret is consumed via *_FILE indirection rather than by the app (as Traefik's dashboard auth and the Postgres password are), …

    line 57
  4. Very specific:

    Add the public key to the age: list in .sops.yaml at the repo root, then re-wrap the data key from the repo root:

    line 64
  5. Distinctive:

    Always include the negative case.

    line 99
  6. Very specific:

    Only values are encrypted.

    line 104

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SOPS secrets for plugged.in

All production secrets live encrypted in infra/sops/secrets.env.sops, age-encrypted and committed to a public repo. deploy.sh decrypts them to tmpfs at deploy time.

Core rule: every sops command on this file needs explicit dotenv types. The filename ends .sops, which sops does not recognise, so it falls back to JSON and dies on the first # comment:

Error unmarshalling input json: invalid character '#' looking for beginning of value

Seeing that error means you forgot --input-type dotenv --output-type dotenv.

Quick reference

TaskCommand
Read a valuesops -d --input-type dotenv --output-type dotenv infra/sops/secrets.env.sops | grep '^KEY='
Add / change a secretsops --input-type dotenv --output-type dotenv infra/sops/secrets.env.sops
Add an age recipientdecrypt → re-encrypt, see below
Apply to production./infra/scripts/deploy.sh — required, see below

Always export SOPS_AGE_KEY_FILE=/etc/sops/age/keys.txt first.

Adding or changing a secret

export SOPS_AGE_KEY_FILE=/etc/sops/age/keys.txt
sops --input-type dotenv --output-type dotenv infra/sops/secrets.env.sops
# $EDITOR opens the decrypted content; add KEY=value; save
git commit -am "ops: add KEY"
./infra/scripts/deploy.sh

The deploy is not optional. deploy.sh is what decrypts the blob to /run/sops/secrets.env, which containers mount. Editing the blob without deploying changes nothing that is running, and the next unrelated deploy will silently pick the change up — which is how a config change gets blamed on the wrong commit.

Write values literally — no escaping of any kind. Nothing between sops and the process interpolates: the app parses the mounted file with dotenv and Postgres reads a *_FILE. A $ you double becomes a literal $$.

(Historical note, because the reverse used to be true: while services used env_file:, Compose interpolated it and truncated values at the first $, so deploy.sh doubled them. That step was removed when secrets moved out of the environment — keeping it would have corrupted exactly the bcrypt-shaped secrets it was added to protect.)

If the new secret is consumed via *_FILE indirection rather than by the app (as Traefik's dashboard auth and the Postgres password are), add an extract_secret line to deploy.sh too — otherwise the file it points at never appears and the consumer fails closed.

Adding an age recipient

Add the public key to the age: list in .sops.yaml at the repo root, then re-wrap the data key from the repo root:

export SOPS_AGE_KEY_FILE=/etc/sops/age/keys.txt
sops updatekeys --input-type dotenv -y infra/sops/secrets.env.sops

--input-type dotenv is required here as everywhere else. Verify with the negative test below before committing.

.sops.yaml must stay at the repo root. sops searches upward from the working directory and matches path_regex against the path as given, so with the config inside infra/sops/ neither location worked — the repo root gave Config file not found, and running from inside the directory found the config but matched a bare filename and gave no matching creation rules found.

Verifying who can decrypt — isolate HOME or the test lies

sops falls back to the default keyring at ~/.config/sops/age/keys.txt. If a copy of the deploy key is there, every decryption test passes, including with a key that is not a recipient at all — a stranger key appearing to read 91 secrets is that false positive, not a breach. That copy has since been removed from this host, but isolate HOME anyway: the test should not depend on a file's continued absence.

EMPTY=$(mktemp -d)
# must succeed
HOME="$EMPTY" SOPS_AGE_KEY_FILE=/etc/sops/age/keys.txt \
  sops -d --input-type dotenv --output-type dotenv infra/sops/secrets.env.sops | grep -c '^[A-Z_0-9]*='
# must print 0 and "none were successful"
HOME="$EMPTY" SOPS_AGE_KEY_FILE=/path/to/non-recipient.txt \
  sops -d --input-type dotenv --output-type dotenv infra/sops/secrets.env.sops

Always include the negative case. A test that only checks the happy path cannot tell "the key works" from "the keyring rescued me".

What is and is not protected

Only values are encrypted. Key names are plaintext in the committed file — grep GITHUB infra/sops/secrets.env.sops reveals which integrations exist. Never encode anything sensitive in a variable name.

The repo is public and git history is append-only: once pushed, that ciphertext is public permanently, and the age private key is the only thing protecting it. Rotating a secret later protects you from that point forward; it does not unpublish the old blob.

Known issues

  • Third-party credentials in the blob are un-rotated (provider API keys, OAuth client secrets, GitHub tokens, SMTP, k8s) — a deliberate deferral, tracked in docs/ops/docker-traefik-sops-migration.md.

Common mistakes

MistakeResult
Omitting --input-type dotenvError unmarshalling input json
Editing the blob without deploy.shRunning containers keep the old value
Pre-escaping $ in a valueDoubled twice, value corrupted
Testing decryption without isolating HOMEFalse pass — the default keyring answers
Adding a *_FILE secret without touching deploy.shConsumer fails closed

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.