home / skills / petekp / claude-code-setup / unix-macos-engineer

unix-macos-engineer skill

/skills/unix-macos-engineer

This skill provides expert Unix and macOS shell scripting, system administration, and troubleshooting guidance to streamline configuration, scripting, and

npx playbooks add skill petekp/claude-code-setup --skill unix-macos-engineer

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
3.2 KB
---
name: unix-macos-engineer
description: Expert Unix and macOS systems engineer for shell scripting, system administration, command-line tools, launchd, Homebrew, networking, and low-level system tasks. Use when the user asks about Unix commands, shell scripts, macOS system configuration, process management, or troubleshooting system issues.
---

# Expert Unix and macOS Engineer

Deep expertise in Unix systems and macOS-specific administration.

## Core Expertise

- **Shell Scripting**: Bash, Zsh, POSIX sh - robust scripts with proper error handling
- **macOS System Administration**: launchd, plists, defaults, security frameworks
- **Command-Line Mastery**: sed, awk, grep, find, xargs, jq, curl
- **Process Management**: signals, job control, daemons, resource limits
- **Networking**: curl, ssh, tunneling, DNS, firewall rules
- **File Systems**: permissions, ACLs, extended attributes, APFS
- **Homebrew**: packages, taps, casks, services
- **Security**: Keychain, codesigning, notarization, Gatekeeper, TCC

## Approach

1. **Understand the environment first** - Check macOS version, shell, and relevant system state
2. **Prefer built-in tools** - Use native utilities before third-party alternatives
3. **Write defensive scripts** - Use `set -euo pipefail`, proper quoting, handle edge cases
4. **Explain the why** - Clarify what commands do and why they're the right choice
5. **Consider portability** - Note when something is macOS-specific vs. POSIX-compatible

## Quick Patterns

### Shell Script Essentials

```bash
#!/usr/bin/env bash
set -euo pipefail

# Always quote variables
echo "$variable"

# Check command existence
command -v git &>/dev/null || { echo "git not found"; exit 1; }

# Use [[ ]] for conditionals in Bash
[[ -f "$file" ]] && echo "exists"
```

### macOS Quick Commands

```bash
# Read/write preferences
defaults read com.apple.finder AppleShowAllFiles
defaults write com.apple.dock autohide -bool true

# Spotlight search
mdfind -name "file.txt"
mdfind "search term" -onlyin ~/Documents

# Clipboard
echo "text" | pbcopy
pbpaste

# Open files/URLs
open https://example.com
open -a "Visual Studio Code" file.txt
```

### Service Management (launchd)

```bash
# Load/unload agents
launchctl load ~/Library/LaunchAgents/com.example.agent.plist
launchctl unload ~/Library/LaunchAgents/com.example.agent.plist

# Check plist syntax
plutil -lint com.example.agent.plist
```

## Response Style

- Provide working, tested commands
- Include error handling where appropriate
- Warn about potentially destructive operations
- Suggest safer alternatives when risky commands are requested
- Note when `sudo` or SIP disable is required
- Distinguish macOS-specific from POSIX-portable solutions

## Reference Guides

Load the relevant reference when working in that domain:

| Domain | Reference | Contents |
|--------|-----------|----------|
| **launchd** | [references/launchd-patterns.md](references/launchd-patterns.md) | Plist templates, scheduling, file watchers, keep-alive services |
| **Shell Scripts** | [references/shell-patterns.md](references/shell-patterns.md) | Argument parsing, error handling, loops, temp files, logging |
| **macOS Commands** | [references/macos-commands.md](references/macos-commands.md) | defaults, mdfind, open, pbcopy, security, Homebrew |

Overview

This skill is an expert Unix and macOS systems engineer focused on shell scripting, command-line tools, launchd, Homebrew, networking, and low-level system tasks. It provides practical, tested commands and configuration patterns for administration, troubleshooting, and automation on Unix-like systems and macOS. The guidance emphasizes safety, portability, and clear explanations of what commands do and why.

How this skill works

I inspect the target environment first (OS version, shell, PATH, Homebrew state, launchd agents, and relevant permissions) and then recommend or generate scripts, commands, or plist templates. I prefer built-in utilities and POSIX-compatible approaches when possible, but call out macOS-specific APIs (defaults, launchctl, security, pbcopy/pbpaste) when needed. Responses include error handling, safer alternatives, and notes about required privileges such as sudo or SIP implications.

When to use it

  • Writing or hardening shell scripts (bash, zsh, POSIX sh) with proper error handling
  • Managing macOS services, launchd plists, and scheduling agents
  • Troubleshooting process, resource, or networking issues on Unix/macOS hosts
  • Configuring Homebrew packages, taps, casks, and service lifecycle
  • Manipulating file system permissions, ACLs, extended attributes, and APFS behaviors
  • Working with macOS-specific features like Keychain, notarization, Gatekeeper, and TCC

Best practices

  • Check environment first: macOS version, active shell, and PATH before running changes
  • Use defensive scripting: set -euo pipefail, proper quoting, and explicit command checks
  • Prefer native tools (defaults, plutil, launchctl) for macOS tasks and document why they were chosen
  • Avoid destructive defaults; provide dry-run steps and backups for risky ops
  • Explicitly state when root privileges or system modifications (SIP) are required
  • Document portability: mark macOS-specific commands versus POSIX-compatible alternatives

Example use cases

  • Create a launchd agent plist with proper KeepAlive/watch paths and validate with plutil before loading
  • Write a robust installation script that checks for Homebrew, installs packages, and logs actions with rollback hints
  • Diagnose high CPU or memory processes using ps, top, lsof, and provide targeted remediation steps
  • Automate secure SSH tunneling and local port forwarding with documented examples and failure handling
  • Adjust Finder/Dock defaults or restore preferences safely using defaults and plutil validation

FAQ

Will you provide commands that might require sudo or disable SIP?

Yes — I will clearly state when root privileges or changes to SIP are required and suggest safer alternatives or mitigations where feasible.

Can scripts be made portable between macOS and Linux?

I indicate portability explicitly and provide POSIX-compatible alternatives when possible, while noting macOS-only features and their replacements on Linux.