Help us improve
Share bugs, ideas, or general feedback.
From iterm
Pattern for sourcing shared utilities from sibling skill directories in the iTerm plugin
npx claudepluginhub manifoldlogic/claude-code-plugins --plugin itermHow this skill is triggered — by the user, by Claude, or both
Slash command
/iterm:iterm-cross-skill-sourcingThe summary Claude sees in its skill listing — used to decide when to auto-load this 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.
Analyzes Claude Code plugin skills to identify script opportunities for performance gains (fewer tokens, faster execution, consistency), then creates scripts optionally via --analyze, --create, or --all.
Provides shared bash libraries for Claude skills: phase0.sh manages session state, intel relay, memory read, hypotheses; signals.sh emits append-only signals. Sourced by other skills.
Creates standalone reusable skills from proven patterns or debugging solutions, generating SKILL.md, README, and reference docs/examples. For recurring, non-obvious, or broadly applicable fixes.
Share bugs, ideas, or general feedback.
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")