Skip to content

Repository files navigation

dotfiles

This is my own dotfiles repository.

Quick Start

cd ~/Develop/dotfiles
./bootstrap.sh

Usage

# Interactive mode (recommended for first setup)
./bootstrap.sh

# Non-interactive mode (for CI/automation)
./bootstrap.sh -y

# Dotfiles only (skip tool installation)
./bootstrap.sh --dotfiles-only

# Dry-run mode (preview changes without executing)
./bootstrap.sh -n

# Force mode (backup and overwrite existing files)
./bootstrap.sh -f

Options

Option Description
-y, --yes Skip confirmation prompts
-f, --force Force overwrite existing files (with backup)
-n, --dry-run Show what would be done without making changes
--dotfiles-only Skip tool installation, only setup dotfiles
-h, --help Show help message

What Gets Installed

Tools

  • Homebrew - Package manager
  • Rust - Rust toolchain
  • mise - dev tool / runtime version manager
  • Claude Code - AI coding assistant
  • Claude Code plugins - the marketplaces and plugins declared in home/.claude/settings.json (extraKnownMarketplaces + enabledPlugins) are registered and installed via claude plugin
  • apm - Agent Package Manager (skill/plugin の宣言的配信)

Dotfiles

ホームディレクトリに張る symlink の正本は bootstrap.sh にある(source と target の対応)。 追加・変更はそこを編集する(README に一覧を再掲すると必ず drift するため載せない)。

  • SYMLINK_PAIRS: source をリポジトリに持つもの。dotfiles 本体。
  • APM_SYMLINK_PAIRS: source を apm が配置するもの。apm install の前は実体が無いので、 存在するときだけ張る。

追加の Claude 設定ディレクトリ向けの pair は配列に書かず、既定の .claude/ 向け pair から 生成する。一覧は追跡外のローカル設定ファイルから読む(ディレクトリ名をこのリポジトリへ 書かないための外部化)。

Additionally, home/.gitconfig.private.example is copied to ~/.gitconfig.private (if it doesn't exist).

Claude Code 設定の管理

home/.claude/settings.json は ~/.claude/settings.json から symlink されており、リポジトリ内のファイルがそのまま live 設定である。committed と live は 1 本で、普通のファイルとして編集してコミットする。

以前は git update-index --skip-worktree で両者を分けていた。分ける理由はローカル絶対パスを持つ directory source の marketplace 宣言と、そこから来る plugin エントリの 2 つだったが、skill と plugin の供給を apm へ移したことで両方消えたため廃止した。

Claude Code は起動中に settings.json を書き換えることがある (承認した MCP サーバの記録など)。skip-worktree が無くなったのでその書き換えは git status に差分として現れる。意図しない差分はコミットせず git checkout -- home/.claude/settings.json で戻す。committed に置けないものの定義は config-guard の不変条件 (scripts/config-guard/src/config_guard/settings_invariants.py) が正本なので README には再掲しない。

config-guard は settings.json だけ working tree ではなく git の index から読む (git show :home/.claude/settings.json)。検査したいのはコミットされようとしている内容であって、未 stage の書き換えではないためである。skill や apm.yml など他の検査対象は working tree を読む。

committed 側は CI で 2 つの仕組みが守る。

  • gitleaks: secret と PII の漏洩を検出する。検出集合は .gitleaks.toml が正本なので README には再掲しない。
  • config-guard: 構造 curation (禁止キー・directory marketplace・dead config・不正なツール名) を検出する。

設定ディレクトリ間で共有するもの

複数の Anthropic アカウントを使い分けるため、projects/(メモリとセッションログ)は設定 ディレクトリごとに持たず、中立な実体への symlink にして共有する。どのアカウントから起動しても 同じ記憶を読む。実体の置き場と pair の生成は bootstrap.sh の claude_shared_symlink_pairs が正本。

bootstrap は既存の projects/ を移行しない。実体を持つ設定ディレクトリを 1 つでも見つけたら 警告して 1 件も張らずに抜ける。稼働中のセッションが開いているディレクトリを移すと、その ファイル記述子は移動先を指したまま書き続けてログが分岐するため、統合は内容を見ながらの 手作業に限る。

tirith によるコマンドセキュリティ

tirith(URL/コマンドセキュリティ CLI, 導入は home/.Brewfile)で実行前チェックを二層に張る。

  • 対話シェル: home/.zshrc の tirith init が zsh のコマンド実行前に検査する。
  • Claude Code: home/.claude/hooks/tirith-check.py を PreToolUse(Bash) フックに登録し、エージェントの Bash 実行前に tirith check へ委譲する。判定ロジックは本体、テストは scripts/claude-hooks を参照。

禁止語ガードのリストの参照

PUBLIC リポジトリへ書けない禁止語リストの在り処を、home/.zshenv が環境変数 LEAK_GUARD_DENYLIST で指す。検査本体は別リポジトリ (agentic-coding-tools) が持ち、ここの 持ち場は export の配線だけ。

指す先は中立な固定パスで、そこをリスト実体への symlink として人が手で張る。bootstrap.sh は この symlink を作らないので、新しいマシンでは張るまで検査が働かない。指す先のパスと、 bootstrap に作らせない理由と、判定に使う演算子の根拠は home/.zshenv のコメントが持つ。

apm による skill 配信 (vendored skills)

一部の Claude Code skill は自作せず、upstream から apm (Agent Package Manager) 経由で取り込む。宣言の正本は home/apm.yml、解決した commit と content hash の pin は home/apm.lock.yaml。

  • 取り込み: home/ で apm install --frozen(bootstrap の install_apm_packages が実行)。commit SHA pin で再現性を担保する。
  • deploy 先 skill (home/.claude/skills/<name>/) と fetch キャッシュ (home/apm_modules/) は再生成物なので gitignore する(home/.gitignore)。gitignore の追記漏れは config-guard が apm.lock.yaml の deployed_files と突合して検出する。自作 skill は従来どおり tracked。
  • upstream 追従は apm outdated / apm update で確認・更新する。
  • apm 管理 skill は gitignore されるため fresh checkout(CI 含む)では未展開で、config-guard の allowed-tools 検査対象外。整合性は apm.lock.yaml の content_hash pin と apm audit --ci で担保する(自作 skill の config-guard 検査とはスコープを分離)。

Testing

# all suites (bats)
bats scripts/tests/

# backup-tool (Python / pytest)
uv run --directory scripts/backup-tool pytest -q

# config-guard (Python / pytest)
uv run --directory scripts/config-guard pytest -q

# config-guard スキャン (skills + settings の stale 参照・構造逸脱検出)
# ここだけ --directory ではなく --project を使う。--directory は cwd を移すため引数の `.` が
# リポジトリルートを指さなくなり、skills の glob が 0 件のまま成功表示になる。
uv run --project scripts/config-guard config-guard .

# claude-hooks (Python / pytest) — Claude Code フック群の統合テスト
uv run --directory scripts/claude-hooks pytest -q

# ast-grep (構文レベル lint)。どちらのフラグも外すと結果が嘘になる
# --skip-snapshot-tests: rules/ はスナップショットを持たないので、外すと baseline 不在で全件 fail する
# --no-ignore hidden: 既定で隠しディレクトリを飛ばすので、外すと home/.config 配下を 1 件も見ずに exit 0
ast-grep test --skip-snapshot-tests
ast-grep scan --no-ignore hidden

# apm 配信 skill の lockfile 整合性 / drift ゲート (違反時 exit 1)
( cd home && apm audit --ci )

About

dotfiles.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages