Files
claude-config/bin/settings_filter.py
T

25 lines
691 B
Python
Executable File

#!/usr/bin/env python3
"""Git's clean filter for settings.json: drop "model" and sort every key.
Claude Code rewrites settings.json, in its own key order, whenever a model is
picked or a plugin installed. Each machine owns its model, so git stores the
file without it, and neither write shows as a change.
"""
import json
import sys
def cleaned(written: str) -> str:
"""settings.json as git stores it: without "model", every key sorted."""
settings = json.loads(written)
settings.pop("model", None)
return json.dumps(settings, ensure_ascii=False, indent=2, sort_keys=True) + "\n"
def main() -> None:
sys.stdout.write(cleaned(sys.stdin.read()))
if __name__ == "__main__":
main()