Building Software
& Automation
The 3-Layer Model

How to organize folders, run automations, and deploy your code — a visual breakdown of the complete workflow.

Layer 1: Files Layer 2: Execution Layer 3: Deployment

Think In 3 Layers

📁 1

Folder Structure

How you organize your code, configs, and documentation in the workspace.

Where things live
2

Execution Model

How your automations actually run — scheduled, event-driven, or always-on.

How things run
🚀 3

Deployment

How your changes go live — in-place, via CI/CD, or packaged as a skill.

How things ship

The Workspace Root

Everything lives under one root directory. Four top-level folders, each with a clear purpose.

/data/.openclaw/workspace/
├── 📦 apps/ — your projects
├── 🧩 skills/ — packaged skill modules
├── 🔧 ops/ — operations & deploy configs
└── 🧠 memory/ — assistant continuity

apps/

Each project gets its own subfolder with src, config, tests, and scripts.

skills/

Only if packaging as a reusable Skill — contains SKILL.md + scripts.

ops/

Runbooks, docker-compose files, systemd configs. How to run & recover.

memory/

MEMORY.md and context files. Not app code — assistant memory only.

Inside apps/<project>/

Every project follows the same clean layout. Predictable structure = fewer mistakes.

apps/my-automation/
├── README.md what it does, how to run
├── config/
├── templates/
└── schemas/
├── src/
├── index.js
└── utils.js
├── scripts/
└── migrate.sh
└── tests/
└── index.test.js

📄 README.md

The single source of truth. What it does, how to install, how to run. Always write this first.

⚙️ config/

Templates, schemas, non-secret configuration. Everything that shapes behavior without being code.

💻 src/

The actual application code. Keep it clean, modular, and well-commented.

🔐 No Secrets in Files!

Use environment variables, .env files (gitignored), or a secret store. Never commit API keys.

How Does Your Code Actually Run?

Pick the right execution model based on what triggers your automation.

Option A

Cron Jobs

Runs on a schedule. Best for daily summaries, periodic syncs, monitoring.

0 9 * * * node run.js
# every day at 9am
💬 Option B

Event-Driven

"When X happens, do Y." Triggered by messages, webhooks, or platform events.

on("message") → process
# react to incoming events
🔄 Option C

Standalone Service

Always-on server. Best for webhooks, queues, background workers, APIs.

pm2 start server.js
# always running

Pick Your Trigger

Match the execution model to what kicks off your automation.

Cron

"Run this every day at 9am"

Daily reports, weekly summaries, data syncs, monitoring checks, reminder systems

Simplest
Event

"When a message arrives, do X"

Chat commands, Telegram bots, Discord handlers, notification routing

Medium
Service

"Always listening for webhooks / processing a queue"

API endpoints, webhook receivers, background job workers, real-time pipelines

Complex

How Changes Go Live

Three paths from code to production. Pick based on your team size and project maturity.

Option 1

In-Place on VPS

Code lives directly on the server. Update by pulling and restarting.

git pull origin main
pm2 restart app
⚡ Fastest Setup
Option 2

GitHub + CI/CD

Push to GitHub → CI builds image → deploys automatically to VPS.

git push origin main
# CI handles the rest
🏗️ Cleanest Long-Term
Option 3

Ship as Skill

Package as a skill folder. Version it. Deploy by updating the skill.

cp -r skill/ /skills/
restart openclaw
🧩 Best if Tightly Coupled

The Deploy Pipeline

Regardless of which option you pick, the flow follows the same pattern.

Option 1 — In-Place
Write Code
Git Pull
Restart Service
Live ✓
Option 2 — CI/CD
Git Push
CI Builds
Tests Pass
Auto Deploy
Live ✓
Option 3 — Skill
Build Skill
Version It
Copy to /skills/
Live ✓

VPS Bot vs Cowork

The bot's answer describes a VPS environment. Here's how Cowork compares.

🤖

Telegram Bot (VPS)

Persistent Server
Persistent filesystem — files stay forever
Docker, pm2, systemd — always-on services
Full network access — webhooks, APIs
Git + CI/CD deployment pipeline
Manual server management & security
No MCP integrations (Notion, GCal, etc.)
💻

Cowork (Desktop)

Session-Based VM
MCP tools — Notion, Calendar, Slack, etc.
Scheduled tasks built-in
Skills system for reusable workflows
Build & test code, then hand off
VM resets between sessions
No always-on services (no Docker/pm2)
VS

Which Tool for Which Job?

📊

Notion/Calendar Automations

Create proposals, clean pages, sync data, scheduled tasks

Cowork
🌐

Static Websites & Landing Pages

Build in Cowork → deploy to Netlify

Both
🤖

Telegram/Discord Bots

Always-on listener, webhook receiver, message handler

VPS
📄

Document Generation & Reports

PPTX, DOCX, PDF, HTML decks, data analysis

Cowork

API Services & Webhook Endpoints

REST APIs, payment webhooks, data pipelines

VPS

Lock In Your 3 Decisions

Answer these and you'll have a complete setup plan in minutes.

1

What Are You Building?

Scheduled Automation Chat-Triggered Flow Webhook / API Service
2

Preferred Runtime?

Node.js Python
3

How Do You Want to Deploy?

In-Place on VPS GitHub + CI/CD Ship as Skill

Once you pick, the bot (or Cowork) can scaffold the exact folder structure + first runnable automation for you.