| name | cli-admin-automation |
| description | Automate system administration workflows on macOS and Linux. Use this skill when: setting up reproducible dev environments (Brewfile), parsing CLI command output programmatically (jc + jq), monitoring remote servers via SSH with alerts, integrating API keys and secrets securely (1Password CLI), building automation workflows (Cherri Siri Shortcuts programming), or batch-managing system configurations. Covers package management (Homebrew), structured JSON parsing (jc), SSH-based remote administration, secure credential injection, cross-platform multi-step automation, and fleet monitoring. |
CLI Administration & Automation
Overview
This skill provides integrated patterns for secrets-first CLI administration across macOS and Linux systems. It combines five core tools:
- jc: Transform CLI command output to structured JSON for programmatic parsing
- Homebrew: Reproducible package management with Brewfile for team environments
- 1Password CLI: Secrets as first-class citizens in scripts (not hardcoded)
- Cherri: Siri Shortcuts programming language for sophisticated automation
- m-cli: macOS system administration toolkit (30+ commands)
Core Integration Pattern
command | jc → JSON | jq filter → conditional logic → 1Password inject → Cherri automate
Use this skill when you need to:
- Parse CLI command output programmatically
- Manage dependencies reproducibly across teams
- Integrate credentials securely into automation
- Monitor remote systems and trigger alerts
- Build deterministic infrastructure-as-code workflows
Module Index
Read references/ modules when the user asks about:
- cli-foundations.md: Shell basics, pipes, quoting, keybindings (prerequisite for others)
- jc-parser-reference.md: Parsing command output (ps, netstat, df, etc.) with jq filtering
- homebrew-workflows.md: Package management, Brewfile setup, team environments
- macos-system-admin.md: macOS-specific CLI (m-cli, defaults write, launchd)
- linux-remote-admin.md: SSH-based Linux admin, package managers, systemctl
- cherri-automation.md: Siri Shortcuts programming, multi-step workflows
- 1password-secrets.md: Secret references, credential rotation, vault management
Critical Gotchas
These non-obvious issues cause most failures. Read them first.
jc
- Locale affects output sorting. Use
LC_ALL=C for reproducibility across systems.
- Timezone-aware parsing varies by jc version. Test with specific jc version pinned.
Homebrew
- Tap authentication requires GitHub token (not plaintext). Store token in 1Password vault, not
~/.gitconfig.
HOMEBREW_NO_ANALYTICS=1 is a hidden environment variable; not set by default.
1Password CLI
- Caching daemon may stale on permission changes. Restart daemon if secret reads fail unexpectedly.
- Secret references (
op://vault/item/field) are immutable after creation. Changing reference syntax requires creating new item.
Cherri
- macOS-only. No Linux equivalent. Reference AppleScript for legacy macOS automation.
- Compiles to binary
.shortcut format (human-unreadable). Development cycle slower than Shortcuts.app GUI.
SSH
- Key-based authentication preferred. Use 1Password CLI agent for key storage (not
~/.ssh/config plaintext).
- SSH key permissions must be exactly
0600. Mismatched permissions cause silent auth failures.
Quick Command Reference
jc (Top 5 Parsers)
ps aux | jc --ps | jq '.[] | select(.comm == "node")'
df -h | jc --df | jq '.[] | select(.use_percent > 80)'
netstat -an | jc --netstat | jq '.[] | select(.state == "ESTABLISHED")'
ls -la | jc --ls | jq '.[] | select(.size > 1000000)'
git log --oneline | jc --git-log | jq '.[] | .commit'
Homebrew
brew install <formula>
brew bundle install
brew tap <owner>/<repo>
brew list
brew cleanup
1Password CLI
op read op://vault/item/field
op run -- command
op item get ItemName
op vault list
m-cli (macOS System)
m battery
m wifi
m disk
m dock add <app>
m system info
Workflows
Scenario 1: Reproducible Team Environment (Brewfile + Validation)
brew bundle dump --file Brewfile
brew bundle install --file Brewfile
bash scripts/parse-homebrew-bundle.sh Brewfile --check
export HOMEBREW_GITHUB_TOKEN=$(op read op://work/github/token)
brew bundle install --file Brewfile --verbose
Use when: Setting up dev environments, CI/CD containers, standardizing across team, or managing private taps with authentication.
Common issues:
- GitHub token not exported → taps fail silently
brew bundle picks wrong Brewfile if multiple exist → use explicit --file
- Cask apps installed via tap require native GUI → fails in headless CI
Scenario 2: Remote Server Health Monitoring (SSH + jc + Alerts)
ssh user@remote 'ps aux' | jc --ps | jq '.[] | select(.cpu_percent > 50)'
high_cpu=$(ssh user@remote 'ps aux' | jc --ps | jq '.[] | select(.cpu_percent > 50)' | wc -l)
if [ "$high_cpu" -gt 5 ]; then
slack_webhook=$(op read op://work/slack/webhook)
curl -X POST -d "High CPU detected: $high_cpu processes" "$slack_webhook"
fi
for host in server1 server2 server3; do
status=$(ssh -o ConnectTimeout=5 user@"$host" 'df -h' | jc --df | jq '.[] | select(.use_percent > 80) | .filesystem' || echo "OFFLINE")
echo "$host: $status"
done
Use when: Monitoring fleets, automating health checks, triggering alerts on conditions, batch diagnostics.
Common issues:
- SSH key perms wrong (not exactly 0600) → silent auth failures
- jc output differs by locale → use
LC_ALL=C for consistency
op read fails if caching daemon stale → restart: killall op-daemon
Scenario 3: Automated Deployment with Secrets (1Password + Validation)
cp deployment-template.yaml deployment-plan.yaml
op read op://prod/db/password > /tmp/db_pass
sed -i "s|DB_PASSWORD|$(cat /tmp/db_pass)|" deployment-plan.yaml
cat deployment-plan.yaml | jq .
shred -vfz /tmp/db_pass 2>/dev/null || rm /tmp/db_pass
kubectl apply -f deployment-plan.yaml
Use when: Infrastructure deployments, credential-protected workflows, multi-step automation, secret rotation.
Common issues:
- Secret files left in
/tmp after script exit → secrets visible in process history
op:// reference syntax changed → immutable after creation, must create new item
- Mixing
op read with shell expansion → loses indentation in YAML
Scenario 4: Multi-Step Cherri Automation (Siri Shortcuts Integration)
cat > backup-automation.cherri << 'EOF'
func backupWithRetry(source: String, destination: String) -> Bool {
var attempts = 0
while attempts < 3 {
if executeCommand("rsync -av \(source) \(destination)") {
return true
}
attempts += 1
}
return false
}
EOF
cherri compile backup-automation.cherri -o backup-automation.shortcut
op run -- open -a Shortcuts backup-automation.shortcut
Use when: macOS-specific automation, conditional retry logic, GUI automation within scripts.
Critical: Cherri is macOS-only. For Linux, use Bash functions or Python instead.
Scenario 5: Batch System Configuration (m-cli + Defaults Write)
m wifi
m battery status
m dock autohide
defaults write com.apple.dock autohide -bool true
defaults write com.apple.finder ShowHiddenFiles -bool true
defaults write com.apple.Safari HistoryDeletionBehavior 2
killall Finder
killall Dock
Use when: Provisioning macOS machines, standardizing dev configs, batch system administration.
Common issues:
- Some defaults require restart to apply
defaults write doesn't validate syntax → typos silently ignored
- User approval required for accessibility/privacy changes → can't automate
Scenario 6: Cross-Platform CLI Output Parsing (jc with Multiple Formats)
{
ps=$(ps aux | jc --ps | jq '.[] | {pid, cmd: .command, cpu: .cpu_percent}')
disk=$(df -h | jc --df | jq '.[] | {filesystem, use_percent}')
net=$(netstat -an | jc --netstat | jq '.[] | {proto: .protocol, state}')
echo "{processes: $ps, disks: $disk, network: $net}" | jq .
}
ssh debian-host 'df -h' | jc --df > debian-df.json
ssh rhel-host 'df -h' | jc --df > rhel-df.json
diff <(jq '.[] | .filesystem' debian-df.json) <(jq '.[] | .filesystem' rhel-df.json)
op item create --template=login --title="Disk Report $(date)" --vault=Audit
Use when: Cross-platform inventory, compliance reporting, multi-system diagnostics.
Progress