From iterm
Pattern for sourcing shared utilities from sibling skill directories in the iTerm plugin
npx claudepluginhub manifoldlogic/claude-code-plugins --plugin itermThis skill uses the workspace's default tool permissions.
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.
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Generates original PNG/PDF visual art via design philosophy manifestos for posters, graphics, and static designs on user request.
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")