The agent that grows with you
Autonomous agent with tools, MCP, and mesh networking
DevDuck is a self-healing agent package that runs from the terminal, TUI, WebSocket, TCP, MCP, and IPC. It can load built-in tools, hot-reload new tools from `./tools/`, record and resume sessions, and deploy or persist itself as a service.
Builders who want an autonomous agent that can stay alive, fix itself, and work across local and remote tools.
You can keep an agent running across sessions and interfaces without rebuilding the setup each time.
What it does
Hot reload
Edits to source or files in `./tools/` take effect without restarting the agent.
Self-healing runtime
Errors trigger automatic recovery so the agent can keep running.
Multi-protocol access
The agent works through CLI, TUI, WebSocket, TCP, MCP, and IPC.
Tool loading
It ships with many built-in tools and can add more at runtime with `manage_tools`.
Session record and resume
You can record a run and restore it later from a saved snapshot or `.zip` session.
Service persistence
It can install itself as a user or system service and restart on failure.
Mesh and peer features
Terminal, browser, and cloud agents can share a ring context and broadcast messages.
MCP exposure
It can be exposed as an MCP server for Claude Desktop or other MCP clients.
How to get it
- 1Run
devduck # interactive REPL devduck --tui # multi-conversation terminal UI devduck "create a REST API" # one-shot devduck --record # record session for replay devduck --resume session.zip # resume from snapshot devduck deploy --launch # ship to AgentCore
- 2Run
git clone git@github.com:cagataycali/devduck.git && cd devduck python3.13 -m venv .venv && source .venv/bin/activate pip install -e . && devduck
README
๐ฆ DevDuck
One file. Self-healing. Builds itself as it runs.
An AI agent that hot-reloads its own code, fixes itself when things break, and expands capabilities at runtime. Terminal, browser, cloud โ or all at once.
pipx install devduck && devduck
What It Does
- Hot-reloads โ edit source, agent restarts instantly
- Self-heals โ errors trigger automatic recovery
- 60+ tools โ shell, GitHub, browser control, speech, scheduler, ML, messaging
- Multi-protocol โ CLI, TUI, WebSocket, TCP, MCP, IPC, Zenoh P2P
- Unified mesh โ terminal + browser + cloud agents in one network
- Deploys anywhere โ
devduck deploy --launchโ AWS AgentCore - Self-replicates โ
devduck service install --ssh hostpersists itself or spawns copies on any host (systemd/launchd)
Requirements: Python 3.10โ3.13 + any model provider (AWS, Anthropic, OpenAI, Ollama, Gemini, etc.)
Quick Start
devduck # interactive REPL
devduck --tui # multi-conversation terminal UI
devduck "create a REST API" # one-shot
devduck --record # record session for replay
devduck --resume session.zip # resume from snapshot
devduck deploy --launch # ship to AgentCore
import devduck
devduck("analyze this code")
Power User Setup
A real-world .zshrc config for daily driving DevDuck with all the bells and whistles:
# Model โ Claude Opus via Bedrock bearer token (fastest auth, no STS calls)
export AWS_BEARER_TOKEN_BEDROCK="ABSK..."
export STRANDS_MODEL_ID="global.anthropic.claude-opus-4-6-v1"
export STRANDS_MAX_TOKENS="64000"
# Tools โ curated toolset (loads faster than all 60+)
export DEVDUCK_TOOLS="devduck.tools:use_github,editor,system_prompt,store_in_kb,manage_tools,websocket,zenoh_peer,agentcore_proxy,manage_messages,sqlite_memory,dialog,listen,use_computer,tasks,scheduler,telegram;strands_tools:retrieve,shell,file_read,file_write,use_agent"
# Knowledge Base โ automatic RAG (stores & retrieves every conversation)
export STRANDS_KNOWLEDGE_BASE_ID="YOUR_KB_ID"
# MCP โ auto-load Strands docs server
export MCP_SERVERS='{"mcpServers":{"strands-docs":{"command":"uvx","args":["strands-agents-mcp-server"]}}}'
# Messaging โ Telegram & Slack bots
export TELEGRAM_BOT_TOKEN="your-telegram-bot-token"
export SLACK_BOT_TOKEN="xoxb-your-slack-bot-token"
export SLACK_APP_TOKEN="xapp-your-slack-app-token"
# Spotify control
export SPOTIFY_CLIENT_ID="your-client-id"
export SPOTIFY_CLIENT_SECRET="your-client-secret"
export SPOTIFY_REDIRECT_URI="http://127.0.0.1:8888/callback"
# Gemini as fallback/sub-agent model
export GEMINI_API_KEY="your-gemini-key"
This gives you:
- ๐ง Opus on Bedrock as primary model with bearer token (zero-latency auth)
- ๐ Auto-RAG โ every conversation stored in Knowledge Base, context retrieved before each query
- ๐ Strands docs available as MCP tools (search + fetch)
- ๐ฑ Telegram + Slack + WhatsApp โ three messaging channels ready
- Telegram & Slack: set tokens above, then
telegram(action="start_listener") - WhatsApp: no token needed โ uses local
waclipairing, justwhatsapp(action="start_listener")
- Telegram & Slack: set tokens above, then
- ๐ต Spotify control via
use_spotify - ๐ Zenoh P2P + mesh auto-enabled (multi-terminal awareness)
- ๐ฌ 26 tools loaded on startup, expandable to 60+ on demand via
manage_tools
Model Detection
Set your key. DevDuck figures out the rest.
export ANTHROPIC_API_KEY=sk-ant-... # โ uses Anthropic
export OPENAI_API_KEY=sk-... # โ uses OpenAI
export GOOGLE_API_KEY=... # โ uses Gemini
# or just have AWS credentials # โ uses Bedrock
# or nothing at all # โ uses Ollama
Priority: Bedrock โ Anthropic โ OpenAI โ GitHub โ Gemini โ Cohere โ Writer โ Mistral โ LiteLLM โ LlamaAPI โ MLX โ Ollama
Override: MODEL_PROVIDER=bedrock STRANDS_MODEL_ID=us.anthropic.claude-sonnet-4-20250514-v1:0 devduck
Tools
Runtime โ no restart needed
manage_tools(action="add", tools="strands_fun_tools.cursor")
manage_tools(action="create", code='...')
manage_tools(action="fetch", url="https://github.com/user/repo/blob/main/tool.py")
Hot-reload from disk
Drop a .py file in ./tools/ โ it's available immediately.
# ./tools/weather.py
from strands import tool
import requests
@tool
def weather(city: str) -> str:
"""Get weather for a city."""
return requests.get(f"https://wttr.in/{city}?format=%C+%t").text
Static config
export DEVDUCK_TOOLS="strands_tools:shell,editor;devduck.tools:use_github,scheduler"
๐ Code Inspection
Built-in inspect tool (powered by strands-inspect) โ turn any Python package into an interactive tool.
inspect(action="scan", target="json") # deep-scan package API
inspect(action="call", target="json.dumps", args='[{"hi": 1}]') # call anything
inspect(action="search", target="pathlib", query="read file")
inspect(action="generate", target="requests.post") # working code example
inspect(action="profile", target="myfunc") # memory + CPU timeline
inspect(action="graph", target="mypkg") # call-graph + hotspots
No wrappers, no stubs โ point it at any installed package and start calling.
Architecture
devduck/
โโโ __init__.py # the whole agent โ single file
โโโ tui.py # multi-conversation Textual UI
โโโ tools/ # 60+ built-in tools (hot-reloadable)
โโโ agentcore_handler.py # AWS AgentCore deployment handler
graph LR
User([๐ค User]) --> Interface
subgraph Interface[" "]
CLI["CLI / REPL"]
TUI["TUI"]
WS["WebSocket"]
TCP["TCP"]
MCP["MCP"]
end
Interface --> Core["๐ฆ DevDuck Core"]
Core --> Tools["๐ง Tools"]
Core <--> Zenoh["๐ Zenoh P2P"]
Core <--> KB["๐ Knowledge Base"]
Core <--> Mesh["๐ Unified Mesh"]
Mesh --> Browser["๐ฅ๏ธ Browser"]
Mesh --> Cloud["โ๏ธ AgentCore"]
style Core fill:#f5a623,stroke:#333,color:#000
style Mesh fill:#4a90d9,stroke:#333,color:#fff
style Zenoh fill:#7ed321,stroke:#333,color:#000
style KB fill:#9b59b6,stroke:#333,color:#fff
Ports: 10000 (mesh relay) ยท 10001 (WebSocket) ยท 10002 (TCP) ยท 10003 (MCP)
TUI Concurrency Model
The TUI (devduck --tui) supports true concurrent conversations with shared awareness:
graph TB
subgraph SharedMessages["๐ SharedMessages (thread-safe)"]
msgs["msg1, msg2, msg3, msg4, ..."]
end
SharedMessages --> A1
SharedMessages --> A2
SharedMessages --> A3
subgraph A1["๐ฆ Agent #1"]
cb1["callback โ panel #1"]
end
subgraph A2["๐ฉ Agent #2"]
cb2["callback โ panel #2"]
end
subgraph A3["๐จ Agent #3"]
cb3["callback โ panel #3"]
end
style SharedMessages fill:#e74c3c,stroke:#333,color:#fff
style A1 fill:#3498db,stroke:#333,color:#fff
style A2 fill:#2ecc71,stroke:#333,color:#fff
style A3 fill:#f1c40f,stroke:#333,color:#000
Each conversation creates a fresh Agent (like TCP/Telegram tools do), but all agents point their .messages at a single SharedMessages instance โ a thread-safe list subclass that serializes all reads and writes via a lock. This gives you:
- True concurrency โ separate Agent instances with separate callback handlers, no conflicts
- Real-time shared awareness โ when Agent #1 appends a message, Agent #2 sees it immediately on its next loop iteration
- Correct ordering โ the lock ensures messages are appended in the order they're produced
- Isolated rendering โ each agent's callback handler routes streaming output to its own color-coded TUI panel
The shared history is capped at 100 messages (configurable via DEVDUCK_TUI_MAX_SHARED_MESSAGES) and auto-clears on context window overflow.
Comparison across interfaces:
| Interface | Agent per request | Shared messages | Use case |
|---|---|---|---|
| CLI | No (reuse one) | N/A (single-threaded) | Sequential interactive REPL |
| TUI | Yes (fresh Agent) | Yes (SharedMessages) | Concurrent conversations with shared context |
| TCP | Yes (fresh DevDuck) | No (fully isolated) | External network clients |
| Telegram | Yes (fresh DevDuck) | No (fully isolated) | Chat bot, each user isolated |
| WebSocket | Yes (fresh DevDuck) | No (fully isolated) | Browser clients |
Multi-Agent Networking
Zenoh P2P โ zero config
# Terminal 1
devduck # โ Zenoh peer: hostname-abc123
# Terminal 2
devduck # auto-discovers Terminal 1
zenoh_peer(action="broadcast", message="git pull && npm test") # all peers
zenoh_peer(action="send", peer_id="hostname-abc123", message="status?") # one peer
Cross-network: ZENOH_CONNECT=tcp/remote:7447 devduck
Unified Mesh โ everything connected
The mesh is DevDuck's shared nervous system. Every agent โ regardless of where it runs โ sees what others are doing via a ring context (a shared circular buffer of recent activity).
graph TB
subgraph Mesh["๐ Unified Mesh (port 10000)"]
direction TB
T1["๐ฅ๏ธ Terminal DevDuck<br/>(Zenoh)"]
T2["๐ฅ๏ธ Terminal DevDuck<br/>(Zenoh)"]
B1["๐ Browser Tab<br/>(WebSocket)"]
AC["โ๏ธ AgentCore<br/>(AWS Cloud)"]
GH["๐ GitHub Actions<br/>(HTTPS)"]
Ring[("๐ Ring Context<br/>shared memory<br/>last 100 msgs")]
T1 <--> Ring
T2 <--> Ring
B1 <--> Ring
AC <--> Ring
GH <--> Ring
end
Registry["๐ mesh_registry.json<br/>(file-based, TTL)"]
Relay["๐ก Relay Server<br/>ws://localhost:10000"]
Ring --> Registry
Ring --> Relay
style Mesh fill:#1a1a2e,stroke:#4a90d9,color:#fff
style Ring fill:#f5a623,stroke:#333,color:#000
style T1 fill:#7ed321,stroke:#333,color:#000
style T2 fill:#7ed321,stroke:#333,color:#000
style B1 fill:#4a90d9,stroke:#333,color:#fff
style AC fill:#9b59b6,stroke:#333,color:#fff
style GH fill:#333,stroke:#fff,color:#fff
style Registry fill:#e74c3c,stroke:#333,color:#fff
style Relay fill:#3498db,stroke:#333,color:#fff
Four peer types, one network:
| Peer Type | Discovery | Transport | Example |
|---|---|---|---|
| Zenoh | Multicast scouting (224.0.0.224:7446) | P2P UDP/TCP | Two terminal DevDucks auto-find each other |
| Browser | WebSocket connect to :10000 | WS | mesh.html or custom web UI registers as peer |
| AgentCore | AWS API (ListAgentRuntimes) | HTTPS | Cloud-deployed agents via devduck deploy |
| GitHub | GitHub Actions API | HTTPS | Workflow-based agents from configured repos |
How it works:
-
Registry (
mesh_registry.py) โ File-based agent registry with TTL. Any process can read/write. Zenoh peers, browser tabs, and local agents all register here. -
Ring Context (
unified_mesh.py) โ In-memory circular buffer (last 100 entries). When any agent does something, it's pushed to the ring. CLI DevDuck injects ring context into every query so it knows what browser/cloud agents are doing. -
Relay (
agentcore_proxy.py) โ WebSocket server on port 10000 that bridges everything:- Browser connects โ gets real-time
ring_updateevents - Browser sends
invokeโ routes to Zenoh peer or AgentCore agent - CLI writes to ring โ browser gets notified instantly
- Handles
list_peers,invoke,broadcast,get_ring,add_ring
- Browser connects โ gets real-time
-
Zenoh (
zenoh_peer.py) โ P2P layer for terminal-to-terminal. Heartbeats every 5s, auto-prune stale peers, command execution on remote peers.
Ring context injection โ every CLI query automatically includes recent mesh activity:
[14:20:59] local:devduck-tui (local [tui]): Q: deploy API โ Done โ
[14:21:05] browser:react-app (browser [ws]): Built component library
[14:21:10] agentcore:reviewer (cloud [aws]): PR #42 approved
This means your terminal DevDuck is always aware of what your browser agent and cloud agents just did โ no explicit sync needed.
WebSocket protocol (port 10000):
{"type": "list_peers"} // all peers across all layers
{"type": "invoke", "peer_id": "...", "prompt": "..."} // invoke any peer
{"type": "broadcast", "message": "..."} // send to all Zenoh peers
{"type": "get_ring", "max_entries": 20} // recent activity
{"type": "add_ring", "agent_id": "my-bot", "text": "done"} // push to ring
{"type": "register_browser_peer", "name": "my-ui", "model": "gpt-4o"} // join mesh
Deploy
devduck deploy --launch
devduck deploy --name reviewer --tools "strands_tools:shell,editor" --launch
devduck list # see deployed agents
devduck invoke "analyze code" --name reviewer
Self-Replication & Persistence
DevDuck can install itself โ or copies of itself โ as a persistent OS service (systemd on Linux, launchd on macOS) that survives terminal close, auto-restarts on failure, and starts at boot.
CLI
# Persist the current devduck as a local service (user-level, no sudo)
devduck service install \
--name my-bot \
--tools "devduck.tools:telegram,scheduler;strands_tools:shell" \
--env TELEGRAM_BOT_TOKEN=... \
--startup-prompt "Start the telegram listener, then stay alive."
# Spawn a copy on a remote host over SSH
devduck service install \
--name worker1 \
--ssh user@host.example.com \
--tools "devduck.tools:scheduler,notify;strands_tools:shell,file_read" \
--env AWS_BEARER_TOKEN_BEDROCK=... \
--startup-prompt "You are worker1. Stay alive."
# Manage
devduck service status --name my-bot
devduck service logs --name my-bot --lines 100 --follow
devduck service restart --name my-bot
devduck service uninstall --name my-bot
# Dry-run preview without installing
devduck service show --name my-bot --ssh user@host
As an agent tool
The service tool is loaded by default, so the agent can replicate itself on command:
import devduck
devduck.ask(
"Spawn a copy of yourself on my worker box at ops@10.0.0.42 named "
"'pr-watcher' with tools use_github+scheduler+telegram. Pass through "
"my GITHUB_TOKEN and TELEGRAM_BOT_TOKEN. Its job: poll PRs every 5 "
"min and notify me via telegram."
)
Under the hood the agent calls:
service(
action="install",
name="pr-watcher",
ssh="ops@10.0.0.42",
tools="devduck.tools:use_github,scheduler,telegram;strands_tools:shell",
env_vars={"GITHUB_TOKEN": "...", "TELEGRAM_BOT_TOKEN": "..."},
startup_prompt="Poll my PRs every 5 min, notify via telegram.",
)
What gets installed
| File | Path (user-level, Linux) |
|---|---|
| systemd unit | ~/.config/systemd/user/devduck-<name>.service |
| Env file | ~/.config/devduck/devduck-<name>.env |
| Wrapper | ~/.local/bin/devduck-<name>-agent |
| Log | ~/.cache/devduck-<name>.log |
Type=simple,Restart=always(15s),MemoryMax=8G- Wrapper self-heals common dep issues (
pydantic-core) and keeps the process alive as an idle loop so schedulers/listeners keep running - Re-running
installis idempotent (overwrites env + unit, restarts) - Remote installs use
sshunder the hood; the target needsdevduckinstalled (any method)
System-wide install
Add --system (requires sudo) to install to /etc/systemd/system/ instead of user-level. On macOS, --system writes to /Library/LaunchDaemons/.
See the full guide for design notes, troubleshooting, and fleet patterns.
Public Tunnels (Cloudflare)
Expose devduck to the public internet via Cloudflare Tunnel. Works for the WebSocket server (10001), relay (10000), or any local tool.
Quick Tunnel โ random *.trycloudflare.com URL
# Install cloudflared (once)
devduck tunnel install
# Expose the WS server โ returns a public URL like https://abc-def.trycloudflare.com
devduck tunnel start --name ws --port 10001
# View / stop
devduck tunnel list
devduck tunnel stop --name ws
No login, no DNS, no config โ great for quick demos.
Named Tunnel โ persistent custom hostname
# Authenticate with Cloudflare (once, opens browser)
devduck tunnel login
# Create a named tunnel mapped to your domain
devduck tunnel create_named --name ws-duck \
--hostname ws.example.com --port 10001
# Start it (runs in background; logs at ~/.devduck/tunnels/logs/)
devduck tunnel start --name ws-duck
Your DNS CNAME is created automatically. Config lives at
~/.cloudflared/<name>.yml and is WebSocket-ready
(originRequest.connectTimeout, noTLSVerify) by default.
Auto-Start Tunnels on Launch
Define tunnels in DEVDUCK_TUNNELS (JSON array) to spin them up at boot:
export DEVDUCK_TUNNELS='[
{"name": "ws", "port": 10001},
{"name": "relay", "port": 10000}
]'
devduck
๐ Protect Public Tunnels with an API Key
By default a tunnel is wide open โ anyone on the internet can talk to your
WS server. To lock it down, set DEVDUCK_WS_API_KEY on the server side. The
check is enforced inside devduck/tools/websocket.py before any session starts.
# Server
export DEVDUCK_WS_API_KEY="$(openssl rand -hex 32)"
devduck
Clients must present the key on connect via any of these:
| Method | Example |
|---|---|
| Query string | wss://ws.example.com/?api_key=YOUR_KEY |
| Header | X-API-Key: YOUR_KEY |
| Bearer auth | Authorization: Bearer YOUR_KEY |
Wrong/missing key โ server closes with WebSocket code 4401 Unauthorized.
duck.nyc web client: paste the same key into
Settings โ DevDuck WS API key. It's appended to every local + relay
WebSocket URL automatically.
// Raw JS client
new WebSocket(`wss://ws.example.com/?api_key=${encodeURIComponent(KEY)}`)
# Python client
import websockets, urllib.parse
key = urllib.parse.quote(os.environ["DEVDUCK_WS_API_KEY"])
async with websockets.connect(f"wss://ws.example.com/?api_key={key}") as ws:
...
Unset DEVDUCK_WS_API_KEY (or set it to empty) to disable auth again.
Session Recording & Resume
devduck --record # captures sys/tool/agent events
devduck --resume session.zip # restores conversation + state
devduck --resume session.zip "continue where we left off"
from devduck import load_session
session = load_session("session.zip")
session.resume_from_snapshot(2, agent=devduck.agent)
Asciinema: DEVDUCK_ASCIINEMA=true devduck โ shareable .cast files.
Background Modes
# Standard ambient โ thinks while you're idle
DEVDUCK_AMBIENT_MODE=true devduck
# Autonomous โ works until done
๐ฆ auto
# Agent signals [AMBIENT_DONE] when finished
Messaging
# Telegram
TELEGRAM_BOT_TOKEN=... STRANDS_TELEGRAM_AUTO_REPLY=true devduck
telegram(action="start_listener")
# Slack
SLACK_BOT_TOKEN=xoxb-... SLACK_APP_TOKEN=xapp-... devduck
slack(action="start_listener")
# WhatsApp (via wacli, no Cloud API)
whatsapp(action="start_listener")
Each incoming message spawns a fresh DevDuck with full tool access.
MCP
Expose as server (Claude Desktop):
{"mcpServers": {"devduck": {"command": "uvx", "args": ["devduck", "--mcp"]}}}
Load external servers:
export MCP_SERVERS='{"mcpServers": {"docs": {"command": "uvx", "args": ["strands-agents-mcp-server"]}}}'
OpenAPI Tool โ Universal API Client
One tool to rule them all. Load any OpenAPI/Swagger spec (JSON or YAML), authenticate once, and call any endpoint. Tokens persist to disk and auto-refresh โ no re-auth needed.
Quick Start
# 1. Load any spec (JSON, YAML, local file, or GitHub URL)
openapi(action="load", spec_url="https://petstore3.swagger.io/api/v3/openapi.json")
openapi(action="load", spec_url="https://raw.githubusercontent.com/sonallux/spotify-web-api/main/fixed-spotify-open-api.yml")
openapi(action="load", spec_url="./my-local-spec.yaml")
openapi(action="load", spec_url="https://github.com/owner/repo/blob/main/openapi.yml") # auto-converts to raw
# 2. List operations
openapi(action="list", alias="spotify")
# 3. Call endpoints
openapi(action="call", alias="spotify", operation="get-current-users-profile")
openapi(action="call", alias="petstore", operation="findPetsByStatus", params='{"status": "available"}')
Authentication
Supports every auth method you'll encounter in the wild:
# API Key
openapi(action="auth", alias="weather", api_key="sk-xxx")
# Bearer Token
openapi(action="auth", alias="myapi", token="eyJhbG...")
# Basic Auth
openapi(action="auth", alias="jenkins", username="admin", password="secret")
# OAuth2 โ Authorization Code (opens browser, waits for callback)
openapi(action="auth", alias="spotify", auth_flow="authorization_code",
client_id="xxx", client_secret="yyy",
scopes="user-read-private,playlist-read-private")
# OAuth2 โ Client Credentials (server-to-server, no br
Files in the repo
- .github
- devduck
- devduck-chrome-extension
- docs
- tests
- tools
- video
- .dockerignore
- .env.example
- .gitignore
- action.yml
- agent_runner.py
- AGENTS.md
- devduck-intro.mp4
- devduck-launcher.jpg
- devduck.cast
- docker-compose.yml
- Dockerfile
- Dockerfile.slim
- duck-animated.svg
- duck.svg
- LICENSE
- MANIFEST.in
- mkdocs.yml
- pyproject.toml
- README.md
- requirements.txt
- setup-aws-oidc.sh
- SOUL.md
- test.py
Discussion (0)
Ask about usage, or say what you built with itSign in to join the discussion.
No comments yet. Be the first to say what this is good for.
More agents
Open-source coding agent for your terminal, built in Rust and on a journey of continuous community improvement. Issues and PRs welcome.
A lightweight alternative to OpenClaw that runs in containers for security. Connects to WhatsApp, Telegram, Slack, Discord, Gmail and other messaging apps,, has memory, scheduled jobs, and runs directly on Anthropic's Agents SDK
OpenSquilla โ Token-Efficient AI Agent with same budget, higher intelligence density

An open-source AI coding agent that lives in your terminal.
Run and supervise teams of coding agents from planning to merge. Any harness (Claude code, codex, +25 more). Desktop, web, mobile, and cloud agents.