Guard

Aider Integration

Integrate AIVory Guard with Aider, the powerful terminal-based AI pair programming tool, to scan AI-generated code for compliance and security issues.

  • Terminal-native workflow - Scan code directly from your terminal alongside Aider
  • Multiple integration options - Shell wrapper, pre-commit hooks, or direct prompts
  • Git-aware scanning - Scan staged changes before committing
  • 17+ compliance standards - OWASP, GDPR, HIPAA, PCI-DSS, and more
Note Aider does not currently support MCP (Model Context Protocol). Use AIVory Guard via shell wrapper, pre-commit hooks, or direct CLI commands instead.

Prerequisites

Before you begin, ensure you have the following installed:

Aider
Install with pip install aider-chat
AIVory Guard CLI
Available via npx (no install needed)
API Key (Optional)

Integration Options

Choose the integration method that best fits your workflow.

Shell Wrapper
Automatic scanning after every Aider session
Pre-commit Hook
Scan staged changes before each commit
Direct Prompts
Ask Aider to run scans on demand

Option 1: Shell Wrapper

Create a wrapper script that automatically scans your code after every Aider session.

Create the Wrapper Script

Create ~/bin/aider-secure:

#!/bin/bash
# Run aider with automatic compliance scanning

# Start aider
aider "$@"

# After aider exits, scan changes
echo "Running AIVory compliance scan..."
npx --yes @aivorynet/guard scan .

Make It Executable

chmod +x ~/bin/aider-secure

Usage

Use the wrapper instead of aider:

aider-secure
Note Add ~/bin to your PATH if it’s not already there. Add export PATH="$HOME/bin:$PATH" to your shell profile.

Option 2: Pre-commit Hook

Add AIVory scanning to your Git workflow to catch compliance issues before they’re committed.

Create the Hook

Add to .git/hooks/pre-commit:

#!/bin/bash
# AIVory compliance check before commit

npx --yes @aivorynet/guard scan --staged
if [ $? -ne 0 ]; then
  echo "Compliance violations found. Fix before committing."
  exit 1
fi

Make It Executable

chmod +x .git/hooks/pre-commit
Warning Pre-commit hooks are repository-specific. You’ll need to set this up for each repository where you want automatic scanning.

Option 3: Direct Prompts

Ask Aider to run AIVory scans directly during your coding session.

Example Prompts

Please scan the code I just wrote using AIVory Guard:
npx --yes @aivorynet/guard scan filename.py
Run a compliance check on the authentication module:
npx --yes @aivorynet/guard scan src/auth/
Note Aider can execute shell commands when asked, making this a flexible on-demand option for quick compliance checks.

API Key Configuration

For full access to all compliance standards and unlimited scans, configure your API key.

Set Environment Variable

export AIVORY_API_KEY="your_api_key_here"
Note Add this to your shell profile (.bashrc, .zshrc, etc.) to persist across sessions.

Get Your API Key

Get your API key from app.aivory.net/tokens.

Free Tier
OWASP Top 10, 15 files/scan, 3 scans/day
Full Access Premium
18+ standards, unlimited scans, dashboard access

Troubleshooting

Common Issues

Command Not Found

  • Ensure npm/npx is installed and in your PATH
  • Try running npx --yes @aivorynet/guard --help directly

API Key Not Working

  • Verify the key is correctly exported: echo $AIVORY_API_KEY
  • Check your key is valid at app.aivory.net/tokens

Pre-commit Hook Not Running

  • Verify the hook is executable: ls -la .git/hooks/pre-commit
  • Check hook permissions: chmod +x .git/hooks/pre-commit

Wrapper Script Issues

  • Ensure ~/bin is in your PATH
  • Check script is executable: chmod +x ~/bin/aider-secure
Advanced Configuration

Enable Specific Standards

Scan for specific compliance standards only:

npx --yes @aivorynet/guard scan --standards OWASP_TOP_10,GDPR .

Scan Options

Flag Description
--staged Scan only staged files
--standards Comma-separated list of standards
--output json Output results as JSON
--verbose Show detailed scan information

Environment Variables

Variable Description
AIVORY_API_KEY Your AIVory API key
AIVORY_ENABLED_STANDARDS Default standards to check
AIVORY_LOG_LEVEL Logging verbosity (debug, info, warn, error)

Next Steps