# .zshrc Organization Standards
## Rule
The .zshrc file MUST be organized into logical sections, stay under 200 lines, and source external files for aliases, functions, and tool-specific configuration.
## Format
```bash
# ~/.zshrc — Master configuration (< 200 lines)
# ─── Environment ───────────────────────────────────
export EDITOR="nvim"
export LANG="en_US.UTF-8"
export PATH="$HOME/.local/bin:$PATH"
# ─── Oh My Zsh / Plugin Manager ───────────────────
export ZSH="$HOME/.oh-my-zsh"
plugins=(git docker z fzf zsh-autosuggestions)
source $ZSH/oh-my-zsh.sh
# ─── Completion ────────────────────────────────────
autoload -Uz compinit && compinit -C
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# ─── History ───────────────────────────────────────
HISTSIZE=50000
SAVEHIST=50000
setopt SHARE_HISTORY HIST_IGNORE_DUPS HIST_IGNORE_SPACE
# ─── Source External Files ─────────────────────────
[[ -f ~/.zsh/aliases.zsh ]] && source ~/.zsh/aliases.zsh
[[ -f ~/.zsh/functions.zsh ]] && source ~/.zsh/functions.zsh
[[ -f ~/.zsh/local.zsh ]] && source ~/.zsh/local.zsh
# ─── Lazy-Loaded Tools ────────────────────────────
# (nvm, pyenv, rbenv — loaded on first use)
# ─── Prompt (last) ────────────────────────────────
eval "$(starship init zsh)"
```
## File Structure
```
~/.zsh/
├── aliases.zsh # All aliases
├── functions.zsh # Custom functions
├── completions.zsh # Custom completions
└── local.zsh # Machine-specific (gitignored)
```
## Good
```bash
# Conditional sourcing (safe if file missing)
[[ -f ~/.zsh/aliases.zsh ]] && source ~/.zsh/aliases.zsh
```
## Bad
```bash
# 500-line .zshrc with everything inline
# No sections, no comments, no sourced files
alias gs="git status"
alias ga="git add"
# ... 200 more aliases ...
function proj() { ... }
# ... 100 more lines ...
```