> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://docs.navalabs.ai/api/mcp` to find what you need.

# NavaClaw \[Developer Preview]

NavaClaw is a DeFi-focused agent harness based on NanoClaw. It enables autonomous AI agents to trade on-chain, remember what they learn, and run on a schedule, including signing transactions, executing swaps, and managing positions.

NavaClaw is a TypeScript monorepo that ships as a single server: plug in a model provider, point it at a chain, give it skills, and let it run.

Suggested prompt for a coding agent:

```text
Set up NavaClaw locally for the Developer Preview. Inspect the repository and existing configuration first. Ask me to choose the model provider, chain, channel, and in-memory or Postgres persistence before editing config. Keep every secret in environment variables and never print its value. Set EXECUTION_MODE=dry-run, do not add a private key, do not enable direct execution, and do not activate a scheduled skill without asking me separately. Install dependencies, build, type-check, test, start the server, and verify both /health and /ready. Report the files changed, checks run, remaining manual credential steps, and anything you deliberately left disabled.
```

## Overview

### What You Get

* **Multi-chain execution.** Protocol-specific execution skills (e.g., `verified-swap` for Uniswap) handle calldata generation, Nava verification, and broadcast internally. Add a new protocol by creating a skill, no code changes required.
* **Nava verification.** NavaClaw can ask Nava Guardian for a policy verdict before execution. The preview version of Nava Guardian is **verdict-only and advisory**; NavaClaw remains responsible for enforcing the verdict before it signs or broadcasts an action. See [Execution safety](/guardian/execution-ownership).
* **Skills on demand.** Drop a `SKILL.md` file into `./skills/` and the agent learns a new capability on the fly. Skills are listed in a compact catalog; the agent reads them via `cat` when needed, not injected into the prompt. Hot-reloaded, no restart needed.
* **Cron and heartbeat.** Schedule recurring jobs with cron expressions. Skills can declare their own schedules in frontmatter.
* **Memory.** Typed `memory` tool with search, recall, and observe actions. Backed by Postgres + pgvector for persistent semantic search, or zero-config in-memory mode for development. Memory is accessed on demand, not injected into every prompt.
* **Channels.** Talk to your agent via Telegram or Slack. Channel plugins are composable and easy to extend.
* **Any model.** Claude, GPT, Gemini, Ollama, OpenRouter. Swap providers without changing your agent config.

### Architecture

:::file-tree
* apps
  * server — HTTP server, boot sequence, graceful shutdown
* packages
  * shared — logging and common utilities
  * config — configuration and execution context
  * models — model-provider discovery
  * memory — persistent and in-memory recall
  * skills — skill loading and hot reload
  * channels — Telegram, Slack, and message routing
  * pipeline — command queue and agent runner
  * heartbeat — scheduled jobs
  * tools — payload store, MCP client, and tool assembly
  * trading — signing, Nava verification, and execution
* skills — on-demand `SKILL.md` definitions
:::

**Data flow:** Inbound message (channel) enters the pipeline (model call, tools) and produces an outbound reply (channel). The heartbeat triggers jobs on cron schedules. On-chain execution is handled by protocol-specific skills that bundle calldata generation, Nava verification, and broadcast into self-contained scripts. Skills are read on demand via bash. Memory is queried via the `memory` tool.

## Setup

### Prerequisites

* **Node.js 22+** (`nvm install 22`)
* **pnpm** (`npm install -g pnpm`)
* **Foundry** (optional, for on-chain reads via `cast-read`)
* **Docker** (optional, for Postgres persistence; omit `DATABASE_URL` for in-memory mode)

### Quick Start

The fastest path is the **interactive setup wizard**, which handles deps, builds, provider config, channels, skills, and generates `config.json` + `.env` for you.

\:::warning Direct execution is an explicit opt-in

Keep `EXECUTION_MODE=dry-run` while you configure providers, channels, policies,
and scheduled skills. The preview version of Nava Guardian is **verdict-only and
advisory**, so NavaClaw is responsible for keeping an action paused unless the
exact proposed action receives an approved verdict. Enable `direct` only after
you have reviewed the [execution safety boundary](/guardian/execution-ownership),
tested the complete flow, and deliberately accepted the signing and broadcast risk.

\:::

### Claude Code

```bash
git clone --recursive git@github.com:navalabs-dev/nava-claw.git && cd nava-claw
```

Open a Claude Code session and run:

```
/setup
```

The wizard should ask for the provider, chain, channel, and persistence choice.
Review its proposed changes before accepting them. Keep dry-run mode enabled and
decline private-key, direct-execution, and schedule activation steps during the
initial setup. After it finishes, run the build, type checks, tests, and both
health probes shown below.

### Cursor

Open the project in Cursor and use the copyable setup prompt at the top of this
page. Cursor picks up the repository setup rule, while the prompt supplies the
required safety defaults and verification steps.

### Manual

```bash
git clone --recursive git@github.com:navalabs-dev/nava-claw.git && cd nava-claw
pnpm install && pnpm build
cp .env.example .env   # Fill in your API keys and secrets
# Create config.json (see Configuration)
EXECUTION_MODE=dry-run pnpm --filter @nava-claw/server start
```

The server starts on `http://localhost:4747`. Health check at `/health`.

:::terminal
```bash [Verify the server]
curl --fail http://localhost:4747/health
curl --fail http://localhost:4747/ready
```
:::

### Docker (with Postgres Persistence)

```bash
cp .env.example .env   # Fill in your API keys
# Set EXECUTION_MODE=dry-run in .env
# Create config.json (see Configuration)
docker compose up
```

This starts Postgres (pgvector) + the app. Memory, cron jobs, and sessions persist across restarts. To run without persistence, just omit `DATABASE_URL` from `.env` and run the server directly.

### Development

```bash
pnpm build          # Build all packages (TypeScript project references)
pnpm check          # Type-check without emitting
pnpm test           # Run all tests (Vitest)
pnpm clean          # Clean build artifacts
```

### API Endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | `/health` | Health check (`{ status: "ok", uptime }`) |
| GET | `/ready` | Readiness probe (503 if not ready) |

## Configuration

NavaClaw uses two config sources: secrets in `.env` and everything else in `config.json`.

### Environment Variables

See `.env.example` for the full list. Key ones:

| Variable | Required | Description |
| --- | --- | --- |
| `ANTHROPIC_API_KEY` | At least one provider key | Anthropic API key |
| `OPENAI_API_KEY` | At least one provider key | OpenAI API key |
| `TELEGRAM_BOT_TOKEN` | If using Telegram | Bot token from @BotFather |
| `SLACK_BOT_TOKEN` | If using Slack | Bot token from Slack app |
| `PRIVATE_KEY` | Only for direct execution | Hex-encoded private key for signing; do not add one during dry-run setup |
| `WALLET_ADDRESS` | If trading | Corresponding wallet address |
| `RPC_URL` | If trading | Chain RPC endpoint |
| `UNISWAP_API_KEY` | If using Uniswap | From https://hub.uniswap.org |
| `NAVA_API_KEY` | If trading | Nava Guardian API key |
| `DATABASE_URL` | For persistence | Postgres connection string (omit for in-memory) |
| `EXECUTION_MODE` | Yes for this guide | Start with `dry-run`; changing to `direct` is a deliberate signing and broadcast opt-in |
| `PORT` | No (default: `4747`) | HTTP server port |
| `LOG_LEVEL` | No (default: `info`) | `debug`, `info`, `warn`, `error` |

### config.json

```json
{
  "port": 4747,
  "agents": [
    {
      "id": "default",
      "name": "Nava",
      "provider": "anthropic",
      "model": "claude-sonnet-4-6",
      "identity": "You are Nava, a trading assistant running in dry-run mode. Never sign or broadcast an action unless the operator has deliberately enabled direct execution and the exact action has an approved Guardian verdict. Treat a missing, pending, malformed, unavailable, rejected, or timed-out verdict as blocked. Never reveal secrets."
    }
  ],
  "providers": {
    "anthropic": {
      "baseUrl": "https://api.anthropic.com",
      "apiKey": { "env": "ANTHROPIC_API_KEY" },
      "api": "anthropic-messages",
      "models": [
        { "id": "claude-sonnet-4-6", "name": "Sonnet 4.6", "contextWindow": 1000000, "supportsToolUse": true }
      ]
    }
  },
  "channels": {
    "telegram": {
      "enabled": true,
      "accounts": {
        "default": { "botToken": { "env": "TELEGRAM_BOT_TOKEN" } }
      }
    }
  },
  "chain": { "id": 42161, "name": "Arbitrum One" },
  "tools": {
    "bash": {
      "enabled": true,
      "allow": {
        "commands": ["curl", "cast-read", "cat", "jq", "grep", "head", "echo"],
        "paths": ["./skills"]
      }
    },
    "typed": true
  }
}
```

Secrets use the `{ "env": "VAR_NAME" }` pattern. Never hardcode keys in config.

### Supported Chains

| Chain | ID | Notes |
| --- | --- | --- |
| Ethereum Mainnet | 1 | Highest liquidity, higher gas |
| Base | 8453 | Coinbase L2, low fees, growing DeFi |
| Arbitrum One | 42161 | Fast, low cost, most common for Uniswap |
| Polygon | 137 | Uniswap + Polymarket |
| Hyperliquid | 999 | Perpetuals and spot trading |
| Sepolia | 11155111 | Testnet, no real funds |

## Writing Skills

Skills are markdown files that teach the agent new behaviors. Drop a `SKILL.md` into `./skills/<name>/` and it’s live on the next heartbeat cycle.

### Directory Structure

```
skills/
  core/           Auto-enabled (cast-read, testnet, mcporter)
  reference/      Supplementary docs (Uniswap Trading API, Uniswap driver)
```

### Skill Format

```markdown
---
name: my-strategy
description: My custom trading strategy
tags: trading
schedule: "0 */2 * * *"    # Optional: runs every 2 hours
---

# My Strategy

## Goal

Describe one bounded strategy and the result it should produce.

## Inputs

List the required market data, wallet state, and operator parameters.

## Decision rules

State the entry, exit, sizing, and stop conditions as testable rules.

## Safety

- Start in dry-run mode.
- Never sign or broadcast unless direct execution is enabled and Guardian has
  approved the exact action.
- Stop on a missing, pending, malformed, unavailable, rejected, or timed-out
  verdict.
- Ask before changing a schedule, chain, credential, or policy.

## Output

Report the proposed action, Guardian result, execution state, and any blocked
condition without exposing secrets.
```

### How Skills Work

* Skills are listed in a compact catalog; the agent reads them via `cat` when needed, not injected into the prompt.
* Hot-reloaded, no restart needed.
* Skills can declare their own schedules in frontmatter using cron expressions.
* The heartbeat runner triggers scheduled skills on their cron schedule.
* Protocol-specific execution skills (e.g., `verified-swap` for Uniswap) bundle calldata generation, Nava verification, and broadcast into self-contained scripts.

## Channels

Talk to your NavaClaw agent via Telegram or Slack. Channel plugins are composable and easy to extend.

### Telegram

1. Create a bot via [@BotFather](https://t.me/BotFather) and get the bot token.
2. Set `TELEGRAM_BOT_TOKEN` in `.env`.
3. Enable in `config.json`:

```json
{
  "channels": {
    "telegram": {
      "enabled": true,
      "accounts": {
        "default": { "botToken": { "env": "TELEGRAM_BOT_TOKEN" } }
      }
    }
  }
}
```

### Slack

1. Create a Slack app and get the bot token.
2. Set `SLACK_BOT_TOKEN` in `.env`.
3. Enable in `config.json`:

```json
{
  "channels": {
    "slack": {
      "enabled": true,
      "accounts": {
        "default": { "botToken": { "env": "SLACK_BOT_TOKEN" } }
      }
    }
  }
}
```
