Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Claude Codeをdotfiles管理しよう! / Let's Manage Claud...

Avatar for shuntaka shuntaka
August 08, 2025
10

Claude Codeをdotfiles管理しよう! / Let's Manage Claude Code with Dotfiles!

Avatar for shuntaka

shuntaka

August 08, 2025
Tweet

More Decks by shuntaka

Transcript

  1. Jsonnetを使った簡易なMCP設定の生成 8 local secrets = import 'secrets.jsonnet'; { mcpServers: {

    "github": { "type": "http", "url": "https://api.githubcopilot.com/mcp", "headers": { "Authorization": "Bearer " + secrets.github.token } }, }, } シークレットはignoreする .mcp-general.json json生成 $ jsonnet xx.jsonnet > .mcp-general.json
  2. .mcp-general.json .config/claude/.claude.json .config/claude/.claude.json mcpServersプロパティを削除 jq 'del(.mcpServers) + $$mcp[0]' ~/.config/claude/.claude.json --slurpfile

    mcp ~/dotfiles/home-manager/programs/mcp/.mcp-claude-code.json > ~/.config/claude/.claude.json.tmp && mv ~/.config/claude/.claude.json.tmp ~/.config/claude/.claude.json ClaudeCodeは既存設定ファイルをjqで置換 jqで削除と結合 11
  3. 17 "hooks": { "Stop": [ { "matcher": "", "hooks": [

    { "type": "command", "command": "~/dotfiles/home-manager/programs/claude/hooks/notify.ts" } ] } ], "Notification": [ {  "matcher": "", "hooks": [ { "type": "command", "command": "~/dotfiles/home-manager/programs/claude/hooks/notify.ts" } ] } ] }, #!/etc/profiles/per-user/shuntaka/bin/denor un --allow-run --allow-env // (中略) if (data.hook_event_name == "Stop") { process = new Deno.Command("osascript", { args: [ "-e", `display notification "Task Completed 🚀" with title "⚡ Claude Code" subtitle "${repoInfo} 📦"`, ], stdout: "piped", stderr: "piped", }); } else if (data.hook_event_name == "Notification") { process = new Deno.Command("osascript", { args: [ "-e", `display notification "Awaiting Confirmation 🔔" with title "⚡ Claude Code" subtitle "${repoInfo} 📦"`, ], stdout: "piped", stderr: "piped", }); } https://github.com/shuntaka9576/dotfiles/blob/ccfb7d237c8d920e7a128cf2128ed0c216e05252/home-manager/programs/claude/hooks/notify.ts https://github.com/shuntaka9576/dotfiles/blob/ccfb7d237c8d920e7a128cf2128ed0c216e05252/home-manager/programs/claude/settings.json
  4. exit 1以上の結果をexit 2 stderrに書き込み直すラッパーCLIを書いた 20 cspell ruff exit 1 stderr

    stdout exit 1 stdout clippy exit 101 stderr $ blocc -s "cspell lint ." { "message": "1 command(s) failed", "results": [ { "command": "cspell lint .", "exitCode": 1, "stderr": "CSpell: …", "stdout": "… Unknown word (oicd)" } ] } ※ brew install shuntaka9576/tap/blocc
  5. 24 ③ 自動リファクタへ誘導 $ blocc -n -s "cspell lint ."

    -o "perl -nle 'print \$1 if /Unknown word \((\w+)\)/' | sort | uniq" 出⼒データが多くてcontext lowになることも 試⾏錯誤していて、汎⽤的なlinterは--stdout-filterと--stderr-filterで原因の場所だ け取り出すようにして改善させることができそう?
  6. [小ネタ] mise(ミーズ)とClaudeCode $ cat ~/.default-npm-packages jwt-cli lighthouse npm-check-updates @biomejs/biome pnpm

    @anthropic-ai/[email protected] typescript-language-server @benborla29/mcp-server-mysql cspell .node-versionを検知すると消える ので、~/.default-npm-packages設 定。 mise installで⼀通りinstallされる ようになる。 @でバージョン固定可能。envの DISABLE_AUTOUPDATERと併⽤す れば特定のバージョンにロック可 能。 ※ 編集した場合、mise uninstall node --allしないといけ ない 26