### Repository Setup Script Example Source: https://docs.terragonlabs.com/docs/configuration/environment-setup/setup-scripts A basic repository setup script that installs project dependencies using pnpm and executes a local setup script. This script is version-controlled and shared among all users of the repository. ```bash #!/bin/bash # This script runs for all users working with this repository pnpm install ./scripts/setup.sh ``` -------------------------------- ### Install Swift Toolchain using Mise Source: https://docs.terragonlabs.com/docs/configuration/environment-setup/setup-scripts Installs necessary runtime dependencies for Swift, installs and configures Mise (a polyglot version manager), installs a specified Swift version, sets it as the global default, and ensures Mise activation in future shells. ```bash #!/bin/bash set -euo pipefail # Desired Swift version SWIFT_VERSION="6.1" # Install runtime dependencies for Swift toolchains sudo apt-get update -y sudo apt-get install -y \ libncurses6 \ libcurl4 \ libxml2 \ libedit2 \ libsqlite3-0 \ zlib1g \ ca-certificates # Install mise curl -fsSL https://mise.run | sh export PATH="$HOME/.local/bin:$PATH" echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc # Ensure mise is active in THIS shell eval "$($HOME/.local/bin/mise activate bash)" # Enable experimental features for Swift mise settings experimental=true # Install Swift version mise install "swift@${SWIFT_VERSION}" # Set it as global default mise use --global "swift@${SWIFT_VERSION}" # Verify installation mise x -- swift --version # (Optional) clear caches to save space mise cache clear || true rm -rf "$HOME/.cache/mise" "$HOME/.local/share/mise/downloads" # Ensure mise activates in future shells echo 'eval "$(mise activate bash)"' >> ~/.bashrc ``` -------------------------------- ### Install OpenJDK Source: https://docs.terragonlabs.com/docs/configuration/environment-setup/setup-scripts Downloads and installs a specific version of OpenJDK from Oracle, extracts it to /usr/local/java, and configures JAVA_HOME and PATH environment variables in ~/.bashrc. ```bash #!/bin/bash JAVA_VERSION="21" JAVA_DOWNLOAD_URL="https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz" echo "Downloading OpenJDK $JAVA_VERSION from Oracle..." curl -fsSL "$JAVA_DOWNLOAD_URL" -o /tmp/openjdk.tar.gz echo "Extracting to /usr/local/java..." mkdir -p /usr/local/java tar -xzf /tmp/openjdk.tar.gz -C /usr/local/java --strip-components=1 rm /tmp/openjdk.tar.gz # Make sure that the java binary is in the PATH when bashrc is sourced echo 'export JAVA_HOME=/usr/local/java' >> ~/.bashrc echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc ``` -------------------------------- ### Install Go Toolchain Source: https://docs.terragonlabs.com/docs/configuration/environment-setup/setup-scripts Installs a specific version of the Go toolchain from a provided URL and adds the Go binary directory to the PATH in ~/.bashrc. This ensures Go commands are available in the sandbox environment. ```bash #!/bin/bash INSTALL_DIR="/usr/local" curl -fsSL https://go.dev/dl/go1.25.0.linux-amd64.tar.gz | tar -C ${INSTALL_DIR} -xz # Make sure that the go binary is in the PATH when bashrc is sourced echo "export PATH=$PATH:${INSTALL_DIR}/go/bin" >> ~/.bashrc ``` -------------------------------- ### Install and Configure Node.js Version Manager (NVM) Source: https://docs.terragonlabs.com/docs/configuration/environment-setup/setup-scripts Installs NVM, configures it for the current shell, installs a specific Node.js version (20), sets it as the default, and adds NVM sourcing to ~/.bashrc for future sessions. ```bash #!/bin/bash node -v curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash # initialize nvm in this shell source ~/.nvm/nvm.sh >/dev/null # install the version we want nvm install 20 nvm use 20 nvm alias default 20 # Add nvm to the bashrc echo 'source ~/.nvm/nvm.sh >/dev/null 2>&1' >> ~/.bashrc ``` -------------------------------- ### Specific Prompt Example for Adding Tests Source: https://docs.terragonlabs.com/docs/tasks/creating-tasks Provides a concrete example of a prompt for adding unit tests, specifying the module, types of scenarios to cover, and referencing existing test patterns. This emphasizes the benefit of clear goals and context. ```markdown ✅ Add unit tests for the payment processing module in @src/payments/. Cover successful transactions, failed payments, refund processing, and webhook handling. Use existing patterns from @src/payments/stripe.test.ts ``` -------------------------------- ### Install Ruby Version Manager (RVM) Source: https://docs.terragonlabs.com/docs/configuration/environment-setup/setup-scripts Installs RVM, sources it for the current shell, installs Ruby version 3.4.4, sets it as the default, and configures ~/.bashrc to source RVM for future shell sessions. ```bash #!/bin/bash # Install RVM gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys \ 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB curl -sSL https://get.rvm.io | bash -s stable # Source RVM source /etc/profile.d/rvm.sh # Ruby install + default rvm install 3.4.4 rvm --default use 3.4.4 # Persist to future shells echo '[[ -s /etc/profile.d/rvm.sh ]] && source /etc/profile.d/rvm.sh >/dev/null 2>&1' >> ~/.bashrc ``` -------------------------------- ### Pull Changes with Terry CLI Source: https://docs.terragonlabs.com/docs/getting-started/quick-start This command allows you to pull changes generated by Terragon to your local repository. Ensure the Terry CLI is installed before use. This is a crucial step for testing and integrating Terragon's output. ```bash terry pull ``` -------------------------------- ### Example System Prompts: Testing Guidelines Source: https://docs.terragonlabs.com/docs/configuration/custom-system-prompts This example outlines system prompts for testing best practices. It emphasizes maintaining a code coverage above 80% and adhering to the Arrange, Act, Assert (AAA) pattern for tests, along with appropriate mocking of external dependencies. ```text coverage remains above 80%. Follow the AAA pattern: Arrange, Act, Assert. Mock external dependencies appropriately. ``` -------------------------------- ### Example .env File Format Source: https://docs.terragonlabs.com/docs/configuration/environment-setup/environment-variables Demonstrates the standard format for a .env file, which is used for importing environment variables into Terragon. It includes examples for API keys, database configurations, feature flags, and external service credentials. ```dotenv # API Keys OPENAI_API_KEY=sk-... ANTHROPIC_API_KEY=sk-ant-... # Database Configuration DATABASE_URL=postgresql://user:password@localhost:5432/mydb REDIS_URL=redis://localhost:6379 # Feature Flags ENABLE_NEW_FEATURE=true DEBUG_MODE=false # External Services WEBHOOK_URL=https://api.example.com/webhook SLACK_TOKEN=xoxb-... ``` -------------------------------- ### Example System Prompts: Project-Specific (Next.js) Source: https://docs.terragonlabs.com/docs/configuration/custom-system-prompts This example provides project-specific system prompts for a Next.js 14 application using the App Router. It mandates input validation with Zod schemas, the use of a custom logger, and adherence to defined error handling patterns. ```text This is a Next.js 14 app using the App Router. All API routes should validate input with Zod schemas. Use our custom logger from '@/lib/logger' for debugging. Follow our error handling patterns in '@/lib/errors.' ``` -------------------------------- ### Install Terragon CLI using npm Source: https://docs.terragonlabs.com/docs/integrations/cli Installs the Terragon CLI globally on your system using npm. Ensure you have Node.js 18+ and npm installed. ```bash npm install -g @terragon-labs/cli ``` -------------------------------- ### Example System Prompts: Code Style (TypeScript/React) Source: https://docs.terragonlabs.com/docs/configuration/custom-system-prompts This example demonstrates a system prompt for defining code style guidelines. It specifies the use of TypeScript with strict mode, functional React components with hooks, Tailwind CSS for styling, and JSDoc comments for exported functions. ```text Always use TypeScript with strict mode enabled. Prefer functional components with hooks in React. Use Tailwind CSS for styling, avoid inline styles. Include JSDoc comments for all exported functions. ``` -------------------------------- ### Specific Prompt Example for Performance Improvement Source: https://docs.terragonlabs.com/docs/tasks/creating-tasks Demonstrates a detailed prompt for performance optimization, outlining specific techniques like lazy loading and pagination, and setting a clear performance target. This showcases the value of setting clear goals. ```markdown ✅ Optimize dashboard loading time by implementing lazy loading for charts, adding pagination to the activity feed (10 items per page), and using React.memo for expensive components. Target: under 1 second load time. ``` -------------------------------- ### Using Environment Variables in Setup Scripts Source: https://docs.terragonlabs.com/docs/configuration/environment-setup/environment-variables Shows how to access and utilize environment variables within a bash script for Terragon sandbox setup. It demonstrates echoing variable values and exporting new variables based on existing ones. ```bash #!/bin/bash echo "API Key: $MY_API_KEY" echo "Database URL: $DATABASE_URL" # Configure application with environment variables export NODE_ENV=production export API_ENDPOINT=$API_URL ``` -------------------------------- ### Multiple MCP Servers Configuration (JSON) Source: https://docs.terragonlabs.com/docs/configuration/mcp-setup Demonstrates how to configure multiple MCP servers of different types (command-based, HTTP, SSE) within a single JSON configuration file. ```json { "mcpServers": { "custom-tools": { "command": "python", "args": ["/home/user/mcp-server.py"] }, "context7": { "type": "http", "url": "https://mcp.context7.com/mcp" }, "sse-server": { "type": "sse", "url": "https://example.com/mcp-sse" }, "another-server": { "command": "mcp-server", "env": { "CONFIG_PATH": "/etc/mcp/config.yaml" } } } } ``` -------------------------------- ### Command-based MCP Server Configuration (JSON) Source: https://docs.terragonlabs.com/docs/configuration/mcp-setup Configures a command-based MCP server, which runs as a local process. Requires a 'command' to execute and optionally accepts 'args' and 'env' variables. ```json { "mcpServers": { "my-custom-server": { "command": "node", "args": ["/path/to/server.js"], "env": { "API_KEY": "your-api-key", "OTHER_CONFIG": "value" } } } } ``` -------------------------------- ### Referencing GitHub Issues in Prompts Source: https://docs.terragonlabs.com/docs/integrations/github-integration This example shows how to reference a GitHub issue within a prompt to Terragon. Terragon will automatically fetch the issue details and link the corresponding pull request. ```text Fix the authentication bug described in issue #234 ``` -------------------------------- ### Specific Prompt Example for Bug Fixing Source: https://docs.terragonlabs.com/docs/tasks/creating-tasks Illustrates a specific and descriptive prompt for fixing a bug, contrasting it with a vague prompt. This highlights the importance of providing detailed context, including file paths and the nature of the bug. ```markdown ✅ Fix the authentication timeout bug where users are logged out after 30 minutes of inactivity. The issue is likely in @src/auth/session.ts where we handle token refresh. ``` -------------------------------- ### MCP Server Configuration Format (JSON) Source: https://docs.terragonlabs.com/docs/configuration/mcp-setup Defines the basic JSON structure for configuring MCP servers in Terragon. It includes a top-level 'mcpServers' object where individual server configurations are defined. ```json { "mcpServers": { "server-name": { // Server configuration } } } ``` -------------------------------- ### SSE-based MCP Server Configuration (JSON) Source: https://docs.terragonlabs.com/docs/configuration/mcp-setup Configures an SSE (Server-Sent Events) MCP server for real-time communication. Requires a 'type' set to 'sse' and a 'url'. Optional 'headers' and 'env' can be provided. ```json { "mcpServers": { "sse-server": { "type": "sse", "url": "https://example.com/mcp-sse", "headers": { "Authorization": "Bearer your-token" } } } } ``` -------------------------------- ### HTTP-based MCP Server Configuration (JSON) Source: https://docs.terragonlabs.com/docs/configuration/mcp-setup Configures an HTTP-based MCP server to connect to a remote endpoint. Requires a 'type' set to 'http' and a 'url'. Optional 'headers' and 'env' can be provided. ```json { "mcpServers": { "context7": { "type": "http", "url": "https://mcp.context7.com/mcp", "headers": { "Authorization": "Bearer your-token" } } } } ``` -------------------------------- ### Add Custom Binary Path to Bashrc Source: https://docs.terragonlabs.com/docs/configuration/environment-setup/setup-scripts This script snippet demonstrates how to add a custom binary directory to the system's PATH environment variable by appending it to the ~/.bashrc file. This ensures that binaries in the specified path are accessible in subsequent shell sessions. ```bash echo "export PATH='$PATH:/path/to/bin'" >> ~/.bashrc ``` -------------------------------- ### Accessing Environment Variables in Shell Scripts Source: https://docs.terragonlabs.com/docs/configuration/environment-setup/environment-variables Provides examples of how to access and use environment variables directly within shell scripts. ```shell # Shell scripts echo "Using API key: $OPENAI_API_KEY" psql "$DATABASE_URL" ``` -------------------------------- ### GitHub CLI Commands for PR and Issue Management Source: https://docs.terragonlabs.com/docs/integrations/github-integration This snippet demonstrates common GitHub CLI commands for viewing pull request details, comments, issue information, and repository context. These commands are available in every sandbox environment managed by Terragon. ```bash # View PR details and comments gh pr view 123 --comments # Check issue information gh issue view 456 # Understand repository context gh repo view ``` -------------------------------- ### Include URL for Task Context in Terragon Source: https://docs.terragonlabs.com/docs/tasks/creating-tasks Shows how to include external URLs, such as issue tracker links, to provide additional context for a task. This helps the AI understand the problem domain or specific requirements. ```markdown Fix the bug described in this issue: https://github.com/myorg/myapp/issues/234 ``` -------------------------------- ### Authenticate with Terragon CLI Source: https://docs.terragonlabs.com/docs/integrations/cli Authenticates the Terragon CLI with your Terragon account. This command opens a browser for authentication, generates a token, and stores credentials in `~/.terry/config.json`. You can override the default settings directory using the `TERRY_SETTINGS_DIR` environment variable. ```bash terry auth ``` ```bash export TERRY_SETTINGS_DIR=~/.config/terry terry auth ```