跳到正文
Skillpedia
部署与云(DevOps)20k · #10422

Dotfiles

它能做什么

把你的 shell 设置和选定的配置文件夹备份到私有 GitHub 仓库中。它适用于希望在每台机器上都拥有相同设置、又不想泄露机密的人。

适用场景

  • ✓当你想把 shell 设置备份到私有 GitHub 仓库的时候。
  • ✓当你想从之前的备份恢复配置文件的时候。
  • ✓当你想检查本地配置是否与仓库存在差异的时候。

技能链接

https://github.com/danielmiessler/LifeOS/blob/main/LifeOS/install/skills/Dotfiles/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/danielmiessler/LifeOS/blob/main/LifeOS/install/skills/Dotfiles/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请把我的 shell 配置和我列出的配置文件夹备份到我的私有 dotfiles 仓库。”

每周 5 个新技能,1 分钟读完。

工作原理

该技能会先检查 GitHub 仓库是私有的,然后在推送前扫描将要推送的内容,查找令牌等机密信息。只复制你选择的文件,恢复时会先进行带时间戳的备份。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

System Dotfiles Management Skill

Contents: Ideal State · Intent Routing · Data & Config · Tool contract · Gotchas · Examples

Manages ~/.zshrc and ~/.config/ against a private GitHub dotfiles repo; the directories under ~/.config that Backup and Restore copy are the ones you list in Config.md (DOTFILES_CONFIG_DIRS). Push local config up, pull it down, sync two-way, restore from a timestamped backup, or check status — with a gitleaks content scan of the staged diff and of every unpushed commit that stops the push on any secret, or when gitleaks is not installed.

The working clone lives at $DOTFILES_DIR and tracks the private remote $DOTFILES_REPO. Push is the default intent; Pull, Sync and Status only compare, Restore is the one intent that overwrites local files, and Backup makes a local copy that never leaves the machine.

Ideal State

  • Every push lands only in $DOTFILES_REPO, after GitHub reported it private (gh repo view --json isPrivate printed true) both before any other Push step and again just before the push, and after gitleaks exited 0 on the staged diff and on every unpushed commit; any failed check, or gitleaks missing, stopped the run before a commit or push.
  • Only configs enter the repo or a backup: Push copies and stages the files the repo already tracks, a new config enters by name, every local backup (Backup, and Restore's backup before it overwrites) copies the DOTFILES_CONFIG_DIRS directories with secret files excluded, and Restore's also copies every tracked .config file it will overwrite, and the whole ~/.config is never copied or staged.
  • Every comparison of local and repo (Pull, Sync, Status, and Restore's check after it copies) covers .zshrc and the files git ls-files .config lists, so a report names only real dotfile differences and a clean machine reports none.
  • No local file is overwritten before a timestamped backup exists in $DOTFILES_BACKUPS and the user confirmed; Pull, Sync and Status leave every local file unchanged.
  • Every run reports the files it changed, the repository it verified, the security check result, the commit hash when it committed, and the next intent to run.

Intent Routing

Intent Trigger File
Push "push dotfiles", "update dotfiles" (default) Intents/Push.md
Pull "pull dotfiles", new machine setup Intents/Pull.md
Sync "sync dotfiles", unsure of direction Intents/Sync.md
Restore "restore dotfiles", recover config Intents/Restore.md
Status "check dotfiles status", "dotfiles status" Intents/Status.md
Backup "backup dotfiles", local timestamped copy Intents/Backup.md
File Read when
Setup.md first-time setup, or Tools/Config.ts stopped on a missing Config.md or key

Data & Config

This skill ships no personal data. All private values live in the USER tree at <configRoot>/LIFEOS/USER/CUSTOMIZATIONS/SKILLS/Dotfiles/Config.md (configRoot is $CLAUDE_CONFIG_DIR when set, else ~/.claude): the keys DOTFILES_DIR, DOTFILES_BACKUPS, DOTFILES_REPO, DOTFILES_REPO_SLUG and DOTFILES_CONFIG_DIRS. Every intent opens with this Config command, which runs Tools/Config.ts, exports those keys and exits non-zero (stopping the intent) when the file or a required key is missing. Nothing has a built-in default. First-time setup: Setup.md.

DOTFILES_ENV="$(bun ~/.claude/skills/Dotfiles/Tools/Config.ts)" || exit 1; eval "$DOTFILES_ENV"   # exports DOTFILES_DIR, DOTFILES_BACKUPS, DOTFILES_REPO, DOTFILES_REPO_SLUG, DOTFILES_CONFIG_DIRS

Tool contract

Recipes two or more intents share. Each runs after the Config command.

Remote check — the remote is the configured repo AND GitHub says it is private

Push runs it before any other step and again before the push. Status runs it inside a subshell, ( … ), so a STOP line becomes the report's remote warning and the rest of the report still runs. In Push, any STOP line ends the intent: no pull, no commit, no push.

cd "$DOTFILES_DIR" || { echo "STOP: no dotfiles clone at $DOTFILES_DIR"; exit 1; }
REMOTE=$(git remote get-url origin) || { echo "STOP: the clone has no origin remote"; exit 1; }
[ "$REMOTE" = "$DOTFILES_REPO" ] || { echo "STOP: origin is $REMOTE, expected $DOTFILES_REPO"; exit 1; }
PRIVATE=$(gh repo view "$REMOTE" --json isPrivate -q .isPrivate) || { echo "STOP: cann
常见问题

它会推送到公开仓库吗?

不会。它在推送前会检查仓库是否为私有,如果不是,就会停止。

如果发现机密信息会怎样?

推送会被阻止,因此 .env 文件或令牌等机密不会离开你的电脑。

它会动我没有选择的文件吗?

不会。只复制你的 shell 文件和你列出的配置文件夹。

详情

作者的原始描述

Manage ~/.zshrc and a chosen set of ~/.config/ directories (you name them in Config.md) against a private GitHub dotfiles repo. Intents: Push (verify private remote, scan secrets), Pull (clone/diff), Sync, Restore (timestamped backup), Status, Backup (local timestamped copy). Security scan blocks .env, secrets, tokens before push. NEVER commits to public repos. USE WHEN dotfiles, push/pull/sync dotfiles, zshrc, restore config, backup config, new machine setup. NOT FOR app configs unrelated to shell/editor/terminal.

repo: danielmiessler/LifeOS

热度

GitHub 星标
20k
排名
#10422
许可证
MIT
更新时间
2026/10/28

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能