Skip to content

AI Assistant Directory Safety Protocol

AI assistants (including GitHub Copilot) frequently lose track of their working directory when using terminal commands, leading to:

  • Commands executed in wrong directories
  • Build artifacts created in incorrect locations
  • Failed operations due to missing context
  • Potential data corruption or misplaced files

Every AI assistant session MUST follow this protocol for ALL terminal operations:

Terminal window
pwd && echo "=== CURRENT LOCATION VERIFIED ==="

Before any terminal command, explicitly state:

  • Need to be at: [target directory]
  • Current status: [what you know about current location]
  • Action: [what you’re about to do]
Terminal window
# BAD - relies on assumptions
cd packages/ui && yarn build
# GOOD - explicit absolute navigation
cd /Users/work-station/company/cloudalt-frontend/packages/ui && yarn build

4. Return to Workspace Root After Operations

Section titled “4. Return to Workspace Root After Operations”
Terminal window
cd /Users/work-station/company/cloudalt-frontend && pwd && echo "=== BACK AT WORKSPACE ROOT ==="
Terminal window
# Pattern: verify → navigate → confirm → execute
pwd && echo "=== VERIFYING LOCATION ===" && cd /path/to/target && pwd && echo "=== CONFIRMED LOCATION ===" && [command]
Terminal window
# Step 1: State intention
echo "Need to build UI package - navigating from workspace root"
# Step 2: Safe navigation with verification
pwd && echo "=== STARTING FROM ===" && cd /Users/work-station/company/cloudalt-frontend/packages/ui && pwd && echo "=== NOW IN UI PACKAGE ===" && yarn build
# Step 3: Return to root
cd /Users/work-station/company/cloudalt-frontend && pwd && echo "=== BACK AT WORKSPACE ROOT ==="
  1. NEVER assume where you are
  2. ALWAYS verify with pwd before operations
  3. ALWAYS use absolute paths for directory changes
  4. ALWAYS return to workspace root after subdirectory work
  5. ALWAYS state your intentions before terminal commands
  • Every new AI chat session MUST implement this protocol
  • No exceptions for “simple” or “quick” operations
  • Protocol must be followed even for read-only operations

This is a systematic workaround for a fundamental GitHub Copilot limitation that should be fixed at the platform level.