An engineering-first framework for building, maintaining and validating a reproducible macOS development workstation with Bash.
git clone https://github.com/SunnyJayaRaju/workstation-framework.git
cd workstation-framework
./scripts/install.sh- At a glance
- Overview
- Why this project?
- Design philosophy
- Key features
- Technology stack
- Current release
- Repository structure
- Prerequisites
- Installation
- Configuration
- Available utilities
- Ruby and Homebrew: three rules
- Development workflow
- Development commands
- Automated testing
- Continuous integration
- Documentation
- Roadmap
- Contributing
- License
- Acknowledgements
An engineering-first framework for building, managing, validating and evolving a professional macOS development workstation using modern Bash engineering practices.
Developer Workstation Framework is a structured, engineering-focused toolkit for building and maintaining a reproducible macOS development environment.
Rather than collecting standalone shell scripts over time, this project treats workstation management as a software engineering discipline. Every utility follows common coding standards, centralized configuration, reusable libraries, automated validation, behavioral testing and continuous integration.
The result is a framework that is easier to understand, extend, maintain, and confidently evolve over time.
Most workstation setup repositories eventually become difficult to maintain because they evolve organically:
- Scripts become duplicated.
- Configuration is scattered.
- Documentation falls behind implementation.
- Validation becomes manual.
- Small changes introduce regressions.
Developer Workstation Framework addresses these problems by organizing workstation automation into a maintainable engineering project with clearly separated responsibilities.
Instead of treating infrastructure as a collection of scripts, the repository treats it as real software.
The framework is guided by several engineering principles.
Common functionality belongs in shared libraries instead of being duplicated across utilities.
Each script should perform one responsibility well.
Readable code is preferred over clever code.
Quality verification should be automated whenever possible.
Every utility follows the same project structure, coding standards, logging style, and validation process.
Configuration, testing, and validation should produce deterministic results both locally and in continuous integration environments.
Shared libraries eliminate duplicated logic and provide reusable functionality for:
- Logging
- Configuration loading
- Filesystem operations
- Validation helpers
- Backup path and manifest handling
- ANSI color output (owned by the logging library)
Configuration is managed through dedicated configuration files with predictable precedence.
Priority order:
- Environment variables
config/user.confconfig/default.conf
This allows local customization without modifying repository defaults while remaining friendly to CI pipelines.
The framework includes utilities for:
- Installing framework utilities
- Updating installations
- Removing installations
- Repository synchronization
- Configuration backup
- Configuration restore
- Repository verification
- Framework diagnostics
- Cleanup
- Shell quality validation
install.sh writes every utility to INSTALL_DIR, which defaults to
~/.local/bin. That directory must be on your PATH for the utilities to be
runnable by name; doctor.sh reports what it finds, and update.sh
reinstalls in place. See config/default.conf for INSTALL_DIR.
Every change is verified using:
- Bash syntax validation
- ShellCheck static analysis
- shfmt formatting verification
- Automated Bats behavioral tests
- GitHub Actions Continuous Integration
make ci-localprints yourbash,bats,shellcheckandshfmtversions, warns when they differ from CI's pins, then runs CI's steps in order:syntax,shellcheck -x,shfmt -d -i 4 -ci,bats tests,make check,make doctor.make test-bash32runs the whole suite under/bin/bash, which is bash 3.2 on macOS; it skips with a message on systems without/bin/bash.- The zsh guard lives at
templates/guard.zsh;install.shdoes not touch your shell files. To activate it:cp templates/guard.zsh ~/.config/zsh/guard.zsh, thenecho 'source ~/.config/zsh/guard.zsh' >> ~/.zshrc. make verify-machineis not part of CI: it compares the guard installed at~/.config/zsh/guard.zshagainsttemplates/guard.zshand checks that topgrade really has both gem steps disabled, reporting MATCH or DIFFERENT.make verify-protectionis also local and read-only: it asks GitHub whatmain's branch protection requires and compares it with.github/required-checks.txt, because those two drifting apart makes a green PR unmergeable.- It is read-only and repairs nothing; run it when you want to know whether this machine still matches the repository.
- The first two mirror
.github/workflows/quality.yml; if CI is red, run them before pushing.
Documentation is treated as part of the codebase.
The repository includes:
- Architecture documentation
- Coding standards
- Security policy (SECURITY.md)
- Commit conventions (docs/COMMIT_CONVENTION.md)
- Review checklist
- Changelog
Development follows a consistent lifecycle:
flowchart TD
A["📐 Design"] --> B["⚒️ Implement"] --> C["✅ Validate"] --> D["🧪 Test"] --> E["🔍 Review"] --> F["📤 Release"]
| Category | Technology |
|---|---|
| Operating System | macOS |
| Shell | Bash |
| Version Control | Git |
| Repository Hosting | GitHub |
| CI/CD | GitHub Actions |
| Testing | Bats |
| Static Analysis | ShellCheck |
| Formatting | shfmt |
| Editor | Visual Studio Code |
| Documentation | Markdown |
Version: v2.4.0
- Modular Bash architecture
- Shared utility libraries
- Centralized configuration management
- Automated behavioral testing
- Continuous Integration
- Engineering documentation
- Reusable workstation utilities
- Consistent project structure
workstation-framework/
├── .github/ # GitHub workflows, templates, CODEOWNERS
├── .vscode/ # Recommended VS Code configuration
├── assets/ # Project assets
├── config/ # Framework configuration
│ ├── default.conf
│ ├── example.conf
│ └── user.conf
├── docs/ # Project documentation
├── scripts/
│ ├── lib/ # Shared Bash libraries
│ ├── backup.sh
│ ├── check-project.sh
│ ├── repo-clean.sh
│ ├── doctor.sh
│ ├── install.sh
│ ├── mac-routine.sh
│ ├── restore.sh
│ ├── shell-quality.sh
│ ├── sync.sh
│ ├── uninstall.sh
│ └── update.sh
├── templates/ # Script templates
├── tests/ # Automated Bats tests
├── Makefile
├── README.md
└── LICENSE
The repository is intentionally organized to separate framework logic, reusable libraries, configuration, documentation, testing, and project assets.
Developer Workstation Framework currently targets macOS.
Required tools:
- Bash
- Git
- ShellCheck
- shfmt
- jq (required by the 1Password backend in
scripts/lib/secrets.sh) - Bats (for development and testing)
Recommended:
- Visual Studio Code
- Homebrew
Clone the repository:
git clone https://github.com/SunnyJayaRaju/workstation-framework.git
cd workstation-frameworkInstall the framework:
./scripts/install.shVerify the installation:
./scripts/doctor.shFramework configuration is stored in the config/ directory.
config/
├── default.conf
├── example.conf
└── user.conf
Configuration precedence follows standard Unix conventions:
Environment Variables
│
▼
config/user.conf
│
▼
config/default.conf
This allows:
- sensible project defaults
- local machine customization
- CI/CD overrides
- temporary runtime overrides
Example:
BACKUP_DIR=/tmp/framework-backups ./scripts/backup.shNo repository files need to be modified for temporary configuration changes.
| Script | Description |
|---|---|
backup.sh |
Create timestamped backups of supported configuration files. |
check-project.sh |
Validate repository structure and required project files. |
repo-clean.sh |
Remove temporary development artifacts safely. |
doctor.sh |
Diagnose framework and workstation health. |
install.sh |
Install framework utilities into the local environment. |
mac-routine.sh |
Run topgrade, mo clean, brew doctor and brew cleanup in order, measuring root-owned files and the gem version between every step. |
restore.sh |
Restore the most recent configuration backup. |
shell-quality.sh |
Run Bash validation, ShellCheck, and formatting checks. |
sync.sh |
Verify synchronization with the remote Git repository. |
uninstall.sh |
Remove framework utilities from the local system. |
update.sh |
Update an installed framework and perform validation. |
These exist because of a real event on 2026-09-16. A RubyGems 4.0.21
source tree — 591 files — was written into
/opt/homebrew/lib/ruby/site_ruby/4.0.0/ with root ownership, at
2026-09-16 14:48:56. Homebrew's Ruby ships 4.0.20, so that tree was an
override, not part of the keg. The root-owned files then blocked brew link
and brew cleanup, and the weekly routine could not finish.
Which process issued that command is still unproven. The zsh history has no timestamps, its oldest per-session file begins 25 Sep, and macOS keeps no sudo log. Do not repeat that claim as fact.
The three rules, the guard and the harness check
brew install <name> # yes
sudo gem install <name> # never: writes into /opt/homebrew as rootHomebrew owns Ruby's gems. sudo gem and sudo brew are refused by
~/.config/zsh/guard.zsh, which is loaded from ~/.zshrc.
What the guard does NOT protect. It covers commands typed in an interactive shell. It does not cover topgrade. Topgrade calls
/usr/bin/sudo -E -H .../gem update --systemas a subprocess: no shell function is inherited into it, so nothing inguard.zshcan stop it. Topgrade is protected by two other things, and only by those two:
~/.config/topgrade.tomldisables thegemandruby_gemssteps.mac-routine.shrecords root-owned counts andgem -vbetween every step and stops the routine if either changes.Any other program that shells out to sudo needs the same treatment.
If a root-owned file appears anyway, the fix — which needs your password — is:
sudo find /opt/homebrew -user root -exec chown -h "$(whoami)":admin {} +Against a Homebrew Ruby it installs a whole RubyGems source tree into
site_ruby, shadowing the one the keg ships. It is also the command the
interpreter's ruby_gems step runs under sudo.
Homebrew's Ruby ships RubyGems with the keg. Upgrade gems individually with
gem install <name>; upgrade Ruby with brew upgrade ruby.
If an override does appear, move it aside rather than deleting it:
TS=$(date +%Y%m%d-%H%M%S); mkdir -p ~/Developer/Backups/site_ruby-stale-$TS
mv /opt/homebrew/lib/ruby/site_ruby/* ~/Developer/Backups/site_ruby-stale-$TS/
## undo: mv ~/Developer/Backups/site_ruby-stale-$TS/* /opt/homebrew/lib/ruby/site_ruby/mac-routine.sh # the real thing
mac-routine.sh --dry-run # measure onlyIt runs topgrade → mo clean → brew doctor → brew cleanup and, between
every step, records two numbers: how many files under /opt/homebrew and
~/.gem are owned by root, and what gem -v reports. If root ownership
changes, or gem -v changes to a version the active Ruby does not ship
(a site_ruby override), it stops: it prints the step responsible, the
new files, and the fix command, and nothing after that step runs. If gem -v
changes while still matching what the active Ruby ships — a legitimate
brew upgrade ruby keg move — it reports the change and continues; the
final health report decides whether the new keg left anything dangling.
At the end it runs the full health report and exits with its code: 0
everything clean, 1 the report printed a FAIL (damage existed or appeared),
2 usage error, 3 the routine stopped mid-way. Damage present before
the run is therefore reported, not waved through.
It never calls sudo. It passes topgrade --no-ask-retry so the
"Retry? (y)es/(N)o/(s)hell/(q)uit" prompt cannot hang it, and adds
--disable containers when no container runtime is answering. The macOS
system-update step is disabled (--disable system): a recorded run had it
auto-consent through --yes to downloading a full macOS upgrade and prompt
for a password mid-routine. An OS upgrade is a deliberate decision, not part
of this routine.
Two prompts can still appear, and both are yours to answer: mo clean's
admin check, and a Homebrew cask upgrade asking for your password to remove
an app's auto-update service. The routine waits for you — a recorded run
sat at that password prompt for 45 minutes (VS Code, 2026-11-11), which is
where a "48-minute" routine actually goes. Run the routine when you can be
at the keyboard.
The guard is bypassed with an explicit environment variable, deliberately and per-invocation:
ALLOW_RISKY_GEM=1 sudo gem install <name>Run bash ~/Developer/Tools/scripts/verify-setup.sh afterwards and read the
Ruby/gem health section.
lib/ruby_gem_health.sh is the single implementation, used by
verify-setup.sh, by mac-routine.sh between steps, and by
tests/ruby-gem-guard.bats. It reports:
| Verdict | Condition |
|---|---|
| FAIL | any root-owned file under /opt/homebrew or ~/.gem |
| FAIL | gem -v differs from the RubyGems version the active Homebrew Ruby ships (means a site_ruby override) |
| FAIL | site_ruby contains files (an empty directory is healthy) |
| FAIL | brew doctor reports an unlinked or unreadable keg |
| FAIL | a ~/.gem plugin points at a path that no longer exists, or a ~/.gem command's shebang names a missing interpreter |
| WARN | two versions of the same gem inside ~/.gem (Homebrew's bundled/default gems are excluded by design) |
| INFO | the interpreter ~/.gem/ruby/*/bin points at |
Every FAIL prints the exact fix. The harness never runs sudo — it prints
the command and you run it.
Every contribution should follow the same engineering workflow.
flowchart TD
A["📋 Plan"] --> B["⚒️ Implement"] --> C["✅ Validate"] --> D["🧪 Test"] --> E["🔍 Review"] --> F["💾 Commit"]
The objective is to maintain a repository where every change is reproducible, reviewable, and well documented.
The project uses a Makefile to simplify routine tasks.
| Command | Purpose |
|---|---|
make all |
Execute the complete quality gate. |
make test |
Run the Bats test suite. |
make lint |
Run ShellCheck validation. |
make doctor |
Execute workstation diagnostics. |
make check |
Verify repository structure. |
Before every commit, run:
make allBefore committing, make check is a quick read-only structure check. Verified locally:
make check[PASS] Repository structure verified.
Behavioral testing is implemented using Bats.
Current coverage includes:
- Backup
- Restore
- Installation
- Update
- Uninstall
- Doctor
- Cleanup
- Repository verification
- Configuration
- Shell quality
- Repository synchronization
Current status:
make testpasses with zero failures
Every push and pull request automatically runs:
- Bash syntax validation
- ShellCheck
- shfmt verification
- Automated Bats tests
This helps ensure that every change remains ready to merge.
Detailed project documentation is available in the docs/ directory.
Included documentation:
- Architecture
- Changelog
- Coding Standards
- Code Review Checklist
- Commit Convention
- Security Policy
Future enhancements may include:
- Additional workstation automation
- Expanded backup support
- Cross-platform compatibility
- Enhanced diagnostics
- More behavioral tests
- Plugin-style utility extensions
The project will continue to prioritize maintainability, modularity, and engineering quality over rapid feature growth.
Contributions are welcome.
Please review:
CONTRIBUTING.mdCODE_OF_CONDUCT.mdSECURITY.md
Before submitting a Pull Request, ensure:
make allpasses successfully.
This project is licensed under the MIT License.
See the LICENSE file for details.
Developer Workstation Framework was built with a strong emphasis on software engineering principles rather than simple shell scripting.
The project focuses on:
- Clean architecture
- Maintainable Bash code
- Reusable libraries
- Automated quality validation
- Documentation-first development
- Continuous improvement
If you find the project useful, consider starring the repository and sharing feedback through GitHub Issues or Pull Requests.