Installation

Keep Silk Code isolated in ~/SilkCode/.venv while making the silkcode command available from every zsh terminal.

Requirements

Install or update Silk Code

This block is safe to paste directly into zsh. It finds an installed Python 3.10+ automatically and recreates an older Silk Code virtual environment when necessary.

PYTHON_BIN=""
for candidate in python3.14 python3.13 python3.12 python3.11 python3.10 python3; do
    if command -v "$candidate" >/dev/null 2>&1 && "$candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3,10) else 1)' 2>/dev/null; then
        PYTHON_BIN="$(command -v "$candidate")"
        break
    fi
done

if [ -z "$PYTHON_BIN" ]; then
    echo "Silk Code requires Python 3.10 or newer."
    echo "On macOS with Homebrew, install one with: brew install python@3.12"
    exit 1
fi

echo "Using $($PYTHON_BIN --version) at $PYTHON_BIN"

if [ -d "$HOME/SilkCode/.git" ]; then
    git -C "$HOME/SilkCode" pull --ff-only
else
    git clone https://github.com/RupertCloud/SilkCode.git "$HOME/SilkCode"
fi

cd "$HOME/SilkCode"

if [ -x .venv/bin/python ] && ! .venv/bin/python -c 'import sys; raise SystemExit(0 if sys.version_info >= (3,10) else 1)' 2>/dev/null; then
    echo "Recreating .venv because it uses Python $( .venv/bin/python --version 2>&1 )"
    rm -rf .venv
fi

[ -d .venv ] || "$PYTHON_BIN" -m venv .venv
.venv/bin/python -m pip install --upgrade pip setuptools wheel
.venv/bin/python -m pip install -e .
"$HOME/SilkCode/.venv/bin/silkcode" --help

grep -Fq 'export PATH="$HOME/SilkCode/.venv/bin:$PATH"' ~/.zshrc 2>/dev/null || \
    echo 'export PATH="$HOME/SilkCode/.venv/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
silkcode --help

If your Mac only has Python 3.9

Older macOS setups may still resolve python3 to Python 3.9. Silk Code requires Python 3.10 or newer.

If you use Homebrew:

brew install python@3.12
python3.12 --version

Then rerun the installer above. It will detect python3.12 and recreate any incompatible .venv.

Why the virtual environment must be recreated

A Python virtual environment is tied to the interpreter that created it. If .venv was created with Python 3.9, upgrading pip does not turn that environment into Python 3.10+. The installer therefore removes only Silk Code's incompatible .venv and recreates it with a supported interpreter.

Why the packaging upgrade matters

Some macOS Python installations create virtual environments with old packaging tools. Before installing Silk Code, the installer upgrades pip, setuptools, and wheel:

.venv/bin/python -m pip install --upgrade pip setuptools wheel

Verify

command -v silkcode
silkcode --help
silkcode models

Troubleshooting

Package 'silkcode' requires a different Python

Your existing virtual environment was created by Python 3.9 or older. If Python 3.12 is installed, repair it with:

cd "$HOME/SilkCode"
rm -rf .venv
python3.12 -m venv .venv
.venv/bin/python -m pip install --upgrade pip setuptools wheel
.venv/bin/python -m pip install -e .
source ~/.zshrc
silkcode --help

ERROR: setup.py or setup.cfg not found

Upgrade the packaging tools and retry:

cd "$HOME/SilkCode"
.venv/bin/python -m pip install --upgrade pip setuptools wheel
.venv/bin/python -m pip install -e .

zsh: command not found: #

The official install block contains no shell comments. If you want interactive comments enabled generally, run:

echo 'setopt interactivecomments' >> ~/.zshrc
source ~/.zshrc

zsh: command not found: silkcode

"$HOME/SilkCode/.venv/bin/silkcode" --help
source ~/.zshrc
command -v silkcode