Skip to main content

Setup scripts

Cyrus supports automated repository initialization through setup scripts that run when creating new Git worktrees for Linear issues. This powerful feature allows you to prepare the development environment automatically for each task.

Overview

When Cyrus processes a Linear issue, it:
  1. Creates a new Git worktree for isolation
  2. Runs setup scripts to prepare the environment
  3. Processes the issue in the prepared worktree
  4. Cleans up the worktree after completion
Setup scripts ensure each worktree starts with the correct dependencies, configuration, and environment.

Repository setup script

Creating a repository script

Place a cyrus-setup.sh script in your repository root:
Make the script executable:

Available environment variables

Cyrus provides these environment variables to your script:
  • LINEAR_ISSUE_ID: The Linear issue ID (UUID format)
  • LINEAR_ISSUE_IDENTIFIER: The issue identifier (e.g., “CEA-123”)
  • LINEAR_ISSUE_TITLE: The issue title
Example Usage:

When to use repository scripts

Common Use Cases:
  • Dependency Installation: npm install, pip install -r requirements.txt
  • Environment Configuration: Copy .env files, set up credentials
  • Database Setup: Create test databases, run migrations
  • Build Steps: Compile code, generate assets
  • Service Startup: Start local services needed for development
Example: Node.js Project
Example: Monorepo

Script best practices

Exit on error

Always use set -e to exit immediately if any command fails:

Keep scripts fast

Setup scripts delay issue processing. Keep them fast:
  • Cache dependencies when possible
  • Skip unnecessary steps
  • Use parallel installation when available

Timeout and error handling

  • Timeout: Scripts have a 5-minute timeout
  • Failure Behavior: Script failures don’t prevent worktree creation
  • Logs: Script output appears in Cyrus logs for debugging

Testing your script

Test the script locally before relying on it:

Advanced patterns

Conditional setup based on issue

Run different setup based on issue labels or title:

Caching dependencies

Speed up setup by caching dependencies:

Parallel setup

Run independent setup tasks in parallel:

Issue-specific configuration

Create configuration specific to each issue:

Troubleshooting

Script not running

Check:
  1. Script exists at repository root
  2. Script is named exactly cyrus-setup.sh
  3. Script has execute permissions (chmod +x cyrus-setup.sh)
  4. Script has correct shebang (#!/bin/bash)

Script failing

Debug Steps:
  1. Test script locally with test environment variables
  2. Check Cyrus logs for script output and errors
  3. Add echo statements to identify where script fails
  4. Verify all dependencies and commands are available
Common Issues:
  • Missing dependencies (e.g., npm not in PATH)
  • Permission errors (e.g., can’t write to directories)
  • Timeout (script takes longer than 5 minutes)

Script timeout

If scripts consistently timeout:
  1. Optimize dependency installation:
  2. Skip unnecessary steps:
  3. Cache dependencies: See caching pattern above

Script works locally but fails in Cyrus

Check that:
  • All paths are relative or use environment variables
  • All required tools are installed in the Cyrus environment
  • No interactive prompts (scripts must run non-interactively)

Next: Remote Hosting