| name | mirror-dotfiles |
| description | ローカル設定→dotfiles repo の triage 同期。$HOME の設定ファイルを変更後 repo へ反映したい時に使用。差分を commit/skip/sanitize 対話判断し、ハードコードパス/secrets を除去して ~/.dotfiles に commit & push。 |
/mirror-dotfiles
$HOME の管理対象ファイルと ~/.dotfiles/ を比較し、triage しつつ repo に反映する。
管理対象
以下のファイル/ディレクトリのみ対象(dotfiles repo に存在するもの):
$HOME/.zshrc ↔ ~/.dotfiles/.zshrc
$HOME/.bashrc ↔ ~/.dotfiles/.bashrc
$HOME/.bash_profile ↔ ~/.dotfiles/.bash_profile
$HOME/.profile ↔ ~/.dotfiles/.profile
$HOME/.gitconfig ↔ ~/.dotfiles/.gitconfig
$HOME/Brewfile ↔ ~/.dotfiles/Brewfile
$HOME/.config/shell/env.sh ↔ ~/.dotfiles/.config/shell/env.sh
$HOME/.config/shell/aliases.sh ↔ ~/.dotfiles/.config/shell/aliases.sh
$HOME/.config/fish/config.fish ↔ ~/.dotfiles/.config/fish/config.fish
$HOME/.config/fish/fish_plugins ↔ ~/.dotfiles/.config/fish/fish_plugins
$HOME/.config/starship.toml ↔ ~/.dotfiles/.config/starship.toml
$HOME/.config/mise/config.toml ↔ ~/.dotfiles/.config/mise/config.toml
$HOME/.config/gh/config.yml ↔ ~/.dotfiles/.config/gh/config.yml
$HOME/.config/karabiner/karabiner.json ↔ ~/.dotfiles/.config/karabiner/karabiner.json
$HOME/.config/git/ignore ↔ ~/.dotfiles/.config/git/ignore
対象外(同期しない):
~/.config/gh/hosts.yml — auth 情報
~/.ssh/ — 公開鍵のみ、1Password 管理
~/.claude/ — Claude Code state(別 repo)
~/.config/fish/functions/ — fisher 生成物 + 別 repo の混在
~/.config/fish/conf.d/* — fisher 自動生成
- 上に列挙されていない任意の
~/.config/* 配下のファイル
ワークフロー
Step 1. 差分検出
各管理対象ファイルについて diff $HOME/<path> ~/.dotfiles/<path> を取得。
状態を 4 分類:
| 状態 | 意味 | デフォルトアクション |
|---|
| identical | 差分なし | 何もしない |
| local-only | $HOME のみに存在 | dotfiles に新規追加候補(要 triage) |
| dotfiles-only | ~/.dotfiles/ のみに存在 | $HOME にデプロイ漏れ(rsync 推奨) |
| diff | 内容差分あり | 要 triage |
Step 2. ユーザに差分提示
各 diff / local-only について以下を提示し、選択肢を渡す:
[N/M] ~/.zshrc
─────────────────────────────────
- # Rancher Desktop ブロック
- export PATH="/Users/yuki.c.watanabe/.rd/bin:$PATH"
+ (なし)
─────────────────────────────────
Action: [c]ommit / [s]kip / [z]sanitize / [v]iew full / [e]dit
- commit: diff をそのまま
~/.dotfiles/ 側に反映
- skip: local 固有のためrepo に入れない。次へ進む
- sanitize: Claude が triage(ハードコードパス除去 / secrets 削除 / コメント整形)してから反映
- 例:
/Users/<user>/path → $HOME/path または ~/path に書換
- 例:
signingkey ssh-ed25519 AAAA... → 削除(user が個別設定)
- 例: API token / credentials → 削除
- view full: 全ファイル内容を表示
- edit: user が手動で repo 側を編集
Step 3. Sanitize の判断基準
Claude は以下のパターンを自動検出し、sanitize 候補を user に提案:
| パターン | 処理 |
|---|
/Users/<username>/... | $HOME/... または ~/... に置換 |
ssh-ed25519 AAAA...(gitconfig signingkey) | 削除 + コメントで「個別設定」と明記 |
MANAGED BY RANCHER DESKTOP ブロック | 削除(dotfiles 管理対象外) |
password = ..., token = ..., api_key = ... | 削除 + 警告 |
*.dena.com, *.dena.jp メール | 削除(業務 local 設定) |
~/google-cloud-sdk/path.bash.inc 等の絶対パス | 削除(gcloud は最小構成から外したため) |
検出後、user に確認:
sanitize 候補:
L12: /Users/watanabe-yuki3/.bun → $HOME/.bun に書換
L18: signingkey ssh-ed25519 AAAA... → 削除(ユーザ個別設定)
適用する? [y/n/edit]
Step 4. dotfiles repo に反映 + commit
すべての triage 完了後:
cd ~/.dotfiles
git add -A
git status
git diff --cached
user に最終確認 → commit メッセージ生成(git-cz 風、prefix 以外は日本語):
chore: 設定ファイルをローカル状態と同期
- .zshrc に bun completions を追記
- .config/fish/config.fish に <変更>
push:
git push origin main
安全装置
- dotfiles repo の状態確認: 開始前に
git status で uncommitted changes 有無を確認、あれば user 確認
- dry-run option: skill 起動時 user が「dry-run」と指定したら、commit/push せず diff 確認のみ
- secrets スキャン: token/password らしき文字列は必ず警告
- rollback: 直前の commit に戻したい場合は
git reset --soft HEAD~1 を提示
制限
- バイナリファイルは対象外(textual config のみ)
~/.config/karabiner/karabiner.json は JSON だが diff 可能
~/.dotfiles/scripts/ ~/.dotfiles/README.md ~/.dotfiles/.claude/ は対象外(mirror 不要、user が直接編集)
実行例
user: /mirror-dotfiles
claude:
[1/15] ~/.zshrc - identical, skip
[2/15] ~/.bashrc - identical, skip
[3/15] ~/.gitconfig - DIFF detected:
ローカル side に signingkey = ssh-ed25519 AAAA... が追加
Action [c/s/z/v/e]: z
claude: sanitize 提案:
L4: 削除 (signingkey は user 個別設定とコメント化)
適用? [y/n]: y
[4/15] ~/Brewfile - identical, skip
...
15個中 1個更新。
変更内容:
modified: .gitconfig (signingkey コメント化)
commit する? [y/n]: y
commit message:
chore: .gitconfig の signingkey をテンプレ化
push する? [y/n]: y
✅ pushed to origin/main