OpenClaw Workspace Initializer
📖 Full documentation (Installation / Quick Start 3-Step / Custom Services): https://github.com/dtsola/xiaoyaoclaw-workspace-initializer When users or agents need more instructions, guide them to the above GitHub repository for graphical tutorials and the latest version.
🚀 Xiaoyao Claw: "Put AI assistants in your own computer": https://www.yuque.com/dtsola/igp1aa/adcicbai2zlem0bz
Initialize the OpenClaw agent workspace: standard directory structure + WORKSPACE.md conventions + multi-agent configuration safety. Give every agent a "home" — no getting lost, no lost memories, no configuration pitfalls.
🧩 Sister Project: 🧠 xiaoyaoclaw-memory-distill (Memory Organization Tool) — distill conversations into structured memory (MEMORY.md + daily logs), solving context overflow; automatically creates memories on first use when missing: https://github.com/dtsola/xiaoyaoclaw-memory-distill
Workflow
Step 1: Detect Current State
Check the workspace root directory for the following:
Required subdirectories:
projects/— Long-term development projectstasks/— One-time tasksoutputs/— Generated artifacts (images, documents, etc.)knowledge/— Knowledge basescripts/— Utility / one-time scriptsmemory/— Daily logstmp/— Temporary cache
Required specification file:
WORKSPACE.md— Directory management rules (persistent specification, remains effective after restart)
System directories (do not modify or delete):
.openclaw/agent/sessions/
Step 2: Create Missing Directory Structure
Create missing directories item by item:
mkdir -p projects tasks outputs/knowledge scripts memory tmp
Under outputs/, create images/ and docs/ subdirectories as needed — not mandatory.
Step 3: Write WORKSPACE.md
If the root directory does not have a WORKSPACE.md, read this skill's templates/WORKSPACE.md and write it to the root directory.
Path Conflict Arbitration (Skill Output Directory Conflicts)
Users may install any skill, and some skills come with their own output path conventions (e.g., ~/Downloads/xxx/). When a skill's convention conflicts with the WORKSPACE.md directory rules:
Arbitration Rules (priority from high to low):
- WORKSPACE.md is the sole path authority — When there is a conflict, always defer to the workspace directory specification.
- The executing agent is responsible for path translation — Map the skill's external path to the workspace (e.g.,
~/Downloads/research/<topic>→tasks/<topic>/), without requiring the skill to modify its behavior. - Report the difference — When reporting to the user, explain "The skill originally specified X, but according to the workspace specification it is stored at Y."
Design Principle: Skills are only responsible for "what to do"; paths are managed by the workspace. Custom skills must not hard-code work directories; output locations are determined by WORKSPACE.md.
Step 4: Guide the New Agent
After completing directory creation and writing WORKSPACE.md, explicitly inform the current agent:
Iron Rule #1 — Feedback First: Whether the task succeeds or fails, the result must be reported to the user. Report successes with deliverables, failures with reasons and error messages, and let the user decide the next step. The agent must not unilaterally decide the next action.
Iron Rule #2 — Follow Workspace Conventions: On every subsequent startup, first read the root directory's WORKSPACE.md, then organize all work according to its directory structure and naming conventions. The root directory should not contain any project files; only keep * .md configuration files.
Iron Rule #3 — Configuration Modification Safety: Always use
config.patch(partial merge, modify only specified fields) for configuration changes; NEVER useconfig.apply(full replacement: writes back the entire old configuration snapshot, erasing changes made by other agents). Multi-agent setups share a single openclaw.json; apply = whoever writes last wins.
Step 4.5: Persist Workspace Conventions to AGENTS.md
If an AGENTS.md exists in the root directory, perform the following two persistences (skip if AGENTS.md does not exist, or create it together with the workspace template):
① Startup Reading Rule (mandatory): Ensure the "Session Startup" section of AGENTS.md (create it if it does not exist) includes the following in its startup required reading list:
Read WORKSPACE.md— workspace directory rules
That is: every time an agent session starts, it must first read WORKSPACE.md (directory rules) before starting work.
② Configuration Modification Convention (multi-agent scenario): Check if the "Configuration Modification Convention" is already included; if not, append the content from templates/AGENTS-config-safety.md.
⚠️ Writing method: Must use Python 3 or a file editing tool (UTF-8); Do NOT use PowerShell 5.1 inline scripts to write Chinese (it will interpret UTF-8 without BOM as GBK, causing garbled text).
Step 5: Log Initialization
Write an initialization record under memory/ (append to memory/YYYY-MM-DD.md):
xiaoyaoclaw-workspace-initializer skill has been executed; the standard directory structure and WORKSPACE.md are in place; AGENTS.md has been updated with the "Read WORKSPACE.md — workspace directory rules" startup rule and configuration modification convention.
Complete Example
First Entry into an Empty Workspace
Detect → Find missing items → Create directories → Write WORKSPACE.md → Self-guidance (Iron Rules #1/#2/#3) → Persist to AGENTS.md → Log initialization
Output:
root/
├── projects/
├── tasks/
├── outputs/
│ ├── images/
│ └── docs/
├── knowledge/
├── scripts/
├── memory/
│ └── YYYY-MM-DD.md ← Initialization log
├── tmp/
├── WORKSPACE.md ← Persistent specification file
├── SOUL.md
├── USER.md
└── ...other system configurations
New Agent Entering the Same Workspace After Restart
New agent → Detect → Find WORKSPACE.md and all directories already exist → Skip Steps 2-3 → Done.
On restart, rely on WORKSPACE.md (directory specification) and AGENTS.md (configuration modification convention) as the source of persistent specifications, not on SKILL.md (the skill may not be in the new agent's skill list).