Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
claude/.claude/settings.json filter=claude-settings
12 changes: 12 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ Personal dotfiles managed with GNU stow. Full details: README.md.
`doctor.sh` detect it's missing.
- The repo must stay cloned at `~/Development/dotfiles`; stow's symlinks are
relative to that path.
- `claude/.claude/settings.json` is owned by Claude Code, which rewrites it on
every `/model` switch, so it's handled in two halves. `.gitattributes` runs it
through `claude-settings-clean.py` (drops the volatile keys, sorts the rest)
so commits only ever carry durable config; a new key Claude Code writes back
as state goes in that script's `VOLATILE`. The file is also marked
`skip-worktree`, because a clean filter alone doesn't quiet `git status` —
git's refresh path hashes the file raw. Both halves are per-clone index and
config state: `bootstrap.sh` sets them, `doctor.sh` checks them.
- To commit a deliberate change to that settings file, unhide it first:
`git update-index --no-skip-worktree claude/.claude/settings.json`, commit,
then re-hide with `--skip-worktree`. While it's hidden, git ignores every
local edit to it, including one you meant to keep.
- Shell scripts: keep `shellcheck`-clean
(`shellcheck bootstrap.sh doctor.sh lib.sh macos/*.sh`).

Expand Down
8 changes: 8 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ else
sudo apt-get install -y git curl stow zsh tmux neovim xclip ripgrep fd-find
fi

# ---- Register the Claude settings clean filter ----
# .gitattributes names the filter; git only ever runs one it has been given a
# command for, so an unregistered clone silently commits the volatile keys.
echo ">>> Registering the Claude settings clean filter..."
cd "$DOTFILES_DIR"
git config "$CLAUDE_SETTINGS_FILTER" "$CLAUDE_SETTINGS_FILTER_CMD"
git update-index --skip-worktree "$CLAUDE_SETTINGS_FILE"

# ---- Init git submodules ----
echo ">>> Initializing git submodules..."
cd "$DOTFILES_DIR"
Expand Down
42 changes: 42 additions & 0 deletions claude-settings-clean.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
"""Git clean filter for claude/.claude/settings.json.

Claude Code owns that file: it rewrites the whole thing whenever a runtime
option changes (/model, the theme picker, sandbox toggles), so a stowed,
tracked copy is dirty again the moment you switch models. This strips the keys
Claude Code writes back as machine state and sorts what's left, leaving git to
see only the durable config — hooks, permissions, statusLine, plugins.

Reads the working-tree file on stdin, writes the committed form on stdout.
Wired up by `git config filter.claude-settings.clean` in bootstrap.sh and
pointed at this file by .gitattributes.
"""

import json
import sys

# Written back by Claude Code itself; per-machine, never worth a commit.
VOLATILE = ("model", "theme", "sandbox", "modelSettings")


def main() -> None:
raw = sys.stdin.read()
try:
settings = json.loads(raw)
except ValueError:
# A half-written or hand-broken file still has to round-trip: a filter
# that errors here wedges every git command touching the file.
sys.stdout.write(raw)
return

for key in VOLATILE:
settings.pop(key, None)

# sort_keys because Claude Code's own key order isn't stable across
# versions — without it a rewrite alone shows up as a diff.
json.dump(settings, sys.stdout, indent=2, sort_keys=True)
sys.stdout.write("\n")


if __name__ == "__main__":
main()
60 changes: 29 additions & 31 deletions claude/.claude/settings.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
{
"model": "sonnet",
"enabledPlugins": {
"claude-md-management@claude-plugins-official": true,
"code-review@claude-plugins-official": true,
"code-simplifier@claude-plugins-official": true,
"frontend-design@claude-plugins-official": true,
"ponytail@ponytail": true,
"security-guidance@claude-plugins-official": true,
"superpowers@claude-plugins-official": false,
"swift-lsp@claude-plugins-official": true
},
"extraKnownMarketplaces": {
"ponytail": {
"source": {
"repo": "DietrichGebert/ponytail",
"source": "github"
}
}
},
"hooks": {
"Notification": [
{
"matcher": "permission_prompt|agent_needs_input",
"hooks": [
{
"type": "command",
"command": "command -v afplay >/dev/null && afplay /System/Library/Sounds/Glass.aiff || true"
"command": "command -v afplay >/dev/null && afplay /System/Library/Sounds/Glass.aiff || true",
"type": "command"
}
]
],
"matcher": "permission_prompt|agent_needs_input"
},
{
"matcher": "idle_prompt|agent_completed",
"hooks": [
{
"type": "command",
"command": "command -v afplay >/dev/null && afplay /System/Library/Sounds/Pop.aiff || true"
"command": "command -v afplay >/dev/null && afplay /System/Library/Sounds/Pop.aiff || true",
"type": "command"
}
]
],
"matcher": "idle_prompt|agent_completed"
}
]
},
"enabledPlugins": {
"frontend-design@claude-plugins-official": true,
"superpowers@claude-plugins-official": false,
"code-review@claude-plugins-official": true,
"code-simplifier@claude-plugins-official": true,
"claude-md-management@claude-plugins-official": true,
"security-guidance@claude-plugins-official": true,
"swift-lsp@claude-plugins-official": true,
"ponytail@ponytail": true
},
"extraKnownMarketplaces": {
"ponytail": {
"source": {
"source": "github",
"repo": "DietrichGebert/ponytail"
}
}
},
"permissions": {
"deny": [
"Bash(rm -rf /)",
Expand All @@ -56,8 +55,7 @@
]
},
"statusLine": {
"type": "command",
"command": "~/.claude/statusline.sh"
},
"theme": "auto"
"command": "~/.claude/statusline.sh",
"type": "command"
}
}
15 changes: 15 additions & 0 deletions doctor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ else
ok "submodules at recorded commits"
fi

configured_filter="$(cd "$DOTFILES_DIR" && git config --get "$CLAUDE_SETTINGS_FILTER" 2>/dev/null)"
if [[ "$configured_filter" == "$CLAUDE_SETTINGS_FILTER_CMD" ]]; then
ok "Claude settings clean filter registered"
else
bad "Claude settings clean filter not registered"
hint "git -C $DOTFILES_DIR config $CLAUDE_SETTINGS_FILTER $CLAUDE_SETTINGS_FILTER_CMD"
fi

if [[ "$(cd "$DOTFILES_DIR" && git ls-files -v "$CLAUDE_SETTINGS_FILE" 2>/dev/null)" == S* ]]; then
ok "Claude settings marked skip-worktree"
else
bad "Claude settings not marked skip-worktree"
hint "git -C $DOTFILES_DIR update-index --skip-worktree $CLAUDE_SETTINGS_FILE"
fi

if [[ -n "$(cd "$DOTFILES_DIR" && git status --porcelain 2>/dev/null)" ]]; then
bad "working tree is dirty"
hint "git -C $DOTFILES_DIR status"
Expand Down
2 changes: 2 additions & 0 deletions git/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.DS_Store
**/.claude/settings.local.json

**/.claude/.cc-writes/
12 changes: 12 additions & 0 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ MACHINE_FILE="$DOTFILES_DIR/.machine"
# Stow packages carrying no special options.
STOW_PACKAGES=(zsh git tmux ghostty nvim base16 claude)

# Claude Code rewrites ~/.claude/settings.json whenever a runtime option
# changes, which dirties the stowed copy on every /model switch. .gitattributes
# routes the file through this clean filter so git only sees the durable config;
# the filter command itself lives in each clone's git config, set by bootstrap.
# The filter keeps volatile keys out of commits; git still reports the file as
# modified though, because its refresh path hashes the file raw and only the
# diff machinery applies the filter. skip-worktree is what actually silences
# that — see CLAUDE.md for how to commit a deliberate change to the file.
CLAUDE_SETTINGS_FILE="claude/.claude/settings.json"
CLAUDE_SETTINGS_FILTER="filter.claude-settings.clean"
CLAUDE_SETTINGS_FILTER_CMD="$DOTFILES_DIR/claude-settings-clean.py"

# ssh is stowed on its own: --no-folding keeps ~/.ssh a real directory holding a
# symlinked config. Folded, ~/.ssh would itself be a symlink into this repo, and
# every key or known_hosts file written there would land in the working tree.
Expand Down
Loading