--- name: agent-handoffs description: Agent parameter passing, memory files, and data handoffs between agents --- # Agent Parameter Passing Guidelines ## Core Principle **Agents are workflow-agnostic.** They perform specific tasks regardless of which workflow invokes them. Workflows pass parameters to agents to tell them: - Which workflow is running - What files to read (input) - What files to write (output) - Any workflow-specific context ## Standard Parameters All agents that work with memory files MUST accept these parameters: ```typescript interface AgentParameters { workflow: string; // "create-module" | "add-operation" | "update-module" moduleId: string; // "github-github" | "amazon-aws-s3" inputFile?: string; // File to read from (optional if agent doesn't need input) outputFile: string; // File to write to } ``` ## Memory Path Construction **CRITICAL: Always use absolute paths for `.localmemory` to avoid issues when working from different directories.** ```bash # Get project root (choose method based on context) PROJECT_ROOT="$(git rev-parse --show-toplevel)" # Standard pattern - ALWAYS use absolute paths MEMORY_PATH="${PROJECT_ROOT}/.claude/.localmemory/${workflow}-${moduleId}" # Examples (where PROJECT_ROOT is your project's absolute path): # ${PROJECT_ROOT}/.claude/.localmemory/create-module-github-github/ # ${PROJECT_ROOT}/.claude/.localmemory/add-operation-github-github/ # ${PROJECT_ROOT}/.claude/.localmemory/update-module-amazon-aws-s3/ ``` ### For Bash Scripts ```bash # Method 1: Using git (preferred if in git repo) PROJECT_ROOT="$(git rev-parse --show-toplevel)" # Method 2: Using script location (if you know the script depth) PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" # Always construct absolute paths MEMORY_PATH="${PROJECT_ROOT}/.claude/.localmemory/${workflow}-${moduleId}" ``` ### For Agents (invoked by Claude) Agents should always receive or construct absolute paths. When constructing paths in agent responses, use the working directory from the environment. ## Reading Input Files ```bash # Agent receives parameters WORKFLOW="create-module" MODULE_ID="github-github" INPUT_FILE="phase-01-discovery.json" # Get project root and construct absolute paths PROJECT_ROOT="$(git rev-parse --show-toplevel)" MEMORY_PATH="${PROJECT_ROOT}/.claude/.localmemory/${WORKFLOW}-${MODULE_ID}" INPUT_PATH="${MEMORY_PATH}/${INPUT_FILE}" # Read data PRODUCT_PACKAGE=$(jq -r '.productPackage' "${INPUT_PATH}") MODULE_PACKAGE=$(jq -r '.modulePackage' "${INPUT_PATH}") ``` ## Writing Output Files ```bash # Agent receives parameters OUTPUT_FILE="phase-02-scaffolding.json" # Get project root and construct absolute paths PROJECT_ROOT="$(git rev-parse --show-toplevel)" MEMORY_PATH="${PROJECT_ROOT}/.claude/.localmemory/${WORKFLOW}-${MODULE_ID}" OUTPUT_PATH="${MEMORY_PATH}/${OUTPUT_FILE}" # Ensure directory exists mkdir -p "${MEMORY_PATH}" # Write data cat > "${OUTPUT_PATH}" <