# peterskoett/self-improving-agent architecture

> Architecture diagram of the GitHub repository peterskoett/self-improving-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/peterskoett/self-improving-agent
- Repository: https://github.com/peterskoett/self-improving-agent

## Overview

1. This repository is an OpenClaw “skill” package for self-improvement. Its purpose is not an application runtime, but a knowledge-capture system that records learnings, errors, and feature requests so future sessions can behave better.

2. The core of the repo is `SKILL.md`. That file is the main skill definition consumed by OpenClaw. The README explicitly points to it as the primary entrypoint, so the rest of the repository supports authoring, activating, and extending that skill.

3. The `assets/` directory is the content store for the skill’s structured memory. It contains separate files for `LEARNINGS.md`, `ERRORS.md`, and `FEATURE_REQUESTS.md`, plus template and guidance files such as `SKILL-TEMPLATE.md`. These files likely serve as durable, human-editable records and canonical formats for what the skill should capture.

4. The `hooks/openclaw/` directory is the runtime integration boundary. It contains `handler.js` and `handler.ts`, indicating the hook logic is implemented in TypeScript and/or compiled to JavaScript for OpenClaw’s hook system. `HOOK.md` documents how that hook behaves and how it should be wired into the platform.

5. The hook layer is probably responsible for observing session events and routing them into the skill’s persistent knowledge files. In architecture terms, this is the “event capture” path: OpenClaw emits events, the hook handler processes them, and the results are written into the asset files or used to update the active skill content.

6. The `scripts/` directory contains operational utilities that support the lifecycle of the skill rather than user-facing behavior. `activator.sh` likely installs or enables the skill, `extract-skill.sh` likely packages content out of the repository into a usable skill artifact, and `error-detector.sh` suggests automated detection or classification of failures for logging into `ERRORS.md`.

7. The `references/` directory is documentation and onboarding support. Files like `hooks-setup.md`, `openclaw-integration.md`, and `examples.md` provide the architectural glue between the skill content and the OpenClaw platform, showing how hooks, activation, and example usage fit together.

8. Data flows through the repository in a simple loop: OpenClaw activity is observed by the hook, relevant events are categorized by the scripts or handler logic, and the resulting knowledge is appended to the corresponding assets. That stored knowledge then informs future sessions via `SKILL.md` and the supporting markdown files.

9. The main boundary in this repo is between static knowledge artifacts and executable integration code. The markdown files define policy, memory, and examples; the hook and shell scripts implement the automation that captures and surfaces that information.

10. Another important boundary is platform integration. Nothing here suggests a standalone server or UI; instead, this repository is designed to be embedded into OpenClaw’s extension/hook mechanism, with the handler and scripts acting as the adapter between platform events and persisted skill state.

11. For an architecture diagram, the central nodes should be: OpenClaw platform, hook handler (`hooks/openclaw`), skill definition (`SKILL.md`), structured memory assets (`assets/`), and operational scripts (`scripts/`). The `references/` folder should be shown as documentation/support rather than runtime logic.

12. In summary, this repo is a self-improvement knowledge pipeline for OpenClaw: observe, classify, store, and reuse. Its architecture is intentionally lightweight, markdown-centric, and hook-driven, with minimal executable code around a core set of persistent skill documents.

Main entry points: [`SKILL.md`](https://github.com/peterskoett/self-improving-agent/blob/master/SKILL.md) (SKILL), [`hooks/openclaw/handler.ts`](https://github.com/peterskoett/self-improving-agent/blob/master/hooks/openclaw/handler.ts) (Hook handler), [`assets/ERRORS.md`](https://github.com/peterskoett/self-improving-agent/blob/master/assets/ERRORS.md) (Errors), [`assets/LEARNINGS.md`](https://github.com/peterskoett/self-improving-agent/blob/master/assets/LEARNINGS.md) (Learnings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_platform["Platform"]
  node_openclaw{{"OpenClaw<br/>platform"}}
end

subgraph group_group_core["Core skill"]
  node_readme["README<br/>entrypoint docs<br/>[README.md]"]
  node_skill["SKILL<br/>[SKILL.md]"]
  node_learn["Learnings<br/>memory log<br/>[LEARNINGS.md]"]
  node_errors["Errors<br/>memory log<br/>[ERRORS.md]"]
  node_features["Requests<br/>memory log"]
  node_template["Template<br/>[SKILL-TEMPLATE.md]"]
end

subgraph group_group_integration["Integration"]
  node_handler["Hook handler<br/>event adapter<br/>[handler.ts]"]
  node_handler_js["Handler JS<br/>built hook<br/>[handler.js]"]
  node_hook_doc["Hook guide<br/>integration docs<br/>[HOOK.md]"]
  node_activator["Activator<br/>shell script<br/>[activator.sh]"]
  node_extractor["Extractor<br/>shell script<br/>[extract-skill.sh]"]
  node_detector["Error detector<br/>shell script<br/>[error-detector.sh]"]
end

subgraph group_group_docs["Docs"]
  node_refs["References<br/>support docs"]
  node_examples["Examples<br/>reference doc<br/>[examples.md]"]
  node_setup["Setup<br/>reference doc<br/>[hooks-setup.md]"]
  node_integration_doc["Integration<br/>reference doc"]
end

node_readme -->|"points to"| node_skill
node_openclaw -->|"emits events to"| node_handler
node_handler -->|"captures learnings"| node_learn
node_handler -->|"captures errors"| node_errors
node_handler -->|"captures requests"| node_features
node_handler -->|"updates skill"| node_skill
node_activator -->|"activates"| node_skill
node_extractor -->|"packages"| node_skill
node_detector -->|"feeds"| node_errors
node_skill -->|"uses template"| node_template
node_hook_doc -->|"documents"| node_handler
node_refs -->|"includes"| node_setup
node_refs -->|"includes"| node_integration_doc
node_refs -->|"includes"| node_examples
node_setup -->|"supports"| node_handler
node_integration_doc -->|"explains"| node_openclaw
node_examples -->|"illustrates"| node_skill
node_learn -->|"informs future sessions"| node_skill
node_errors -->|"prevents repeats"| node_skill
node_features -->|"guides extensions"| node_skill

click node_readme "https://github.com/peterskoett/self-improving-agent/blob/master/README.md"
click node_skill "https://github.com/peterskoett/self-improving-agent/blob/master/SKILL.md"
click node_learn "https://github.com/peterskoett/self-improving-agent/blob/master/assets/LEARNINGS.md"
click node_errors "https://github.com/peterskoett/self-improving-agent/blob/master/assets/ERRORS.md"
click node_features "https://github.com/peterskoett/self-improving-agent/blob/master/assets/FEATURE_REQUESTS.md"
click node_template "https://github.com/peterskoett/self-improving-agent/blob/master/assets/SKILL-TEMPLATE.md"
click node_handler "https://github.com/peterskoett/self-improving-agent/blob/master/hooks/openclaw/handler.ts"
click node_handler_js "https://github.com/peterskoett/self-improving-agent/blob/master/hooks/openclaw/handler.js"
click node_hook_doc "https://github.com/peterskoett/self-improving-agent/blob/master/hooks/openclaw/HOOK.md"
click node_activator "https://github.com/peterskoett/self-improving-agent/blob/master/scripts/activator.sh"
click node_extractor "https://github.com/peterskoett/self-improving-agent/blob/master/scripts/extract-skill.sh"
click node_detector "https://github.com/peterskoett/self-improving-agent/blob/master/scripts/error-detector.sh"
click node_examples "https://github.com/peterskoett/self-improving-agent/blob/master/references/examples.md"
click node_setup "https://github.com/peterskoett/self-improving-agent/blob/master/references/hooks-setup.md"
click node_integration_doc "https://github.com/peterskoett/self-improving-agent/blob/master/references/openclaw-integration.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_openclaw toneBlue
class node_readme,node_skill,node_learn,node_errors,node_features,node_template toneAmber
class node_handler,node_handler_js,node_hook_doc,node_activator,node_extractor,node_detector toneMint
class node_refs,node_examples,node_setup,node_integration_doc toneRose
```

## Components

### Platform

OpenClaw runtime boundary that emits events into the skill package.

- **OpenClaw**: platform · Host platform that triggers hooks and consumes the skill package.

### Core skill

Primary skill definition and its persistent knowledge store.

- [README](https://github.com/peterskoett/self-improving-agent/blob/master/README.md): entrypoint docs · Repository overview that points to the main skill definition. · `README.md`
- [SKILL](https://github.com/peterskoett/self-improving-agent/blob/master/SKILL.md): skill definition · Primary OpenClaw skill entrypoint. · `SKILL.md`
- [Learnings](https://github.com/peterskoett/self-improving-agent/blob/master/assets/LEARNINGS.md): memory log · Persistent record of useful learnings. · `assets/LEARNINGS.md`
- [Errors](https://github.com/peterskoett/self-improving-agent/blob/master/assets/ERRORS.md): memory log · Persistent record of failures and mistakes. · `assets/ERRORS.md`
- [Requests](https://github.com/peterskoett/self-improving-agent/blob/master/assets/FEATURE_REQUESTS.md): memory log · Persistent record of feature requests and ideas. · `assets/FEATURE_REQUESTS.md`
- [Template](https://github.com/peterskoett/self-improving-agent/blob/master/assets/SKILL-TEMPLATE.md): content template · Canonical markdown template for skill content. · `assets/SKILL-TEMPLATE.md`

### Integration

Hook entrypoint and supporting automation that connect the skill to the platform.

- [Hook handler](https://github.com/peterskoett/self-improving-agent/blob/master/hooks/openclaw/handler.ts): event adapter · OpenClaw hook implementation that captures and routes events. · `hooks/openclaw/handler.ts`
- [Handler JS](https://github.com/peterskoett/self-improving-agent/blob/master/hooks/openclaw/handler.js): built hook · JavaScript variant of the hook entrypoint. · `hooks/openclaw/handler.js`
- [Hook guide](https://github.com/peterskoett/self-improving-agent/blob/master/hooks/openclaw/HOOK.md): integration docs · Documentation for the hook behavior and wiring. · `hooks/openclaw/HOOK.md`
- [Activator](https://github.com/peterskoett/self-improving-agent/blob/master/scripts/activator.sh): shell script · Installs or enables the skill in the platform. · `scripts/activator.sh`
- [Extractor](https://github.com/peterskoett/self-improving-agent/blob/master/scripts/extract-skill.sh): shell script · Packages skill content out of the repository. · `scripts/extract-skill.sh`
- [Error detector](https://github.com/peterskoett/self-improving-agent/blob/master/scripts/error-detector.sh): shell script · Identifies failures for capture into error memory. · `scripts/error-detector.sh`

### Docs

Guidance and examples for wiring and using the skill.

- **References**: support docs · Onboarding and integration notes supporting the skill.
- [Examples](https://github.com/peterskoett/self-improving-agent/blob/master/references/examples.md): reference doc · Example usage and patterns for the skill. · `references/examples.md`
- [Setup](https://github.com/peterskoett/self-improving-agent/blob/master/references/hooks-setup.md): reference doc · Hook setup instructions. · `references/hooks-setup.md`
- [Integration](https://github.com/peterskoett/self-improving-agent/blob/master/references/openclaw-integration.md): reference doc · OpenClaw integration guide. · `references/openclaw-integration.md`

## Connections

- README → SKILL: points to · README identifies the skill definition as the main entrypoint.
- OpenClaw → Hook handler: emits events to · Platform activity is observed through the hook boundary.
- Hook handler → Learnings: captures learnings · Relevant events are appended to durable learning memory.
- Hook handler → Errors: captures errors · Failures and mistakes are routed into error memory.
- Hook handler → Requests: captures requests · Feature ideas are stored as persistent requests.
- Hook handler → SKILL: updates skill · Hook results inform the active skill content.
- Activator → SKILL: activates · Operational script enables the skill artifact.
- Extractor → SKILL: packages · Script extracts skill content for reuse or distribution.
- Error detector → Errors: feeds · Automated detection produces error records.
- SKILL → Template: uses template · Skill structure is guided by the canonical template.
- Hook guide → Hook handler: documents · Hook documentation explains the runtime adapter.
- References → Setup: includes · References section collects setup guidance.
- References → Integration: includes · References section collects platform integration guidance.
- References → Examples: includes · References section collects example usage.
- Setup → Hook handler: supports · Setup guidance helps wire the hook into OpenClaw.
- Integration → OpenClaw: explains · Integration guide describes the platform boundary.
- Examples → SKILL: illustrates · Examples show how the skill should be used.
- Learnings → SKILL: informs future sessions · Captured learning feeds back into later behavior.
- Errors → SKILL: prevents repeats · Error history helps avoid recurring mistakes.
- Requests → SKILL: guides extensions · Requested improvements shape future skill evolution.
