Reference

API reference for commands, tools, and configuration.

This page is written as a practical reference for users and contributors. SafeClaw’s public surface is currently the CLI, environment configuration, local tool contracts, and the Twilio-compatible WhatsApp webhook.

CLI commands

safeclaw run TASK

Runs one task and returns the final assistant response.

safeclaw run "search my workspace for installer docs" --session default --model gpt-4.1-mini --permission-profile readonly

safeclaw chat

Starts an interactive terminal loop. Built-in commands include exit, reset, and memory.

safeclaw doctor

Checks setup health. Use --strict in automation when failures should return a non-zero exit.

safeclaw doctor --port 8080 --strict

safeclaw session-config

Stores per-session model and permission metadata.

safeclaw session-config default --model llama3.2:3b --permission-profile readonly

Tool capabilities

Tools are exposed to the assistant and gated by permission profile before execution.

ToolCapabilityRisk class
list_filesList files inside the configured workspace.Read
read_fileRead a workspace file with size trimming.Read
search_filesSearch names and optionally content inside the workspace.Read
write_fileCreate or overwrite a workspace file with backup behavior.Write
edit_fileReplace text in a file, optionally all matches, with backup behavior.Write
apply_patchApply a git-style patch after path and patch checks.Write
fetch_urlFetch a URL and trim output.Network
web_searchFetch search result data from a web endpoint.Network
shellRun shell commands when shell is enabled and profile permits it.Shell
send_whatsappSend outbound WhatsApp messages through Twilio.Messaging
rememberSave local memory for the current session.Memory
recall_memoryRead local memory for the current session.Memory
search_memorySearch saved local memory notes.Memory
forgetDelete saved memory by id or matching text.Memory
session_statusShow session message counts, memory counts, model, and permission settings.Session

Environment variables

NamePurpose
OPENAI_API_KEYAPI key for the configured OpenAI-compatible provider. Use ollama as a dummy value for local Ollama.
OPENAI_BASE_URLOptional provider base URL, for example http://localhost:11434/v1.
OPENAI_MODELDefault model name.
WORKSPACEFolder SafeClaw tools can access.
SAFECLAW_PERMISSION_PROFILEDefault profile: readonly, workspace-write, network-allow, shell-ask, shell-allow, or messaging-allow.
SAFECLAW_APPROVAL_MODEApproval behavior: ask, deny, or auto.
ALLOW_SHELLMust be true before shell commands can run.
MAX_TOOL_STEPSMaximum number of tool-call rounds for a task.
TWILIO_ACCOUNT_SIDTwilio account identifier for WhatsApp.
TWILIO_AUTH_TOKENTwilio auth token.
TWILIO_WHATSAPP_FROMTwilio WhatsApp sender, such as whatsapp:+14155238886.
SAFECLAW_ALLOWED_SENDERSComma-separated WhatsApp sender allowlist.

WhatsApp webhook

Run safeclaw whatsapp to expose a Twilio-compatible webhook. Configure Twilio to send inbound WhatsApp messages to:

POST https://your-public-url/whatsapp

Supported remote commands include /help, /status, /memory, /reset, /permissions, /permissions readonly, and /model MODEL.

Testing and live mode

SafeClaw’s test suite is mocked by default. Live/unmocked tests are opt-in so contributors can run normal tests without spending API calls or hitting real services.

python3 -m pytest
python3 -m pytest --cov=safeclaw --cov-report=term-missing
python3 -m pytest --run-live