Skip to main content

Overview

Post-clone scripts run automatically after Blocks clones your repository into the sandbox, before the coding agent starts working. Use them to install dependencies, set up tooling, or run any initialization commands your project needs.

Creating a post-clone script

  1. Create a .blocks directory in your repository root
  2. Add a file named post-clone or post-clone.sh
  3. Make it executable: chmod +x .blocks/post-clone
#!/bin/bash
set -e

# Install dependencies
npm ci

# Install Python packages
pip install -r requirements.txt

echo "Post-clone setup complete!"
The script runs with root privileges, so you can install system packages via apt-get.
Always start with set -e. Without it, the agent continues even if setup fails, which leads to confusing errors mid-task.

Common use cases

#!/bin/bash
set -e

npm ci
pip install -r requirements.txt
go mod download

Best practices

Check before installing — make scripts idempotent so they run cleanly every session:
if ! command -v mytool &> /dev/null; then
    curl -L https://example.com/mytool -o /usr/local/bin/mytool
    chmod +x /usr/local/bin/mytool
fi
Use lock files — prefer npm ci over npm install for faster, reproducible installs. Add PATH exports to ~/.bashrc — binaries installed to custom paths need to be on PATH for the agent to find them. Log progressecho statements make it easy to spot where a script stalls.

Limitations

Each Blocks session runs in a fresh sandbox. Packages installed by a post-clone script are not persisted — the script runs every time a new session starts on that repository.
For a full list of tools pre-installed in the sandbox, see Environment.