Skip to main content

IDE Integration

Vectra Guard integrates seamlessly with your development environment, providing security protection across terminals, VSCode, Cursor, and any IDE.

Quick Start

The shell tracker automatically protects all environments:
./scripts/install-shell-tracker.sh
This single installation enables protection in:
  • ✅ Terminal
  • ✅ VSCode integrated terminal
  • ✅ Cursor IDE
  • ✅ Any IDE terminal
  • ✅ SSH sessions

VSCode / Cursor Integration

Complete Setup

1

Install Vectra Guard

curl -fsSL https://raw.githubusercontent.com/xadnavyaai/vectra-guard/main/install.sh | bash
2

Install Shell Tracker

./scripts/install-shell-tracker.sh --shells "bash zsh"
Or install for all detected shells interactively:
./scripts/install-shell-tracker.sh
3

Configure IDE Tasks

Run the Cursor protection setup script:
WORKSPACE=$(pwd) ./scripts/setup-cursor-protection.sh
This creates:
  • .vscode/settings.json - Terminal environment configuration
  • .vscode/tasks.json - Protected build tasks
  • .vectra-guard/init.sh - Session initialization
4

Restart Your IDE

Restart VSCode or Cursor to load the new configuration.

VSCode Tasks Configuration

The setup script creates a complete tasks.json with protected commands:
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "🛡️ Protected: Install Dependencies",
      "type": "shell",
      "command": "vectra-guard",
      "args": ["exec", "--session", "${env:VECTRAGUARD_SESSION_ID}", "--", "npm", "install"],
      "group": "build",
      "presentation": {
        "echo": true,
        "reveal": "always",
        "panel": "shared",
        "showReuseMessage": false
      }
    },
    {
      "label": "🛡️ Protected: Run Tests",
      "type": "shell",
      "command": "vectra-guard",
      "args": ["exec", "--session", "${env:VECTRAGUARD_SESSION_ID}", "--", "npm", "test"],
      "group": "test"
    },
    {
      "label": "🛡️ Protected: Build",
      "type": "shell",
      "command": "vectra-guard",
      "args": ["exec", "--session", "${env:VECTRAGUARD_SESSION_ID}", "--", "npm", "run", "build"],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    },
    {
      "label": "🛡️ Protected: Deploy (Interactive)",
      "type": "shell",
      "command": "vectra-guard",
      "args": ["exec", "--interactive", "--session", "${env:VECTRAGUARD_SESSION_ID}", "--", "./scripts/deploy.sh"],
      "group": "none"
    },
    {
      "label": "🛡️ Start Session",
      "type": "shell",
      "command": "source .vectra-guard/init.sh",
      "group": "none"
    },
    {
      "label": "🛡️ View Session",
      "type": "shell",
      "command": "vectra-guard session show ${env:VECTRAGUARD_SESSION_ID}",
      "group": "none"
    }
  ]
}

Terminal Integration

Shell Tracker Installation

The shell tracker provides automatic session management and command logging across all shells.
Bash integration is automatically added to ~/.bashrc:
# Vectra Guard Shell Tracker (Auto-generated)
if [ -n "$BASH_VERSION" ] && command -v vectra-guard &> /dev/null; then
  _vectra_guard_init() {
    if [ -z "$VECTRAGUARD_SESSION_ID" ]; then
      SESSION=$(vectra-guard session start --agent "${USER}-bash" --workspace "$PWD" 2>/dev/null | tail -n 1 || echo "")
      if [ -n "$SESSION" ]; then
        export VECTRAGUARD_SESSION_ID=$SESSION
        echo $SESSION > ~/.vectra-guard-session
      fi
    fi
  }

  _vectra_guard_preexec() {
    local cmd="$BASH_COMMAND"
    if [[ "$cmd" =~ ^vectra-guard ]] || [[ "$cmd" =~ ^vg[[:space:]] ]]; then
      return 0
    fi
    VECTRA_LAST_CMD="$cmd"
  }

  _vectra_guard_precmd() {
    local exit_code=$?
    if [ -n "$VECTRA_LAST_CMD" ] && [ -n "$VECTRAGUARD_SESSION_ID" ]; then
      vectra-guard session record --session "$VECTRAGUARD_SESSION_ID" --command "$VECTRA_LAST_CMD" --exit-code "$exit_code" &>/dev/null
    fi
    unset VECTRA_LAST_CMD
  }

  shopt -s extdebug
  trap '_vectra_guard_preexec' DEBUG
  PROMPT_COMMAND="_vectra_guard_precmd${PROMPT_COMMAND:+; $PROMPT_COMMAND}"
  _vectra_guard_init
fi

Installation Options

# Prompts to select shells
./scripts/install-shell-tracker.sh

Session Management

Once the shell tracker is installed, sessions are managed automatically:
# Session starts automatically when you open a new terminal
echo $VECTRAGUARD_SESSION_ID
# Output: session-1234567890

# All commands are logged automatically
npm install
git commit -m "feat: add feature"
npm test

# View session activity
vg session show $VECTRAGUARD_SESSION_ID

# List all sessions
vg session list

Verification

After installation, verify the integration:
1

Restart Terminal

# Bash
source ~/.bashrc

# Zsh
source ~/.zshrc

# Fish (auto-loads on restart)
2

Check Session ID

echo $VECTRAGUARD_SESSION_ID
# Should output: session-XXXXXXXXXX
3

Test Command Logging

echo "hello world"
vg session show $VECTRAGUARD_SESSION_ID
# Should show the echo command in the log
4

Test Protected Execution

vg exec -- npm install
# Command runs with protection

IDE Coverage Table

Tool/ContextTracked?Protected?Setup Required
Terminal✅ (via vg exec)Shell tracker
VSCode✅ (via tasks)Shell tracker + tasks.json
Cursor✅ (via tasks)Shell tracker + tasks.json
Any IDE✅ (via vg exec)Shell tracker
SSH Sessions✅ (via vg exec)Shell tracker
Scripts✅ (via vg exec)Shell tracker

Uninstallation

To remove shell tracker integration:
# Restore backups
mv ~/.bashrc.vectra-backup ~/.bashrc
mv ~/.zshrc.vectra-backup ~/.zshrc
mv ~/.config/fish/config.fish.vectra-backup ~/.config/fish/config.fish

# Remove tracker files
rm -rf ~/.vectra-guard
rm -f ~/.vectra-guard-session

Next Steps

AI Agent Integration

Configure AI agents to use Vectra Guard

CI/CD Integration

Add protection to your CI/CD pipelines

Git Hooks

Validate scripts before commit

Configuration

Customize Vectra Guard settings

Build docs developers (and LLMs) love