Technical details about how this setup works.
- The repository uses a dual-script architecture for optimal performance:
setup.sh: Production script with parallel processing (uses system CPU cores)setup-validate.sh: Validation script optimized for dry-runs (6x faster I/O)
- Smart delegation:
setup.sh previewautomatically delegates tosetup-validate.sh - Parallel execution for package installations
- No-auto-update flags for Homebrew operations to reduce overhead
macbook-dev-setup/
├── setup.sh # Main setup script (parallel execution)
├── setup-validate.sh # Fast validation/dry-run script
├── lib/
│ ├── common.sh # Shared functions and utilities
│ └── config.sh # Configuration parser
├── scripts/
│ ├── install-*.sh # Component installers
│ ├── setup-*.sh # Configuration scripts
│ ├── backup-manager.sh # Centralized backup system
│ ├── health-check.sh # System verification
│ ├── update.sh # Update automation
│ ├── pre-push-check.sh # Git pre-push validation
│ ├── commit-helper.sh # Interactive commit creator
│ ├── setup-git-hooks.sh # Conventional commit setup
│ └── setup-branch-protection.sh # GitHub branch rules
├── dotfiles/
│ ├── .zshrc # Modular shell config loader
│ ├── .gitconfig # Git configuration
│ └── .config/
│ ├── zsh/ # Modular Zsh configs
│ └── nvim/ # Neovim configuration
├── homebrew/
│ ├── Brewfile # Main package definitions
│ └── Brewfile.minimal # Essential packages only
├── vscode/
│ ├── settings.json # VS Code settings
│ └── extensions.txt # Extension list
├── .claude/
│ └── agents/ # Native sub-agent definitions
├── tests/
│ ├── run_tests.sh # Test runner
│ ├── test_framework.sh # Test utilities
│ └── test_*.sh # Test suites
└── docs/ # Documentation
Parallel Execution:
- Uses
$(nproc)to determine CPU cores - Runs independent tasks concurrently
- 30-50% faster than sequential execution
Smart Delegation:
setup.sh previewdelegates tosetup-validate.sh- Validation script skips unnecessary operations
- 6x faster for dry runs
Caching:
- Homebrew prefix cached in shell startup
- NVM lazy-loaded to improve shell speed
- Package checks before installation
Validation:
- Prerequisites checked before execution
- Dry-run mode for preview
- Comprehensive error handling
Backups:
- Centralized backup system in ~/.setup-backups/
- Organized by category (dotfiles, configs, restore-points, scripts)
- Automatic cleanup (keeps 10 most recent per category)
- Latest symlinks for quick access
- Metadata tracking with timestamps and descriptions
Idempotency:
- Scripts can be run multiple times safely
- Checks for existing installations
- Skips already-configured items
Component Scripts:
- Each script handles one responsibility
- Can be run independently
- Share common library functions
Configuration:
- Zsh config split into logical modules
- Easy to disable/modify components
- Local overrides supported
Progress Feedback:
- Color-coded output messages
- Progress bars for long operations
- Clear success/failure indicators
Documentation:
- Comprehensive help messages
- Inline documentation
- Troubleshooting guides
The project uses an orchestrator pattern for complex development tasks:
- Main Claude session acts as orchestrator — dispatches sub-agents, never implements complex tasks directly
- 7 native agents in
.claude/agents/: product-strategist → product-tactician → researcher → planner → implementer → reviewer → designer - Worktree isolation: Each implementer runs in its own git worktree, enabling parallel-safe execution
- Checkpoint commits: One commit per completed task for easy rollback (slot machine rule: revert > fix)
- Ephemeral artifacts:
product-brief.md→research.md/design-spec.md→plan.md→ implementation → review. Gitignored, cleaned up after PR merge. - Persistent artifacts:
product-lab/contains product strategy state (evaluation, discovery, positioning) that persists across sessions. - Task classification: Trivial tasks skip the workflow; complex tasks get the full Phase 1-4 treatment
See Claude Agents for details on each agent and the orchestration protocol.
Main orchestrator that:
- Validates environment
- Detects Warp Terminal
- Installs Homebrew
- Runs component scripts in parallel
- Reports results
Key features:
- Simplified command interface (preview, minimal, fix, warp, backup)
- Environment variable support for power users
- Automatic Warp Terminal detection and optimization
- Performance monitoring
- Logging support
Lightweight validation script that:
- Checks prerequisites
- Validates configurations
- Previews changes
- Never modifies system
Optimizations:
- Minimal imports
- Skip expensive operations
- Fast file checks only
Shared library providing:
- Color output functions
- OS/architecture detection
- Error handling
- Progress indicators
- Backup utilities
- Warp Terminal detection
- Command validation
Used by all scripts for consistency.
Centralized backup system that:
- Creates categorized backups
- Maintains metadata
- Auto-cleans old backups
- Provides latest symlinks
- Supports migration from old backup locations
graph TD
A[setup.sh] --> B{Validate Prerequisites}
B -->|Pass| C[Install Homebrew]
B -->|Fail| X[Exit with Error]
C --> D[Parallel Execution]
D --> E[Install Packages]
D --> F[Setup Dotfiles]
D --> G[Configure macOS]
D --> H[Setup Applications]
E --> I[Merge Results]
F --> I
G --> I
H --> I
I --> J[Health Check]
J --> K[Show Summary]
# Execute multiple commands concurrently
execute_parallel() {
local pids=()
for cmd in "$@"; do
eval "$cmd" &
pids+=($!)
done
# Wait for all processes
for pid in "${pids[@]}"; do
wait "$pid"
done
}NVM optimization in .config/zsh/10-languages.zsh:
# Define stub functions
nvm() {
unset -f nvm node npm npx
source "$NVM_DIR/nvm.sh"
nvm "$@"
}# Disable auto-update during installation
export HOMEBREW_NO_AUTO_UPDATE=1
# Skip cleanup during batch operations
export HOMEBREW_NO_INSTALL_CLEANUP=1Files loaded in order:
00-*- Core setup (Homebrew, paths)10-*- Language managers20-*- Tool configurations30-*- Aliases35-*- Commit aliases (git shortcuts)40-*- Functions45-*- Warp Terminal config (if detected)50-*- Environment90-99- Local overrides
V2.0 simplified from 16+ flags to 5 commands:
preview- Dry run to see changesminimal- Essential tools onlyfix- Diagnostics and fixeswarp- Warp Terminal setupbackup- Backup management
Power users can use environment variables:
SETUP_VERBOSE=1- Verbose outputSETUP_JOBS=n- Custom parallel jobsSETUP_LOG=file- Log to fileSETUP_NO_WARP=true- Skip Warp detection
# Try preferred method, fall back if needed
if ! brew bundle; then
warning "Brew bundle failed, trying individual installs"
install_packages_individually
fi# Clear error messages with solutions
if ! command_exists git; then
error "Git is not installed"
info "Install Xcode Command Line Tools:"
info " xcode-select --install"
exit 1
fi- Test individual functions
- Mock external commands
- Verify error handling
- Test script interactions
- Verify file creation
- Check idempotency
- Run on every push
- Test on macOS runners
- Validate documentation
- Secrets in
99-local.zsh(gitignored) - Environment variables for sensitive data
- Secure credential storage
- HTTPS for all downloads
- Checksum verification where possible
- Official sources only
- Minimal sudo usage
- Clear permission requirements
- User consent for changes
Add to scripts/ directory:
#!/bin/bash
source "$(dirname "$0")/../lib/common.sh"
# Your custom logicEdit homebrew/Brewfile:
# Your tools
brew "your-tool"
cask "your-app"Use ~/.config/zsh/99-local.zsh:
# Override defaults
export EDITOR="code"
alias ls="ls -la"- Configuration profiles UI
- Automated testing expansion
- Plugin system for extensions
- Cross-platform support (Linux)
- Sub-10 minute full installation
- Instant shell startup (<100ms)
- Zero-downtime updates
- Move to configuration as code
- Container-based testing
- Self-updating capability