> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch42-hands-on-project/42.1-project-planning.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 42.1 Project Planning

> **Generated by**: Claude Opus 4.6 (initial draft) / Claude Opus 5 (`v2026.3.9` revision) **Token usage**: Input \~350k tokens, Output \~4k tokens (this section) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`)

***

After 33 chapters of source code analysis, readers have gained a deep understanding of OpenClaw's architecture and implementation details. This chapter takes a practical approach, guiding readers to build a simplified multi-channel AI assistant—**MiniClaw**. MiniClaw is not a complete replica of OpenClaw, but rather a **Minimum Viable Product** (MVP) that extracts its core design principles.

## 42.1.1 Requirements Analysis

### Core Requirements

MiniClaw aims to implement the following features:

| Feature            | Corresponding OpenClaw Module | MVP Scope                                 |
| ------------------ | ----------------------------- | ----------------------------------------- |
| Gateway Server     | `src/gateway/`                | WebSocket server + RPC protocol           |
| Session Management | `src/sessions/`               | In-memory session storage + basic routing |
| AI Agent Runtime   | `src/agents/`                 | Single Agent + tool invocation loop       |
| Message Channels   | `src/channels/`               | Telegram Bot + WebChat                    |
| Tool System        | `src/agents/tools/`           | Bash execution + file read/write          |
| Memory System      | `src/memory/`                 | Markdown file memory                      |

### Non-Requirements (Excluded from MVP)

The following features are not implemented in the MVP but have reserved extension interfaces:

* Multi-agent architecture
* Sandbox isolation
* Canvas / A2UI
* Browser automation
* Cron scheduling
* Native clients
* Skill system

### User Stories

```
As a user, I want to:
1. Send messages to my AI assistant via Telegram
2. Interact with my AI assistant through a web interface
3. Have the AI assistant execute local commands (e.g., view files, run scripts)
4. Have the AI assistant remember things I've told it previously
5. Deploy the assistant on a VPS and use it anytime, anywhere
```

## 42.1.2 Architecture Design Reference

MiniClaw's architecture borrows from OpenClaw's layered design but is significantly simplified:

```
            ┌─────────────┐   ┌─────────────┐
            │ Telegram Bot│   │   WebChat    │
            └──────┬──────┘   └──────┬──────┘
                   │                  │
            ┌──────▼──────────────────▼──────┐
            │       Gateway (WebSocket)       │
            │   · RPC protocol                │
            │   · Session routing             │
            │   · Event broadcasting          │
            └──────────────┬─────────────────┘
                           │
            ┌──────────────▼─────────────────┐
            │       Agent Runner              │
            │   · LLM API invocation         │
            │   · Tool invocation loop       │
            │   · Context window management  │
            └──────────────┬─────────────────┘
                           │
         ┌─────────┬───────┴───────┬──────────┐
         │         │               │          │
      ┌──▼──┐  ┌───▼───┐   ┌──────▼───┐  ┌───▼────┐
      │Bash │  │ Read  │   │  Write   │  │ Memory │
      │Tool │  │ Tool  │   │  Tool    │  │ Search │
      └─────┘  └───────┘   └──────────┘  └────────┘
```

Correspondence with OpenClaw:

| MiniClaw Component | OpenClaw Counterpart             | Simplification Strategy                                 |
| ------------------ | -------------------------------- | ------------------------------------------------------- |
| Gateway            | `src/gateway/server.impl.ts`     | Remove HTTP layer, authentication, service discovery    |
| Agent Runner       | `src/agents/pi-embedded-runner/` | Remove multi-model fallback, context pruning strategies |
| Session Store      | `src/sessions/`                  | Pure in-memory Map, no persistence                      |
| Channel Adapter    | `src/channels/`                  | Direct implementation, no plugin architecture           |
| Tool System        | `src/agents/tools/`              | Hardcoded tool list, no dynamic registration            |

## 42.1.3 Technology Selection Recommendations

### Runtime and Language

| Option              | Recommendation | Rationale                                           |
| ------------------- | -------------- | --------------------------------------------------- |
| **Language**        | TypeScript     | Consistent with OpenClaw, type-safe, rich ecosystem |
| **Runtime**         | Node.js 22+    | Native ES Modules, WebSocket support                |
| **Package Manager** | pnpm           | Faster installation, workspace support              |

### Core Dependencies

```json
{
  "dependencies": {
    "ws": "^8.0.0",               // WebSocket server
    "openai": "^4.0.0",           // OpenAI API client (compatible with Anthropic)
    "@anthropic-ai/sdk": "^0.30", // Anthropic API client
    "grammy": "^1.0.0",           // Telegram Bot framework
    "express": "^4.0.0",          // HTTP server (WebChat)
    "zod": "^3.0.0",              // Runtime type validation
    "chalk": "^5.0.0"             // Terminal coloring
  },
  "devDependencies": {
    "typescript": "^5.5.0",
    "vitest": "^2.0.0",
    "tsdown": "^0.5.0"
  }
}
```

### LLM API Selection

MiniClaw should support at least two LLM providers:

1. **Anthropic Claude**: Via `@anthropic-ai/sdk`, supporting tool invocation, streaming output, thinking process
2. **OpenAI GPT**: Via `openai` SDK, supporting function calling, streaming output

It's recommended to use the **Adapter Pattern** (referencing OpenClaw's `src/providers/`) to unify API differences across providers:

```typescript
interface LLMProvider {
  chat(params: {
    messages: Message[];
    tools?: ToolDefinition[];
    stream?: boolean;
  }): AsyncIterable<ChatChunk>;
}

class AnthropicProvider implements LLMProvider { /* ... */ }
class OpenAIProvider implements LLMProvider { /* ... */ }
```

### Project Directory Structure

```
miniclaw/
├── src/
│   ├── gateway/
│   │   ├── server.ts        ← WebSocket server
│   │   ├── protocol.ts      ← RPC protocol definition
│   │   └── session-store.ts ← Session storage
│   ├── agent/
│   │   ├── runner.ts        ← Agent execution loop
│   │   ├── context.ts       ← Context window management
│   │   └── tools/
│   │       ├── bash.ts      ← Bash tool
│   │       ├── read.ts      ← File read tool
│   │       └── write.ts     ← File write tool
│   ├── channels/
│   │   ├── telegram.ts      ← Telegram Bot adapter
│   │   └── webchat.ts       ← WebChat adapter
│   ├── memory/
│   │   └── markdown.ts      ← Markdown memory
│   ├── providers/
│   │   ├── anthropic.ts     ← Anthropic adapter
│   │   └── openai.ts        ← OpenAI adapter
│   └── config.ts            ← Configuration loading
├── ui/                      ← WebChat frontend
├── package.json
├── tsconfig.json
└── vitest.config.ts
```

### Development Phase Planning

| Phase       | Content                                | Estimated Hours |
| ----------- | -------------------------------------- | --------------- |
| **Phase 1** | Gateway + Agent Runner + Bash tool     | 8-12 hours      |
| **Phase 2** | Telegram channel + WebChat             | 6-8 hours       |
| **Phase 3** | File tools + Memory system             | 4-6 hours       |
| **Phase 4** | Docker deployment + Security hardening | 4-6 hours       |
| **Total**   | Complete MVP                           | 22-32 hours     |

For students with TypeScript and Node.js experience, the entire project can be completed in one to two weeks.

***

## Summary of This Section

1. **MiniClaw** is a minimal viable implementation of OpenClaw's core design, focusing on four major modules: Gateway + Agent + Channels + Tools.
2. **Architecture design** borrows from OpenClaw's layered pattern but removes advanced features like multi-agent, sandbox, and Canvas.
3. **Technology selection** recommends TypeScript + Node.js 22+, with dependencies on `ws` (WebSocket), `openai`/`@anthropic-ai/sdk` (LLM), and `grammy` (Telegram).
4. **Adapter pattern** unifies API differences across different LLM providers, facilitating future extensions.
5. **Four-phase development plan**: Gateway → Channels → Tools/Memory → Deployment, totaling 22-32 hours.
