Secrets Sync with Chezmoi

VerifiedCaution

Manage chezmoi-managed secrets: add, edit, list, apply, sync Bitwarden sessions, and run GPG encryption. Also troubleshoot chezmoi config path issues.

Sby Skills Guide Bot
SecurityIntermediate
7/23/2026
Claude CodeCodex
#secrets-management#chezmoi#bitwarden#gpg#dotfiles

Recommended for

Automated summary

Manages a repository's secrets through chezmoi with a project-local config, Bitwarden templates, GPG encryption, and the .secrets submodule.

Strengths

  • Gives the exact command per operation (add, edit, list, apply, diff) including the mandatory --config flag
  • Documents the source-of-truth chain from Bitwarden to .env.bitwarden to chezmoi templates to target files
  • Calls out real pitfalls: uncommitted submodule pointer, direct chezmoi add being refused, accidentally hitting the global config
  • The chezmoi-add-secret.sh helper handles dot_ and encrypted_ prefixes and auto-sources the Bitwarden session

Limitations

  • Heavily repo-specific: paths, the GPG key ID and the config location do not transfer to other projects
  • Assumes chezmoi, the Bitwarden CLI and GPG are already installed and configured
  • Does not address secret rotation or leak-response procedures
When to use it

Use it whenever you need to add, edit, list or apply a chezmoi-managed secret in this repository.

When not to use it

Avoid it for secrets outside this repo or for projects that rely on a standard global chezmoi config.

Security analysis

Caution
Quality score86/100

The skill is a legitimate secrets-management workflow using chezmoi, Bitwarden, GPG, and git. It contains no exfiltration, destructive commands, obfuscated payloads, or safety-disabling instructions, but it does handle live secrets and executes repo-local scripts with file-modifying operations, so it warrants caution rather than a clean safe rating.

Findings
  • •Instructs sourcing a Bitwarden session script (`source_bitwarden_session.sh`), exposing `BW_SESSION` to the shell and relying on a repo-local script not included in the SKILL.md.
  • •Runs `chezmoi apply` and `merge`, which can modify or overwrite target project files; `diff` is recommended but not enforced before applying.
  • •References helper scripts (`chezmoi-add-secret.sh`, `source_bitwarden_session.sh`) whose actual behavior cannot be verified from this file alone.
How this analysis is made

Examples

Add a new secret
Add DATABASE_URL as a new chezmoi-managed secret in this repo and make sure it gets encrypted.
Apply and verify secrets
Source my Bitwarden session, apply the chezmoi secrets with the project config, and show me the diff before anything lands.
Troubleshoot chezmoi
chezmoi seems to be editing the wrong files - check whether this repo's .chezmoi.toml is being used and list the managed files.

name: secrets-sync description: "Use when the user adds, edits, lists, or applies chezmoi-managed secrets; syncs Bitwarden sessions; runs GPG encryption on project files; or works with the .secrets submodule. Also use when troubleshooting chezmoi config path issues in this repository."

secrets-sync

All chezmoi commands in this repo require --config ./.chezmoi.toml because the config is project-local, not in ~/.config/chezmoi.

Source-of-Truth Chain

digraph secrets {
  rankdir=LR;
  node [shape=box];
  "Bitwarden" -> ".env.bitwarden" -> "chezmoi templates\n(.secrets/)";
  "chezmoi templates\n(.secrets/)" -> "chezmoi apply" [shape=plaintext];
  "chezmoi apply" -> "target files\n(project root)";
}

Quick Reference

| Operation | Command | |---|---| | Add new secret | ./dotfile-utils/scripts/chezmoi-add-secret.sh [--encrypt] <path> | | Edit existing secret | Edit file in place, then chezmoi --config ./.chezmoi.toml merge <path> to sync back to source | | List managed files | chezmoi --config ./.chezmoi.toml managed | | Apply secrets | chezmoi --config ./.chezmoi.toml apply | | Check diff | chezmoi --config ./.chezmoi.toml diff | | Source Bitwarden | source ./dotfile-utils/scripts/source_bitwarden_session.sh | | Stage in submodule | chezmoi --config ./.chezmoi.toml git -- add <chezmoi-path> |

Workflow

  1. Determine operation: add / edit / list / apply
  2. If working with encrypted or Bitwarden-templated secrets, source the Bitwarden session first (auto-sourced by helper script when .env.bitwarden exists or BW_SESSION is set)
  3. Run the correct command from the table above
  4. Verify with managed or diff
  5. Stage changes inside .secrets submodule
  6. Remind user to commit the updated submodule pointer in the parent repo

Key Facts

  • Config flag required: Every chezmoi invocation needs --config ./.chezmoi.toml
  • GPG key ID: 9A4ABBA2F90BCF19
  • .secrets is a git submodule -- changing files inside it means the parent repo sees a dirty submodule pointer that must also be committed
  • chezmoi-add-secret.sh handles dot-prefix conversion (.env -> dot_env) and encrypted_ prefix automatically; it also auto-sources Bitwarden if .env.bitwarden exists
  • Source dir: .secrets/ (set via sourceDir in .chezmoi.toml)
  • Dest dir: project root . (set via destDir in .chezmoi.toml)

Common Mistakes

  • Running bare chezmoi without --config ./.chezmoi.toml (will use ~/.config/chezmoi and operate on the wrong source)
  • Forgetting to commit the submodule pointer in the parent repo after changing .secrets
  • Using chezmoi add directly instead of chezmoi-add-secret.sh for project files (chezmoi refuses to add files from its own dest dir)

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/secrets-sync-with-chezmoi-mrx3xwj6/download' --output '.skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6/SKILL.md.part' && mv '.skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6/SKILL.md.part' '.skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Original excerpt: Quick Reference
OperationCommand
Add new secret./dotfile-utils/scripts/chezmoi-add-secret.sh [--encrypt] <path>
Edit existing secretEdit file in place, then chezmoi --config ./.chezmoi.toml merge <path> to sync back to source
List managed fileschezmoi --config ./.chezmoi.toml managed
Apply secretschezmoi --config ./.chezmoi.toml apply
Check diffchezmoi --config ./.chezmoi.toml diff
Source Bitwardensource ./dotfile-utils/scripts/source_bitwarden_session.sh
Stage in submodulechezmoi --config ./.chezmoi.toml git -- add <chezmoi-path>

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6/SKILL.md' && test -s '.skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/secrets-sync' && cp -R '.skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6' '.claude/skills/secrets-sync'

Codex
test -f '.skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6/SKILL.md' && test -s '.skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/secrets-sync' && cp -R '.skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6' '.agents/skills/secrets-sync'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6'

openskills read 'secrets-sync-with-chezmoi-mrx3xwj6'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/secrets-sync-with-chezmoi-mrx3xwj6/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills