/iterm:iterm-cross-skill-sourcingfrom iterm
Pattern for sourcing shared utilities from sibling skill directories in the iTerm plugin
Ships in iterm. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill documents the pattern for sourcing shared utilities from sibling skill directories within the iTerm plugin. The iTerm plugin uses a shared utilities file (iterm-utils.sh) located in the tab-management skill that must be sourced by scripts in other skills (like pane-management). This pattern ensures scripts can locate and source dependencies regardless of how they are invoked.
Use this pattern when creating new iTerm plugin scripts that need access to shared utilities:
pane-management skill that need iterm-utils.shrun_applescript(), is_container(), validate_iterm() that are defined in iterm-utils.shplugins/iterm/skills/
tab-management/
scripts/
iterm-utils.sh <-- SHARED utilities
iterm-open-tab.sh
iterm-list-tabs.sh
pane-management/
scripts/
iterm-split-pane.sh <-- Sources from sibling skill
#!/usr/bin/env bash
set -euo pipefail
##############################################################################
# Script Location and Sourcing
##############################################################################
# Get absolute path of script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Compute path to sibling skill's scripts directory
UTILS_DIR="$(cd "$SCRIPT_DIR/../../tab-management/scripts" && pwd)"
# Source shared utilities with error handling
# shellcheck source=../../tab-management/scripts/iterm-utils.sh
if ! source "$UTILS_DIR/iterm-utils.sh" 2>/dev/null; then
echo "[ERROR] Failed to source iterm-utils.sh from $UTILS_DIR" >&2
exit 3
fi
BASH_SOURCE[0] not $0: BASH_SOURCE[0] gives the script's path even when sourcedcd and pwd: Ensures the path works regardless of how the script is invokedIf sourcing fails, exit with code 3 (EXIT_INVALID_ARGS) to indicate a setup/configuration problem. This matches the iTerm plugin's exit code conventions:
From plugins/iterm/skills/pane-management/scripts/iterm-split-pane.sh:
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
UTILS_DIR="$(cd "$SCRIPT_DIR/../../tab-management/scripts" && pwd)"
if ! source "$UTILS_DIR/iterm-utils.sh" 2>/dev/null; then
echo "[ERROR] Failed to source iterm-utils.sh from $UTILS_DIR" >&2
exit 3
fi
# Now can use functions from iterm-utils.sh:
is_container
validate_iterm
run_applescript "$applescript"
If creating a new session-management skill that needs utils:
# From plugins/iterm/skills/session-management/scripts/iterm-manage-session.sh
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
UTILS_DIR="$(cd "$SCRIPT_DIR/../../tab-management/scripts" && pwd)"
if ! source "$UTILS_DIR/iterm-utils.sh" 2>/dev/null; then
echo "[ERROR] Failed to source iterm-utils.sh from $UTILS_DIR" >&2
exit 3
fi
Test scripts in the tests/ directory can also source utilities for validation:
# From plugins/iterm/skills/pane-management/tests/test-split-pane.sh
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
UTILS_SCRIPT="$SCRIPT_DIR/../../tab-management/scripts/iterm-utils.sh"
# Verify utils can be sourced (optional in tests)
if [[ -f "$UTILS_SCRIPT" ]]; then
source "$UTILS_SCRIPT"
fi
plugins/iterm/skills/pane-management/scripts/iterm-split-pane.sh (lines 44-52)plugins/iterm/skills/tab-management/scripts/iterm-utils.sh (shared utilities)archive/tickets/PANE-001_core-split-script/planning/architecture.md (section "Integration Points")What SKILL.md sets; muted values are Claude Code's defaults
9 skills in this plugin
/eleven-category-test-structureStandard 11-category test organization for iTerm plugin shell scripts/iterm-applescript-generationPattern for generating iTerm2 AppleScript with window checks, dual tell blocks, and conditional configuration/iterm-conditional-applescript-generationPattern for generating AppleScript variants based on window/tab filters to optimize iteration scopenpx claudepluginhub manifoldlogic/claude-code-plugins --plugin itermOther plugins' skills for the same job