AsterClaw
AsterClaw is a lightweight Rust AI agent with a local gateway, tool execution, and channel integrations.
This documentation includes:
- user setup and runtime basics
- architecture overview
- CLI and configuration reference
- security and operations practices
- profiling scripts
- GitHub Pages publishing flow
- developer workflow and extension guidance
Quick Start
Requirements
- Rust (
stable) cargo- Git
- optional:
mdbook
Build
cargo build --release
Initialize
asterclaw onboard
Run gateway
asterclaw gateway
Check status
asterclaw status
Preview docs locally
mdbook serve docs
CLI Reference
Based on src/main.rs.
Core commands
asterclaw onboard
asterclaw agent [-m|--message <text>] [-s|--session <key>]
asterclaw gateway [--debug]
asterclaw status
asterclaw version
Global flags
-d, --debug(global):asterclaw --debug <command>gateway --debugis parsed, but currently adds no separate behavior beyond global--debug
Cron
asterclaw cron list [--enabled-only]
asterclaw cron add --name <name> --message <text> [--every <sec> | --cron <expr>] [--channel <name>] [--chat-id <id>] [--enabled true|false]
asterclaw cron remove <id>
asterclaw cron enable <id>
asterclaw cron disable <id>
Auth
asterclaw auth login [--provider <name>] [--token <token>] [--device-code]
asterclaw auth logout [--provider <name>]
asterclaw auth status
Skills
asterclaw skills list
asterclaw skills install <owner/repo/path>
asterclaw skills remove <name>
asterclaw skills search
asterclaw skills show <name>
Migrate
asterclaw migrate [--dry-run] [--config-only] [--workspace-only] [--force]
Architecture
Core modules:
main.rs— CLI and runtime bootstrapagent.rs— agent loop and tool-call orchestrationtools/*— tool implementationschannels.rs— channel adaptersproviders/*— LLM provider adaptershealth.rs—/healthand/ready
Request flow:
- inbound message is received
- context is built
- model may call tools
- tool results are returned to model context
- final response is emitted and session is persisted
Configuration
Current source of truth: src/config.rs.
Config locations
- primary:
~/.asterclaw/config.json - legacy fallback:
~/.picoclaw/config.json - if
ASTERCLAW_HOMEis set, path resolves toASTERCLAW_HOME/config.json
Template:
config/config.example.json
Top-level sections
agentschannelsprovidersgatewayruntimetoolsheartbeatdevices
agents.defaults
workspacerestrict_to_workspaceprovidermodelmax_tokenstemperaturemax_tool_iterations
channels.telegram
enabledtokenproxyallow_from
When Telegram is enabled, token and non-empty allow_from are required.
providers
Sections present in Config schema:
openai,openrouter,groq,zhipu,gemini,deepseek,anthropic
Providers actually implemented in runtime (src/providers/mod.rs):
openai,openrouter,groq,zhipu(glm),deepseek
Important:
anthropic/claudeis explicitly rejected in current MVPgeminiexists in config schema, but provider runtime support is not implemented yet
Fields per provider section:
api_key,api_base,proxy,auth_method,connect_mode
API keys can be provided via config or env:
OPENAI_API_KEYOPENROUTER_API_KEYGROQ_API_KEYZHIPU_API_KEYDEEPSEEK_API_KEY
gateway
hostport
runtime
worker_threadsmax_blocking_threads
Low-memory baseline:
worker_threads: 1max_blocking_threads: 8..16
tools.web
brave.*duckduckgo.*fetch_default_max_charsfetch_hard_max_charsfetch_hard_max_bytes
For Brave, API key is taken from tools.web.brave.api_key or BRAVE_API_KEY.
tools.exec
confirm_unknownauto_allow_prefixesrequire_confirm_prefixesalways_deny_prefixesstdout_max_bytesstderr_max_bytes
tools.tool_output_max_chars
0means no truncation>0applies truncation in tool loop context
Tools
Registered in ToolRegistry::register_builtin_tools() (src/tools/mod.rs).
Filesystem
read_filewrite_fileedit_fileappend_filelist_dir
Shell
exec
Includes policy checks and output limits. Exec command timeout is 30 seconds.
Web
web_searchweb_fetch
Includes SSRF guard and configurable response bounds.
web_search clamps count to 1..10.
Messaging and orchestration
messagespawnsubagent
Scheduling and memory
cronmemory(read,write,append,read_daily,append_daily)
Tool-output context limit
tools.tool_output_max_charslimits what tool responses are sent back into LLM context0disables truncation
Device
i2cspi
On non-Linux hosts, device operations may fail at runtime by design.
Security
Telegram
When channels.telegram.enabled=true:
tokenis required- non-empty
allow_fromis required
Use private chat + allow-list mode in production.
Exec policy
Command classes:
- auto-allow
- require-confirm
- always-deny
Recommended baseline:
- keep
confirm_unknown = true - keep
auto_allow_prefixesminimal - avoid weakening
always_deny_prefixes
Web protection
web_fetchblocks local/private targets (SSRF guard)- keep
tools.web.fetch_*bounds in place
Secret management
- do not commit real API keys
- keep secrets in local config or CI secret store
Operations
Start gateway
asterclaw gateway
Health endpoints
GET /healthGET /ready
Common operational commands
asterclaw status
asterclaw cron list
asterclaw auth status
asterclaw skills list
Restart gateway after editing ~/.asterclaw/config.json.
For verbose logs, use asterclaw --debug gateway.
asterclaw gateway --debug is currently equivalent to normal gateway run (without global debug).
Profiling and NFR
Scripts are available in scripts/.
Baseline
pwsh scripts/nfr_baseline.ps1
Comparison harness
pwsh scripts/nfr-harness.ps1
Tool-focused sampling
pwsh scripts/simply-profile.ps1
Use identical scenarios before/after changes for valid comparisons.
GitHub Pages Deployment
Build locally:
mdbook build docs
The HTML output is generated in docs/book.
Workflow file:
.github/workflows/docs-pages.yml
Repository setup:
Settings -> PagesBuild and deployment -> Source: GitHub Actions- Ensure branch target in workflow matches your default branch
Before first deploy, update:
docs/book.toml -> git-repository-urldocs/book.toml -> edit-url-template
Developer Guide
Project layout
src/main.rs— CLI bootstrapsrc/agent.rs— agent loopsrc/tools/— toolssrc/channels.rs— channel adapterssrc/providers/— provider adapterssrc/config.rs— config schematests/— e2e testsscripts/— profiling/NFR scripts
Local workflow
cargo check
cargo fmt
cargo clippy -- -D warnings
cargo test
Adding a tool
- create a module in
src/tools/ - implement
Tooltrait - export and register it in
src/tools/mod.rs - add tests for success/error/edge cases
- update docs in
docs/src,docs/src/en,docs/src/pt-br
Keeping docs aligned with code
- CLI:
cargo run -- --help,cargo run -- <subcommand> --help - Config:
src/config.rsandconfig/config.example.json - Tools:
src/tools/mod.rsandsrc/tools/*.rs - Docs build check:
mdbook build docs