Skip to main content

How do you test what a defaults key actually does before codifying it?

  • July 28, 2026
  • 3 replies
  • 31 views

emilymakesapps
Forum|alt.badge.img

Disclosure up front: I make a Mac app called Mainspring, so I have a horse in this race. Mods, happy to have this pulled if it is not a fit.

The workflow I keep running into, and I suspect I am not alone:

A user asks for some macOS behaviour changed. It is not exposed in a Configuration Profile payload, so it comes down to a defaults key in a script or a custom plist. You find the key on a blog from 2015, push it to a test machine, and then spend twenty minutes working out whether it actually did anything, whether it needed a killall, and what the original value was if you want to back it out.

The part that gets me is the last one. defaults read tells you the current value, but only if the key already exists. Plenty of these keys are absent until something writes them, so there is no "before" value to capture, and your rollback script has to delete the key rather than restore it. Easy to get wrong at 5pm on a Friday.

Two questions for the group:

1. How do you validate a new key before it goes anywhere near production?
   Snapshot the plist, diff it, something more structured?

2. How do you handle rollback for keys that did not exist beforehand? Do you
   bother, or do you just document the default and move on?

For what it is worth, the way I ended up handling this on my own admin Mac is a GUI that flips the key, shows the effect immediately, and records the prior state so it can be put back. That is the app I mentioned above, and to be clear it is a per-user tool, not an MDM one. It does not scale to a fleet and I would not pretend otherwise. It is useful for the "what does this key actually do" stage before something becomes a profile or a script.

3 replies

PaulHazelden
Forum|alt.badge.img+14
  • Jamf Heroes
  • July 28, 2026

There is a page that lists all current available Defaults and their values.
https://macos-defaults.com/

On a quick look at the lists they do give you a return to defaults line, plus if there is a killall required they list that in there too.

Personally I have a few “Test” Macs available to me, and everything I do gets tested on these before hitting the production Macs. I have a second level Test Mac, that another tech has access to and I ask them to run a test there.


Hope this is helpful to you.


emilymakesapps
Forum|alt.badge.img
  • Author
  • New Contributor
  • July 28, 2026

Seconding macos-defaults.com.

Two things that aren't on it and have saved me pain:

Find undocumented keys by diffing.

defaults read > /tmp/before.plist
# change the setting by hand in System Settings
defaults read > /tmp/after.plist
diff /tmp/before.plist /tmp/after.plist

delete ≠ writing the default value. defaults delete <domain> <key> falls back to the real default; writing what you think the default is bakes in a literal that won't track OS changes. For revert actions, prefer delete.

One Jamf-specific gotcha: most of these are per-user domains, so a policy script running as root writes to root's prefs and looks like it did nothing. Run it as the console user — launchctl asuser "$uid" sudo -u "$user" defaults write …

Disclosure: I build a Mac app in this space, Mainspring (https://trymainspring.com) — same tweaks, packaged as recipes you can roll back. Single Macs, not fleets, so not a Jamf substitute.


Chubs
Forum|alt.badge.img+26
  • Jamf Heroes
  • July 28, 2026

This is interesting.  Are you writing simply macOS tweaks or third party tweaks too?

I wrote a script that can build these on the fly with dynamic parameters needed.  Kinda like what you have but without an app interface.