squid 🦑
An AI-powered command-line tool for code reviews and suggestions. Privacy-focused and local-first - your code never leaves your hardware when using local models.
Features
- 🤖 Chat with LLMs via OpenAI-compatible APIs
- 📄 Provide file context for AI analysis
- 🔍 AI-powered code reviews with language-specific prompts
- 🔧 Tool calling support (file read/write/search operations) with multi-layered security
- 🔒 Path validation (whitelist/blacklist) and .squidignore support
- 🛡️ User approval required for all tool executions (read/write files)
- 🌊 Streaming support for real-time responses
- 🎨 Enhanced UI with styled prompts, emoji icons, and color-coded information
- 🦑 Friendly squid assistant personality with professional responses
- ⚙️ Configurable via environment variables
- 🔌 Works with LM Studio, OpenAI, and other compatible services
Privacy & Local-First
Your code never leaves your hardware when using local LLM services (LM Studio, Ollama, etc.).
- 🔒 Complete Privacy - Run models entirely on your own machine
- 🏠 Local-First - No data sent to external servers with local models
- 🛡️ You Control Your Data - Choose between local models (private) or cloud APIs (convenient)
- 🔐 Secure by Default - Multi-layered security prevents unauthorized file access
Privacy Options:
- Maximum Privacy: Use LM Studio or Ollama - everything runs locally, no internet required for inference
- Cloud Convenience: Use OpenAI or other cloud providers - data sent to their servers for processing
- Your Choice: Squid works with both - you decide based on your privacy needs
All file operations require your explicit approval, regardless of which LLM service you use.
Prerequisites
Before you begin, you'll need:
-
Rust toolchain (for building squid)
| -
An OpenAI-compatible LLM service (choose one):
Option A: LM Studio (Recommended for Local Development)
LM Studio provides a user-friendly interface for running local LLMs.
- Download and install LM Studio from https://lmstudio.ai/
- Download a model - We recommend Qwen2.5-Coder for code-related tasks:
- In LM Studio, search for:
lmstudio-community/Qwen2.5-Coder-7B-Instruct-MLX-4bit - Or browse: https://huggingface.co/lmstudio-community/Qwen2.5-Coder-7B-Instruct-MLX-4bit
- Click download and wait for it to complete
- In LM Studio, search for:
- Load the model - Select the downloaded model in LM Studio
- Start the local server:
- Click the "Local Server" tab (↔️ icon on the left)
- Click "Start Server"
- Default endpoint:
http://127.0.0.1:1234/v1 - Note: No API key required for local server
Alternative models in LM Studio:
Meta-Llama-3.1-8B-Instruct- General purposedeepseek-coder- Code-focused- Any other model compatible with your hardware
Option B: Ollama (Lightweight CLI Option)
Ollama is a lightweight, command-line tool for running LLMs.
-
Install Ollama:
# macOS # Linux | # Or download from https://ollama.com/ -
Start Ollama service:
-
Pull the recommended model - Qwen2.5-Coder:
- Model page: https://ollama.com/library/qwen2.5-coder
- Available sizes: 0.5B, 1.5B, 3B, 7B, 14B, 32B
- Default (7B) is recommended for most use cases
-
Verify it's running:
Alternative models in Ollama:
codellama- Code generationdeepseek-coder- Code understandingllama3.1- General purpose- See all at https://ollama.com/library
Option C: OpenAI API
Use OpenAI's cloud API for access to GPT models:
- Get an API key from https://platform.openai.com/api-keys
- Add credits to your OpenAI account
- Choose a model:
gpt-4,gpt-4-turbo,gpt-3.5-turbo, etc.
Option D: Other OpenAI-Compatible Services
Squid works with any OpenAI-compatible REST API:
- OpenRouter (https://openrouter.ai/) - Access to multiple LLM providers
- Together AI (https://together.ai/) - Fast inference
- Anyscale (https://anyscale.com/) - Enterprise solutions
- Local APIs - Any custom OpenAI-compatible endpoint
Installation
From crates.io (Recommended)
This installs the squid command globally from crates.io. You can then use squid from anywhere.
From Source
Clone the repository and install locally:
For Development
For development, use cargo run -- instead of squid in the examples below.
Configuration
You can configure squid in two ways:
Option 1: Interactive Setup (Recommended)
Use the init command to create a squid.config.json file:
Interactive Mode (Default)
# Initialize in current directory
# Initialize in a specific directory
This will prompt you for:
- API URL: The base URL for your LLM service (e.g.,
http://127.0.0.1:1234/v1) - API Model: The model identifier (e.g.,
local-model,qwen2.5-coder,gpt-4) - API Key: Optional API key (leave empty for local models like LM Studio or Ollama)
- Log Level: Logging verbosity (
error,warn,info,debug,trace)
Example session:
$ squid init
INFO: Initializing squid configuration in "."...
? API URL: http://127.0.0.1:1234/v1
? API Model: local-model
? API Key (optional, press Enter to skip):
? Log Level: info
Configuration saved to: "squid.config.json"
API URL: http://127.0.0.1:1234/v1
API Model: local-model
API Key: [not set]
Log Level: info
✓ Created .squidignore with default patterns
Edit this file to customize which files squid should ignore
Non-Interactive Mode
You can also provide configuration values via command-line arguments to skip the interactive prompts:
# Initialize with all parameters
# Initialize in a specific directory with parameters
# Partial parameters (will prompt for missing values)
# Will still prompt for API Key and Log Level
# Include API key for cloud services
Available options:
--url <URL>- API URL (e.g.,http://127.0.0.1:1234/v1)--model <MODEL>- API Model (e.g.,local-model,qwen2.5-coder,gpt-4)--api-key <KEY>- API Key (optional for local models)--log-level <LEVEL>- Log Level (error,warn,info,debug,trace)
The configuration is saved to squid.config.json in the specified directory (or current directory if not specified). This file can be committed to your repository to share project settings with your team.
Option 2: Manual Configuration
Create a .env file in the project root:
# OpenAI API Configuration (for LM Studio or OpenAI)
API_URL=http://127.0.0.1:1234/v1
API_MODEL=local-model
API_KEY=not-needed
Important Notes:
squid.config.jsontakes precedence over.envvariables. If both exist, the config file will be used.- Commit
squid.config.jsonto your repository to share project settings with your team - Keep
.envprivate - it should contain sensitive information like API keys and is excluded from git - For cloud API services (OpenAI, etc.), store the actual API key in
.envand omitapi_keyfromsquid.config.json
Configuration Options
-
API_URL: The base URL for the API endpoint- LM Studio:
http://127.0.0.1:1234/v1(default) - Ollama:
http://localhost:11434/v1 - OpenAI:
https://api.openai.com/v1 - Other: Your provider's base URL
- LM Studio:
-
API_MODEL: The model to use- LM Studio:
local-model(uses whatever model is loaded) - Ollama:
qwen2.5-coder(recommended) or any pulled model - OpenAI:
gpt-4,gpt-3.5-turbo, etc. - Other: Check your provider's model names
- LM Studio:
-
API_KEY: Your API key- LM Studio:
not-needed(no authentication required) - Ollama:
not-needed(no authentication required) - OpenAI: Your actual API key (e.g.,
sk-...) - Other: Your provider's API key
- LM Studio:
-
LOG_LEVEL: Logging verbosity (optional, default:error)error: Only errors (default)warn: Warnings and errorsinfo: Informational messagesdebug: Detailed debugging informationtrace: Very verbose output
Usage
Note: The examples below use the
squidcommand (after installation withcargo install --path .).
For development, replacesquidwithcargo run --(e.g.,cargo run -- ask "question").
Ask a Question
# Basic question (streaming by default)
# With additional context using -m
# Use a custom system prompt
# Disable streaming for complete response at once (useful for scripting)
By default, responses are streamed in real-time, displaying tokens as they are generated. Use --no-stream to get the complete response at once (useful for piping or scripting).
Ask About a File
# Basic file question (streams by default)
# With additional context using -m
# Use a custom system prompt for specialized analysis
# Disable streaming for complete response
This will read the file content and include it in the prompt, allowing the AI to answer questions based on the file's content.
Review Code
# Review a file with language-specific prompts (streams by default)
# Focus on specific aspects
# Get complete review at once (no streaming)
The review command automatically selects the appropriate review prompt based on file type:
- Rust (
.rs) - Ownership, safety, idioms, error handling - TypeScript/JavaScript (
.ts,.js,.tsx,.jsx) - Type safety, modern features, security - HTML (
.html,.htm) - Semantics, accessibility, SEO - CSS (
.css,.scss,.sass) - Performance, responsive design, maintainability - Other files - Generic code quality and best practices
Tool Calling (with Multi-Layered Security)
The LLM has been trained to intelligently use tools when needed. It understands when to read, write, or search files based on your questions.
Security Layers:
- Path Validation - Automatically blocks system directories (
/etc,/root,~/.ssh, etc.) - Ignore Patterns -
.squidignorefile blocks specified files/directories (like.gitignore) - User Approval - Manual confirmation required for each operation
For details, see Security Features.
# LLM intelligently reads files when you ask about them
# You'll be prompted: "Allow reading file: [filename]? (Y/n)"
# LLM can write files
# You'll be prompted with a preview: "Allow writing to file: hello.txt?"
# Use custom prompts with tool calling
# LLM can search for patterns in files using grep
# You'll be prompted: "Allow searching for pattern '...' in: [path]? (Y/n)"
# Results show file path, line number, and matched content
# Use --no-stream for non-streaming mode
Available Tools:
- 📖 read_file - Read file contents from the filesystem
- 📝 write_file - Write content to files
- 🔍 grep - Search for patterns in files using regex (supports directories and individual files)
Key Features:
- 🤖 Intelligent tool usage - LLM understands when to read/write/search files from natural language
- 🛡️ Path validation - Automatic blocking of system and sensitive directories
- 📂 Ignore patterns -
.squidignorefile for project-specific file blocking - 🔒 Security approval - All tool executions require user confirmation
- 📋 Content preview - File write operations show what will be written
- ⌨️ Simple controls - Press
Yto allow orNto skip - 📝 Full logging - All tool calls are logged for transparency
- 🔍 Regex support - Grep tool supports regex patterns with configurable case sensitivity
- 🔐 Privacy preserved - With local models (LM Studio/Ollama), all file operations happen locally on your machine
Using .squidignore:
Create a .squidignore file in your project root to block specific files and directories:
# .squidignore - Works like .gitignore
Patterns are automatically enforced - the LLM cannot access ignored files even if approved.
Documentation
- Quick Start Guide - Get started in 5 minutes
- Security Features - Tool approval and security safeguards
- System Prompts Reference - Guide to all system prompts and customization
- Examples - Comprehensive usage examples and workflows
- Changelog - Version history and release notes
- Sample File - Test file for trying out the file context feature
- Example Files - Test files for code review prompts
- AI Agents Guide - Instructions for AI coding assistants working on this project
Testing
Try the code review and security features with the provided test scripts:
# Test code reviews (automated)
# Test security approval (interactive)
# Or test individual examples
See tests/README.md for complete testing documentation and sample-files/README.md for details on each example file.
Examples
Using with LM Studio
- Download and install LM Studio from https://lmstudio.ai/
- Download the recommended model:
lmstudio-community/Qwen2.5-Coder-7B-Instruct-MLX-4bit - Load the model in LM Studio
- Start the local server (↔️ icon → "Start Server")
- Set up your
.env:API_URL=http://127.0.0.1:1234/v1 API_MODEL=local-model API_KEY=not-needed - Run:
# Or with a file # Use --no-stream for complete response at once
Using with Ollama
- Install Ollama from https://ollama.com/
- Start Ollama service:
- Pull the recommended model:
- Set up your
.env:API_URL=http://localhost:11434/v1 API_MODEL=qwen2.5-coder API_KEY=not-needed - Run:
# Or with a file # Use --no-stream if needed
Using with OpenAI
- Get your API key from https://platform.openai.com/api-keys
- Set up your
.env:API_URL=https://api.openai.com/v1 API_MODEL=gpt-4 API_KEY=sk-your-api-key-here - Run:
# Or analyze a file # Use --no-stream for scripting result=
License
Apache-2.0 License. See LICENSE file for details.