OpenClaw Self-learning Agent

An OpenClaw-style personal AI agent accessible via Telegram that learns by creating, discovering, and executing skills stored in a persistent space - teaching itself new capabilities from every conversation and waking up on a heartbeat schedule to tend to its own workspace.

openclaw
self-learning
skills
2778

The OpenClaw Self-learning Agent blueprint implements an open-ended AI assistant inspired by the OpenClaw philosophy: an autonomous agent with a persistent workspace, shell access, and the ability to teach itself new skills over time. Accessible via Telegram and driven by a heartbeat trigger, it combines the platform's skill system with shell execution to create an agent that genuinely self-improves.

The Self-learning Loop

Most AI agents are static - they can only do what was configured at design time. This agent breaks that pattern with a four-step loop:

  1. Discover - the agent lists existing skills to see what it already knows how to do.
  2. Execute - if a matching skill exists, the agent reads it and follows its instructions using shell execution.
  3. Learn - if no skill exists, the agent figures out how to accomplish the task, then writes a new skill file capturing what it learned.
  4. Improve - the next time the same request (or a similar one) comes in, the skill is already there. Over time the skill library grows organically from real usage.

Architecture

The agent has a single skillset with five abilities connected to one persistent space:

  • List Skills (space/skill/list) - scans the space for skill files and returns their names and descriptions. This is how the agent introspects its own knowledge base.
  • Read Skills (space/skill/read) - loads the full content of a skill by path. The agent reads instructions just in time.
  • Create Skills (space/skill/create) - writes new skill files to the space. This is how the agent learns - it crystallizes successful approaches into reusable skills.
  • Bash (shell/exec) - executes shell commands in the space's sandbox. Skills can include shell commands, scripts, API calls, or any other executable instructions.
  • Read/Write Files (shell/rw) - reads and writes arbitrary files in the space for configuration, data, and outputs.

Telegram Integration

The Telegram integration makes the agent always within reach. Message it from your phone to ask a question, assign a task, or teach it something new. The persistent space means everything the agent learns carries over to the next conversation - including skills, downloaded files, saved data, and environment configuration.

Skill Format

Each skill is a SKILL.md file under .skills/<name>/ with frontmatter metadata:

---
name: Fetch and Summarize URL
description: Downloads a web page and produces a concise summary
---

# Fetch and Summarize URL

## Instructions
1. Use curl to download the URL content
2. Extract the main text content
3. Produce a 3-5 sentence summary
4. Save the summary to /outputs/<domain>-summary.md

The name and description fields are what the List Skills ability returns, so the agent can match skills to requests without reading every file.

Why This Works

  • Compounding value - the agent starts with no skills and accumulates them from real usage. After a few weeks, it handles most of the user's recurring requests without figuring anything out from scratch.
  • Portable knowledge - skills are plain Markdown files in the space. They can be browsed, edited, exported, or even copied to another agent.
  • Transparent behavior - every capability the agent has is visible as a file. There is no hidden logic - if you want to know why the agent did something a certain way, read the skill.
  • Recoverable - if a skill produces bad results, delete or edit it. The agent will either use the updated version or learn again from scratch.

Heartbeat

Like any OpenClaw-style agent, this one does not just wait for commands. A scheduled heartbeat trigger wakes the agent periodically so it can review its workspace, consolidate recently learned skills, clean up stale outputs, and run any maintenance routines it has taught itself. The heartbeat turns the agent from a reactive tool into a proactive assistant that tends to its own environment.

Getting Started

  1. Set your Telegram bot token on the Telegram integration.
  2. Message the agent with a task - it will attempt to complete it and offer to save what it learned as a skill.
  3. Over time, check the Space File Browser to see the growing skill library.
  4. Edit or delete skills as needed to steer the agent's behavior.
  5. The heartbeat trigger runs every 6 hours by default - adjust the schedule to suit your needs.

Backstory

Common information about the bot's experience, skills and personality. For more information, see the Backstory documentation.

You are a self-learning AI assistant. You have a persistent workspace where you store skills, files, and data. You are accessible via Telegram. ## HOW YOU WORK You learn by doing. When a user asks you to do something: 1. LIST SKILLS Always call "List Skills" first to discover what you already know how to do. This returns the name, description, and path of every skill in your workspace. 2. MATCH AND READ If a skill matches the request, call "Read Skills" to load its full instructions. Follow them step by step. 3. EXECUTE Use bash and file tools to carry out the task in your workspace. All files persist across conversations. 4. LEARN If no existing skill matched, and you successfully completed the task, offer to save what you did as a new skill. Use "Create Skills" to write a SKILL.md file with: - A clear name and description (these are what you see when listing skills) - Step-by-step instructions you can follow next time - Any shell commands, scripts, or API calls involved - Notes on edge cases or things to watch out for ## SELF-IMPROVEMENT - After completing a task with an existing skill, consider whether the skill needs updating. If you found a better approach or hit an edge case, offer to update the skill. - Organize related skills logically - use descriptive names and clear descriptions. - When creating skills, write them as if someone else will follow them. Be explicit about each step. ## WORKSPACE Your workspace is a persistent space. You can: - Store configuration in a .env file (source it before API calls) - Save outputs under /outputs/ - Keep downloaded files under /downloads/ - Skills live under .skills/ (managed by the skill abilities) ## RULES - Always list skills before attempting a task - If you successfully solve something new, offer to save it as a skill - Be transparent about what you are doing and why - Ask for confirmation before destructive operations - When a task fails, explain what went wrong before retrying - The current date is ${EARTH_DATE}

Skillset

This example uses a dedicated Skillset. Skillsets are collections of abilities that can be used to create a bot with a specific set of functions and features it can perform.

  • 🇩🇪

    List Skills

    Lists all skills the agent has learned. Returns the name, description, and path of each skill found in the workspace.
  • 🌓

    Read Skills

    Reads the full content of one or more skill files by path. Use List Skills first to discover available paths.
  • Create Skills

    Creates new skill files in the workspace. Use this to save learned approaches as reusable skills for future conversations.
  • 🏢

    Bash

    Execute shell commands and scripts in the workspace sandbox
  • 🐀

    Rw

    Read or write files in the workspace for configuration, data, and outputs

Terraform Code

This blueprint can be deployed using Terraform, enabling infrastructure-as-code management of your ChatBotKit resources. Use the code below to recreate this example in your own environment.

Copy this Terraform configuration to deploy the blueprint resources:

Next steps:

  1. Save the code above to a file named main.tf
  2. Set your API key: export CHATBOTKIT_API_KEY=your-api-key
  3. Run terraform init to initialize
  4. Run terraform plan to preview changes
  5. Run terraform apply to deploy

Learn more about the Terraform provider

A dedicated team of experts is available to help you create your perfect chatbot. Reach out via or chat for more information.