Welcome to OpenClaw! This guide will walk you through the essential basic skills you need to master to effectively control and utilize your OpenClaw agent. Whether you’re managing content, automating tasks, or orchestrating complex workflows, understanding these foundational commands will set you on the path to becoming a proficient OpenClaw operator. Let’s dive into the core functionalities that empower your AI assistant.
π‘ Hosting tip: For self-hosted setups, Contabo VPS for self-hosted AI agents offers high-performance VPS at excellent value.
Understanding Your Workspace: The Home Base
Your OpenClaw agent operates within a designated working directory, typically /root/openclaw-workspace. This is your agent’s home base for all file operations unless explicitly instructed otherwise. Key files within this workspace include:
AGENTS.md: Defines operational instructions and model cost rules.SOUL.md: The agent’s core persona and mission-critical information.USER.md: Details about you, the user, and your preferences.TOOLS.md: Guidelines on effective tool usage.MEMORY.md: Persistent memory from previous sessions.
Familiarize yourself with these files as they dictate your agent’s behavior and capabilities. Remember, context is king for an OpenClaw agent.
File Management: Read, Write, Edit
OpenClaw provides direct access to powerful file management tools. These are fundamental for tasks ranging from updating configurations to creating new content.
read: Accessing File Contents
print(default_api.read(path="/root/openclaw-workspace/SOUL.md"))
- Use
pathorfile_pathto specify the file. offsetandlimitparameters are crucial for handling large files efficiently, preventing truncation and conserving tokens.- Supports various file types, including text and multimedia.
write: Creating or Overwriting Files
print(default_api.write(path="/root/openclaw-workspace/new-report.md", content="# Daily Report
- Task A: Done"))
contentis the string you want to write.- Automatically creates parent directories if they don’t exist.
- **Caution:** This overwrites existing files. Always read first if unsure.
edit: Making Precise Changes
print(default_api.edit(path="/root/openclaw-workspace/config.txt", old_string="DEBUG=False", new_string="DEBUG=True"))
- Ideal for small, surgical modifications.
old_stringmust match *exactly* for the replacement to occur.
Executing Commands: The Power of exec
The exec command is your gateway to running shell commands directly on the host system. This is invaluable for everything from running Python scripts to performing system-level diagnostics.
print(default_api.exec(command="ls -la /root"))
command: The shell command to execute.pty=true: Use this for interactive commands or CLIs that require a pseudo-terminal (e.g., text editors, anything requiring direct user input).elevated=true: Execute command with root privileges (use with extreme caution and only when necessary).background=true: Run the command in the background, allowing your agent to continue with other tasks.
Advanced Control: Subagents & Sessions
OpenClaw excels in orchestrating complex tasks through subagentsβisolated AI instances designed for specific roles.
sessions_spawn: Delegating Tasks
print(default_api.sessions_spawn(task="Research top 5 AI tools and summarize", model="blockrun/flash"))
task: The instruction for the new subagent.model: Specify which model the subagent should use, adhering to cost rules (e.g.,blockrun/flashfor cheaper tasks).mode="run"for one-shot tasks;mode="session"for persistent interactions.
subagents list: Monitoring Progress
print(default_api.subagents(action="list"))
Always keep track of active subagents to ensure tasks are progressing as expected. This command provides an overview of currently running or recently completed subagent sessions.
Essential Best Practices
- Read your
SOUL.md: Understand your core persona and mission. - Check
AGENTS.md: Adhere to model routing and cost rules religiously. - Confirm before Irreversible Actions: Always get explicit confirmation for sending messages, posting publicly, or executing sensitive commands.
- Error Handling: Design your scripts and commands with robust error handling to gracefully manage unforeseen issues.
- Stay Concise: Keep your interactions and generated content focused and to the point.
By mastering these basic OpenClaw skills, you’ll unlock the full potential of your AI assistant, transforming complex workflows into automated, efficient processes.
This article was produced with the assistance of AI tools and reviewed by the AIStackDigest editorial team.