Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ knowledge-base/
├── AGENTS.md # Shared agent instructions (code philosophy, etc.)
├── CLAUDE.md -> AGENTS.md # Symlink for Claude Code compatibility
├── scripts/ # Utility scripts
├── setup/ # New Mac setup: Brewfile, dotfiles, setup.sh
└── skills/ # Portable agent skills
```

Expand Down
30 changes: 30 additions & 0 deletions setup/AGENT_PROMPT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Agent Prompt: Set Up This Mac

Paste everything below into a coding agent running on the new machine.

---

Set up this Mac from my knowledge-base repo.

## Steps

1. If `~/Repositories/knowledge-base` does not exist, clone `https://github.com/sunwrobert/knowledge-base.git` there.
2. Read `setup/README.md` and `setup/setup.sh` before running anything.
3. Run `setup/setup.sh`. If it stops for the Xcode command line tools installer, wait for me to finish it, then run the script again.
4. If a step fails, find the cause, fix it and run the script again. It is safe to run more than once. If a Homebrew cask no longer exists, tell me instead of substituting another one.
5. Verify the result:
- `brew bundle check --file setup/Brewfile` passes.
- `git`, `gh`, `gt`, `bun`, `pnpm`, `node`, `uv`, `tilt`, `tofu`, `infisical`, `pi`, `codex`, `claude`, `omp` and `agent-browser` all resolve in a new login shell (`zsh -lic 'command -v <name>'`).
- `~/.zshrc`, `~/.zprofile`, `~/.config/zed/settings.json` and `~/.config/herdr/config.toml` are symlinks into `setup/dotfiles`.
- `git config --global --get-all include.path` lists `setup/dotfiles/gitconfig`.
- `~/.agents/skills` contains the skills from the repo.
6. Report what was installed, what failed, and the manual steps from `setup/README.md` that are still open.

## Rules

- Never write a secret, API key or token to any file in the repo. Secrets go in `~/.zshrc.local` only, and I enter them myself.
- Do not log in to any account for me. List the login commands I need to run.
- Do not put an OpenRouter key in any shell file. Agents get their credential from `ori login`.
- Do not install or remove employer-managed software such as device management, security or compliance agents.
- Do not commit or push changes to the repo unless I ask.
- Do not delete the `.backup.<timestamp>` files the script creates.
63 changes: 63 additions & 0 deletions setup/Brewfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
tap "hashicorp/tap"
tap "infisical/get-cli"
tap "oven-sh/bun"
tap "speakeasy-api/tap"
tap "withgraphite/tap"

# Languages and package managers
brew "fnm"
brew "mise"
brew "oven-sh/bun/bun"
brew "pnpm"
brew "uv"

# Git
brew "git"
brew "gh"
brew "withgraphite/tap/graphite"
brew "gnupg"

# Shell utilities
brew "jq"
brew "hurl"
brew "hyperfine"
brew "k6"
brew "ffmpeg"
brew "imagemagick"

# Infrastructure
brew "tilt"
brew "helm"
brew "argocd"
brew "opentofu"
brew "hashicorp/tap/terraform"
brew "infisical/get-cli/infisical"
brew "stripe-cli"
brew "speakeasy-api/tap/speakeasy"
brew "postgresql@18"

# Command line casks
cask "1password-cli"
cask "gcloud-cli"
cask "orbstack"

# Apps
cask "1password"
cask "caffeine"
cask "cap"
cask "chatgpt"
cask "claude"
cask "conductor"
cask "cursor"
cask "discord"
cask "ghostty"
cask "google-chrome"
cask "granola"
cask "linear-linear"
cask "notion"
cask "obsidian"
cask "raycast"
cask "slack"
cask "t3-code@nightly"
cask "yaak"
cask "zed@preview"
42 changes: 42 additions & 0 deletions setup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Machine Setup

One script sets up a new Mac: apps, command line tools, shell, dotfiles, Node, global packages and agent skills.

## Run

```bash
git clone https://github.com/sunwrobert/knowledge-base.git ~/Repositories/knowledge-base
~/Repositories/knowledge-base/setup/setup.sh
```

The script is safe to run again. Existing dotfiles are moved to `<name>.backup.<timestamp>` before they are replaced with symlinks into this folder. `~/.gitconfig` is the exception: it stays a real file that includes `dotfiles/gitconfig`.

## Contents

- `Brewfile`: Homebrew formulae and casks.
- `dotfiles/`: `zshrc`, `zprofile`, `gitconfig`, Zed settings and Herdr config.
- `setup.sh`: the setup script.
- `AGENT_PROMPT.md`: a prompt that has a coding agent run and verify the setup.

## Manual Steps

1. Sign in to 1Password and turn on its SSH agent.
2. Run `gh auth login`, `gh auth setup-git`, `gt auth` and `gcloud auth login`.
3. Install the command line tools with no package: `ori`, `herdr`, `fx` and `devin`.
4. Run `ori login`, then `ori alias` so plain `pi`, `claude`, `codex` and `omp` run through Ori. No OpenRouter key goes in the shell config.
5. Install the apps with no Homebrew cask: Devin, Hex, Magnet, Ports, PR Review, Readout, Grok Bot, Rex Beta and Xcode.
6. Import Raycast settings.
7. Put any other secrets in `~/.zshrc.local`, which the script creates and git never sees.

## Not Included

- Secrets: SSH keys, API keys and auth tokens.
- Apps and agents an employer installs.

## Updating

Add a tool to `Brewfile` or the package list in `setup.sh` when you start using it. Edit dotfiles in place; they are symlinks into this repo.

## With An Agent

Once a coding agent is installed, paste `AGENT_PROMPT.md` into it. The agent runs the script, fixes failures, checks the result and lists the manual steps that are left.
24 changes: 24 additions & 0 deletions setup/dotfiles/gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[alias]
co = checkout
cob = checkout -b
sw = switch
swc = switch -c
br = branch
st = status --short --branch
aa = add --all
ap = add --patch
ci = commit
cm = commit -m
ca = commit --amend
df = diff
ds = diff --staged
unstage = reset HEAD --
last = log -1 HEAD
lg = log --graph --pretty=format:%C(auto)%h%C(reset) %C(auto)%d%C(reset) %s %C(dim white)- %an, %ar%C(reset) --all
rb = rebase
rbi = rebase --interactive
cp = cherry-pick
aliases = !git config --get-regexp \"^alias\\\\.\"
[user]
name = sunwrobert
email = sunwrobert@gmail.com
17 changes: 17 additions & 0 deletions setup/dotfiles/herdr/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
onboarding = false

[ui.sound]
enabled = true

[[keys.command]]
key = "prefix+f"
type = "plugin_action"
command = "herdr-file-viewer.open-file-viewer"
description = "open file viewer in split"

[[keys.command]]
key = "prefix+shift+f"
type = "plugin_action"
command = "herdr-file-viewer.open-file-viewer-tab"
description = "open file viewer in tab"

33 changes: 33 additions & 0 deletions setup/dotfiles/zed/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Zed settings
//
// For information on how to configure Zed, see the Zed
// documentation: https://zed.dev/docs/configuring-zed
//
// To see all of Zed's default settings without changing your
// custom settings, run `zed: open default settings` from the
// command palette (cmd-shift-p / ctrl-shift-p)
{
"edit_predictions": {
"provider": "zed"
},
"project_panel": {
"dock": "left"
},
"session": {
"trust_all_worktrees": true
},
"vim_mode": true,
"base_keymap": "Cursor",
"icon_theme": {
"mode": "dark",
"light": "Catppuccin Frappé",
"dark": "Catppuccin Frappé"
},
"ui_font_size": 16,
"buffer_font_size": 15,
"theme": {
"mode": "dark",
"light": "One Light",
"dark": "Catppuccin Macchiato"
}
}
4 changes: 4 additions & 0 deletions setup/dotfiles/zprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export PATH="$HOME/.local/bin:$PATH"

# OrbStack command-line tools and integration
source ~/.orbstack/shell/init.zsh 2>/dev/null || :
19 changes: 19 additions & 0 deletions setup/dotfiles/zshrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="robbyrussell"
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
source "$ZSH/oh-my-zsh.sh"

# fnm
if command -v fnm >/dev/null 2>&1; then
eval "$(fnm env --shell zsh)"
fi

# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
[ -s "$BUN_INSTALL/_bun" ] && source "$BUN_INSTALL/_bun"

export PATH="$HOME/.local/bin:$HOME/.opencode/bin:$PATH"

# Secrets and machine-specific settings live outside the repo.
[ -f "$HOME/.zshrc.local" ] && source "$HOME/.zshrc.local"
104 changes: 104 additions & 0 deletions setup/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env bash
# One-stop setup for a new Mac. Safe to run again.
set -euo pipefail

SETUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(dirname "$SETUP_DIR")"
DOTFILES="$SETUP_DIR/dotfiles"
NODE_VERSION="24"

step() { printf '\n==> %s\n' "$1"; }

# Symlink $1 to $2, moving any existing real file aside first.
link() {
local source="$1" target="$2"
mkdir -p "$(dirname "$target")"
if [ -e "$target" ] && [ ! -L "$target" ]; then
mv "$target" "$target.backup.$(date +%Y%m%d%H%M%S)"
fi
ln -sfn "$source" "$target"
echo "linked $target"
}

if [ "$(uname)" != "Darwin" ]; then
echo "This script only supports macOS." >&2
exit 1
fi

step "Xcode command line tools"
if ! xcode-select -p >/dev/null 2>&1; then
xcode-select --install
echo "Finish the installer, then run this script again."
exit 0
fi

step "Homebrew"
if ! command -v brew >/dev/null 2>&1 && [ ! -x /opt/homebrew/bin/brew ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
if [ -x /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi

step "Apps and command line tools"
brew bundle --file "$SETUP_DIR/Brewfile"

step "Oh My Zsh"
ZSH_DIR="$HOME/.oh-my-zsh"
if [ ! -d "$ZSH_DIR" ]; then
RUNZSH=no CHSH=no KEEP_ZSHRC=yes \
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
for plugin in zsh-autosuggestions zsh-syntax-highlighting; do
plugin_dir="$ZSH_DIR/custom/plugins/$plugin"
[ -d "$plugin_dir" ] ||
git clone --depth 1 "https://github.com/zsh-users/$plugin" "$plugin_dir"
done

step "Dotfiles"
link "$DOTFILES/zshrc" "$HOME/.zshrc"
link "$DOTFILES/zprofile" "$HOME/.zprofile"
# Included, not linked, so tools that write to ~/.gitconfig leave the repo clean.
git config --global --get-all include.path | grep -qxF "$DOTFILES/gitconfig" ||
git config --global --add include.path "$DOTFILES/gitconfig"
link "$DOTFILES/zed/settings.json" "$HOME/.config/zed/settings.json"
link "$DOTFILES/herdr/config.toml" "$HOME/.config/herdr/config.toml"
if [ ! -f "$HOME/.zshrc.local" ]; then
printf '# Secrets and machine-specific settings. Never commit this file.\n' >"$HOME/.zshrc.local"
chmod 600 "$HOME/.zshrc.local"
echo "created ~/.zshrc.local"
fi

step "Node"
eval "$(fnm env --shell bash)"
fnm install "$NODE_VERSION"
fnm default "$NODE_VERSION"
fnm use "$NODE_VERSION"

step "Global npm and bun packages"
npm install --global \
@earendil-works/pi-coding-agent \
@openai/codex \
agent-browser \
executor \
hunkdiff \
prime-agent
bun add --global @oh-my-pi/pi-coding-agent

step "Claude Code"
command -v claude >/dev/null 2>&1 || [ -x "$HOME/.local/bin/claude" ] ||
curl -fsSL https://claude.ai/install.sh | bash

step "Agent skills"
mkdir -p "$HOME/.agents/skills" "$HOME/.claude/skills"
for skill_dir in "$REPO_DIR"/skills/*/; do
name="$(basename "$skill_dir")"
[ -e "$HOME/.agents/skills/$name" ] ||
ln -s "${skill_dir%/}" "$HOME/.agents/skills/$name"
[ -e "$HOME/.claude/skills/$name" ] ||
ln -s "../../.agents/skills/$name" "$HOME/.claude/skills/$name"
done

step "Done"
echo "Open a new terminal, then follow the manual steps in setup/README.md."
echo "Or hand setup/AGENT_PROMPT.md to a coding agent to finish and verify."
Loading