Orkestra
GitHub

The .orkestra/scripts/ directory contains three shell scripts that Orkestra executes at lifecycle boundaries. All three are created by ork trak list on first run and are committed to version control.

ScriptWhen it runsWorking directory
checks.shAfter each agent work stage with a gate configuredTrak’s worktree (set by Orkestra)
worktree_setup.shAfter Orkestra creates a new worktree, before the first stage startsProject root
worktree_cleanup.shBefore Orkestra removes a worktreeProject root

checks.sh

The gate script. Runs after the agent completes a stage that references it via gate.command. Its exit code determines what happens next:

  • Exit 0 — gate passes. The stage advances to human review (or auto-advances if is_automated: true).
  • Non-zero exit — gate fails. stdout and stderr are captured and sent to the agent as feedback. The agent retries.

Environment variables

VariableAlways set?Description
ORKESTRA_WORKTREE_PATHYesAbsolute path to the Trak’s worktree
ORKESTRA_PROJECT_ROOTYesAbsolute path to the project root
ORKESTRA_TASK_IDYesThe Trak’s ID (e.g., only-decisive-chiffchaff)
ORKESTRA_TASK_TITLEYesThe Trak’s title
ORKESTRA_BASE_BRANCHYesThe branch the Trak was created from
ORKESTRA_BRANCHYesThe Trak’s git branch name
ORKESTRA_PARENT_IDSubtraks onlyParent Trak’s ID

Examples

Orkestra sets the working directory to the Trak’s worktree before invoking checks.sh. The cd "$ORKESTRA_WORKTREE_PATH" in these examples is defensive — it ensures the script works correctly regardless of the invocation context.

Node.js project:

#!/bin/bash
set -e
cd "$ORKESTRA_WORKTREE_PATH"

pnpm install --frozen-lockfile
pnpm run lint
pnpm run typecheck
pnpm test

Rust project:

#!/bin/bash
set -e
cd "$ORKESTRA_WORKTREE_PATH"

cargo fmt --check
cargo clippy -- -D warnings
cargo test

worktree_setup.sh

Runs after Orkestra creates a new git worktree for a Trak, before the first stage starts. Use it to prepare the worktree so the agent can work — copying environment files, installing dependencies, or creating symlinks.

Working directory: Project root.

Arguments: The absolute path to the new worktree as $1.

Exit behavior:

  • Exit 0 — setup succeeded. The Trak proceeds.
  • Non-zero exit — setup failed. Worktree creation is blocked.

Example

#!/bin/bash
set -e
WORKTREE_PATH="$1"

# Copy environment config to the new worktree
cp .env "$WORKTREE_PATH/.env"

# Install dependencies in the worktree
cd "$WORKTREE_PATH"
pnpm install --frozen-lockfile

worktree_cleanup.sh

Runs before Orkestra removes a Trak’s worktree, on completion, failure, or manual cleanup. Use it to remove anything worktree_setup.sh created that Git won’t clean up automatically (.env copies, caches, symlinks).

Working directory: Project root.

Arguments: The absolute path to the worktree being removed as $1.

Exit behavior: The exit code is ignored. Cleanup always proceeds regardless of whether this script fails. Output is not captured or logged.

Example

#!/bin/bash
WORKTREE_PATH="$1"

# Remove the env file copied in worktree_setup.sh
rm -f "$WORKTREE_PATH/.env"