Skip to content

CLI Reference

The Anvil CLI provides commands for project setup, tool management, and system diagnostics.

The CLI is installed automatically with the package:

Terminal window
pip install anvil-agent
anvil --help
Terminal window
anvil --version # Show version
anvil --help # Show help

Initialize a new Anvil project.

Terminal window
anvil init [OPTIONS]
OptionShortDefaultDescription
--dir-d.Directory to initialize.
--tools-diranvil_toolsName of the tools directory.
--force-fOverwrite existing files.
--skip-keysSkip interactive API key setup.
  1. Creates the tools directory structure
  2. Sets up .gitignore to protect API keys
  3. Prompts for API keys (optional)
  4. Creates a .env file
  5. Generates an example script
Terminal window
# Initialize current directory
anvil init
# Initialize a specific directory
anvil init --dir ./my-project
# Custom tools directory
anvil init --tools-dir my_tools
# Non-interactive mode
anvil init --skip-keys
# Overwrite existing files
anvil init --force

Check system requirements and configuration.

Terminal window
anvil doctor
  • Python version (requires 3.10+)
  • Docker availability
  • API key configuration
  • .env file existence
  • Tools directory status
🩺 System Health Check
┌───────┬─────────────────────────────┬───────────╮
│ ✓ │ Python │ 3.12.0 │
│ ✓ │ Docker │ 24.0.7 │
│ ✓ │ Rich CLI │ enabled │
╰───────┴─────────────────────────────┴───────────╯
🔑 API Keys
┌───────┬────────────────────────┬──────────────────────╮
│ ✓ │ ANTHROPIC_API_KEY │ sk-ant-...1234 │
│ ○ │ FIRECRAWL_API_KEY │ not set (optional) │
╰───────┴────────────────────────┴──────────────────────╯
╭──────────────────────────────────────────────────────╮
│ All checks passed! │
╰──────────────────────────────────────────────────────╯

List all cached tools.

Terminal window
anvil list [OPTIONS]
OptionShortDefaultDescription
--dir-d./anvil_toolsTools directory.
--jsonOutput as JSON.
Terminal window
# List tools
anvil list
# Custom directory
anvil list --dir ./my_tools
# JSON output (for scripting)
anvil list --json
📦 Anvil Tools (3 total)
┌────────┬──────────────────┬─────────┬─────────────────────────────────┐
│ Status │ Name │ Version │ Intent │
├────────┼──────────────────┼─────────┼─────────────────────────────────┤
│ ● │ search_github │ v1.0 │ Search GitHub repositories │
│ ● │ get_weather │ v1.2 │ Get current weather for a city │
│ ○ │ custom_tool │ v1.0 │ Custom implementation │
╰────────┴──────────────────┴─────────┴─────────────────────────────────╯
IconMeaning
● (green)Active, working tool
● (red)Failed tool
○ (yellow)Ejected (user-controlled)
{
"tools": [
{
"name": "search_github",
"file": "./anvil_tools/search_github.py",
"version": "1.0",
"intent": "Search GitHub repositories",
"status": "active",
"size_bytes": 1234,
"modified": "2025-01-18T10:00:00"
}
]
}

Clear the tool cache to force regeneration.

Terminal window
anvil clean [OPTIONS]
OptionShortDefaultDescription
--dir-d./anvil_toolsTools directory.
--force-fSkip confirmation prompt.
--keep-ejectedKeep user-controlled tools.
  1. Removes all managed tool files
  2. Updates the tool registry
  3. Clears __pycache__
  4. Optionally preserves ejected tools
Terminal window
# Interactive confirmation
anvil clean
# Skip confirmation
anvil clean --force
# Keep user-edited tools
anvil clean --keep-ejected
# Clean specific directory
anvil clean --dir ./my_tools --force
🧹 Anvil Clean
Managed tools to remove: 5
- search_github
- get_weather
- send_email
... and 2 more
Ejected tools (keeping): 1
Proceed with cleanup? [y/N]: y
✓ Removed 5 tools.
ℹ Tools will be regenerated on next use.

Verify a tool’s code in the sandbox.

Terminal window
anvil verify <TOOL_NAME> [OPTIONS]
ArgumentDescription
TOOL_NAMEName of the tool to verify.
OptionShortDefaultDescription
--dir-d./anvil_toolsTools directory.
  1. Loads the tool’s source code
  2. Runs static security analysis
  3. Executes in sandbox (if Docker available)
  4. Reports violations or success
Terminal window
# Verify a tool
anvil verify search_github
# Verify tool in custom directory
anvil verify my_tool --dir ./custom_tools
🔍 Verifying: search_github
Sandbox: docker
✓ Code passed verification!
Duration: 45.2ms
🔍 Verifying: dangerous_tool
Sandbox: docker
✗ Code failed verification!
Error: Security violation detected
Security violations:
- Blocked import: subprocess
- Dangerous function call: os.system

CodeMeaning
0Success
1Error or verification failure

The CLI respects these environment variables:

VariableDescription
ANTHROPIC_API_KEYAnthropic API key
OPENAI_API_KEYOpenAI API key
XAI_API_KEYGrok API key
FIRECRAWL_API_KEYFireCrawl API key