How can I add autocorrect shortcuts programmatically?
You can copy the settings to another Mac by copying ~/Library/Preferences/.GlobalPreferences.plist.

Note that preferences are cached on 10.9, so if you replace a plist or edit it directly, quitting and reopening applications won't apply the changes. You can apply the changes by running defaults read -g, by running killall cfprefsd, or by logging out and back in. Changes made with defaults are still applied if you just quit and reopen an application.

Print the current settings:

defaults read -g NSUserDictionaryReplacementItems


Add one setting:

defaults write -g NSUserDictionaryReplacementItems -array-add '{on=1;replace=cmd;with="⌘";}'


Replace all settings:

defaults write -g NSUserDictionaryReplacementItems '(
{on=1;replace=cmd;with="⌘";},
{on=1;replace=opt;with="⌥";}
)'


Print the current settings as XML:

defaults read -g NSUserDictionaryReplacementItems | plutil -convert xml1 - -o -


Replace all settings:

amp() { local x=${1//&amp;/&amp;amp; }; x=${x//&lt;/&amp;lt; }; printf %s "${x//&gt;/&amp;gt; }"; }
out='&lt;array&gt;'
while IFS= read -r l; do
  out+="&lt;dict&gt;&lt;key&gt;on&lt;/key&gt;&lt;integer&gt;1&lt;/integer&gt;&lt;key&gt;replace&lt;/key&gt;&lt;string&gt;$(amp "${l%% *}")&lt;/string&gt;&lt;key&gt;with&lt;/key&gt;&lt;string&gt;$(amp "${l#* }")&lt;/string&gt;&lt;/dict&gt;"
done &lt;&lt;&lt; 'cmd ⌘
opt ⌥'
defaults write -g NSUserDictionaryReplacementItems "$out&lt;/array&gt;"


Replace NSUserDictionaryReplacementItems with NSUserReplacementItems in 10.8 and earlier.