This guide provides practical examples for getting started with nano-claw. Perfect for beginners!
- Node.js >= 18.0.0
- An API key from a supported LLM provider (we recommend OpenRouter)
- nano-claw installed (
npm install -g nano-claw)
# Initialize configuration
nano-claw onboardThis creates the configuration directory at ~/.nano-claw/ with the following structure:
~/.nano-claw/
├── config.json # Configuration file
├── memory/ # Conversation history
├── skills/ # Custom skills
└── logs/ # Application logs
Edit ~/.nano-claw/config.json and add your API key:
{
"providers": {
"openrouter": {
"apiKey": "sk-or-v1-YOUR_KEY_HERE"
}
},
"agents": {
"defaults": {
"model": "anthropic/claude-opus-4-5"
}
}
}nano-claw agent -m "Hello! Can you introduce yourself?"Expected Output:
🤖 Agent: Processing your request...
Hello! I'm nano-claw, an ultra-lightweight AI assistant designed to help you with
various tasks. I can:
- Answer questions and provide information
- Help with coding tasks
- Execute shell commands
- Manage files
- And much more!
What can I help you with today?
Ask nano-claw to perform calculations:
nano-claw agent -m "What is 1234 * 5678?"Expected Output:
🤖 Agent: 1234 × 5678 = 7,006,652
Request information on any topic:
nano-claw agent -m "Explain what TypeScript is in 3 sentences"Expected Output:
🤖 Agent: TypeScript is a strongly-typed programming language that builds on JavaScript,
developed by Microsoft. It adds optional static typing to JavaScript, which helps catch
errors during development and provides better tooling support. TypeScript code compiles
down to clean, readable JavaScript that can run anywhere JavaScript runs.
Start a continuous conversation:
nano-claw agentSession Example:
🐈 nano-claw Interactive Mode
Type your message and press Enter. Type "exit" or "quit" to end.
You: What's the weather like today?
🤖 Agent: I don't have real-time internet access to check current weather.
However, if you tell me your location, I can help you find weather information
or suggest ways to check it.
You: Can you help me write a Python function?
🤖 Agent: Of course! What kind of function would you like me to help you create?
Please describe what you need it to do.
You: A function that reverses a string
🤖 Agent: Here's a simple Python function that reverses a string:
```python
def reverse_string(text: str) -> str:
"""
Reverse a string.
Args:
text: The string to reverse
Returns:
The reversed string
"""
return text[::-1]
```
# Example usage
original = "Hello, World!"
reversed_text = reverse_string(original)
print(f"Original: {original}")
print(f"Reversed: {reversed_text}")
# Output: !dlroW ,olleH
This uses Python's slicing notation [start:stop:step] with a step of -1 to reverse the string.
You: exit
👋 Goodbye!
Separate conversations by session:
# Work session
nano-claw agent --session work -m "Help me review this code"
# Personal session
nano-claw agent --session personal -m "Plan my weekend activities"
# Project-specific session
nano-claw agent --session my-project -m "What tasks are left?"Each session maintains its own conversation history and context.
Create and read files using nano-claw:
nano-claw agent -m "Create a file called notes.txt with the content 'Hello from nano-claw!'"Expected Output:
🤖 Agent: I'll create that file for you.
[Tool: write_file executed]
Path: notes.txt
Content: Hello from nano-claw!
✓ File created successfully: notes.txt
Execute shell commands (use with caution!):
nano-claw agent -m "List all TypeScript files in the current directory"Expected Output:
🤖 Agent: I'll list the TypeScript files for you.
[Tool: execute_shell executed]
Command: find . -name "*.ts" -type f
Files found:
./src/index.ts
./src/agent/loop.ts
./src/agent/context.ts
./src/utils/logger.ts
Request code snippets:
nano-claw agent -m "Write a TypeScript function to calculate the factorial of a number"Expected Output:
🤖 Agent: Here's a TypeScript function to calculate factorial:
```typescript
/**
* Calculate the factorial of a number using recursion
* @param n - The number to calculate factorial for
* @returns The factorial of n
* @throws Error if n is negative
*/
function factorial(n: number): number {
// Handle edge cases
if (n < 0) {
throw new Error('Factorial is not defined for negative numbers');
}
if (n === 0 || n === 1) {
return 1;
}
// Recursive calculation
return n * factorial(n - 1);
}
// Example usage:
console.log(factorial(5)); // Output: 120
console.log(factorial(0)); // Output: 1
console.log(factorial(10)); // Output: 3628800
// Iterative version (more efficient for large numbers):
function factorialIterative(n: number): number {
if (n < 0) {
throw new Error('Factorial is not defined for negative numbers');
}
let result = 1;
for (let i = 2; i <= n; i++) {
result *= i;
}
return result;
}
```
The recursive version is elegant but can hit stack limits with large numbers.
The iterative version is more efficient for production use.
View your current configuration:
nano-claw statusExpected Output:
📊 nano-claw Status
✓ Configuration loaded from: /home/user/.nano-claw/config.json
Providers:
✓ openrouter - Configured
Agent Settings:
Model: anthropic/claude-opus-4-5
Temperature: 0.7
Max Tokens: 4096
Tools:
Restrict to Workspace: false
Allowed Commands: (all)
Denied Commands: (none)
Channels:
Telegram: ✗ Not configured
Discord: ✗ Not configured
Memory:
Sessions: 3
Total Messages: 47
Set API keys via environment variables:
# Set the API key
export OPENROUTER_API_KEY="sk-or-v1-YOUR_KEY_HERE"
# Now you can use nano-claw without modifying config.json
nano-claw agent -m "Hello!"This is useful for:
- CI/CD environments
- Shared development machines
- Temporary API key changes
- Testing different providers
- Start Simple: Begin with basic questions and gradually explore more features
- Use Sessions: Organize different conversations by topic using
--session - Check Status Often: Use
nano-claw statusto verify your setup - Read Error Messages: nano-claw provides helpful error messages
- Explore Interactive Mode: Interactive mode is great for back-and-forth conversations
- Review Configuration: Check
~/.nano-claw/config.jsonto understand your settings
# Initialize configuration
nano-claw onboard
# Single message
nano-claw agent -m "Your message here"
# Interactive mode
nano-claw agent
# Session-specific chat
nano-claw agent --session my-session
# Check status
nano-claw status
# Start gateway server (for chat channels)
nano-claw gateway
# Manage cron tasks
nano-claw cron list
nano-claw cron add "0 9 * * *" "Daily briefing"
nano-claw cron remove <id>- Integration Examples - Connect to chat platforms
- Advanced Features - Custom skills, cron tasks, and more
- Use Case Scenarios - Real-world examples
- Configuration Guide - Complete configuration reference
If you encounter issues:
- Run
nano-claw statusto check your configuration - Check the logs at
~/.nano-claw/logs/ - Review the Troubleshooting section
- Open an issue on GitHub