clawpier
CLAUDE.md71 starsChanged 8 months agoMITView on GitHub
ClawPier is a macOS desktop app for managing sandboxed OpenClaw and Hermes AI agent instances via Docker. Built with Tauri v2 (Rust backend + React frontend). The frontend calls typed invoke() wrappers in lib/tauri.ts which map to #[tauri::command] handlers in commands.rs. The Rust backend emits bot-status-update events every 5s; the frontend subscribes via use-bot-events.ts hook. All defined in commands.rs, invoked from lib/tauri.ts: - check_docker / check_image — Verify Docker daemon and image availability - list_bots — Get all bots with…
- Installs packages
The file
We split this CLAUDE.md into the rules it gives an agent
9 rules. About 0 are common, 3 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 85
All defined in commands.rs, invoked from lib/tauri.ts:
- Very specific: line 105
Must use tauri::{Emitter, Manager} in lib.rs for handle.state() and handle.emit()
- Very specific: line 111
Default: --network none (sandbox isolation)
- Very specific: line 133
Test files live in __tests__/ subdirectories next to their source (e.g., stores/__tests__/, hooks/__tests__/)
- Very specific: line 138
Test modules in: models.rs, docker_manager.rs, streaming.rs
- Distinctive: line 154
Vite version: Must use Vite 6 (not 8) — Vite 8 has esbuild issues with Tauri
- Very specific: line 155
React plugin: Must use @vitejs/plugin-react@4 (not v6) — v6 requires Vite 8
- Distinctive: line 157
Icons: Must be RGBA PNGs (color type 6), not RGB
- Distinctive: line 166
No barrel exports — import directly from component files
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
ClawPier is a macOS desktop app for managing sandboxed OpenClaw and Hermes AI agent instances via Docker. Built with Tauri v2 (Rust backend + React frontend).
Tech Stack
- Framework: Tauri v2 (Rust + WebView)
- Frontend: React 19, TypeScript, Tailwind CSS v4 (via
@tailwindcss/vite), Zustand - Backend: Rust with bollard 0.18 (Docker API), tokio, serde, thiserror
- Package manager: pnpm
- Icons: lucide-react
- Build: Vite 6 +
@vitejs/plugin-react@4
Development Commands
pnpm install # Install frontend dependencies
pnpm tauri dev # Run in dev mode with hot-reload
pnpm tauri build # Release build (.app + DMG)
pnpm build # Frontend-only build (tsc + vite)
pnpm lint # ESLint
pnpm test # Unit tests (vitest)Running Single Tests
# Frontend — filter by filename pattern
pnpm test bot-store
pnpm test use-auto-restart
# Rust — all unit tests
cargo test --manifest-path src-tauri/Cargo.toml
# Rust — single test by name
cargo test --manifest-path src-tauri/Cargo.toml split_timestamp
# Rust — integration tests only (requires Docker running)
cargo test --manifest-path src-tauri/Cargo.toml -- --ignoredType-check Only
pnpm exec tsc -bArchitecture
Data Flow
React UI (Zustand store) ←→ Tauri IPC (invoke / events) ←→ Rust commands ←→ Docker (bollard)The frontend calls typed invoke() wrappers in lib/tauri.ts which map to #[tauri::command] handlers in commands.rs. The Rust backend emits bot-status-update events every 5s; the frontend subscribes via use-bot-events.ts hook.
Rust Backend (src-tauri/src/)
lib.rs— Tauri app setup, plugin registration, 5s status polling loopmain.rs— Entry point, callsclawpier_lib::run()models.rs—BotProfile,BotStatus,BotWithStatus,ContainerStats,LogEntry,FileEntry(serde-serializable)docker_manager.rs— Docker operations via bollard (start/stop/status/pull/stats/logs/exec)bot_store.rs— JSON persistence at~/.config/clawpier/bots.jsoncommands.rs— All#[tauri::command]IPC handlersstate.rs—AppStatewithtokio::sync::Mutex<BotStore>,Mutex<DockerManager>,Mutex<StreamManager>streaming.rs— Manages active log/stats streams and interactive terminal sessions per boterror.rs—AppErrorenum withthiserror, implementsSerializefor IPC
Frontend (src/)
App.tsx— Root: Docker check → welcome screen → bot liststores/bot-store.ts— Zustand store for all bot state + actionshooks/— Custom hooks for Tauri event subscriptions, log/stats streaming, interactive terminal, zoomlib/tauri.ts— Typedinvoke()wrappers for all IPC commandslib/types.ts— TypeScript types mirroring Rust modelscomponents/— One component per file (BotCard, BotDetail, ConfigDashboard, etc.)
IPC Commands
All defined in commands.rs, invoked from lib/tauri.ts:
check_docker/check_image— Verify Docker daemon and image availabilitylist_bots— Get all bots with live statuscreate_bot/delete_bot/rename_bot— Bot profile CRUDstart_bot/stop_bot/restart_bot— Container lifecycletoggle_network— Flip network isolation per botset_workspace_path— Configure workspace directoryupdate_env_vars— Set environment variables per botpull_image— Pull Docker imagestart_stats_stream/stop_stats_stream— Live CPU/memory/network statsstart_log_stream/stop_log_stream— Real-time container log streamingstart_terminal_session/write_terminal_input/resize_terminal— Interactive PTY terminalexec_command— Run a one-off command in a containerlist_workspace_files/read_workspace_file— File browserget_bot_config— Read OpenClaw config filesresolve_telegram_bot— Resolve Telegram bot info via API
Key Patterns
Tauri v2 Specifics
- Must
use tauri::{Emitter, Manager}inlib.rsforhandle.state()andhandle.emit() - Capabilities defined in
src-tauri/capabilities/default.json - Identifier is
com.clawpier.manager(not.app— conflicts with macOS)
Docker Conventions
- Container names:
clawpier-{uuid} - Default:
--network none(sandbox isolation) - Always injects:
OPENCLAW_GATEWAY_HOST=127.0.0.1 - Container matching uses exact name comparison via bollard filters
- OpenClaw config persisted via host bind mounts at
~/.config/clawpier/data/{bot-id}/
State Management
- Rust:
AppStateholdsMutex<BotStore>+Mutex<DockerManager>+Mutex<StreamManager>, accessed viaState<'_, AppState> - Frontend: Zustand store with
actionInProgressset for optimistic UI loading states - Status sync: Rust emits
bot-status-updateevents every 5s; frontend listens via@tauri-apps/api/event - Streams:
StreamManagertracks active log/stats streams and interactive sessions per bot; streams are cleaned up on bot stop/delete/restart
Persistence
- Bot profiles saved to
~/.config/clawpier/bots.json - OpenClaw config data at
~/.config/clawpier/data/{bot-id}/ - Auto-saves on every mutation (create, delete, rename, toggle network, env vars, workspace path)
- Name uniqueness enforced case-insensitively
Testing
Frontend
- Vitest with jsdom environment, configured in
vite.config.ts(not a separate vitest config) - Setup file at
src/test/setup.tsmocks@tauri-apps/api/coreand@tauri-apps/api/event - Test files live in
__tests__/subdirectories next to their source (e.g.,stores/__tests__/,hooks/__tests__/)
Rust
- Unit tests use
#[test]and#[tokio::test]within#[cfg(test)]modules - Integration tests requiring Docker use
#[tokio::test]+#[ignore]— CI runs them separately with-- --ignored - Test modules in:
models.rs,docker_manager.rs,streaming.rs
CI Pipeline (.github/workflows/ci.yml)
Three jobs: frontend (lint → type-check → vitest), rust (cargo test → cargo check --release), integration (pulls busybox:latest, runs -- --ignored tests)
Versioning
The app version is defined in three files that must be kept in sync:
package.json→"version"(frontend / pnpm)src-tauri/Cargo.toml→version(Rust crate)src-tauri/tauri.conf.json→"version"(Tauri app metadata, shown in UI title bar)
When tagging a release, always update all three files to match the tag (e.g., v0.3.1 → "0.3.1" in all three). The version in tauri.conf.json is what the user sees in the app header.
Build Gotchas
- Vite version: Must use Vite 6 (not 8) — Vite 8 has esbuild issues with Tauri
- React plugin: Must use
@vitejs/plugin-react@4(not v6) — v6 requires Vite 8 - pnpm esbuild: Needs
"pnpm": { "onlyBuiltDependencies": ["esbuild"] }in package.json - Icons: Must be RGBA PNGs (color type 6), not RGB
- Tailwind v4: Uses
@import "tailwindcss"in CSS, notailwind.config.jsneeded - ESLint: Uses flat config (
eslint.config.js); react-hooks v7 enforcesset-state-in-effect— do not callsetStatesynchronously insideuseEffectbodies (async callbacks like.then()are fine)
Code Style
- Rust: standard
rustfmt,thiserrorfor errors, async/await with tokio - TypeScript: strict mode, functional React components, Tailwind utility classes
- Components: one component per file in
src/components/ - No barrel exports — import directly from component files
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

